Search in sources :

Example 1 with ResequencingMessageHandler

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

the class ResequencerParserTests method shouldSetReleasePartialSequencesFlag.

@Test
public void shouldSetReleasePartialSequencesFlag() {
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("completelyDefinedResequencer");
    ResequencingMessageHandler resequencer = TestUtils.getPropertyValue(endpoint, "handler", ResequencingMessageHandler.class);
    assertEquals("The ResequencerEndpoint is not configured with the appropriate 'release partial sequences' flag", true, getPropertyValue(getPropertyValue(resequencer, "releaseStrategy"), "releasePartialSequences"));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ResequencingMessageHandler(org.springframework.integration.aggregator.ResequencingMessageHandler) Test(org.junit.Test)

Example 2 with ResequencingMessageHandler

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

the class ResequencerParserTests method testCorrelationStrategyRefOnly.

@Test
public void testCorrelationStrategyRefOnly() throws Exception {
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithCorrelationStrategyRefOnly");
    ResequencingMessageHandler resequencer = TestUtils.getPropertyValue(endpoint, "handler", ResequencingMessageHandler.class);
    assertEquals("The ResequencerEndpoint is not configured with the appropriate CorrelationStrategy", context.getBean("testCorrelationStrategy"), getPropertyValue(resequencer, "correlationStrategy"));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ResequencingMessageHandler(org.springframework.integration.aggregator.ResequencingMessageHandler) Test(org.junit.Test)

Example 3 with ResequencingMessageHandler

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

the class ResequencerParserTests method testCorrelationStrategyRefAndMethod.

@Test
public void testCorrelationStrategyRefAndMethod() throws Exception {
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithCorrelationStrategyRefAndMethod");
    ResequencingMessageHandler resequencer = TestUtils.getPropertyValue(endpoint, "handler", ResequencingMessageHandler.class);
    Object correlationStrategy = getPropertyValue(resequencer, "correlationStrategy");
    assertEquals("The ResequencerEndpoint is not configured with a CorrelationStrategy adapter", MethodInvokingCorrelationStrategy.class, correlationStrategy.getClass());
    MethodInvokingCorrelationStrategy adapter = (MethodInvokingCorrelationStrategy) correlationStrategy;
    assertEquals("foo", adapter.getCorrelationKey(MessageBuilder.withPayload("not important").build()));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ResequencingMessageHandler(org.springframework.integration.aggregator.ResequencingMessageHandler) MethodInvokingCorrelationStrategy(org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy) Test(org.junit.Test)

Example 4 with ResequencingMessageHandler

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

the class ResequencerParserTests method testReleaseStrategyRefOnly.

@Test
public void testReleaseStrategyRefOnly() throws Exception {
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithReleaseStrategyRefOnly");
    ResequencingMessageHandler resequencer = getPropertyValue(endpoint, "handler", ResequencingMessageHandler.class);
    assertEquals("The ResequencerEndpoint is not configured with the appropriate ReleaseStrategy", context.getBean("testReleaseStrategy"), getPropertyValue(resequencer, "releaseStrategy"));
    assertFalse(TestUtils.getPropertyValue(resequencer, "expireGroupsUponTimeout", Boolean.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ResequencingMessageHandler(org.springframework.integration.aggregator.ResequencingMessageHandler) Test(org.junit.Test)

Example 5 with ResequencingMessageHandler

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

the class ResequencerParserTests method testReleaseStrategyRefAndMethod.

@Test
public void testReleaseStrategyRefAndMethod() throws Exception {
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("resequencerWithReleaseStrategyRefAndMethod");
    ResequencingMessageHandler resequencer = getPropertyValue(endpoint, "handler", ResequencingMessageHandler.class);
    Object releaseStrategyBean = context.getBean("testReleaseStrategyPojo");
    assertTrue("Release strategy is not of the expected type", releaseStrategyBean instanceof TestReleaseStrategyPojo);
    TestReleaseStrategyPojo expectedReleaseStrategy = (TestReleaseStrategyPojo) releaseStrategyBean;
    int currentInvocationCount = expectedReleaseStrategy.invocationCount;
    ReleaseStrategy effectiveReleaseStrategy = (ReleaseStrategy) getPropertyValue(resequencer, "releaseStrategy");
    assertTrue("The release strategy is expected to be a MethodInvokingReleaseStrategy", effectiveReleaseStrategy instanceof MethodInvokingReleaseStrategy);
    effectiveReleaseStrategy.canRelease(new SimpleMessageGroup("test"));
    assertEquals("The ResequencerEndpoint was not invoked the expected number of times;", currentInvocationCount + 1, expectedReleaseStrategy.invocationCount);
    assertTrue(TestUtils.getPropertyValue(resequencer, "expireGroupsUponTimeout", Boolean.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ResequencingMessageHandler(org.springframework.integration.aggregator.ResequencingMessageHandler) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)9 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)9 MessageChannel (org.springframework.messaging.MessageChannel)3 QueueChannel (org.springframework.integration.channel.QueueChannel)2 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)2 IntegrationMessageHeaderAccessor (org.springframework.integration.IntegrationMessageHeaderAccessor)1 MethodInvokingCorrelationStrategy (org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy)1 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)1 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)1 NullChannel (org.springframework.integration.channel.NullChannel)1 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)1