Package org.springframework.amqp.rabbit.connection

Examples of org.springframework.amqp.rabbit.connection.Connection


  }

  @Test
  public void testChangeQueues() throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Channel channel1 = mock(Channel.class);
    Channel channel2 = mock(Channel.class);
    when(channel1.isOpen()).thenReturn(true);
    when(channel2.isOpen()).thenReturn(true);
    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createChannel(false)).thenReturn(channel1, channel2);
    List<Consumer> consumers = new ArrayList<Consumer>();
    AtomicInteger consumerTag = new AtomicInteger();
    CountDownLatch latch1 = new CountDownLatch(1);
    CountDownLatch latch2 = new CountDownLatch(2);
    setupMockConsume(channel1, consumers, consumerTag, latch1);
View Full Code Here


  }

  @Test
  public void testAddQueuesAndStartInCycle() throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Channel channel1 = mock(Channel.class);
    when(channel1.isOpen()).thenReturn(true);
    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createChannel(false)).thenReturn(channel1);

    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setMessageListener(new MessageListener() {

      @Override
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testConsumerCancel() throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Channel channel = mock(Channel.class);
    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createChannel(false)).thenReturn(channel);
    final AtomicReference<Consumer> consumer = new AtomicReference<Consumer>();
    doAnswer(new Answer<Object>() {

      @Override
      public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

  }

  @Test
  public void testPrefetchIsSetOnFailedPassiveDeclaration() throws IOException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Channel channel = mock(Channel.class);

    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createChannel(Mockito.anyBoolean())).thenReturn(channel);
    when(channel.queueDeclarePassive(Mockito.anyString()))
        .then(new Answer<Object>() {

          @Override
          public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

public class RabbitAdminDeclarationTests {

  @Test
  public void testUnconditional() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);
    Connection conn = mock(Connection.class);
    Channel channel = mock(Channel.class);
    when(cf.createConnection()).thenReturn(conn);
    when(conn.createChannel(false)).thenReturn(channel);
    when(channel.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
    final AtomicReference<ConnectionListener> listener = new AtomicReference<ConnectionListener>();
    doAnswer(new Answer<Object>() {

      @Override
View Full Code Here

  }

  @Test
  public void testUnconditionalWithExplicitFactory() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);
    Connection conn = mock(Connection.class);
    Channel channel = mock(Channel.class);
    when(cf.createConnection()).thenReturn(conn);
    when(conn.createChannel(false)).thenReturn(channel);
    when(channel.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
    final AtomicReference<ConnectionListener> listener = new AtomicReference<ConnectionListener>();
    doAnswer(new Answer<Object>() {

      @Override
View Full Code Here

  }

  @Test
  public void testSkipBecauseDifferentFactory() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);
    Connection conn = mock(Connection.class);
    Channel channel = mock(Channel.class);
    when(cf.createConnection()).thenReturn(conn);
    when(conn.createChannel(false)).thenReturn(channel);
    when(channel.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
    final AtomicReference<ConnectionListener> listener = new AtomicReference<ConnectionListener>();
    doAnswer(new Answer<Object>() {

      @Override
View Full Code Here

  }

  @Test
  public void testSkipBecauseShouldntDeclare() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);
    Connection conn = mock(Connection.class);
    Channel channel = mock(Channel.class);
    when(cf.createConnection()).thenReturn(conn);
    when(conn.createChannel(false)).thenReturn(channel);
    when(channel.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
    final AtomicReference<ConnectionListener> listener = new AtomicReference<ConnectionListener>();
    doAnswer(new Answer<Object>() {

      @Override
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.connection.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.