Best code examples for Android BasicHttpResponse class (org.apache.http.message.BasicHttpResponse)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android BasicHttpResponse class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android BasicHttpResponse examples from Open Source projects
This code example shows how to use the following methods: addHeader
        Assert.assertTrue(conn.contentDecoder instanceof IdentityDecoder);
    } 
 
    @Test 
    public void testPrepareLengthDelimitedDecoder() throws Exception { 
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(HTTP.CONTENT_LEN, "10");
        response.addHeader(HTTP.CONTENT_TYPE, "stuff");
        response.addHeader(HTTP.CONTENT_ENCODING, "identity");
        Mockito.when(session.channel()).thenReturn(channel);
 
        final HttpEntity entity = conn.prepareDecoder(response);
        Assert.assertNotNull(entity);
        Assert.assertEquals(10, entity.getContentLength());
        Assert.assertFalse(entity.isChunked());
        Assert.assertNotNull(entity.getContentType());
        Assert.assertEquals("stuff", entity.getContentType().getValue());
        Assert.assertNotNull(entity.getContentEncoding());
        Assert.assertEquals("identity", entity.getContentEncoding().getValue());
        Assert.assertTrue(conn.contentDecoder instanceof LengthDelimitedDecoder);
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setEntity
This code example shows how to use the following methods: equals, setEntity
     */ 
    @Test 
    public void testHandleSuccess(){ 
        String successJSON = "{\"ok\" : true, \"operation_id\" : \"OpID\", " +
                "\"schedule_ids\" : [\"ScheduleID\"]}"; 
        HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(
                new ProtocolVersion("HTTP",1,1), 200, "OK"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(successJSON.getBytes()),
                successJSON.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        ScheduleAPIResponseHandler handler = new ScheduleAPIResponseHandler();
 
        try { 
            APIClientResponse<APIScheduleResponse> response =
                    handler.handleResponse(httpResponse);
            assertTrue("Operation ID incorrect", 
                       response.getApiResponse().getOperationId().equals("OpID"));
            assertTrue("HttpResponse is incorrect", 
                       httpResponse.equals(httpResponse));

6
CodeRank
This code example shows how to use the following methods: getStatusLine
                handlerResolver);
        final HttpCoreContext context = HttpCoreContext.create();
        final HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        final HttpRequest request = new BasicHttpRequest("GET", "/");
        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
 
        httpservice.handleRequest(conn, context);
 
        Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getStatusLine().getStatusCode());
 
        Assert.assertSame(conn, context.getConnection());
        Assert.assertSame(request, context.getRequest());
        Assert.assertSame(response, context.getResponse());
 
        Mockito.verify(httprocessor).process(request, context);
        Mockito.verify(httprocessor).process(response, context);
        Mockito.verify(conn).sendResponseHeader(response);

6
CodeRank
This code example shows how to use the following methods:
        return getInstrumentation().getContext();
    } 
 
    public PersitingActorTestCase<T> given(InputStream in) {
        httpResponse = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("http", 1, 1),
                200, "OK")); 
        InputStreamEntity entity = new InputStreamEntity(in, -1);
        httpResponse.setEntity(entity);
        return this;
    } 
 
    public PersitingActorTestCase<T> given(String httpResponseBody) {
        httpResponse = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("http", 1, 1),
                200, "OK")); 
        StringEntity entity = null;
        try { 
            entity = new StringEntity(httpResponseBody);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } 
Full Snippet Info
6
CodeRank
Related Android BasicHttpResponse Questions & Answers:
See Code Examples for Android BasicHttpResponse Methods: