Search in sources :

Example 61 with MessageGroup

use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.

the class MethodInvokingReleaseStrategyTests method testListSubclassParameterUsingMethodName.

@Test
public void testListSubclassParameterUsingMethodName() {
    class TestReleaseStrategy {

        @SuppressWarnings("unused")
        public boolean listSubclassParameter(LinkedList<?> l1) {
            return true;
        }
    }
    ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "listSubclassParameter");
    MessageGroup messages = createListOfMessages(3);
    Assert.assertTrue(adapter.canRelease(messages));
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 62 with MessageGroup

use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.

the class MethodInvokingReleaseStrategyTests method testWrongReturnType.

@Test(expected = ConversionFailedException.class)
public void testWrongReturnType() throws SecurityException, NoSuchMethodError {
    class TestReleaseStrategy {

        @SuppressWarnings("unused")
        public String wrongReturnType(List<Message<?>> messages) {
            return "foo";
        }
    }
    ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "wrongReturnType");
    MessageGroup messages = createListOfMessages(3);
    Assert.assertTrue(adapter.canRelease(messages));
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 63 with MessageGroup

use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.

the class MethodInvokingReleaseStrategyTests method testAdapterWithPojoBasedMethodReturningObject.

@Test
public void testAdapterWithPojoBasedMethodReturningObject() {
    class TestReleaseStrategy {

        @SuppressWarnings("unused")
        public // the data
        boolean checkCompletenessOnListOfStrings(List<String> messages) {
            StringBuffer buffer = new StringBuffer();
            for (String content : messages) {
                buffer.append(content);
            }
            return buffer.length() >= 9;
        }
    }
    ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "checkCompletenessOnListOfStrings");
    MessageGroup messages = createListOfMessages(3);
    Assert.assertTrue(adapter.canRelease(messages));
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 64 with MessageGroup

use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.

the class MethodInvokingReleaseStrategyTests method testAdapterWithTypeParametrizedMessageBasedMethod.

@Test
public void testAdapterWithTypeParametrizedMessageBasedMethod() {
    class TestReleaseStrategy {

        @SuppressWarnings("unused")
        public boolean checkCompletenessOnListOfMessagesParametrizedWithString(List<Message<String>> messages) {
            Assert.assertTrue(messages.size() > 0);
            return messages.size() > new IntegrationMessageHeaderAccessor(messages.iterator().next()).getSequenceSize();
        }
    }
    ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), "checkCompletenessOnListOfMessagesParametrizedWithString");
    MessageGroup messages = createListOfMessages(3);
    Assert.assertTrue(adapter.canRelease(messages));
}
Also used : IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 65 with MessageGroup

use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.

the class MethodInvokingReleaseStrategyTests method testListSubclassParameterUsingMethodObject.

@Test
public void testListSubclassParameterUsingMethodObject() throws SecurityException, NoSuchMethodException {
    class TestReleaseStrategy {

        @SuppressWarnings("unused")
        public boolean listSubclassParameter(LinkedList<?> l1) {
            return true;
        }
    }
    ReleaseStrategy adapter = new MethodInvokingReleaseStrategy(new TestReleaseStrategy(), TestReleaseStrategy.class.getMethod("listSubclassParameter", new Class<?>[] { LinkedList.class }));
    MessageGroup messages = createListOfMessages(3);
    Assert.assertTrue(adapter.canRelease(messages));
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

MessageGroup (org.springframework.integration.store.MessageGroup)98 Test (org.junit.Test)79 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)54 GenericMessage (org.springframework.messaging.support.GenericMessage)36 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)25 Message (org.springframework.messaging.Message)20 ArrayList (java.util.ArrayList)19 RedisAvailable (org.springframework.integration.redis.rules.RedisAvailable)15 RedisConnectionFactory (org.springframework.data.redis.connection.RedisConnectionFactory)14 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)13 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)13 MongoClient (com.mongodb.MongoClient)12 SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)12 Transactional (org.springframework.transaction.annotation.Transactional)10 LinkedList (java.util.LinkedList)8 List (java.util.List)7 Matchers.containsString (org.hamcrest.Matchers.containsString)7 UUID (java.util.UUID)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)6 HashMap (java.util.HashMap)5