Merge pull request #82 from ghillert/INTSAMPLES-102
INTSAMPLES-102 - Advanced-testing-examples - Fix failing test
This commit is contained in:
@@ -7,12 +7,17 @@
|
|||||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||||
<name>Samples (Advanced) - Advanced Testing Examples</name>
|
<name>Samples (Advanced) - Advanced Testing Examples</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<prerequisites>
|
||||||
|
<maven>2.2.1</maven>
|
||||||
|
</prerequisites>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<spring.integration.version>2.2.0.RELEASE</spring.integration.version>
|
<spring.integration.version>2.2.0.RELEASE</spring.integration.version>
|
||||||
<spring.version>3.1.3.RELEASE</spring.version>
|
<spring.version>3.1.3.RELEASE</spring.version>
|
||||||
<log4j.version>1.2.16</log4j.version>
|
<log4j.version>1.2.17</log4j.version>
|
||||||
<junit.version>4.10</junit.version>
|
<junit.version>4.11</junit.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -51,60 +56,62 @@
|
|||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
<version>1.8.5</version>
|
<version>1.9.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<testResources>
|
<testResources>
|
||||||
<testResource>
|
<testResource>
|
||||||
<directory>src/test/java</directory>
|
<directory>src/test/java</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*</include>
|
<include>**/*</include>
|
||||||
</includes>
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*.java</exclude>
|
<exclude>**/*.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</testResource>
|
</testResource>
|
||||||
<testResource>
|
<testResource>
|
||||||
<directory>src/test/resources</directory>
|
<directory>src/test/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*</include>
|
<include>**/*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</testResource>
|
</testResource>
|
||||||
</testResources>
|
</testResources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.5</source>
|
<source>1.6</source>
|
||||||
<target>1.5</target>
|
<target>1.6</target>
|
||||||
<compilerArgument>-Xlint:all</compilerArgument>
|
<compilerArgument>-Xlint:all</compilerArgument>
|
||||||
<showWarnings>true</showWarnings>
|
<showWarnings>true</showWarnings>
|
||||||
<showDeprecation>false</showDeprecation>
|
<showDeprecation>true</showDeprecation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<configuration>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<includes>
|
<version>2.12.4</version>
|
||||||
<include>**/*Tests.java</include>
|
<configuration>
|
||||||
</includes>
|
<includes>
|
||||||
</configuration>
|
<include>**/*Tests.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -1,33 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
xmlns:int="http://www.springframework.org/schema/integration"
|
|
||||||
xmlns:int-groovy="http://www.springframework.org/schema/integration/groovy"
|
xmlns:int-groovy="http://www.springframework.org/schema/integration/groovy"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
http://www.springframework.org/schema/integration/groovy http://www.springframework.org/schema/integration/groovy/spring-integration-groovy.xsd
|
http://www.springframework.org/schema/integration/groovy http://www.springframework.org/schema/integration/groovy/spring-integration-groovy.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
<!--
|
|
||||||
This implements the core business logic of the integration flow. Not
|
|
||||||
binding input and output channels to JMS (or any other protocol) within makes this flow more
|
|
||||||
easily testable.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
<!-- This implements the core business logic of the integration flow. Not
|
||||||
|
binding input and output channels to JMS (or any other protocol) within makes
|
||||||
|
this flow more easily testable. -->
|
||||||
|
|
||||||
<!-- Throw an exception -->
|
<!-- Throw an exception -->
|
||||||
<int:transformer input-channel="inputChannel" output-channel="outputChannel">
|
<int:transformer input-channel="inputChannel"
|
||||||
<int-groovy:script><![CDATA[
|
output-channel="outputChannel">
|
||||||
if (!payload.equals('hello')) {
|
<int-groovy:script><![CDATA[
|
||||||
throw new RuntimeException('invalid payload')
|
if (!payload.equals('hello')) {
|
||||||
}
|
throw new RuntimeException('invalid payload')
|
||||||
payload
|
}
|
||||||
]]>
|
payload
|
||||||
</int-groovy:script>
|
]]>
|
||||||
</int:transformer>
|
</int-groovy:script>
|
||||||
<int:channel id="outputChannel"/>
|
</int:transformer>
|
||||||
|
|
||||||
|
<int:channel id="outputChannel" />
|
||||||
|
|
||||||
<!-- Do some error handling -->
|
<!-- Do some error handling -->
|
||||||
<int:transformer input-channel="errorChannel" output-channel="invalidMessageChannel" expression="payload.cause.cause.message"/>
|
<int:transformer input-channel="errorChannel"
|
||||||
|
output-channel="invalidMessageChannel" expression="payload.cause.cause.message" />
|
||||||
|
|
||||||
<int:channel id="invalidMessageChannel"/>
|
<int:channel id="invalidMessageChannel" />
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@@ -7,25 +7,20 @@
|
|||||||
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.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">
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
<!--
|
<!-- This is a test context that injects a Mock JMS template into a JMS
|
||||||
This is a test context that injects a Mock JMS template into a JMS
|
inbound channel adapter. The inbound-channel-adapter provides or overrides
|
||||||
inbound channel adapter. The inbound-channel-adapter provides or overrides the 'real'
|
the 'real' adapter for testing purposes. If the flow imported flow throws
|
||||||
adapter for testing purposes.
|
an exception, an ErrorMessage containg the exception will be sent to the
|
||||||
|
error channel for additional handling. -->
|
||||||
|
|
||||||
If the flow imported flow throws an exception, an ErrorMessage containg the exception will be sent
|
<import resource="classpath:integration-config.xml" />
|
||||||
to the error channel for additional handling.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<import resource="classpath:integration-config.xml"/>
|
<int-jms:inbound-channel-adapter jms-template="jmsTemplate" channel="inputChannel">
|
||||||
|
<int:poller fixed-rate="500" max-messages-per-poll="1" error-channel="errorChannel" />
|
||||||
<int-jms:inbound-channel-adapter jms-template="jmsTemplate"
|
</int-jms:inbound-channel-adapter>
|
||||||
channel="inputChannel">
|
|
||||||
<int:poller fixed-rate="500" max-messages-per-poll="1" error-channel="errorChannel"/>
|
|
||||||
</int-jms:inbound-channel-adapter>
|
|
||||||
|
|
||||||
<bean id="jmsTemplate" class="org.mockito.Mockito" factory-method="mock">
|
|
||||||
<constructor-arg value="org.springframework.jms.core.JmsTemplate"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
<bean id="jmsTemplate" class="org.mockito.Mockito" factory-method="mock">
|
||||||
|
<constructor-arg value="org.springframework.jms.core.JmsTemplate" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
* 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
|
* the License. You may obtain a copy of the License at
|
||||||
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.TextMessage;
|
import javax.jms.TextMessage;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -44,6 +45,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class JmsMockTests {
|
public class JmsMockTests {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(JmsMockTests.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
JmsTemplate mockJmsTemplate;
|
JmsTemplate mockJmsTemplate;
|
||||||
|
|
||||||
@@ -59,7 +62,6 @@ public class JmsMockTests {
|
|||||||
@Qualifier("invalidMessageChannel")
|
@Qualifier("invalidMessageChannel")
|
||||||
SubscribableChannel invalidMessageChannel;
|
SubscribableChannel invalidMessageChannel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies that a message received on a polling JMS inbound channel adapter is
|
* 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
|
* routed to the designated channel and that the message payload is as expected
|
||||||
@@ -116,7 +118,7 @@ public class JmsMockTests {
|
|||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
protected boolean verifyJmsMessageReceivedOnOutputChannel(Object obj, SubscribableChannel expectedOutputChannel, CountDownHandler handler) throws JMSException, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,12 +158,17 @@ public class JmsMockTests {
|
|||||||
|
|
||||||
expectedOutputChannel.subscribe(handler);
|
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 {
|
private abstract class CountDownHandler implements MessageHandler {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user