public NatsServerProtocolMock(ExitAt exitAt) { this(NatsTestServer.nextPort(), exitAt); }
public NatsTestServer(boolean debug) { this(NatsTestServer.nextPort(), debug); }
public NatsServerProtocolMock(Customizer custom, String customInfo) { this.port = NatsTestServer.nextPort(); this.exitAt = ExitAt.NO_EXIT; this.customizer = custom; this.customInfo = customInfo; start(); }
public NatsServerProtocolMock(Customizer custom) { this.port = NatsTestServer.nextPort(); this.exitAt = ExitAt.NO_EXIT; this.customizer = custom; start(); }
public NatsTestServer(String configFilePath, boolean debug) { this.configFilePath = configFilePath; this.debug = debug; this.port = nextPort(); start(); }
public NatsTestServer(String[] customArgs, boolean debug) { this.port = NatsTestServer.nextPort(); this.debug = debug; this.customArgs = customArgs; start(); }
NatsConnection nc = null; TestHandler handler = new TestHandler(); int port = NatsTestServer.nextPort(); Duration reconnectWait = Duration.ofMillis(100); // thrash int thrashCount = 5;
TestHandler handler = new TestHandler(); Connection nc = null; int port = NatsTestServer.nextPort(); Options options = new Options.Builder(). server("nats://localhost:"+port).
@Test public void testUserPassInURLOnReconnect() throws Exception { TestHandler handler = new TestHandler(); int port = NatsTestServer.nextPort(); Connection nc = null; Subscription sub = null;
@Test public void testUserPassOnReconnect() throws Exception { TestHandler handler = new TestHandler(); int port = NatsTestServer.nextPort(); Connection nc = null; Subscription sub = null;
@Test public void testMaxReconnects() throws Exception { Connection nc = null; TestHandler handler = new TestHandler(); int port = NatsTestServer.nextPort(); try { try (NatsTestServer ts = new NatsTestServer(port, false)) { Options options = new Options.Builder(). server(ts.getURI()). maxReconnects(1). connectionListener(handler). reconnectWait(Duration.ofMillis(10)). build(); nc = Nats.connect(options); assertTrue("Connected Status", Connection.Status.CONNECTED == nc.getStatus()); handler.prepForStatusChange(Events.CLOSED); } flushAndWait(nc, handler); assertTrue("Closed Status", Connection.Status.CLOSED == nc.getStatus()); } finally { if (nc != null) { nc.close(); assertTrue("Closed Status", Connection.Status.CLOSED == nc.getStatus()); } } }
@Test public void testErrorOnAsync() throws IOException, InterruptedException { TestHandler handler = new TestHandler(); Options options = new Options.Builder(). server("nats://localhost:"+NatsTestServer.nextPort()). connectionListener(handler). errorListener(handler). noReconnect(). build(); handler.prepForStatusChange(Events.CLOSED); Nats.connectAsynchronously(options, false); handler.waitForStatusChange(10, TimeUnit.SECONDS); assertTrue(1 <= handler.getExceptionCount()); assertTrue(handler.getConnection() == null || Connection.Status.CLOSED == handler.getConnection().getStatus()); } }