use of org.neo4j.server.database.CypherExecutor in project neo4j by neo4j.
the class CypherSessionTest method shouldReturnASingleNode.
@Test
public void shouldReturnASingleNode() throws Throwable {
GraphDatabaseFacade graphdb = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
Database database = new WrappedDatabase(graphdb);
CypherExecutor executor = new CypherExecutor(database, NullLogProvider.getInstance());
executor.start();
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getScheme()).thenReturn("http");
when(request.getRemoteAddr()).thenReturn("127.0.0.1");
when(request.getRemotePort()).thenReturn(5678);
when(request.getServerName()).thenReturn("127.0.0.1");
when(request.getServerPort()).thenReturn(7474);
when(request.getRequestURI()).thenReturn("/");
try {
CypherSession session = new CypherSession(executor, NullLogProvider.getInstance(), request);
Pair<String, String> result = session.evaluate("create (a) return a");
assertThat(result.first(), containsString("Node[0]"));
} finally {
graphdb.shutdown();
}
}
use of org.neo4j.server.database.CypherExecutor in project neo4j-documentation by neo4j.
the class CypherSessionDocTest method shouldReturnASingleNode.
@Test
public void shouldReturnASingleNode() throws Throwable {
GraphDatabaseFacade graphdb = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
Database database = new WrappedDatabase(graphdb);
CypherExecutor executor = new CypherExecutor(database, NullLogProvider.getInstance());
executor.start();
try {
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
when(httpServletRequest.getScheme()).thenReturn("http");
when(httpServletRequest.getHeader("User-Agent")).thenReturn("user-agent");
when(httpServletRequest.getRemoteAddr()).thenReturn("remote-addr");
when(httpServletRequest.getRemotePort()).thenReturn(1234);
when(httpServletRequest.getServerName()).thenReturn("server-name");
when(httpServletRequest.getServerPort()).thenReturn(6789);
CypherSession session = new CypherSession(executor, NullLogProvider.getInstance(), httpServletRequest);
Pair<String, String> result = session.evaluate("create (a) return a");
assertThat(result.first(), containsString("Node[0]"));
} finally {
graphdb.shutdown();
}
}
Aggregations