use of org.neo4j.server.database.Database 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.Database in project neo4j by neo4j.
the class DatabaseMetadataServiceTest method shouldAdvertiseRelationshipTypesThatCurrentlyInUseInTheDatabase.
@Test
public void shouldAdvertiseRelationshipTypesThatCurrentlyInUseInTheDatabase() throws Throwable {
try (Transaction tx = db.beginTx()) {
db.getRelationshipById(relId).delete();
tx.success();
}
Database database = new WrappedDatabase(db);
DatabaseMetadataService service = new DatabaseMetadataService(database);
try (Transaction tx = db.beginTx()) {
Response response = service.getRelationshipTypes(true);
assertEquals(200, response.getStatus());
List<Map<String, Object>> jsonList = JsonHelper.jsonToList(response.getEntity().toString());
assertEquals(2, jsonList.size());
}
database.stop();
}
use of org.neo4j.server.database.Database in project neo4j by neo4j.
the class AbstractNeoServer method createDefaultInjectables.
protected Collection<InjectableProvider<?>> createDefaultInjectables() {
Collection<InjectableProvider<?>> singletons = new ArrayList<>();
Database database = getDatabase();
singletons.add(new DatabaseProvider(database));
singletons.add(new DatabaseActions.Provider(databaseActions));
singletons.add(new GraphDatabaseServiceProvider(database));
singletons.add(new NeoServerProvider(this));
singletons.add(providerForSingleton(new ConfigAdapter(getConfig()), Configuration.class));
singletons.add(providerForSingleton(getConfig(), Config.class));
singletons.add(new WebServerProvider(getWebServer()));
PluginInvocatorProvider pluginInvocatorProvider = new PluginInvocatorProvider(this);
singletons.add(pluginInvocatorProvider);
RepresentationFormatRepository repository = new RepresentationFormatRepository(this);
singletons.add(new InputFormatProvider(repository));
singletons.add(new OutputFormatProvider(repository));
singletons.add(new CypherExecutorProvider(cypherExecutor));
singletons.add(providerForSingleton(transactionFacade, TransactionFacade.class));
singletons.add(providerFromSupplier(authManagerSupplier, AuthManager.class));
singletons.add(providerFromSupplier(userManagerSupplier, UserManagerSupplier.class));
singletons.add(new TransactionFilter(database));
singletons.add(new LoggingProvider(logProvider));
singletons.add(providerForSingleton(logProvider.getLog(NeoServer.class), Log.class));
singletons.add(providerForSingleton(resolveDependency(UsageData.class), UsageData.class));
return singletons;
}
use of org.neo4j.server.database.Database 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();
}
}
use of org.neo4j.server.database.Database in project neo4j by neo4j.
the class RESTApiModuleTest method shouldRegisterASingleUri.
@Test
public void shouldRegisterASingleUri() throws Exception {
// Given
WebServer webServer = mock(WebServer.class);
Map<String, String> params = new HashMap();
String path = "/db/data";
params.put(ServerSettings.rest_api_path.name(), path);
Config config = Config.embeddedDefaults(params);
Dependencies deps = new Dependencies();
deps.satisfyDependency(new UsageData(mock(JobScheduler.class)));
Database db = mock(Database.class);
// When
RESTApiModule module = new RESTApiModule(webServer, config, deps, NullLogProvider.getInstance());
module.start();
// Then
verify(webServer).addJAXRSClasses(any(List.class), anyString(), anyCollection());
}
Aggregations