use of org.robolectric.tester.org.apache.http.TestHttpResponse in project RoboZombie by sahan.
the class ResponseEndpointTest method testRawResponse.
/**
* <p>Test for a request which expects the raw {@link HttpResponse}.</p>
*
* @since 1.3.0
*/
@Test
public final void testRawResponse() throws ParseException, IOException {
String subpath = "/rawresponse";
String url = "http://0.0.0.0:8080" + subpath;
String body = "Welcome to the Republic of Genosha";
Robolectric.addHttpResponseRule(HttpGet.METHOD_NAME, url, new TestHttpResponse(200, body));
Object response = responseEndpoint.rawResponse();
assertNotNull(response);
assertTrue(response instanceof HttpResponse);
assertEquals(EntityUtils.toString(((HttpResponse) response).getEntity()), body);
}
use of org.robolectric.tester.org.apache.http.TestHttpResponse in project RoboZombie by sahan.
the class ResponseEndpointTest method testRawEntity.
/**
* <p>Test for a request which expects the raw {@link HttpEntity}.</p>
*
* @since 1.3.0
*/
@Test
public final void testRawEntity() throws ParseException, IOException {
String subpath = "/rawentity";
String url = "http://0.0.0.0:8080" + subpath;
String body = "Hulk, make me a sandwich";
Robolectric.addHttpResponseRule(HttpGet.METHOD_NAME, url, new TestHttpResponse(200, body));
Object response = responseEndpoint.rawEntity();
assertNotNull(response);
assertTrue(response instanceof HttpEntity);
assertEquals(EntityUtils.toString(((HttpEntity) response)), body);
}
use of org.robolectric.tester.org.apache.http.TestHttpResponse in project RoboZombie by sahan.
the class ResponseEndpointTest method testNoDeserializer.
/**
* <p>Test for a request which expects the raw {@link HttpEntity}.</p>
*
* @since 1.3.0
*/
@Test
public final void testNoDeserializer() {
String subpath = "/nodeserializer";
String url = "http://0.0.0.0:8080" + subpath;
String body = new Gson().toJson(new User(1, "Cain", "Marko", 37, false));
Robolectric.addHttpResponseRule(HttpGet.METHOD_NAME, url, new TestHttpResponse(200, body));
expectedException.expect(Is.isA(InvocationException.class));
responseEndpoint.noDeserializer();
}
Aggregations