final String rpcBindAddress = (rpcBindAddressOpt.trim().isEmpty()) ? fabric.getAddress() : rpcBindAddressOpt;
@Test public void firstDisconnectRecovery() throws Exception { CountDownLatch closeLatch = new CountDownLatch(1); FabricRunnerFactory factory = getFabric().registerProtocol(new Protocol(closeLatch)); FabricCommandRunner runner = factory.getCommandRunner(getFabric().getAddress(), getFabric().getPort()); // send a message, establishing the connection. { SimpleMessage m = new SimpleMessage(1); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); } closeLatch.countDown(); // wait for the local connection to be closed. Thread.sleep(1000); // ensure we can send message again. { SimpleMessage m = new SimpleMessage(1); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); } }
@Test(expected=ChannelClosedException.class) public void failureOnDisconnection() throws Exception { FabricRunnerFactory factory = getFabric().registerProtocol(new Protocol(null)); FabricCommandRunner runner = factory.getCommandRunner(getFabric().getAddress(), getFabric().getPort()); SimpleMessage m = new SimpleMessage(2); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); }