Package org.springframework.amqp.rabbit.connection

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


  @Rule
  public BrokerRunning brokerIsRunning = BrokerRunning.isRunning();

  @Test
  public void testSettingOfNullConectionFactory() {
    ConnectionFactory connectionFactory = null;
    try {
      new RabbitAdmin(connectionFactory);
      fail("should have thrown IllegalArgumentException when ConnectionFactory is null.");
    }
    catch (IllegalArgumentException e) {
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>() {

View Full Code Here

    assertEquals("Admin should not have created a channel", 0,  mockChannels.size());
  }

  @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

    verify(channel).queueBind("foo", "bar", "foo", null);
  }

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

    verify(channel, times(0)).queueBind("foo", "bar", "foo", null);
  }

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

  }

  @Test
  public void testAddRemove() {
    Queue queue = new Queue("foo");
    ConnectionFactory cf = mock(ConnectionFactory.class);
    RabbitAdmin admin1 = new RabbitAdmin(cf);
    RabbitAdmin admin2 = new RabbitAdmin(cf);
    queue.setAdminsThatShouldDeclare(admin1, admin2);
    assertEquals(2, queue.getDeclaringAdmins().size());
    queue.setAdminsThatShouldDeclare(admin1);
View Full Code Here

    private static ConnectionListener listener2;

    @Bean
    public ConnectionFactory cf1() throws IOException {
      ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
      when(connectionFactory.createConnection()).thenReturn(conn1);
      when(conn1.createChannel(false)).thenReturn(channel1);
      when(channel1.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
      doAnswer(new Answer<Object>() {

        @Override
View Full Code Here

      return connectionFactory;
    }

    @Bean
    public ConnectionFactory cf2() throws IOException {
      ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
      when(connectionFactory.createConnection()).thenReturn(conn2);
      when(conn2.createChannel(false)).thenReturn(channel2);
      when(channel2.queueDeclare("foo", true, false, false, null)).thenReturn(new AMQImpl.Queue.DeclareOk("foo", 0, 0));
      doAnswer(new Answer<Object>() {

        @Override
View Full Code Here

      }
      else {
        lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext);
      }
      if (lookupKey != null) {
        ConnectionFactory connectionFactory = routingConnectionFactory.getTargetConnectionFactory(lookupKey);
        if (connectionFactory != null) {
          return connectionFactory;
        }
        else if (!routingConnectionFactory.isLenientFallback()) {
          throw new IllegalStateException("Cannot determine target ConnectionFactory for lookup key ["
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.