From a7c2df55f32f83a5b67420f31ef3e6a836679cbe Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 22 Mar 2011 13:55:22 +0000 Subject: [PATCH] Add -P integration profile for tests involving broker --- spring-amqp-parent/pom.xml | 69 +++++++++++++------ spring-rabbit/pom.xml | 13 +--- .../admin/JInterfaceIntegrationTests.java | 36 ++++++---- 3 files changed, 73 insertions(+), 45 deletions(-) diff --git a/spring-amqp-parent/pom.xml b/spring-amqp-parent/pom.xml index 52249b84..2e8548c4 100644 --- a/spring-amqp-parent/pom.xml +++ b/spring-amqp-parent/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.springframework.amqp spring-amqp-parent @@ -35,6 +36,39 @@ true + + integration + + true + + + + + maven-surefire-plugin + + + + BROKER_INTEGRATION_TEST + ${integration.test} + + + false + + **/*Tests.java + + + **/Abstract*.java + + junit:junit + + + + com.springsource.bundlor + com.springsource.bundlor.maven + + + + staging @@ -78,10 +112,9 @@ - + @@ -248,10 +281,9 @@ - + log4j log4j @@ -262,8 +294,7 @@ - + org.springframework.build.aws org.springframework.build.aws.maven 3.0.0.RELEASE @@ -356,14 +387,11 @@ - com.springsource.bundlor com.springsource.bundlor.maven @@ -407,8 +435,7 @@ - + org.apache.maven.plugins maven-project-info-reports-plugin 2.1 diff --git a/spring-rabbit/pom.xml b/spring-rabbit/pom.xml index a7d717d6..de89500d 100644 --- a/spring-rabbit/pom.xml +++ b/spring-rabbit/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.springframework.amqp @@ -25,7 +26,7 @@ true - + org.springframework spring-aop @@ -114,12 +115,4 @@ - - - - com.springsource.bundlor - com.springsource.bundlor.maven - - - diff --git a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java index b26d8674..fb635164 100755 --- a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java +++ b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java @@ -4,7 +4,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.net.InetAddress; import java.net.UnknownHostException; import junit.framework.Assert; @@ -12,12 +11,13 @@ import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.springframework.amqp.rabbit.test.BrokerTestUtils; import org.springframework.amqp.rabbit.test.EnvironmentAvailable; import org.springframework.erlang.connection.SingleConnectionFactory; import org.springframework.erlang.core.ErlangTemplate; -import org.springframework.util.exec.Os; import com.ericsson.otp.erlang.OtpConnection; import com.ericsson.otp.erlang.OtpErlangBinary; @@ -32,16 +32,32 @@ public class JInterfaceIntegrationTests { private static int counter; + private static final String NODE_NAME = "spring@localhost"; + private OtpConnection connection = null; + private RabbitBrokerAdmin brokerAdmin; + @Rule public static EnvironmentAvailable environment = new EnvironmentAvailable("BROKER_INTEGRATION_TEST"); + @Before + public void init() { + brokerAdmin = BrokerTestUtils.getRabbitBrokerAdmin(NODE_NAME); + RabbitStatus status = brokerAdmin.getStatus(); + if (!status.isRunning()) { + brokerAdmin.startBrokerApplication(); + } + } + @After public void close() { if (connection != null) { connection.close(); } + if (brokerAdmin != null) { + brokerAdmin.stopNode(); + } } @Test @@ -49,7 +65,7 @@ public class JInterfaceIntegrationTests { OtpSelf self = new OtpSelf("rabbit-monitor"); - String hostName = "rabbit@" + getHostName(); + String hostName = NODE_NAME; OtpPeer peer = new OtpPeer(hostName); connection = self.connect(peer); @@ -67,7 +83,7 @@ public class JInterfaceIntegrationTests { public void otpTemplate() throws UnknownHostException { String selfNodeName = "rabbit-monitor"; - String peerNodeName = "rabbit@" + getHostName(); + String peerNodeName = NODE_NAME; SingleConnectionFactory cf = new SingleConnectionFactory(selfNodeName, peerNodeName); @@ -82,14 +98,6 @@ public class JInterfaceIntegrationTests { } - private String getHostName() throws UnknownHostException { - String hostName = InetAddress.getLocalHost().getHostName(); - if (Os.isFamily("windows")) { - hostName = hostName.toUpperCase(); - } - return hostName; - } - @Test public void testRawOtpConnect() throws Exception { createConnection(); @@ -98,7 +106,7 @@ public class JInterfaceIntegrationTests { @Test public void stressTest() throws Exception { String cookie = readCookie(); - logger.info("Cookie: "+cookie); + logger.info("Cookie: " + cookie); OtpConnection con = createConnection(); boolean recycleConnection = false; for (int i = 0; i < 100; i++) { @@ -115,7 +123,7 @@ public class JInterfaceIntegrationTests { public OtpConnection createConnection() throws Exception { OtpSelf self = new OtpSelf("rabbit-monitor-" + counter++); - OtpPeer peer = new OtpPeer("rabbit@" + getHostName()); + OtpPeer peer = new OtpPeer(NODE_NAME); return self.connect(peer); }