@Test
 public void testConnectionFactoryBackOff() {
   load(TestConfiguration2.class);
   RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
   CachingConnectionFactory connectionFactory =
       this.context.getBean(CachingConnectionFactory.class);
   assertThat(connectionFactory).isEqualTo(rabbitTemplate.getConnectionFactory());
   assertThat(connectionFactory.getHost()).isEqualTo("otherserver");
   assertThat(connectionFactory.getPort()).isEqualTo(8001);
 }
 @Test
 public void testConnectionFactoryWithOverrides() {
   load(
       TestConfiguration.class,
       "spring.rabbitmq.host:remote-server",
       "spring.rabbitmq.port:9000",
       "spring.rabbitmq.username:alice",
       "spring.rabbitmq.password:secret",
       "spring.rabbitmq.virtual_host:/vhost");
   CachingConnectionFactory connectionFactory =
       this.context.getBean(CachingConnectionFactory.class);
   assertThat(connectionFactory.getHost()).isEqualTo("remote-server");
   assertThat(connectionFactory.getPort()).isEqualTo(9000);
   assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost");
 }
 @Test
 public void testDefaultRabbitConfiguration() {
   load(TestConfiguration.class);
   RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
   RabbitMessagingTemplate messagingTemplate = this.context.getBean(RabbitMessagingTemplate.class);
   CachingConnectionFactory connectionFactory =
       this.context.getBean(CachingConnectionFactory.class);
   DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
   RabbitAdmin amqpAdmin = this.context.getBean(RabbitAdmin.class);
   assertThat(rabbitTemplate.getConnectionFactory()).isEqualTo(connectionFactory);
   assertThat(getMandatory(rabbitTemplate)).isFalse();
   assertThat(messagingTemplate.getRabbitTemplate()).isEqualTo(rabbitTemplate);
   assertThat(amqpAdmin).isNotNull();
   assertThat(connectionFactory.getHost()).isEqualTo("localhost");
   assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(false);
   assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(false);
   assertThat(this.context.containsBean("rabbitListenerContainerFactory"))
       .as("Listener container factory should be created by default")
       .isTrue();
 }