checkstyle Misc Rules
checkstyle Nesting checkstyle GenericWhitespace checkstyle MethodParamPad checkstyle NoWhiteSpace checkstyle ParenPad Script checkstyle ParenPad
This commit is contained in:
committed by
Artem Bilan
parent
05cc7be644
commit
57f96bb759
@@ -100,7 +100,7 @@ public class MapContentMatchers<T, V> extends
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
// @Override
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("an entry with key ").appendValue(key)
|
||||
.appendText(" and value matching ").appendDescriptionOf(
|
||||
|
||||
@@ -92,7 +92,7 @@ public class MockitoMessageMatchers {
|
||||
|
||||
public static <T> Message<?> messageWithHeaderEntry(String key,
|
||||
Matcher<T> valueMatcher) {
|
||||
return argThat(HeaderMatcher.<T> hasHeader(key, valueMatcher));
|
||||
return argThat(HeaderMatcher.<T>hasHeader(key, valueMatcher));
|
||||
}
|
||||
|
||||
public static Message<?> messageWithHeaderEntries(Map<String, ?> entries) {
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
/**
|
||||
* Convenience class for testing Spring Integration request-response message scenarios. Users
|
||||
* create subclasses to execute on or more {@link RequestResponseScenario} tests. each scenario defines:
|
||||
* Convenience class for testing Spring Integration request-response message scenarios.
|
||||
* Users create subclasses to execute on or more {@link RequestResponseScenario} tests.
|
||||
* each scenario defines:
|
||||
* <ul>
|
||||
* <li>An inputChannelName</li>
|
||||
* <li>An outputChannelName</li>
|
||||
@@ -49,55 +49,57 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public abstract class AbstractRequestResponseScenarioTests {
|
||||
|
||||
private List<RequestResponseScenario> scenarios = null;
|
||||
private List<RequestResponseScenario> scenarios = null;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
scenarios = defineRequestResponseScenarios();
|
||||
}
|
||||
@Before
|
||||
public void setUp() {
|
||||
scenarios = defineRequestResponseScenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute each scenario. Instantiate the message channels, send the request message on the
|
||||
* input channel and invoke the validator on the response received on the output channel.
|
||||
* This can handle subscribable or pollable output channels.
|
||||
*/
|
||||
@Test
|
||||
public void testRequestResponseScenarios() {
|
||||
int i = 1;
|
||||
for (RequestResponseScenario scenario: scenarios) {
|
||||
String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName();
|
||||
scenario.init();
|
||||
MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(), MessageChannel.class);
|
||||
MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(), MessageChannel.class);
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator());
|
||||
}
|
||||
/**
|
||||
* Execute each scenario. Instantiate the message channels, send the request message
|
||||
* on the input channel and invoke the validator on the response received on the
|
||||
* output channel. This can handle subscribable or pollable output channels.
|
||||
*/
|
||||
@Test
|
||||
public void testRequestResponseScenarios() {
|
||||
int i = 1;
|
||||
for (RequestResponseScenario scenario : scenarios) {
|
||||
String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName();
|
||||
scenario.init();
|
||||
MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(),
|
||||
MessageChannel.class);
|
||||
MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(),
|
||||
MessageChannel.class);
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator());
|
||||
}
|
||||
|
||||
assertTrue(name + ": message not sent on " + scenario.getInputChannelName()
|
||||
, inputChannel.send(scenario.getMessage()));
|
||||
assertTrue(name + ": message not sent on " + scenario.getInputChannelName(),
|
||||
inputChannel.send(scenario.getMessage()));
|
||||
|
||||
if (outputChannel instanceof PollableChannel) {
|
||||
Message<?> response = ((PollableChannel) outputChannel).receive(10000);
|
||||
assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response);
|
||||
scenario.getResponseValidator().handleMessage(response);
|
||||
}
|
||||
if (outputChannel instanceof PollableChannel) {
|
||||
Message<?> response = ((PollableChannel) outputChannel).receive(10000);
|
||||
assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response);
|
||||
scenario.getResponseValidator().handleMessage(response);
|
||||
}
|
||||
|
||||
assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.",
|
||||
assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.",
|
||||
scenario.getResponseValidator().getLastMessage());
|
||||
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Implement this method to define RequestResponse scenarios
|
||||
* @return - A List of {@link RequestResponseScenario}
|
||||
*/
|
||||
protected abstract List<RequestResponseScenario> defineRequestResponseScenarios();
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement this method to define RequestResponse scenarios
|
||||
* @return - A List of {@link RequestResponseScenario}
|
||||
*/
|
||||
protected abstract List<RequestResponseScenario> defineRequestResponseScenarios();
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractResponseValidator<T> implements MessageHandler {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
this.lastMessage = message;
|
||||
validateResponse((T) (extractPayload() ? message.getPayload() : message ));
|
||||
validateResponse((T) (extractPayload() ? message.getPayload() : message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user