Skip to content

Commit

Permalink
[Tests] Removing generic-ness from naming part 2. (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf authored Oct 6, 2023
1 parent fe2a871 commit c0fd720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/test/java/io/nats/client/impl/JetStreamTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 6 additions & 19 deletions src/test/java/io/nats/client/utils/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c0fd720

Please sign in to comment.