use of org.springframework.integration.handler.DelayHandler in project spring-integration by spring-projects.
the class DelayerParserTests method customScheduler.
@Test
public void customScheduler() {
Object endpoint = context.getBean("delayerWithCustomScheduler");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(DelayHandler.class, handler.getClass());
DelayHandler delayHandler = (DelayHandler) handler;
assertEquals(Ordered.LOWEST_PRECEDENCE, delayHandler.getOrder());
DirectFieldAccessor accessor = new DirectFieldAccessor(delayHandler);
assertEquals(context.getBean("output"), accessor.getPropertyValue("outputChannel"));
assertEquals(new Long(0), accessor.getPropertyValue("defaultDelay"));
assertEquals(context.getBean("testScheduler"), accessor.getPropertyValue("taskScheduler"));
assertNotNull(accessor.getPropertyValue("taskScheduler"));
assertEquals(Boolean.TRUE, new DirectFieldAccessor(accessor.getPropertyValue("taskScheduler")).getPropertyValue("waitForTasksToCompleteOnShutdown"));
}
use of org.springframework.integration.handler.DelayHandler in project spring-integration by spring-projects.
the class DelayerParserTests method customMessageStore.
@Test
public void customMessageStore() {
Object endpoint = context.getBean("delayerWithCustomMessageStore");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object handler = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(DelayHandler.class, handler.getClass());
DelayHandler delayHandler = (DelayHandler) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(delayHandler);
assertEquals(context.getBean("testMessageStore"), accessor.getPropertyValue("messageStore"));
}
use of org.springframework.integration.handler.DelayHandler in project spring-integration by spring-projects.
the class DelayerParserTests method transactionalSubElement.
// INT-2649
@Test
public void transactionalSubElement() throws Exception {
Object endpoint = context.getBean("delayerWithTransactional");
DelayHandler delayHandler = TestUtils.getPropertyValue(endpoint, "handler", DelayHandler.class);
List<?> adviceChain = TestUtils.getPropertyValue(delayHandler, "delayedAdviceChain", List.class);
assertEquals(1, adviceChain.size());
Object advice = adviceChain.get(0);
assertTrue(advice instanceof TransactionInterceptor);
TransactionAttributeSource transactionAttributeSource = ((TransactionInterceptor) advice).getTransactionAttributeSource();
assertTrue(transactionAttributeSource instanceof MatchAlwaysTransactionAttributeSource);
Method method = MessageHandler.class.getMethod("handleMessage", Message.class);
TransactionDefinition definition = transactionAttributeSource.getTransactionAttribute(method, null);
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, definition.getPropagationBehavior());
assertEquals(TransactionDefinition.ISOLATION_DEFAULT, definition.getIsolationLevel());
assertEquals(TransactionDefinition.TIMEOUT_DEFAULT, definition.getTimeout());
assertFalse(definition.isReadOnly());
}
use of org.springframework.integration.handler.DelayHandler in project spring-integration by spring-projects.
the class DelayerParserTests method testInt2243ExpressionSubElement.
@Test
public void testInt2243ExpressionSubElement() {
DelayHandler delayHandler = context.getBean("delayerWithExpressionSubElement.handler", DelayHandler.class);
assertEquals("headers.timestamp + 1000", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
}
use of org.springframework.integration.handler.DelayHandler in project spring-integration by spring-projects.
the class DelayerParserTests method defaultScheduler.
@Test
public void defaultScheduler() {
DelayHandler delayHandler = context.getBean("delayerWithDefaultScheduler.handler", DelayHandler.class);
assertEquals(99, delayHandler.getOrder());
assertEquals(context.getBean("output"), TestUtils.getPropertyValue(delayHandler, "outputChannel"));
assertEquals(new Long(1234), TestUtils.getPropertyValue(delayHandler, "defaultDelay", Long.class));
// INT-2243
assertNotNull(TestUtils.getPropertyValue(delayHandler, "delayExpression"));
assertEquals("headers.foo", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
assertEquals(new Long(987), TestUtils.getPropertyValue(delayHandler, "messagingTemplate.sendTimeout", Long.class));
assertNull(TestUtils.getPropertyValue(delayHandler, "taskScheduler"));
}
Aggregations