Package org.springframework.amqp.rabbit.connection

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


  }

  @SuppressWarnings("unchecked")
  @Test
  public void testConsumerArgs() 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>();
    final AtomicReference<Map<?, ?>> args = new AtomicReference<Map<?,?>>();
    doAnswer(new Answer<Object>() {
View Full Code Here


    container.stop();
  }

  @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);
View Full Code Here

    verify(channel2, atLeastOnce()).basicCancel("2");
  }

  @Test
  public void testChangeQueuesSimple() throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setQueueNames("foo");
    List<?> queues = TestUtils.getPropertyValue(container, "queueNames", List.class);
    assertEquals(1, queues.size());
    container.addQueues(new AnonymousQueue(), new AnonymousQueue());
View Full Code Here

    container.stop();
  }

  @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() {
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
View Full Code Here

    testRequeueOrNotDefaultNo(new MessageRejectedWhileStoppingException(), true);
  }

  @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
View Full Code Here

    verify(channel).basicQos(20);
  }

  private void testRequeueOrNotDefaultYes(Exception ex, boolean expectedRequeue) throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Channel channel = mock(Channel.class);
    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 1, "testQ");
    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
View Full Code Here

        AcknowledgeMode.AUTO, true, 1, "testQ");
    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
  }

  private void testRequeueOrNotDefaultNo(Exception ex, boolean expectedRequeue) throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Channel channel = mock(Channel.class);
    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 1, false, "testQ");
    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
View Full Code Here

  }

  @Test
  public void testListenerSendsMessageAndThenContainerCommits() throws Exception {

    ConnectionFactory connectionFactory = createConnectionFactory();
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    new RabbitAdmin(connectionFactory).declareQueue(sendQueue);

    acknowledgeMode = AcknowledgeMode.AUTO;
    transactional = true;
View Full Code Here

  }

  @Test
  public void testListenerSendsMessageAndThenRollback() throws Exception {

    ConnectionFactory connectionFactory = createConnectionFactory();
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    new RabbitAdmin(connectionFactory).declareQueue(sendQueue);

    acknowledgeMode = AcknowledgeMode.AUTO;
    transactional = true;
View Full Code Here

TOP

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

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.