Search in sources :

Example 1 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase 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();
    }
}
Also used : CypherExecutor(org.neo4j.server.database.CypherExecutor) HttpServletRequest(javax.servlet.http.HttpServletRequest) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Database(org.neo4j.server.database.Database) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) CypherSession(org.neo4j.server.rest.management.console.CypherSession) Test(org.junit.Test)

Example 2 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase in project neo4j by neo4j.

the class RestfulGraphDatabaseTest method doBefore.

@BeforeClass
public static void doBefore() throws IOException {
    graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
    database = new WrappedDatabase(graph);
    helper = new GraphDbHelper(database);
    output = new EntityOutputFormat(new JsonFormat(), URI.create(BASE_URI), null);
    service = new TransactionWrappingRestfulGraphDatabase(graph, new RestfulGraphDatabase(new JsonFormat(), output, new DatabaseActions(new LeaseManager(Clocks.fakeClock()), true, database.getGraph()), new ConfigAdapter(Config.embeddedDefaults())));
}
Also used : GraphDbHelper(org.neo4j.server.rest.domain.GraphDbHelper) JsonFormat(org.neo4j.server.rest.repr.formats.JsonFormat) LeaseManager(org.neo4j.server.rest.paging.LeaseManager) ConfigAdapter(org.neo4j.server.plugins.ConfigAdapter) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) EntityOutputFormat(org.neo4j.test.server.EntityOutputFormat) BeforeClass(org.junit.BeforeClass)

Example 3 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase 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();
}
Also used : Response(javax.ws.rs.core.Response) Transaction(org.neo4j.graphdb.Transaction) Database(org.neo4j.server.database.Database) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) Map(java.util.Map) Test(org.junit.Test)

Example 4 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase in project neo4j by neo4j.

the class PagingTraversalTest method startDatabase.

@Before
public void startDatabase() throws IOException {
    graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
    database = new WrappedDatabase(graph);
    helper = new GraphDbHelper(database);
    EntityOutputFormat output = new EntityOutputFormat(new JsonFormat(), URI.create(BASE_URI), null);
    leaseManager = new LeaseManager(Clocks.fakeClock());
    service = new RestfulGraphDatabase(new JsonFormat(), output, new DatabaseActions(leaseManager, true, database.getGraph()), null);
    service = new TransactionWrappingRestfulGraphDatabase(graph, service);
}
Also used : GraphDbHelper(org.neo4j.server.rest.domain.GraphDbHelper) JsonFormat(org.neo4j.server.rest.repr.formats.JsonFormat) LeaseManager(org.neo4j.server.rest.paging.LeaseManager) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) EntityOutputFormat(org.neo4j.test.server.EntityOutputFormat) Before(org.junit.Before)

Example 5 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase in project neo4j by neo4j.

the class DatabaseActionsTest method createDb.

@BeforeClass
public static void createDb() throws IOException {
    graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
    database = new WrappedDatabase(graph);
    graphdbHelper = new GraphDbHelper(database);
    actions = new TransactionWrappedDatabaseActions(new LeaseManager(Clocks.fakeClock()), database.getGraph());
}
Also used : GraphDbHelper(org.neo4j.server.rest.domain.GraphDbHelper) LeaseManager(org.neo4j.server.rest.paging.LeaseManager) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) BeforeClass(org.junit.BeforeClass)

Aggregations

WrappedDatabase (org.neo4j.server.database.WrappedDatabase)8 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)6 Test (org.junit.Test)4 Database (org.neo4j.server.database.Database)4 GraphDbHelper (org.neo4j.server.rest.domain.GraphDbHelper)4 LeaseManager (org.neo4j.server.rest.paging.LeaseManager)4 JsonFormat (org.neo4j.server.rest.repr.formats.JsonFormat)3 EntityOutputFormat (org.neo4j.test.server.EntityOutputFormat)3 Map (java.util.Map)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Response (javax.ws.rs.core.Response)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 Transaction (org.neo4j.graphdb.Transaction)2 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)2 CypherExecutor (org.neo4j.server.database.CypherExecutor)2 CypherSession (org.neo4j.server.rest.management.console.CypherSession)2 ConfigAdapter (org.neo4j.server.plugins.ConfigAdapter)1