Search in sources :

Example 11 with Driver

use of org.neo4j.ogm.driver.Driver in project neo4j-ogm by neo4j.

the class DistanceComparisonBoltTest method init.

@BeforeClass
public static void init() {
    assumeTrue(isBoltDriver());
    Configuration ogmConfiguration = getBaseConfigurationBuilder().useNativeTypes().build();
    Driver boltOgmDriver = new BoltDriver();
    boltOgmDriver.configure(ogmConfiguration);
    sessionFactory = new SessionFactory(boltOgmDriver, DatesBoltTest.class.getPackage().getName());
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) DatesBoltTest(org.neo4j.ogm.persistence.types.nativetypes.DatesBoltTest) BoltDriver(org.neo4j.ogm.drivers.bolt.driver.BoltDriver) Configuration(org.neo4j.ogm.config.Configuration) Driver(org.neo4j.ogm.driver.Driver) BoltDriver(org.neo4j.ogm.drivers.bolt.driver.BoltDriver) BeforeClass(org.junit.BeforeClass)

Example 12 with Driver

use of org.neo4j.ogm.driver.Driver in project neo4j-ogm by neo4j.

the class DriverServiceTest method shouldLoadEmbeddedDriver.

@Test
public void shouldLoadEmbeddedDriver() {
    Configuration driverConfiguration = new Configuration.Builder().uri(TMP_NEO4J_DB.toUri().toString()).build();
    SessionFactory sf = new SessionFactory(driverConfiguration, "org.neo4j.ogm.domain.social.User");
    Driver driver = sf.unwrap(Driver.class);
    assertThat(driver).isNotNull();
    driver.close();
    sf.close();
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) HttpDriver(org.neo4j.ogm.drivers.http.driver.HttpDriver) Driver(org.neo4j.ogm.driver.Driver) Test(org.junit.Test)

Example 13 with Driver

use of org.neo4j.ogm.driver.Driver in project neo4j-ogm by neo4j.

the class DriverServiceTest method shouldLoadHttpDriver.

@Test
public void shouldLoadHttpDriver() {
    Configuration driverConfiguration = new Configuration.Builder().uri("http://neo4j:password@localhost:7474").build();
    SessionFactory sf = new SessionFactory(driverConfiguration, "org.neo4j.ogm.domain.social.User");
    Driver driver = sf.unwrap(Driver.class);
    assertThat(driver).isNotNull();
    sf.close();
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) HttpDriver(org.neo4j.ogm.drivers.http.driver.HttpDriver) Driver(org.neo4j.ogm.driver.Driver) Test(org.junit.Test)

Example 14 with Driver

use of org.neo4j.ogm.driver.Driver in project neo4j-ogm by neo4j.

the class CypherModificationSPITest method driverShouldProvideNoopModificationWithoutAnyProvider.

@Test
public void driverShouldProvideNoopModificationWithoutAnyProvider() {
    Driver driver = new TestDriver();
    driver.configure(new Configuration.Builder().build());
    Function<String, String> cypherModification = driver.getCypherModification();
    String cypher = "MATCH (n) RETURN n";
    assertThat(cypherModification.apply(cypher)).isEqualTo(cypher);
}
Also used : AbstractConfigurableDriver(org.neo4j.ogm.driver.AbstractConfigurableDriver) Driver(org.neo4j.ogm.driver.Driver) Test(org.junit.Test)

Example 15 with Driver

use of org.neo4j.ogm.driver.Driver in project neo4j-ogm by neo4j.

the class CypherModificationSPITest method abstractDriverShouldLoadCypherModificationsInCorrectOrder.

@Test
public void abstractDriverShouldLoadCypherModificationsInCorrectOrder() {
    Thread currentThread = Thread.currentThread();
    ClassLoader originalClassLoader = currentThread.getContextClassLoader();
    currentThread.setContextClassLoader(new TestServiceLoaderClassLoader(originalClassLoader));
    Configuration driverConfiguration = new Configuration.Builder().withCustomProperty("config1", 6).withCustomProperty("config2", 9).build();
    Driver driver = new TestDriver();
    driver.configure(driverConfiguration);
    try {
        Function<String, String> cypherModification = driver.getCypherModification();
        assertThat(cypherModification.apply("What do you get if you multiply six by nine?")).isEqualTo("42");
    } finally {
        currentThread.setContextClassLoader(originalClassLoader);
    }
}
Also used : Configuration(org.neo4j.ogm.config.Configuration) AbstractConfigurableDriver(org.neo4j.ogm.driver.AbstractConfigurableDriver) Driver(org.neo4j.ogm.driver.Driver) Test(org.junit.Test)

Aggregations

Driver (org.neo4j.ogm.driver.Driver)15 SessionFactory (org.neo4j.ogm.session.SessionFactory)8 Test (org.junit.Test)6 Configuration (org.neo4j.ogm.config.Configuration)6 BeforeClass (org.junit.BeforeClass)5 Neo4JSessionExt (com.pamirs.attach.plugin.neo4j.config.Neo4JSessionExt)3 DriverConfiguration (org.neo4j.ogm.config.DriverConfiguration)3 AbstractConfigurableDriver (org.neo4j.ogm.driver.AbstractConfigurableDriver)3 HttpDriver (org.neo4j.ogm.drivers.http.driver.HttpDriver)3 BoltDriver (org.neo4j.ogm.drivers.bolt.driver.BoltDriver)2 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)2 DriverConfig (com.pamirs.attach.plugin.neo4j.config.DriverConfig)1 Neo4JSessionOperation (com.pamirs.attach.plugin.neo4j.config.Neo4JSessionOperation)1 Operation (com.pamirs.attach.plugin.neo4j.operation.Operation)1 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)1 ShadowDatabaseConfig (com.pamirs.pradar.internal.config.ShadowDatabaseConfig)1 DataSourceMeta (com.pamirs.pradar.pressurement.agent.shared.service.DataSourceMeta)1 AuthTokenCredentials (org.neo4j.ogm.authentication.AuthTokenCredentials)1 Credentials (org.neo4j.ogm.authentication.Credentials)1 UsernamePasswordCredentials (org.neo4j.ogm.authentication.UsernamePasswordCredentials)1