Skip to content

Commit

Permalink
Test Base Tuning (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf authored Oct 28, 2023
1 parent 126850f commit 5c09fc6
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/test/java/io/nats/client/utils/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,20 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
runInServer(debug, jetstream, builder, null, inServerTest);
}

private static ServerInfo RUN_SERVER_INFO;
public static ServerInfo RUN_SERVER_INFO;

public static ServerInfo ensureRunServerInfo() throws Exception {
if (RUN_SERVER_INFO == null) {
runInServer(false, false, null, null, nc -> {});
}
return RUN_SERVER_INFO;
}

public static void initRunServerInfo(Connection nc) {
if (RUN_SERVER_INFO == null) {
RUN_SERVER_INFO = nc.getServerInfo();
}
}

public static void runInServer(boolean debug, boolean jetstream, Options.Builder builder, VersionCheck vc, InServerTest inServerTest) throws Exception {
if (vc != null && RUN_SERVER_INFO != null) {
Expand All @@ -186,9 +199,7 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
try (NatsTestServer ts = new NatsTestServer(debug, jetstream);
Connection nc = standardConnection(builder.server(ts.getURI()).build()))
{
if (RUN_SERVER_INFO == null) {
initRunServerInfo(nc);
}
initRunServerInfo(nc);

if (vc != null) {
if (!vc.runTest(RUN_SERVER_INFO)) {
Expand All @@ -207,17 +218,6 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
}
}

public static ServerInfo ensureRunServerInfo() throws Exception {
if (RUN_SERVER_INFO == null) {
runInServer(nc -> {});
}
return RUN_SERVER_INFO;
}

private static void initRunServerInfo(Connection nc) {
RUN_SERVER_INFO = nc.getServerInfo();
}

public static class LongRunningNatsTestServer extends NatsTestServer {
public final boolean jetstream;
public final Options.Builder builder;
Expand Down

0 comments on commit 5c09fc6

Please sign in to comment.