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();
}
}
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();
}
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();
}
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();
}
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);
}
}
Aggregations