Package org.springframework.amqp.rabbit.connection

Examples of org.springframework.amqp.rabbit.connection.ConnectionFactory.createConnection()


  @Test
  public void testTxSizeAcks() 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


  @Test
  public void testTxSizeAcksWIthShortSet() 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

  @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

    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

  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

  @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

  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

    RabbitTemplate template = new RabbitTemplate(connectionFactory1);

    CountDownLatch latch = new CountDownLatch(messageCount);
    ConnectionFactory connectionFactory2 = createConnectionFactory();
    container = createContainer(queue.getName(),
        new CloseConnectionListener((ConnectionProxy) connectionFactory2.createConnection(), latch),
        connectionFactory2);
    for (int i = 0; i < messageCount; i++) {
      template.convertAndSend(queue.getName(), i + "foo");
    }
View Full Code Here

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

TOP
Copyright © 2018 www.massapi.com. 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.