diff --git a/advanced/advanced-testing-examples/pom.xml b/advanced/advanced-testing-examples/pom.xml
index 82f31be3..50a535fb 100644
--- a/advanced/advanced-testing-examples/pom.xml
+++ b/advanced/advanced-testing-examples/pom.xml
@@ -7,12 +7,17 @@
2.2.0.BUILD-SNAPSHOTSamples (Advanced) - Advanced Testing Examplesjar
+
+
+ 2.2.1
+
+
UTF-82.2.0.RELEASE3.1.3.RELEASE
- 1.2.16
- 4.10
+ 1.2.17
+ 4.11
@@ -51,60 +56,62 @@
${spring.version}
-
- org.apache.geronimo.specs
- geronimo-jms_1.1_spec
- 1.1.1
- provided
-
+
+ org.apache.geronimo.specs
+ geronimo-jms_1.1_spec
+ 1.1.1
+ provided
+
-
- org.mockito
- mockito-all
- 1.8.5
- test
-
+
+ org.mockito
+ mockito-all
+ 1.9.5
+ test
+
-
- src/test/java
-
- **/*
-
-
- **/*.java
-
-
-
- src/test/resources
-
- **/*
-
-
+
+ src/test/java
+
+ **/*
+
+
+ **/*.java
+
+
+
+ src/test/resources
+
+ **/*
+
+ org.apache.maven.pluginsmaven-compiler-plugin
- 2.3.2
+ 3.0
- 1.5
- 1.5
+ 1.6
+ 1.6-Xlint:alltrue
- false
+ true
- maven-surefire-plugin
-
-
- **/*Tests.java
-
-
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.12.4
+
+
+ **/*Tests.java
+
+
diff --git a/advanced/advanced-testing-examples/src/main/resources/integration-config.xml b/advanced/advanced-testing-examples/src/main/resources/integration-config.xml
index d179b99b..8ba6be64 100644
--- a/advanced/advanced-testing-examples/src/main/resources/integration-config.xml
+++ b/advanced/advanced-testing-examples/src/main/resources/integration-config.xml
@@ -1,33 +1,32 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests-context.xml b/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests-context.xml
index acfccd05..b1ba42b5 100644
--- a/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests-context.xml
+++ b/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests-context.xml
@@ -6,26 +6,21 @@
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests.java b/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests.java
index a1d9edc7..b92d5a45 100644
--- a/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests.java
+++ b/advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2002-2011 the original author or authors.
- *
+ * Copyright 2002-2012 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import javax.jms.JMSException;
import javax.jms.TextMessage;
+import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +45,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration
public class JmsMockTests {
+ private static final Logger LOGGER = Logger.getLogger(JmsMockTests.class);
+
@Autowired
JmsTemplate mockJmsTemplate;
@@ -58,12 +61,11 @@ public class JmsMockTests {
@Autowired
@Qualifier("invalidMessageChannel")
SubscribableChannel invalidMessageChannel;
-
/**
* This test verifies that a message received on a polling JMS inbound channel adapter is
* routed to the designated channel and that the message payload is as expected
- *
+ *
* @throws JMSException
* @throws InterruptedException
* @throws IOException
@@ -71,7 +73,7 @@ public class JmsMockTests {
@Test
public void testReceiveMessage() throws JMSException, InterruptedException, IOException {
String msg = "hello";
-
+
boolean sent = verifyJmsMessageReceivedOnOutputChannel(msg, outputChannel,new CountDownHandler() {
@Override
@@ -82,11 +84,11 @@ public class JmsMockTests {
);
assertTrue("message not sent to expected output channel", sent);
}
-
+
/**
* This test verifies that a message received on a polling JMS inbound channel adapter is
* routed to the errorChannel and that the message payload is the expected exception
- *
+ *
* @throws JMSException
* @throws IOException
* @throws InterruptedException
@@ -100,12 +102,12 @@ public class JmsMockTests {
protected void verifyMessage(Message> message) {
assertEquals("invalid payload",message.getPayload());
}
-
+
}
);
- assertTrue("message not sent to expected output channel", sent);
+ assertTrue("message not sent to expected output channel", sent);
}
-
+
/**
* Provide a message via a mock JMS template and wait for the default timeout to receive the message on the expected channel
* @param obj The message provided to the poller (currently must be a String)
@@ -116,16 +118,16 @@ public class JmsMockTests {
* @throws InterruptedException
*/
protected boolean verifyJmsMessageReceivedOnOutputChannel(Object obj, SubscribableChannel expectedOutputChannel, CountDownHandler handler) throws JMSException, InterruptedException{
- return verifyJmsMessageOnOutputChannel(obj, expectedOutputChannel, handler, 5000);
+ return verifyJmsMessageOnOutputChannel(obj, expectedOutputChannel, handler, 7000);
}
-
-
+
+
/**
- * Provide a message via a mock JMS template and wait for the specified timeout to receive the message on the expected channel
+ * Provide a message via a mock JMS template and wait for the specified timeout to receive the message on the expected channel
* @param obj The message provided to the poller (currently must be a String)
* @param expectedOutputChannel The expected output channel
* @param handler An instance of CountDownHandler to handle (verify) the output message
- * @param timeoutMillisec The timeout period. Note that this must allow at least enough time to process the entire flow. Only set if the default is
+ * @param timeoutMillisec The timeout period. Note that this must allow at least enough time to process the entire flow. Only set if the default is
* not long enough
* @return true if the message was received on the expected channel
* @throws JMSException
@@ -137,12 +139,12 @@ public class JmsMockTests {
if (!(obj instanceof String)) {
throw new IllegalArgumentException("Only TextMessage is currently supported");
}
-
+
/*
* Use mocks to create a message returned to the JMS inbound adapter. It is assumed that the JmsTemplate
* is also a mock.
*/
-
+
TextMessage message = mock(TextMessage.class);
doReturn(new SimpleMessageConverter()).when(mockJmsTemplate).getMessageConverter();
doReturn(message).when(mockJmsTemplate).receiveSelected(anyString());
@@ -151,38 +153,43 @@ public class JmsMockTests {
CountDownLatch latch = new CountDownLatch(1);
handler.setLatch(latch);
-
+
doReturn(text).when(message).getText();
expectedOutputChannel.subscribe(handler);
- return latch.await(timeoutMillisec, TimeUnit.MILLISECONDS);
+ boolean latchCountedToZero = latch.await(timeoutMillisec, TimeUnit.MILLISECONDS);
+
+ if (!latchCountedToZero) {
+ LOGGER.warn(String.format("The specified waiting time of the latch (%s ms) elapsed.", timeoutMillisec));
+ }
+
+ return latchCountedToZero;
-
}
/*
- * A MessageHandler that uses a CountDownLatch to syncronize with the calling thread
+ * A MessageHandler that uses a CountDownLatch to synchronize with the calling thread
*/
private abstract class CountDownHandler implements MessageHandler {
CountDownLatch latch;
-
+
public final void setLatch(CountDownLatch latch){
this.latch = latch;
}
-
+
protected abstract void verifyMessage(Message> message);
/*
* (non-Javadoc)
- *
+ *
* @see
* org.springframework.integration.core.MessageHandler#handleMessage
* (org.springframework.integration.Message)
*/
public void handleMessage(Message> message) throws MessagingException {
verifyMessage(message);
- latch.countDown();
+ latch.countDown();
}
}
}