/** * Close the connections of the {@link SessionFactory} so that the process can terminate. */ public void close() { this.sessionFactory.close(); }
@AfterClass public static void closeSessionFactory() { sessionFactory.close(); } }
@AfterClass public static void closeSessionFactory() { sessionFactory.close(); } }
@AfterClass public static void closeSessionFactory() { sessionFactory.close(); } }
@AfterClass public static void stopServer() { sessionFactory.close(); serverControls.close(); } }
@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(); }
@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(); }
@Test // GH-479 public void shouldIgnoreResultsIfQueryMapsToVoid() { SessionFactory sessionFactory = null; try (Driver driver = GraphDatabase.driver(boltURI, driverConfig)) { sessionFactory = new SessionFactory(new BoltDriver(driver), ResponseMapperTest.class.getName()); Session session = sessionFactory.openSession(); // The call would have been successfull if the procedure would have returned a stream of // things with at max 1 attribute, but in the end, that would be what was requested for. session.query(void.class, "CALL apoc.periodic.iterate('MATCH (d:Document) RETURN d', " + " 'SET d.thisIsAProperty = 0'" + " ,{batchSize:200, parallel:false, iterateList:true}) ", new HashMap<>()); } finally { if (sessionFactory != null) { sessionFactory.close(); } } }
@Test public void loadLoadBoltDriver() { String uri = getBaseConfiguration().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(); }