Search in sources :

Example 1 with ReleaseStrategy

use of org.springframework.integration.aggregator.ReleaseStrategy in project spring-integration by spring-projects.

the class ReleaseStrategyFactoryBeanTests method testRefWithNoMethodWithAnnotation.

@Test
public void testRefWithNoMethodWithAnnotation() throws Exception {
    Bar bar = new Bar();
    ReleaseStrategyFactoryBean factory = new ReleaseStrategyFactoryBean();
    factory.setTarget(bar);
    factory.afterPropertiesSet();
    ReleaseStrategy delegate = factory.getObject();
    assertThat(delegate, instanceOf(MethodInvokingReleaseStrategy.class));
    assertThat(TestUtils.getPropertyValue(delegate, "adapter.delegate.targetObject", Bar.class), is(bar));
}
Also used : MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) Test(org.junit.Test)

Example 2 with ReleaseStrategy

use of org.springframework.integration.aggregator.ReleaseStrategy in project spring-integration by spring-projects.

the class ReleaseStrategyFactoryBeanTests method testRefThatImplements.

@Test
public void testRefThatImplements() throws Exception {
    Baz baz = new Baz();
    ReleaseStrategyFactoryBean factory = new ReleaseStrategyFactoryBean();
    factory.setTarget(baz);
    factory.afterPropertiesSet();
    ReleaseStrategy delegate = factory.getObject();
    assertThat(delegate, is(baz));
}
Also used : MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) Test(org.junit.Test)

Example 3 with ReleaseStrategy

use of org.springframework.integration.aggregator.ReleaseStrategy in project spring-integration by spring-projects.

the class ReleaseStrategyFactoryBeanTests method testRefWithNoMethodNoAnnotation.

@Test
public void testRefWithNoMethodNoAnnotation() throws Exception {
    Foo foo = new Foo();
    ReleaseStrategyFactoryBean factory = new ReleaseStrategyFactoryBean();
    factory.setTarget(foo);
    factory.afterPropertiesSet();
    ReleaseStrategy delegate = factory.getObject();
    assertThat(delegate, instanceOf(SequenceSizeReleaseStrategy.class));
}
Also used : SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) Test(org.junit.Test)

Example 4 with ReleaseStrategy

use of org.springframework.integration.aggregator.ReleaseStrategy in project spring-integration by spring-projects.

the class ReleaseStrategyFactoryBeanTests method testNoRefNoMethod.

@Test
public void testNoRefNoMethod() throws Exception {
    ReleaseStrategyFactoryBean factory = new ReleaseStrategyFactoryBean();
    factory.afterPropertiesSet();
    ReleaseStrategy delegate = factory.getObject();
    assertThat(delegate, instanceOf(SequenceSizeReleaseStrategy.class));
}
Also used : SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) SequenceSizeReleaseStrategy(org.springframework.integration.aggregator.SequenceSizeReleaseStrategy) Test(org.junit.Test)

Example 5 with ReleaseStrategy

use of org.springframework.integration.aggregator.ReleaseStrategy in project spring-integration by spring-projects.

the class AggregatorParserTests method testAggregatorWithPojoReleaseStrategy.

@Test
@SuppressWarnings("unchecked")
public void testAggregatorWithPojoReleaseStrategy() {
    MessageChannel input = this.context.getBean("aggregatorWithPojoReleaseStrategyInput", MessageChannel.class);
    EventDrivenConsumer endpoint = this.context.getBean("aggregatorWithPojoReleaseStrategy", EventDrivenConsumer.class);
    ReleaseStrategy releaseStrategy = TestUtils.getPropertyValue(endpoint, "handler.releaseStrategy", ReleaseStrategy.class);
    Assert.assertTrue(releaseStrategy instanceof MethodInvokingReleaseStrategy);
    MessagingMethodInvokerHelper<Long> methodInvokerHelper = TestUtils.getPropertyValue(releaseStrategy, "adapter.delegate", MessagingMethodInvokerHelper.class);
    Object handlerMethods = TestUtils.getPropertyValue(methodInvokerHelper, "handlerMethods");
    assertNull(handlerMethods);
    Object handlerMethod = TestUtils.getPropertyValue(methodInvokerHelper, "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());
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) MessageChannel(org.springframework.messaging.MessageChannel) PollableChannel(org.springframework.messaging.PollableChannel) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) ExpressionEvaluatingReleaseStrategy(org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)11 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)11 SequenceSizeReleaseStrategy (org.springframework.integration.aggregator.SequenceSizeReleaseStrategy)6 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)5 ExpressionEvaluatingReleaseStrategy (org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy)4 MessageChannel (org.springframework.messaging.MessageChannel)3 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 CorrelationStrategy (org.springframework.integration.aggregator.CorrelationStrategy)2 ExpressionEvaluatingCorrelationStrategy (org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy)2 PollableChannel (org.springframework.messaging.PollableChannel)2 AggregatingMessageHandler (org.springframework.integration.aggregator.AggregatingMessageHandler)1 MethodInvokingMessageGroupProcessor (org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor)1 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)1 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)1 LockRegistry (org.springframework.integration.support.locks.LockRegistry)1