use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldBeAbleToTraverseAllThePagesWithDefaultPageSize.
@Documented("Paging through the results of a paged traverser.\n\n" + "Paged traversers hold state on the server, and allow clients to page through the results of a traversal.\n" + "To progress to the next page of traversal results, the client issues a HTTP `GET` request on the paged traversal URI which causes the traversal to fill the next page (or partially fill it if insufficient results are available).\n \n" + "Note that if a traverser expires through inactivity it will cause a 404 response on the next `GET` request.\n" + "Traversers' leases are renewed on every successful access for the same amount of time as originally specified.\n\n" + "When the paged traverser reaches the end of its results, the client can expect a 404 response as the traverser is disposed by the server.")
@Test
public void shouldBeAbleToTraverseAllThePagesWithDefaultPageSize() {
theStartNode = createLinkedList(LONG_LIST_LENGTH, server.getDatabase());
URI traverserLocation = createPagedTraverser().getLocation();
int enoughPagesToExpireTheTraverser = 3;
for (int i = 0; i < enoughPagesToExpireTheTraverser; i++) {
gen.get().expectedType(MediaType.APPLICATION_JSON_TYPE).expectedStatus(200).payload(traverserDescription()).get(traverserLocation.toString());
}
JaxRsResponse response = new RestRequest(traverserLocation).get();
assertEquals(404, response.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class NeoServerJAXRSDocIT method shouldMakeJAXRSClassesAvailableViaHTTP.
@Test
public void shouldMakeJAXRSClassesAvailableViaHTTP() throws Exception {
CommunityWebContainerBuilder builder = CommunityWebContainerBuilder.builder();
webContainer = WebContainerHelper.createContainer(builder, folder, true);
FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(webContainer);
JaxRsResponse response = new RestRequest().get(functionalTestHelper.baseUri().toASCIIString());
assertEquals(200, response.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class BatchOperationHeaderDocIT method shouldPassHeaders.
@Test
public void shouldPassHeaders() throws Exception {
String jsonData = new PrettyJSON().array().object().key("method").value("GET").key("to").value("../.." + DUMMY_WEB_SERVICE_MOUNT_POINT + "/needs-auth-header").key("body").object().endObject().endObject().endArray().toString();
JaxRsResponse response = new RestRequest(null, "user", "pass").post("http://localhost:7474/db/data/batch", jsonData);
assertEquals(200, response.getStatus());
final List<Map<String, Object>> responseData = jsonToList(response.getEntity());
Map<String, Object> res = (Map<String, Object>) responseData.get(0).get("body");
/*
* {
* Accept=[application/json],
* Content-Type=[application/json],
* Authorization=[Basic dXNlcjpwYXNz],
* User-Agent=[Java/1.6.0_27] <-- ignore that, it changes often
* Host=[localhost:7474],
* Connection=[keep-alive],
* Content-Length=[86]
* }
*/
assertEquals("Basic dXNlcjpwYXNz", res.get("Authorization"));
assertEquals("application/json", res.get("Accept"));
assertEquals("application/json", res.get("Content-Type"));
assertEquals("localhost:7474", res.get("Host"));
assertEquals("keep-alive", res.get("Connection"));
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class ServerConfigDocIT method shouldNotGenerateWADLWhenExplicitlyDisabledInConfig.
@Test
public void shouldNotGenerateWADLWhenExplicitlyDisabledInConfig() throws IOException {
server = server().withProperty(ServerSettings.wadl_enabled.name(), "false").usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
JaxRsResponse response = new RestRequest().get("http://localhost:7474/application.wadl", MediaType.WILDCARD_TYPE);
assertEquals(404, response.getStatus());
}
use of org.neo4j.doc.server.rest.RestRequest in project neo4j-documentation by neo4j.
the class ServerConfigDocIT method shouldGenerateWADLWhenExplicitlyEnabledInConfig.
@Test
public void shouldGenerateWADLWhenExplicitlyEnabledInConfig() throws IOException {
server = server().withProperty(ServerSettings.wadl_enabled.name(), "true").usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
JaxRsResponse response = new RestRequest().get("http://localhost:7474/application.wadl", MediaType.WILDCARD_TYPE);
assertEquals(200, response.getStatus());
assertEquals("application/vnd.sun.wadl+xml", response.getHeaders().get("Content-Type").iterator().next());
assertThat(response.getEntity(), containsString("<application xmlns=\"http://wadl.dev.java" + ".net/2009/02\">"));
}
Aggregations