public void testConnectionRecoveryWithArrayOfAddresses() throws IOException, InterruptedException, TimeoutException { final Address[] addresses = {new Address("127.0.0.1"), new Address("127.0.0.1", 5672)}; AutorecoveringConnection c = newRecoveringConnection(addresses); try { assertTrue(c.isOpen()); closeAndWaitForRecovery(c); assertTrue(c.isOpen()); } finally { c.abort(); } }
public void testNamedConnectionRecovery() throws IOException, InterruptedException, TimeoutException { String connectionName = "custom name"; AutorecoveringConnection c = newRecoveringConnection(connectionName); try { assertTrue(c.isOpen()); assertEquals(connectionName, c.getClientProvidedName()); closeAndWaitForRecovery(c); assertTrue(c.isOpen()); assertEquals(connectionName, c.getClientProvidedName()); } finally { c.abort(); } }
public void testConnectionRecoveryWithDisabledTopologyRecovery() throws IOException, InterruptedException, TimeoutException { AutorecoveringConnection c = newRecoveringConnection(true); Channel ch = c.createChannel(); String q = "java-client.test.recovery.q2"; ch.queueDeclare(q, false, true, false, null); ch.queueDeclarePassive(q); assertTrue(c.isOpen()); try { CountDownLatch shutdownLatch = prepareForShutdown(c); CountDownLatch recoveryLatch = prepareForRecovery(c); Host.closeConnection(c); wait(shutdownLatch); wait(recoveryLatch); assertTrue(c.isOpen()); ch.queueDeclarePassive(q); fail("expected passive declaration to throw"); } catch (java.io.IOException e) { // expected } finally { c.abort(); } }