Build on top of Spring 4's new messaging types
This commit updates Spring Integration to depend upon Spring 4, making use of the message types that have moved from Spring Integration into Spring's new spring-messaging module. The default message converter no longer supports conversion of a message that is null, throwing an IllegalArgumentException if an attempt is made to convert null. Furthermore, GenericMessagingTemplate does not support sending null, again throwing an IllegalArgumentException. Previously, MessagingTemplate had no-oped an attempt to send null. ConcurrentAggregatorTests and AggregatorTests both had a single test that was specifically testing the behaviour of an aggregator that returns null for its message. These tests have been removed. CorrelatingMessageHandlerTests have been updated to specify some additional behaviour for its mocks so that null messages are not returned. These are the only functional changes that have been made. All other changes are simply for moving to the repackaged and/or renamed types. In the move to being part of core Spring, a number of constants and header accessor methods have moved from MessageHeaders to MessageHeaderAccessor. This commit continues this pattern for the enterprise integration headers that are specific to Spring Integration. A new class, EiMessageHeaderAccessor, has been created. This class provides constants and methods for working with SI-specific headers. The main code and tests have been updated to use this new class.
This commit is contained in:
committed by
Gary Russell
parent
8dca61c62a
commit
28ab8394de
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.integration.test.matcher;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Assert;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Assert;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Are the {@link MessageHeaders} of a {@link Message} containing any entry
|
||||
@@ -121,7 +122,7 @@ public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
@Factory
|
||||
public static <T> Matcher<Message<?>> hasCorrelationId(T value) {
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(MessageHeaders.CORRELATION_ID, value));
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(EiMessageHeaderAccessor.CORRELATION_ID, value));
|
||||
}
|
||||
|
||||
@Factory
|
||||
@@ -131,7 +132,7 @@ public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
@Factory
|
||||
public static Matcher<Message<?>> hasSequenceNumber(Matcher<Integer> matcher) {
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(MessageHeaders.SEQUENCE_NUMBER, matcher));
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(EiMessageHeaderAccessor.SEQUENCE_NUMBER, matcher));
|
||||
}
|
||||
|
||||
@Factory
|
||||
@@ -141,7 +142,7 @@ public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
@Factory
|
||||
public static Matcher<Message<?>> hasSequenceSize(Matcher<Integer> value) {
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(MessageHeaders.SEQUENCE_SIZE, value));
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(EiMessageHeaderAccessor.SEQUENCE_SIZE, value));
|
||||
}
|
||||
|
||||
@Factory
|
||||
@@ -151,7 +152,7 @@ public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
@Factory
|
||||
public static Matcher<Message<?>> hasExpirationDate(Matcher<Long> matcher) {
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(MessageHeaders.EXPIRATION_DATE, matcher));
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(EiMessageHeaderAccessor.EXPIRATION_DATE, matcher));
|
||||
}
|
||||
|
||||
@Factory
|
||||
@@ -164,4 +165,4 @@ public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
return new HeaderMatcher(MapContentMatchers.hasEntry(MessageHeaders.TIMESTAMP, matcher));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* Mockito matcher factory for {@link Message} matcher creation.
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Matcher to make assertions about message equality easier. Usage:
|
||||
@@ -87,4 +87,4 @@ public class PayloadAndHeaderMatcher extends BaseMatcher<Message<?>> {
|
||||
payload).appendText(" and headers: ").appendValue(headers);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.core.IsEqual;
|
||||
import org.junit.Assert;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* Is the payload of a {@link Message} equal to a given value or is matching
|
||||
@@ -90,4 +90,4 @@ public class PayloadMatcher extends TypeSafeMatcher<Message> {
|
||||
public static <T> Matcher<Message> hasPayload(Matcher<? super T> payloadMatcher) {
|
||||
return new PayloadMatcher(payloadMatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides several {@link org.hamcrest.BaseMatcher} implementations.
|
||||
*/
|
||||
package org.springframework.integration.test.matcher;
|
||||
package org.springframework.integration.test.matcher;
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.springframework.integration.test.support;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
/**
|
||||
* The base class for response validators used for {@link RequestResponseScenario}s
|
||||
* @author David Turanski
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.integration.test.support;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
/**
|
||||
* Validate a message. Create an anonymous instance or subclass to
|
||||
* implement the validateMessage() method
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.integration.test.support;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.util.Assert;
|
||||
/**
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
* Provides several test support classes including for testing Spring Integration
|
||||
* request-response message scenarios.
|
||||
*/
|
||||
package org.springframework.integration.test.support;
|
||||
package org.springframework.integration.test.support;
|
||||
|
||||
@@ -33,18 +33,18 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.channel.MessagePublishingErrorHandler;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -85,7 +85,7 @@ public abstract class TestUtils {
|
||||
|
||||
public static TestApplicationContext createTestApplicationContext() {
|
||||
TestApplicationContext context = new TestApplicationContext();
|
||||
ErrorHandler errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(context));
|
||||
ErrorHandler errorHandler = new MessagePublishingErrorHandler(new BeanFactoryMessageChannelDestinationResolver(context));
|
||||
ThreadPoolTaskScheduler scheduler = createTaskScheduler(10);
|
||||
scheduler.setErrorHandler(errorHandler);
|
||||
registerBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, scheduler, context);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
* {@link org.springframework.integration.test.util.TestUtils} provides convenience
|
||||
* helpers to easily retrieve private bean properties.
|
||||
*/
|
||||
package org.springframework.integration.test.util;
|
||||
package org.springframework.integration.test.util;
|
||||
|
||||
@@ -43,7 +43,7 @@ import java.util.UUID;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,9 +21,9 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -26,7 +26,7 @@ import static org.springframework.integration.test.matcher.PayloadMatcher.hasPay
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,10 +22,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.annotation.Header;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.springframework.integration.test.matcher.PayloadMatcher.hasPay
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user