Author: richard.opalka(a)jboss.com
Date: 2009-10-30 06:35:37 -0400 (Fri, 30 Oct 2009)
New Revision: 11074
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java
Log:
[JBPAPP-3041] backport
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-30
10:18:55 UTC (rev 11073)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2009-10-30
10:35:37 UTC (rev 11074)
@@ -112,6 +112,14 @@
<include name="jboss-service.xml"/>
</metainf>
</jar>
+ <jar
jarfile="${tests.output.dir}/test-libs/jaxws-samples-dar-jms-client-test.sar">
+ <fileset dir="${tests.output.dir}/test-libs">
+ <include name="jaxws-samples-dar-jms-client.war"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/dar/META-INF">
+ <include name="jboss-service.xml"/>
+ </metainf>
+ </jar>
<!-- jaxws-samples-jmstransport -->
<jar
jarfile="${tests.output.dir}/test-libs/jaxws-samples-jmstransport.jar">
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java 2009-10-30
10:18:55 UTC (rev 11073)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java 2009-10-30
10:35:37 UTC (rev 11074)
@@ -27,11 +27,17 @@
import java.net.URL;
import java.util.Date;
-import javax.management.ObjectName;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
import junit.framework.Test;
-import org.jboss.wsf.common.ObjectNameFactory;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
@@ -47,13 +53,12 @@
public static Test suite()
{
- return new JBossWSTestSetup(JMSClientTestCase.class,
"jaxws-samples-dar-jms-client.sar,jaxws-samples-dar-jms.jar");
+ return new JBossWSTestSetup(JMSClientTestCase.class,
"jaxws-samples-dar-jms-client-test.sar,jaxws-samples-dar-jms.jar");
}
public void test() throws Exception
{
String url = "http://" + getServerHost() +
":8080/dar-jms-client/JMSClient";
- int count = getMessageCount("DarResponseQueue");
Date start = new Date();
HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
int responseCode = connection.getResponseCode();
@@ -70,14 +75,18 @@
assertTrue(buffer.toString().contains("Request message sent, doing something
interesting in the mean time... ;-) "));
Date stop = new Date();
assertTrue(stop.getTime() - start.getTime() < TEST_RUN_TIME / 2);
- Thread.sleep(TEST_RUN_TIME);
- assertEquals(count + 1, getMessageCount("DarResponseQueue"));
+
+ //receive the message
+ InitialContext context = new InitialContext();
+ QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)context.lookup("ConnectionFactory");
+ QueueConnection con = connectionFactory.createQueueConnection();
+ QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue resQueue = (Queue)context.lookup("queue/DarResponseQueue");
+ con.start();
+ MessageConsumer consumer = session.createConsumer(resQueue);
+ TextMessage textMessage = (TextMessage)consumer.receive(TEST_RUN_TIME);
+ String result = textMessage.getText();
+ assertTrue(result != null);
+ con.stop();
}
-
- private int getMessageCount(String queue) throws Exception
- {
- ObjectName oname =
ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=" + queue);
- return (Integer)getServer().getAttribute(oname, "MessageCount");
- }
-
}
Show replies by date