Search in sources :

Example 1 with PayloadTypeSelector

use of org.springframework.integration.selector.PayloadTypeSelector in project spring-integration by spring-projects.

the class PayloadTypeSelectorTests method testNonAcceptedTypeIsNotSelected.

@Test
public void testNonAcceptedTypeIsNotSelected() {
    PayloadTypeSelector selector = new PayloadTypeSelector(Integer.class);
    assertFalse(selector.accept(new GenericMessage<String>("test")));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) PayloadTypeSelector(org.springframework.integration.selector.PayloadTypeSelector) Test(org.junit.Test)

Example 2 with PayloadTypeSelector

use of org.springframework.integration.selector.PayloadTypeSelector in project spring-integration by spring-projects.

the class PayloadTypeSelectorTests method testSuperclassOfAcceptedTypeIsNotSelected.

@Test
public void testSuperclassOfAcceptedTypeIsNotSelected() {
    PayloadTypeSelector selector = new PayloadTypeSelector(RuntimeException.class);
    assertFalse(selector.accept(new ErrorMessage(new Exception("test"))));
}
Also used : ErrorMessage(org.springframework.messaging.support.ErrorMessage) MessagingException(org.springframework.messaging.MessagingException) PayloadTypeSelector(org.springframework.integration.selector.PayloadTypeSelector) Test(org.junit.Test)

Example 3 with PayloadTypeSelector

use of org.springframework.integration.selector.PayloadTypeSelector in project spring-integration by spring-projects.

the class PayloadTypeSelectorTests method testSubclassOfAcceptedTypeIsSelected.

@Test
public void testSubclassOfAcceptedTypeIsSelected() {
    PayloadTypeSelector selector = new PayloadTypeSelector(RuntimeException.class);
    assertTrue(selector.accept(new ErrorMessage(new MessagingException("test"))));
}
Also used : MessagingException(org.springframework.messaging.MessagingException) ErrorMessage(org.springframework.messaging.support.ErrorMessage) PayloadTypeSelector(org.springframework.integration.selector.PayloadTypeSelector) Test(org.junit.Test)

Example 4 with PayloadTypeSelector

use of org.springframework.integration.selector.PayloadTypeSelector in project spring-integration by spring-projects.

the class PayloadTypeSelectorTests method testAcceptedTypeIsSelected.

@Test
public void testAcceptedTypeIsSelected() {
    PayloadTypeSelector selector = new PayloadTypeSelector(String.class);
    assertTrue(selector.accept(new GenericMessage<String>("test")));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) PayloadTypeSelector(org.springframework.integration.selector.PayloadTypeSelector) Test(org.junit.Test)

Example 5 with PayloadTypeSelector

use of org.springframework.integration.selector.PayloadTypeSelector in project spring-integration by spring-projects.

the class PayloadTypeSelectorTests method testMultipleAcceptedTypes.

@Test
public void testMultipleAcceptedTypes() {
    PayloadTypeSelector selector = new PayloadTypeSelector(String.class, Integer.class);
    assertTrue(selector.accept(new GenericMessage<String>("test1")));
    assertTrue(selector.accept(new GenericMessage<Integer>(2)));
    assertFalse(selector.accept(new ErrorMessage(new RuntimeException())));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) ErrorMessage(org.springframework.messaging.support.ErrorMessage) PayloadTypeSelector(org.springframework.integration.selector.PayloadTypeSelector) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 PayloadTypeSelector (org.springframework.integration.selector.PayloadTypeSelector)5 ErrorMessage (org.springframework.messaging.support.ErrorMessage)3 GenericMessage (org.springframework.messaging.support.GenericMessage)3 MessagingException (org.springframework.messaging.MessagingException)2