Search in sources :

Example 1 with SmartLifecycleRoleController

use of org.springframework.integration.support.SmartLifecycleRoleController in project spring-integration by spring-projects.

the class XPathFilterParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
    assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
    assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
    assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
    assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
    SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Example 2 with SmartLifecycleRoleController

use of org.springframework.integration.support.SmartLifecycleRoleController in project spring-integration by spring-projects.

the class JmsInboundGatewayParserTests method testGatewayWithContainerReference.

@Test
public void testGatewayWithContainerReference() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("inboundGatewayWithContainerReference.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = context.getBean("gatewayWithContainerReference", JmsMessageDrivenEndpoint.class);
    AbstractMessageListenerContainer messageListenerContainer = context.getBean("messageListenerContainer", AbstractMessageListenerContainer.class);
    assertFalse(gateway.isRunning());
    assertFalse(messageListenerContainer.isRunning());
    SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") MultiValueMap<String, SmartLifecycle> lifecycles = TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class);
    assertTrue(lifecycles.containsKey("foo"));
    assertSame(gateway, lifecycles.getFirst("foo"));
    gateway.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(messageListenerContainer, container);
    assertTrue(gateway.isRunning());
    assertTrue(messageListenerContainer.isRunning());
    gateway.stop();
    context.close();
}
Also used : SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SmartLifecycle(org.springframework.context.SmartLifecycle) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 3 with SmartLifecycleRoleController

use of org.springframework.integration.support.SmartLifecycleRoleController in project spring-integration by spring-projects.

the class MarshallingTransformerParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("parseOnly");
    assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
    assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
    assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
    assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
    SmartLifecycleRoleController roleController = appContext.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Example 4 with SmartLifecycleRoleController

use of org.springframework.integration.support.SmartLifecycleRoleController in project spring-integration by spring-projects.

the class UnmarshallingTransformerParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("parseOnly");
    assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
    assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
    assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
    assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
    SmartLifecycleRoleController roleController = appContext.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Example 5 with SmartLifecycleRoleController

use of org.springframework.integration.support.SmartLifecycleRoleController in project spring-integration by spring-projects.

the class XPathHeaderEnricherParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
    assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
    assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
    assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
    assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
    SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 SmartLifecycle (org.springframework.context.SmartLifecycle)8 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)8 List (java.util.List)7 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)7 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 JmsMessageDrivenEndpoint (org.springframework.integration.jms.JmsMessageDrivenEndpoint)1 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)1