@Test
  public void testInTcp() {
    DirectFieldAccessor dfa = new DirectFieldAccessor(tcpIn);
    assertSame(cfS1, dfa.getPropertyValue("serverConnectionFactory"));
    assertEquals("testInTcp", tcpIn.getComponentName());
    assertEquals("ip:tcp-inbound-channel-adapter", tcpIn.getComponentType());
    assertEquals(errorChannel, dfa.getPropertyValue("errorChannel"));
    assertFalse(cfS1.isLookupHost());
    assertFalse(tcpIn.isAutoStartup());
    assertEquals(124, tcpIn.getPhase());
    TcpMessageMapper cfS1Mapper =
        TestUtils.getPropertyValue(cfS1, "mapper", TcpMessageMapper.class);
    assertSame(mapper, cfS1Mapper);
    assertTrue((Boolean) TestUtils.getPropertyValue(cfS1Mapper, "applySequence"));
    Object socketSupport = TestUtils.getPropertyValue(cfS1, "tcpSocketFactorySupport");
    assertTrue(socketSupport instanceof DefaultTcpNetSSLSocketFactorySupport);
    assertNotNull(TestUtils.getPropertyValue(socketSupport, "sslContext"));

    TcpSSLContextSupport contextSupport =
        TestUtils.getPropertyValue(
            cfS1, "tcpSocketFactorySupport.sslContextSupport", TcpSSLContextSupport.class);
    assertSame(contextSupport, this.contextSupport);
    assertTrue(TestUtils.getPropertyValue(contextSupport, "keyStore") instanceof ClassPathResource);
    assertTrue(
        TestUtils.getPropertyValue(contextSupport, "trustStore") instanceof ClassPathResource);

    contextSupport = new DefaultTcpSSLContextSupport("http:foo", "file:bar", "", "");
    assertTrue(TestUtils.getPropertyValue(contextSupport, "keyStore") instanceof UrlResource);
    assertTrue(TestUtils.getPropertyValue(contextSupport, "trustStore") instanceof UrlResource);
  }
 @Test
 public void testSecureServer() {
   DirectFieldAccessor dfa = new DirectFieldAccessor(secureServer);
   assertSame(socketFactorySupport, dfa.getPropertyValue("tcpSocketFactorySupport"));
   assertSame(socketSupport, dfa.getPropertyValue("tcpSocketSupport"));
   assertEquals(34, TestUtils.getPropertyValue(this.secureServerNio, "sslHandshakeTimeout"));
 }
 @Test // see INT-2011
 public void testAggregatorWithPojoReleaseStrategyAsCollection() {
   MessageChannel input =
       (MessageChannel) context.getBean("aggregatorWithPojoReleaseStrategyInputAsCollection");
   EventDrivenConsumer endpoint =
       (EventDrivenConsumer) context.getBean("aggregatorWithPojoReleaseStrategyAsCollection");
   ReleaseStrategy releaseStrategy =
       (ReleaseStrategy)
           new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"))
               .getPropertyValue("releaseStrategy");
   Assert.assertTrue(releaseStrategy instanceof MethodInvokingReleaseStrategy);
   DirectFieldAccessor releaseStrategyAccessor =
       new DirectFieldAccessor(
           new DirectFieldAccessor(
                   new DirectFieldAccessor(releaseStrategy).getPropertyValue("adapter"))
               .getPropertyValue("delegate"));
   Object handlerMethods = releaseStrategyAccessor.getPropertyValue("handlerMethods");
   assertNull(handlerMethods);
   Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod");
   assertTrue(handlerMethod.toString().contains("checkCompleteness"));
   input.send(createMessage(1L, "correlationId", 4, 0, null));
   input.send(createMessage(2L, "correlationId", 4, 1, null));
   input.send(createMessage(3L, "correlationId", 4, 2, null));
   PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
   Message<?> reply = outputChannel.receive(0);
   Assert.assertNull(reply);
   input.send(createMessage(5L, "correlationId", 4, 3, null));
   reply = outputChannel.receive(0);
   Assert.assertNotNull(reply);
   assertEquals(11L, reply.getPayload());
 }
 @Test
 public void replyQosPropertiesDisabledByDefault() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext("inboundGatewayDefault.xml", this.getClass());
   JmsMessageDrivenEndpoint gateway = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
   DirectFieldAccessor accessor =
       new DirectFieldAccessor(new DirectFieldAccessor(gateway).getPropertyValue("listener"));
   assertEquals(false, accessor.getPropertyValue("explicitQosEnabledForReplies"));
 }
 @Test
 public void testRabbitTemplateMessageConverters() {
   load(MessageConvertersConfiguration.class);
   RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
   assertThat(rabbitTemplate.getMessageConverter())
       .isSameAs(this.context.getBean("myMessageConverter"));
   DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
   assertThat(dfa.getPropertyValue("retryTemplate")).isNull();
 }
 @Test
 @SuppressWarnings("unchecked")
 public void putOrDeleteMethodsSupported() throws Exception {
   DirectFieldAccessor accessor = new DirectFieldAccessor(putOrDeleteAdapter);
   List<String> supportedMethods = (List<String>) accessor.getPropertyValue("supportedMethods");
   assertEquals(2, supportedMethods.size());
   assertTrue(supportedMethods.contains(HttpMethod.PUT));
   assertTrue(supportedMethods.contains(HttpMethod.DELETE));
 }
 @Test
 public void testGatewayWithDefaultExtractPayload() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext(
           "jmsGatewaysWithExtractPayloadAttributes.xml", this.getClass());
   JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("defaultGateway");
   DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
   accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
   assertEquals(Boolean.TRUE, accessor.getPropertyValue("extractReplyPayload"));
 }
 @Test
 public void minimalConfig() {
   HttpRequestExecutingMessageHandler handler =
       (HttpRequestExecutingMessageHandler)
           new DirectFieldAccessor(this.minimalConfigEndpoint).getPropertyValue("handler");
   MessageChannel requestChannel =
       (MessageChannel)
           new DirectFieldAccessor(this.minimalConfigEndpoint).getPropertyValue("inputChannel");
   assertEquals(this.applicationContext.getBean("requests"), requestChannel);
   DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
   Object replyChannel = handlerAccessor.getPropertyValue("outputChannel");
   assertNull(replyChannel);
   DirectFieldAccessor templateAccessor =
       new DirectFieldAccessor(handlerAccessor.getPropertyValue("restTemplate"));
   ClientHttpRequestFactory requestFactory =
       (ClientHttpRequestFactory) templateAccessor.getPropertyValue("requestFactory");
   assertTrue(requestFactory instanceof SimpleClientHttpRequestFactory);
   Expression uriExpression = (Expression) handlerAccessor.getPropertyValue("uriExpression");
   assertEquals("http://localhost/test1", uriExpression.getValue());
   assertEquals(
       HttpMethod.POST.name(),
       TestUtils.getPropertyValue(handler, "httpMethodExpression", Expression.class)
           .getExpressionString());
   assertEquals("UTF-8", handlerAccessor.getPropertyValue("charset"));
   assertEquals(true, handlerAccessor.getPropertyValue("extractPayload"));
   assertEquals(false, handlerAccessor.getPropertyValue("transferCookies"));
 }
 @Test
 public void testTransactionManagerIsNullByDefault() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext(
           "jmsGatewayTransactionManagerTests.xml", this.getClass());
   JmsMessageDrivenEndpoint gateway =
       (JmsMessageDrivenEndpoint) context.getBean("gatewayWithoutTransactionManager");
   DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
   accessor = new DirectFieldAccessor(accessor.getPropertyValue("listenerContainer"));
   assertNull(accessor.getPropertyValue("transactionManager"));
 }
  @Test
  public void outboundGateway() throws Exception {
    DirectFieldAccessor accessor =
        new DirectFieldAccessor(new DirectFieldAccessor(gateway).getPropertyValue("handler"));
    File expected = new ClassPathResource("").getFile();

    Expression destinationDirectoryExpression =
        (Expression) accessor.getPropertyValue("destinationDirectoryExpression");
    File actual = new File(destinationDirectoryExpression.getExpressionString());

    assertEquals("'destinationDirectory' should be set", expected, actual);
  }
 @Test
 public void queueNameWithResolverChannel() {
   assertEquals(JmsDestinationBackedMessageChannel.class, queueNameWithResolverChannel.getClass());
   JmsDestinationBackedMessageChannel channel =
       (JmsDestinationBackedMessageChannel) queueNameWithResolverChannel;
   DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
   JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
   AbstractMessageListenerContainer container =
       (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
   assertEquals("foo", jmsTemplate.getDefaultDestinationName());
   assertEquals("foo", container.getDestinationName());
 }
 @Test
 public void topicReferenceChannel() {
   assertEquals(JmsDestinationBackedMessageChannel.class, topicReferenceChannel.getClass());
   JmsDestinationBackedMessageChannel channel =
       (JmsDestinationBackedMessageChannel) topicReferenceChannel;
   DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
   JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
   AbstractMessageListenerContainer container =
       (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
   assertEquals(topic, jmsTemplate.getDefaultDestination());
   assertEquals(topic, container.getDestination());
 }
 @Test
 public void channelWithConcurrencySettings() {
   assertEquals(
       JmsDestinationBackedMessageChannel.class, channelWithConcurrencySettings.getClass());
   JmsDestinationBackedMessageChannel channel =
       (JmsDestinationBackedMessageChannel) channelWithConcurrencySettings;
   DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
   DefaultMessageListenerContainer container =
       (DefaultMessageListenerContainer) accessor.getPropertyValue("container");
   assertEquals(11, container.getConcurrentConsumers());
   assertEquals(55, container.getMaxConcurrentConsumers());
 }
 @Test
 public void testRabbitListenerContainerFactoryBackOff() {
   load(TestConfiguration5.class);
   SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory =
       this.context.getBean(
           "rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class);
   rabbitListenerContainerFactory.setTxSize(10);
   verify(rabbitListenerContainerFactory).setTxSize(10);
   DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
   Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
   assertThat(adviceChain).isNull();
 }
 @Test
 public void testGatewayWithReplyQosProperties() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext("inboundGatewayWithReplyQos.xml", this.getClass());
   JmsMessageDrivenEndpoint gateway =
       context.getBean("gatewayWithReplyQos", JmsMessageDrivenEndpoint.class);
   DirectFieldAccessor accessor =
       new DirectFieldAccessor(new DirectFieldAccessor(gateway).getPropertyValue("listener"));
   assertEquals(12345L, accessor.getPropertyValue("replyTimeToLive"));
   assertEquals(7, accessor.getPropertyValue("replyPriority"));
   assertEquals(DeliveryMode.NON_PERSISTENT, accessor.getPropertyValue("replyDeliveryMode"));
   assertEquals(true, accessor.getPropertyValue("explicitQosEnabledForReplies"));
 }
 @Test
 public void testConnectionFactoryPublisherSettings() {
   load(
       TestConfiguration.class,
       "spring.rabbitmq.publisher-confirms=true",
       "spring.rabbitmq.publisher-returns=true");
   CachingConnectionFactory connectionFactory =
       this.context.getBean(CachingConnectionFactory.class);
   RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
   DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
   assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(true);
   assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(true);
   assertThat(getMandatory(rabbitTemplate)).isTrue();
 }
 @Test
 public void customRouter() {
   Object endpoint = context.getBean("customRouter");
   Object handler = TestUtils.getPropertyValue(endpoint, "handler");
   assertEquals(RecipientListRouter.class, handler.getClass());
   RecipientListRouter router = (RecipientListRouter) handler;
   DirectFieldAccessor accessor = new DirectFieldAccessor(router);
   assertEquals(
       new Long(1234),
       new DirectFieldAccessor(accessor.getPropertyValue("messagingTemplate"))
           .getPropertyValue("sendTimeout"));
   assertEquals(Boolean.TRUE, accessor.getPropertyValue("applySequence"));
   assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreSendFailures"));
 }
 @Test
 public void testParseWithQueueNames() throws Exception {
   SimpleMessageListenerContainer container =
       beanFactory.getBean("container1", SimpleMessageListenerContainer.class);
   assertEquals(AcknowledgeMode.MANUAL, container.getAcknowledgeMode());
   assertEquals(beanFactory.getBean(ConnectionFactory.class), container.getConnectionFactory());
   assertEquals(MessageListenerAdapter.class, container.getMessageListener().getClass());
   DirectFieldAccessor listenerAccessor = new DirectFieldAccessor(container.getMessageListener());
   assertEquals(
       beanFactory.getBean(TestBean.class), listenerAccessor.getPropertyValue("delegate"));
   assertEquals("handle", listenerAccessor.getPropertyValue("defaultListenerMethod"));
   Queue queue = beanFactory.getBean("bar", Queue.class);
   assertEquals(
       "[foo, " + queue.getName() + "]", Arrays.asList(container.getQueueNames()).toString());
   assertEquals(5, ReflectionTestUtils.getField(container, "concurrentConsumers"));
   assertEquals(6, ReflectionTestUtils.getField(container, "maxConcurrentConsumers"));
   assertEquals(1234L, ReflectionTestUtils.getField(container, "startConsumerMinInterval"));
   assertEquals(2345L, ReflectionTestUtils.getField(container, "stopConsumerMinInterval"));
   assertEquals(12, ReflectionTestUtils.getField(container, "consecutiveActiveTrigger"));
   assertEquals(34, ReflectionTestUtils.getField(container, "consecutiveIdleTrigger"));
   assertEquals(9876L, ReflectionTestUtils.getField(container, "receiveTimeout"));
   Map<?, ?> consumerArgs = TestUtils.getPropertyValue(container, "consumerArgs", Map.class);
   assertEquals(1, consumerArgs.size());
   Object xPriority = consumerArgs.get("x-priority");
   assertNotNull(xPriority);
   assertEquals(10, xPriority);
   assertEquals(
       Long.valueOf(5555),
       TestUtils.getPropertyValue(container, "recoveryBackOff.interval", Long.class));
   assertFalse(TestUtils.getPropertyValue(container, "exclusive", Boolean.class));
   assertFalse(TestUtils.getPropertyValue(container, "missingQueuesFatal", Boolean.class));
   assertTrue(TestUtils.getPropertyValue(container, "autoDeclare", Boolean.class));
   assertEquals(5, TestUtils.getPropertyValue(container, "declarationRetries"));
   assertEquals(1000L, TestUtils.getPropertyValue(container, "failedDeclarationRetryInterval"));
   assertEquals(30000L, TestUtils.getPropertyValue(container, "retryDeclarationInterval"));
   assertEquals(
       beanFactory.getBean("tagger"),
       TestUtils.getPropertyValue(container, "consumerTagStrategy"));
   Collection<?> group = beanFactory.getBean("containerGroup", Collection.class);
   assertEquals(3, group.size());
   assertThat(
       group,
       Matchers.contains(
           beanFactory.getBean("container1"),
           beanFactory.getBean("testListener1"),
           beanFactory.getBean("testListener2")));
   assertEquals(1235L, ReflectionTestUtils.getField(container, "idleEventInterval"));
   assertEquals("container1", container.getListenerId());
 }
Пример #19
0
  @Before
  public void setUp() throws Exception {
    DatabaseOperation.CLEAN_INSERT.execute(getConnection(), getDataSet());
    loginServiceImpl = new LoginServiceImpl();
    hibernateTemplate = new HibernateTemplate<Customer>();

    directFieldAccessor = new DirectFieldAccessor(loginServiceImpl);
    directFieldAccessor.setPropertyValue("hibernateTemplate", hibernateTemplate);

    directFieldAccessor = new DirectFieldAccessor(hibernateTemplate);
    directFieldAccessor.setPropertyValue("session", hibernateSession.openSession());

    username = "******";
    password = "******";
  }
 @Test
 public void testParseWithQueueNames() throws Exception {
   SimpleMessageListenerContainer container =
       this.context.getBean("testListener", SimpleMessageListenerContainer.class);
   assertEquals(AcknowledgeMode.MANUAL, container.getAcknowledgeMode());
   assertEquals(this.context.getBean(ConnectionFactory.class), container.getConnectionFactory());
   assertEquals(MessageListenerAdapter.class, container.getMessageListener().getClass());
   DirectFieldAccessor listenerAccessor = new DirectFieldAccessor(container.getMessageListener());
   assertEquals(
       this.context.getBean(TestBean.class), listenerAccessor.getPropertyValue("delegate"));
   assertEquals("handle", listenerAccessor.getPropertyValue("defaultListenerMethod"));
   Queue queue = this.context.getBean("bar", Queue.class);
   assertEquals(
       "[foo, " + queue.getName() + "]", Arrays.asList(container.getQueueNames()).toString());
 }
  @Test
  public void testUsageWithoutSpringInitialization() {
    LoggingHandler loggingHandler = new LoggingHandler("ERROR");
    DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
    Log log = (Log) accessor.getPropertyValue("messageLogger");
    log = spy(log);
    accessor.setPropertyValue("messageLogger", log);

    String testPayload = "TEST_PAYLOAD";
    Message<String> message = MessageBuilder.withPayload(testPayload).build();

    loggingHandler.handleMessage(message);

    verify(log).error(testPayload);
  }
 private void testEarlyClose(
     final AbstractServerConnectionFactory factory, String property, String message)
     throws Exception {
   factory.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
   factory.setBeanName("foo");
   factory.registerListener(mock(TcpListener.class));
   factory.afterPropertiesSet();
   Log logger = spy(TestUtils.getPropertyValue(factory, "logger", Log.class));
   new DirectFieldAccessor(factory).setPropertyValue("logger", logger);
   final CountDownLatch latch1 = new CountDownLatch(1);
   final CountDownLatch latch2 = new CountDownLatch(1);
   final CountDownLatch latch3 = new CountDownLatch(1);
   when(logger.isInfoEnabled()).thenReturn(true);
   when(logger.isDebugEnabled()).thenReturn(true);
   doAnswer(
           invocation -> {
             latch1.countDown();
             // wait until the stop nulls the channel
             latch2.await(10, TimeUnit.SECONDS);
             return null;
           })
       .when(logger)
       .info(contains("Listening"));
   doAnswer(
           invocation -> {
             latch3.countDown();
             return null;
           })
       .when(logger)
       .debug(contains(message));
   factory.start();
   assertTrue("missing info log", latch1.await(10, TimeUnit.SECONDS));
   // stop on a different thread because it waits for the executor
   Executors.newSingleThreadExecutor().execute(() -> factory.stop());
   int n = 0;
   DirectFieldAccessor accessor = new DirectFieldAccessor(factory);
   while (n++ < 200 && accessor.getPropertyValue(property) != null) {
     Thread.sleep(100);
   }
   assertTrue("Stop was not invoked in time", n < 200);
   latch2.countDown();
   assertTrue("missing debug log", latch3.await(10, TimeUnit.SECONDS));
   String expected = "foo, port=" + factory.getPort() + message;
   ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
   verify(logger, atLeast(1)).debug(captor.capture());
   assertThat(captor.getAllValues(), hasItem(expected));
   factory.stop();
 }
 @Test
 public void testOutTcp() {
   DirectFieldAccessor dfa = new DirectFieldAccessor(tcpOut);
   assertSame(cfC1, dfa.getPropertyValue("clientConnectionFactory"));
   assertEquals("testOutTcpNio", tcpOut.getComponentName());
   assertEquals("ip:tcp-outbound-channel-adapter", tcpOut.getComponentType());
   assertFalse(cfC1.isLookupHost());
   assertEquals(35, dfa.getPropertyValue("order"));
   assertFalse(tcpOutEndpoint.isAutoStartup());
   assertEquals(125, tcpOutEndpoint.getPhase());
   assertFalse(
       (Boolean)
           TestUtils.getPropertyValue(
               TestUtils.getPropertyValue(cfC1, "mapper"), "applySequence"));
   assertEquals(10000L, TestUtils.getPropertyValue(cfC1, "readDelay"));
 }
 @Test
 public void testConnectionFactoryCacheSettings() {
   load(
       TestConfiguration.class,
       "spring.rabbitmq.cache.channel.size=23",
       "spring.rabbitmq.cache.channel.checkoutTimeout=1000",
       "spring.rabbitmq.cache.connection.mode=CONNECTION",
       "spring.rabbitmq.cache.connection.size=2");
   CachingConnectionFactory connectionFactory =
       this.context.getBean(CachingConnectionFactory.class);
   DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
   assertThat(dfa.getPropertyValue("channelCacheSize")).isEqualTo(23);
   assertThat(dfa.getPropertyValue("cacheMode")).isEqualTo(CacheMode.CONNECTION);
   assertThat(dfa.getPropertyValue("connectionCacheSize")).isEqualTo(2);
   assertThat(dfa.getPropertyValue("channelCheckoutTimeout")).isEqualTo(1000L);
 }
Пример #25
0
 public static Object getPropertyValue(Object root, String propertyPath) {
   Object value = null;
   DirectFieldAccessor accessor = new DirectFieldAccessor(root);
   String[] tokens = propertyPath.split("\\.");
   for (int i = 0; i < tokens.length; i++) {
     value = accessor.getPropertyValue(tokens[i]);
     if (value != null) {
       accessor = new DirectFieldAccessor(value);
     } else if (i == tokens.length - 1) {
       return null;
     } else {
       throw new IllegalArgumentException("intermediate property '" + tokens[i] + "' is null");
     }
   }
   return value;
 }
 @Test
 public void testGatewayWithTransactionManagerReference() {
   ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext(
           "jmsGatewayTransactionManagerTests.xml", this.getClass());
   JmsMessageDrivenEndpoint gateway =
       (JmsMessageDrivenEndpoint) context.getBean("gatewayWithTransactionManager");
   DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
   accessor = new DirectFieldAccessor(accessor.getPropertyValue("listenerContainer"));
   Object txManager = accessor.getPropertyValue("transactionManager");
   assertEquals(JmsTransactionManager.class, txManager.getClass());
   assertEquals(context.getBean("txManager"), txManager);
   assertEquals(
       context.getBean("testConnectionFactory"),
       ((JmsTransactionManager) txManager).getConnectionFactory());
 }
 @Test
 public void testInGateway1() {
   DirectFieldAccessor dfa = new DirectFieldAccessor(tcpInboundGateway1);
   assertSame(cfS2, dfa.getPropertyValue("serverConnectionFactory"));
   assertEquals(456L, dfa.getPropertyValue("replyTimeout"));
   assertEquals("inGateway1", tcpInboundGateway1.getComponentName());
   assertEquals("ip:tcp-inbound-gateway", tcpInboundGateway1.getComponentType());
   assertEquals(errorChannel, dfa.getPropertyValue("errorChannel"));
   assertTrue(cfS2.isLookupHost());
   assertFalse(tcpInboundGateway1.isAutoStartup());
   assertEquals(126, tcpInboundGateway1.getPhase());
   assertFalse(
       (Boolean)
           TestUtils.getPropertyValue(
               TestUtils.getPropertyValue(cfS2, "mapper"), "applySequence"));
   assertEquals(100L, TestUtils.getPropertyValue(cfS2, "readDelay"));
 }
  @SuppressWarnings("unchecked")
  @Test
  public void testSqlParametersAreSet() throws Exception {
    setUp("basicStoredProcOutboundChannelAdapterTest.xml", getClass());

    DirectFieldAccessor accessor = new DirectFieldAccessor(this.consumer);
    Object handler = accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(handler);

    Object executor = accessor.getPropertyValue("executor");
    DirectFieldAccessor executorAccessor = new DirectFieldAccessor(executor);

    Object sqlParameters = executorAccessor.getPropertyValue("sqlParameters");

    assertNotNull(sqlParameters);
    assertTrue(sqlParameters instanceof List);

    List<SqlParameter> sqlParametersAsList = (List<SqlParameter>) sqlParameters;

    assertTrue(sqlParametersAsList.size() == 4);

    SqlParameter parameter1 = sqlParametersAsList.get(0);
    SqlParameter parameter2 = sqlParametersAsList.get(1);
    SqlParameter parameter3 = sqlParametersAsList.get(2);
    SqlParameter parameter4 = sqlParametersAsList.get(3);

    assertEquals("username", parameter1.getName());
    assertEquals("password", parameter2.getName());
    assertEquals("age", parameter3.getName());
    assertEquals("description", parameter4.getName());

    assertNull("Expect that the scale is null.", parameter1.getScale());
    assertNull("Expect that the scale is null.", parameter2.getScale());
    assertEquals("Expect that the scale is 5.", Integer.valueOf(5), parameter3.getScale());
    assertNull("Expect that the scale is null.", parameter4.getScale());

    assertEquals("SqlType is ", Types.VARCHAR, parameter1.getSqlType());
    assertEquals("SqlType is ", Types.VARCHAR, parameter2.getSqlType());
    assertEquals("SqlType is ", Types.INTEGER, parameter3.getSqlType());
    assertEquals("SqlType is ", Types.VARCHAR, parameter4.getSqlType());

    assertTrue(parameter1 instanceof SqlParameter);
    assertTrue(parameter2 instanceof SqlOutParameter);
    assertTrue(parameter3 instanceof SqlInOutParameter);
    assertTrue(parameter4 instanceof SqlParameter);
  }
  @Test
  public void testProcedureNameIsSet() throws Exception {
    setUp("basicStoredProcOutboundChannelAdapterTest.xml", getClass());

    DirectFieldAccessor accessor = new DirectFieldAccessor(this.consumer);
    Object handler = accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(handler);

    Object executor = accessor.getPropertyValue("executor");
    DirectFieldAccessor executorAccessor = new DirectFieldAccessor(executor);

    Expression testProcedure1 =
        (Expression) executorAccessor.getPropertyValue("storedProcedureNameExpression");
    assertEquals(
        "Resolution Required should be 'testProcedure1' but was " + testProcedure1,
        "testProcedure1",
        testProcedure1.getValue());
  }
 @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();
 }