From c0fd720a0124741d52eefab3e94f7980473b9717 Mon Sep 17 00:00:00 2001 From: Scott Fauerbach Date: Fri, 6 Oct 2023 13:25:10 -0400 Subject: [PATCH] [Tests] Removing generic-ness from naming part 2. (#1004) --- .../nats/client/impl/JetStreamTestBase.java | 4 +-- .../java/io/nats/client/utils/TestBase.java | 25 +++++-------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/test/java/io/nats/client/impl/JetStreamTestBase.java b/src/test/java/io/nats/client/impl/JetStreamTestBase.java index 916acfa54..6ef2b41bf 100644 --- a/src/test/java/io/nats/client/impl/JetStreamTestBase.java +++ b/src/test/java/io/nats/client/impl/JetStreamTestBase.java @@ -45,11 +45,11 @@ public class JetStreamTestBase extends TestBase { public static final String InvalidMeta10Tokens = "$JS.ACK.v2Domain.v2Hash.test-stream.test-consumer.1.2.3.1605139610113260000"; public static final String InvalidMetaData = "$JS.ACK.v2Domain.v2Hash.test-stream.test-consumer.1.2.3.1605139610113260000.not-a-number"; - public static RunningServer jsServer; + public static LongRunningNatsTestServer jsServer; @BeforeAll public static void beforeAll() throws IOException, InterruptedException { - jsServer = new RunningServer(); + jsServer = new LongRunningNatsTestServer(false, true, null); } @AfterAll diff --git a/src/test/java/io/nats/client/utils/TestBase.java b/src/test/java/io/nats/client/utils/TestBase.java index dc86bc793..12b5d1804 100644 --- a/src/test/java/io/nats/client/utils/TestBase.java +++ b/src/test/java/io/nats/client/utils/TestBase.java @@ -188,40 +188,27 @@ private static void initRunServerInfo(Connection nc) { RUN_SERVER_INFO = nc.getServerInfo(); } - public static class RunningServer implements AutoCloseable { - public final boolean debug; + public static class LongRunningNatsTestServer extends NatsTestServer { public final boolean jetstream; - public final NatsTestServer ts; public final Options.Builder builder; public final Connection nc; - public RunningServer() throws IOException, InterruptedException { - this(false, true, null); - } - - public RunningServer(boolean debug, boolean jetstream, Options.Builder builder) throws IOException, InterruptedException { - this.debug = debug; + public LongRunningNatsTestServer(boolean debug, boolean jetstream, Options.Builder builder) throws IOException, InterruptedException { + super(debug, jetstream); this.jetstream = jetstream; this.builder = builder == null ? new Options.Builder() : builder; - ts = new NatsTestServer(debug, jetstream); nc = connect(); initRunServerInfo(nc); } public Connection connect() throws IOException, InterruptedException { - return standardConnection(builder.server(ts.getURI()).build()); + return standardConnection(builder.server(getURI()).build()); } @Override public void close() throws Exception { - if (jetstream) { - afterJetstream(); - } - nc.close(); - } - - public void afterJetstream() { - cleanupJs(nc); + try { nc.close(); } catch (Exception ignore) {}; + super.close(); } public void run(InServerTest inServerTest) throws Exception {