use of org.springframework.context.SmartLifecycle in project spring-integration by spring-projects.
the class SmartLifecycleRoleControllerTests method testOrder.
@Test
public void testOrder() {
SmartLifecycle lc1 = mock(SmartLifecycle.class);
when(lc1.getPhase()).thenReturn(2);
SmartLifecycle lc2 = mock(SmartLifecycle.class);
when(lc2.getPhase()).thenReturn(1);
MultiValueMap<String, SmartLifecycle> map = new LinkedMultiValueMap<>();
map.add("foo", lc1);
map.add("foo", lc2);
SmartLifecycleRoleController controller = new SmartLifecycleRoleController(map);
controller.startLifecyclesInRole("foo");
controller.stopLifecyclesInRole("foo");
InOrder inOrder = inOrder(lc1, lc2);
inOrder.verify(lc2).start();
inOrder.verify(lc1).start();
inOrder.verify(lc1).stop();
inOrder.verify(lc2).stop();
}
use of org.springframework.context.SmartLifecycle in project spring-integration by spring-projects.
the class SmartLifecycleRoleControllerTests method allEndpointRunning.
@Test
public void allEndpointRunning() {
SmartLifecycle lc1 = new PseudoSmartLifecycle();
SmartLifecycle lc2 = new PseudoSmartLifecycle();
MultiValueMap<String, SmartLifecycle> map = new LinkedMultiValueMap<>();
map.add("foo", lc1);
map.add("foo", lc2);
try {
new SmartLifecycleRoleController(map);
} catch (Exception e) {
assertThat(e.getMessage()).contains("Cannot add the Lifecycle 'bar' to the role 'foo' " + "because a Lifecycle with the name 'bar' is already present.");
}
}
use of org.springframework.context.SmartLifecycle in project spring-integration by spring-projects.
the class SmartLifecycleRoleController method doAddLifecyclesToRole.
private void doAddLifecyclesToRole(String role, List<String> lifecycleBeanNames) {
lifecycleBeanNames.forEach(lifecycleBeanName -> {
try {
SmartLifecycle lifecycle = this.applicationContext.getBean(lifecycleBeanName, SmartLifecycle.class);
addLifecycleToRole(role, lifecycle);
} catch (NoSuchBeanDefinitionException e) {
logger.warn("Skipped; no such bean: " + lifecycleBeanName);
}
});
}
use of org.springframework.context.SmartLifecycle 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));
}
use of org.springframework.context.SmartLifecycle 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));
}
Aggregations