@AfterClass public static void tearDown() { db.shutdown(); server.close(); }
@Override public void start() { if (serverControls == null) { serverControls = new InProcessServerBuilder().newServer(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { serverControls.close(); } catch (Exception ignored) { } })); } }
/** * Stops the underlying server bootstrapper and, in turn, the Neo4j server. */ public void shutdown() { if (database != null && database.isAvailable(100)) { LOGGER.info("Stopping {} server on: {}", enableBolt ? "BOLT" : "HTTP", port); database.shutdown(); database = null; } controls.close(); }
@Override public void start() { if (serverControls == null) { serverControls = new InProcessServerBuilder() .withFunction(Neo4jTestUserFunction.class) .newServer(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { serverControls.close(); } catch (Exception ignored) { } })); } }
serverControls.close();
@Override public void start() { if (serverControls == null) { serverControls = new InProcessServerBuilder() .withFunction(Neo4jTestUserFunction.class) .newServer(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { serverControls.close(); } catch (Exception ignored) { } })); } }
@Override public void start() { if (serverControls == null) { serverControls = new InProcessServerBuilder() .withFunction(Neo4jTestUserFunction.class) .newServer(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { serverControls.close(); } catch (Exception ignored) { } })); } }
@AfterClass public static void stopServer() { serverControls.close(); } }
@AfterClass public static void tearDownNeo4j() { serverControls.close(); }
@AfterClass public static void stopServer() { sessionFactory.close(); serverControls.close(); } }
@Test public void translatesServiceUnavailabeException() { try (ServerControls serverControls = TestServerBuilders.newInProcessBuilder().newServer()) { BoltDriver driver = new BoltDriver(); Configuration ogmConfiguration = new Configuration.Builder().uri(serverControls.boltURI().toString()) .verifyConnection(true).build(); driver.configure(ogmConfiguration); SessionFactory sessionFactory = new SessionFactory(driver, DOMAIN_PACKAGE); Session session = sessionFactory.openSession(); serverControls.close(); assertThatExceptionOfType(ConnectionException.class).isThrownBy(() -> { session.loadAll(ConstraintedNode.class); }).withCauseInstanceOf(ServiceUnavailableException.class); } } }