Search in sources :

Example 1 with ClasspathConfigurationSource

use of org.neo4j.ogm.config.ClasspathConfigurationSource in project neo4j-ogm by neo4j.

the class BoltDriverConfigurationTest method shouldCallCloseOnJavaDriverWhenVerifyConnectivityFails.

@Test(expected = ConnectionException.class)
public void shouldCallCloseOnJavaDriverWhenVerifyConnectivityFails() {
    Driver javaDriver = Mockito.mock(Driver.class);
    Mockito.when(GraphDatabase.driver(Mockito.any(URI.class), Mockito.any(), Mockito.any())).thenReturn(javaDriver);
    Mockito.doThrow(ServiceUnavailableException.class).when(javaDriver).verifyConnectivity();
    try {
        new BoltDriver().configure(new Configuration.Builder(new ClasspathConfigurationSource("ogm-bolt.properties")).uri("bolt://localhost:" + TestUtils.getAvailablePort()).verifyConnection(true).build());
    } finally {
        Mockito.verify(javaDriver).close();
    }
}
Also used : ClasspathConfigurationSource(org.neo4j.ogm.config.ClasspathConfigurationSource) Driver(org.neo4j.driver.Driver) URI(java.net.URI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ClasspathConfigurationSource

use of org.neo4j.ogm.config.ClasspathConfigurationSource in project neo4j-ogm by neo4j.

the class BoltDriverServiceTest method loadBoltDriver.

@Test
public void loadBoltDriver() {
    String uri = new Configuration.Builder(new ClasspathConfigurationSource("ogm.properties")).build().getURI();
    Configuration driverConfiguration = new Configuration.Builder().uri(uri).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) ClasspathConfigurationSource(org.neo4j.ogm.config.ClasspathConfigurationSource) Configuration(org.neo4j.ogm.config.Configuration) Driver(org.neo4j.ogm.driver.Driver) Test(org.junit.Test)

Example 3 with ClasspathConfigurationSource

use of org.neo4j.ogm.config.ClasspathConfigurationSource in project neo4j-ogm by neo4j.

the class DriverExceptionTest method shouldThrowExceptionWhenHttpDriverCannotConnect.

// TODO: All drivers should consistently throw the same exception on configuration or connection failure.
@Test(expected = Exception.class)
public void shouldThrowExceptionWhenHttpDriverCannotConnect() {
    Configuration configuration = new Configuration.Builder(new ClasspathConfigurationSource("ogm-http-invalid.properties")).build();
    SessionFactory sessionFactory = new SessionFactory(configuration, "org.neo4j.ogm.domain.social");
    Session session = sessionFactory.openSession();
    session.purgeDatabase();
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) ClasspathConfigurationSource(org.neo4j.ogm.config.ClasspathConfigurationSource) Configuration(org.neo4j.ogm.config.Configuration) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 4 with ClasspathConfigurationSource

use of org.neo4j.ogm.config.ClasspathConfigurationSource in project neo4j-ogm by neo4j.

the class DriverExceptionTest method shouldThrowExceptionWhenBoltDriverCannotConnect.

// TODO: All drivers should consistently throw the same exception on configuration or connection failure.
@Test(expected = Exception.class)
public void shouldThrowExceptionWhenBoltDriverCannotConnect() {
    Configuration configuration = new Configuration.Builder(new ClasspathConfigurationSource("ogm-bolt-invalid.properties")).build();
    SessionFactory sessionFactory = new SessionFactory(configuration, "org.neo4j.ogm.domain.social");
    Session session = sessionFactory.openSession();
    session.purgeDatabase();
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) ClasspathConfigurationSource(org.neo4j.ogm.config.ClasspathConfigurationSource) Configuration(org.neo4j.ogm.config.Configuration) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Example 5 with ClasspathConfigurationSource

use of org.neo4j.ogm.config.ClasspathConfigurationSource in project neo4j-ogm by neo4j.

the class EmbeddedDriverTest method shouldHandleCustomConfFilesFromOgmProperties.

@Test
public void shouldHandleCustomConfFilesFromOgmProperties() {
    try (EmbeddedDriver driver = new EmbeddedDriver()) {
        driver.configure(new Configuration.Builder(new ClasspathConfigurationSource("ogm-pointing-to-custom-conf.properties")).build());
        assertCustomConfiguration(driver);
    }
}
Also used : ClasspathConfigurationSource(org.neo4j.ogm.config.ClasspathConfigurationSource) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ClasspathConfigurationSource (org.neo4j.ogm.config.ClasspathConfigurationSource)6 Configuration (org.neo4j.ogm.config.Configuration)4 SessionFactory (org.neo4j.ogm.session.SessionFactory)4 Session (org.neo4j.ogm.session.Session)3 URI (java.net.URI)1 DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)1 Driver (org.neo4j.driver.Driver)1 Driver (org.neo4j.ogm.driver.Driver)1 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1