@After public void tearDown() { this.brokerRunning.removeTestQueues(); ((CachingConnectionFactory) this.rabbitTemplate.getConnectionFactory()).destroy(); }
@Test public void pubSubLostConnectionTest() throws Exception { final CyclicBarrier latch = new CyclicBarrier(2); channel.subscribe(message -> { try { latch.await(10, TimeUnit.SECONDS); } catch (Exception e) { } }); this.channel.send(new GenericMessage<>("foo")); latch.await(10, TimeUnit.SECONDS); latch.reset(); BlockingQueueConsumer consumer = (BlockingQueueConsumer) TestUtils.getPropertyValue(this.channel, "container.consumers", Set.class).iterator().next(); connectionFactory.destroy(); waitForNewConsumer(this.channel, consumer); this.channel.send(new GenericMessage<>("bar")); latch.await(10, TimeUnit.SECONDS); this.channel.destroy(); this.pubSubWithEP.destroy(); this.withEP.destroy(); this.pollableWithEP.destroy(); assertEquals(0, TestUtils.getPropertyValue(connectionFactory, "connectionListener.delegates", Collection.class).size()); }
private void testNackOrRequeue(boolean requeue) throws IOException, TimeoutException { Channel channel = mock(Channel.class); willReturn(true).given(channel).isOpen(); Envelope envelope = new Envelope(123L, false, "ex", "rk"); BasicProperties props = new BasicProperties.Builder().build(); GetResponse getResponse = new GetResponse(envelope, props, "bar".getBytes(), 0); willReturn(getResponse).given(channel).basicGet("foo", false); Connection connection = mock(Connection.class); willReturn(true).given(connection).isOpen(); willReturn(channel).given(connection).createChannel(); ConnectionFactory connectionFactory = mock(ConnectionFactory.class); willReturn(connection).given(connectionFactory).newConnection((ExecutorService) isNull(), anyString()); CachingConnectionFactory ccf = new CachingConnectionFactory(connectionFactory); AmqpMessageSource source = new AmqpMessageSource(ccf, "foo"); Message<?> received = source.receive(); verify(connection).createChannel(); StaticMessageHeaderAccessor.getAcknowledgmentCallback(received) .acknowledge(requeue ? Status.REQUEUE : Status.REJECT); verify(channel).basicReject(123L, requeue); verify(connection).createChannel(); ccf.destroy(); verify(channel).close(); verify(connection).close(30000); }
notCached.close(); cached.close(); ccf.destroy(); verify(channel, times(2)).close(); verify(connection).close(30000);
@After public void cleanUp() { this.templateWithConfirmsEnabled.stop(); this.templateWithReturnsEnabled.stop(); this.connectionFactory.destroy(); this.connectionFactoryWithConfirmsEnabled.destroy(); this.connectionFactoryWithReturnsEnabled.destroy(); this.brokerIsRunning.removeTestQueues(); this.executorService.shutdown(); }
@AfterClass public static void tearDown() { brokerRunning.removeTestQueues(); adminCf.destroy(); }
@After public void close() { if (context != null) { context.close(); } if (connectionFactory != null) { connectionFactory.destroy(); } }
@After public void cleanUp() { if (connectionFactoryWithConfirmsEnabled != null) { connectionFactoryWithConfirmsEnabled.destroy(); } this.brokerIsRunning.removeTestQueues(); }
@After public void tearDown() throws Exception { this.lqcf.destroy(); this.defaultConnectionFactory.destroy(); }
@After public void tearDown() { this.brokerIsRunning.removeTestQueues(); this.connectionFactory.destroy(); }
@Test public void testConnectionCloseLog() { Log logger = spy(TestUtils.getPropertyValue(this.connectionFactory, "logger", Log.class)); new DirectFieldAccessor(this.connectionFactory).setPropertyValue("logger", logger); Connection conn = this.connectionFactory.createConnection(); conn.createChannel(false); this.connectionFactory.destroy(); verify(logger, never()).error(anyString()); }
@After public void cleanUp() { this.brokerIsRunning.removeTestQueues(); this.template.stop(); this.connectionFactory.destroy(); }
@After public void cleanup() { this.template.stop(); this.connectionFactory.destroy(); this.brokerIsRunning.removeTestQueues(); }
@After public void close() { if (!this.connectionFactory.getVirtualHost().equals("non-existent")) { this.brokerIsRunning.removeTestQueues(); } assertEquals("bar", connectionFactory.getRabbitConnectionFactory().getClientProperties().get("foo")); connectionFactory.destroy(); }
@Test public void testConnectionName() { Connection connection = this.connectionFactory.createConnection(); com.rabbitmq.client.Connection rabbitConnection = TestUtils.getPropertyValue(connection, "target.delegate", com.rabbitmq.client.Connection.class); assertEquals(CF_INTEGRATION_CONNECTION_NAME, rabbitConnection.getClientProperties().get("connection_name")); this.connectionFactory.destroy(); }
@After public void cleanUp() { if (!repeat.isFinalizing()) { return; } this.template.stop(); this.connectionFactory.destroy(); this.brokerIsRunning.removeTestQueues(); }
@BeforeClass @AfterClass public static void setupAndCleanUp() { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); RabbitAdmin admin = new RabbitAdmin(cf); admin.deleteQueue("stop.start.queue"); admin.deleteExchange("stop.start.exchange"); cf.destroy(); }
@BeforeClass @AfterClass public static void setupAndCleanUp() { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); RabbitAdmin admin = new RabbitAdmin(cf); admin.deleteExchange("remoting.test.exchange"); admin.deleteQueue("remoting.test.queue"); cf.destroy(); }
@Before public void init() { connectionFactory.setHost("localhost"); context = new GenericApplicationContext(); context.refresh(); rabbitAdmin = new RabbitAdmin(connectionFactory); rabbitAdmin.deleteQueue("test.queue"); // Force connection factory to forget that it has been used to delete the queue connectionFactory.destroy(); rabbitAdmin.setApplicationContext(context); rabbitAdmin.setAutoStartup(true); }