use of org.restlet.Request in project camel by apache.
the class RestletRouteBuilderTest method testNotFound.
@Test
public void testNotFound() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.POST, "http://localhost:" + portNum + "/unknown"));
// expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
assertNotNull(response.getEntity().getText());
}
use of org.restlet.Request in project camel by apache.
the class RestletRouteBuilderTest method testConsumer.
@Test
public void testConsumer() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.GET, "http://localhost:" + portNum + "/orders/99991/6"));
assertEquals("received GET request with id=99991 and x=6", response.getEntity().getText());
}
use of org.restlet.Request in project camel by apache.
the class RestletRouteBuilderTest method testConsumerWithSpaces.
@Test
public void testConsumerWithSpaces() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.GET, "http://localhost:" + portNum + "/orders with spaces in path/99991/6"));
assertEquals("received GET request with id=99991 and x=6", response.getEntity().getText());
}
use of org.restlet.Request in project lucene-solr by apache.
the class TestRestManager method testResolveResourceIdDecodeUrlEntities.
@Test
public void testResolveResourceIdDecodeUrlEntities() throws Exception {
Request testRequest = new Request();
Reference rootRef = new Reference("http://solr.apache.org/");
testRequest.setRootRef(rootRef);
Reference resourceRef = new Reference("http://solr.apache.org/schema/analysis/synonyms/de/%C3%84ndern");
testRequest.setResourceRef(resourceRef);
String resourceId = RestManager.ManagedEndpoint.resolveResourceId(testRequest);
assertEquals(resourceId, "/schema/analysis/synonyms/de/Ă„ndern");
}
use of org.restlet.Request in project helix by apache.
the class AdminTestHelper method get.
public static ZNRecord get(Client client, String url) throws IOException {
Reference resourceRef = new Reference(url);
Request request = new Request(Method.GET, resourceRef);
Response response = client.handle(request);
Assert.assertEquals(response.getStatus(), Status.SUCCESS_OK);
Representation result = response.getEntity();
StringWriter sw = new StringWriter();
result.write(sw);
String responseStr = sw.toString();
Assert.assertTrue(responseStr.toLowerCase().indexOf("error") == -1);
Assert.assertTrue(responseStr.toLowerCase().indexOf("exception") == -1);
ObjectMapper mapper = new ObjectMapper();
ZNRecord record = mapper.readValue(new StringReader(responseStr), ZNRecord.class);
return record;
}
Aggregations