You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2014/03/04 13:34:42 UTC
[1/2] Making jms tests more robust
Repository: cxf
Updated Branches:
refs/heads/master 30d6e812d -> 979297158
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSSharedQueueTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSSharedQueueTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSSharedQueueTest.java
index ac88a2f..b50ccd8 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSSharedQueueTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSSharedQueueTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.systest.jms;
+import java.io.Closeable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,15 +44,14 @@ import org.junit.BeforeClass;
import org.junit.Test;
public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
-// private static final String BROKER_URI = "vm://SharedQueueTest"
-// + "?jms.watchTopicAdvisories=false&broker.persistent=false";
-
+ public static final String PORT = allocatePort(JMSSharedQueueTest.class);
+ private static final String SERVICE_NS = "http://cxf.apache.org/hello_world_jms";
private static EmbeddedJMSBrokerLauncher broker;
private String wsdlString;
@BeforeClass
public static void startServers() throws Exception {
- broker = new EmbeddedJMSBrokerLauncher();
+ broker = new EmbeddedJMSBrokerLauncher("tcp://localhost:" + PORT);
launchServer(broker);
launchServer(new Server(broker));
createStaticBus();
@@ -150,18 +150,16 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
@Test
public void testTwoWayQueueAppCorrelationID() throws Throwable {
- QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceAppCorrelationID");
- QName portNameEng = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPortAppCorrelationIDEng");
- QName portNameSales =
- new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPortAppCorrelationIDSales");
+ QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceAppCorrelationID");
+ QName portNameEng = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDEng");
+ QName portNameSales = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDSales");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
- HelloWorldServiceAppCorrelationID service =
- new HelloWorldServiceAppCorrelationID(wsdl, serviceName);
- assertNotNull(service);
+ HelloWorldServiceAppCorrelationID service = new HelloWorldServiceAppCorrelationID(wsdl, serviceName);
+ HelloWorldPortType portEng = service.getPort(portNameEng, HelloWorldPortType.class);
ClientRunnable engClient =
- new ClientRunnable(service.getPort(portNameEng, HelloWorldPortType.class),
+ new ClientRunnable(portEng,
new CorrelationIDFactory() {
private int counter;
public String createCorrealtionID() {
@@ -169,8 +167,9 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
}
});
+ HelloWorldPortType portSales = service.getPort(portNameSales, HelloWorldPortType.class);
ClientRunnable salesClient =
- new ClientRunnable(service.getPort(portNameSales, HelloWorldPortType.class),
+ new ClientRunnable(portSales,
new CorrelationIDFactory() {
private int counter;
public String createCorrealtionID() {
@@ -179,28 +178,32 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
});
executeAsync(engClient, salesClient);
+ ((Closeable)portEng).close();
+ ((Closeable)portSales).close();
}
@Test
public void testTwoWayQueueAppCorrelationIDStaticPrefix() throws Throwable {
- QName serviceName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName serviceName = new QName(SERVICE_NS,
"HelloWorldServiceAppCorrelationIDStaticPrefix");
- QName portNameEng = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portNameEng = new QName(SERVICE_NS,
"HelloWorldPortAppCorrelationIDStaticPrefixEng");
- QName portNameSales = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portNameSales = new QName(SERVICE_NS,
"HelloWorldPortAppCorrelationIDStaticPrefixSales");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldServiceAppCorrelationIDStaticPrefix service =
new HelloWorldServiceAppCorrelationIDStaticPrefix(wsdl, serviceName);
- ClientRunnable engClient =
- new ClientRunnable(service.getPort(portNameEng, HelloWorldPortType.class));
+ HelloWorldPortType portEng = service.getPort(portNameEng, HelloWorldPortType.class);
+ ClientRunnable engClient = new ClientRunnable(portEng);
- ClientRunnable salesClient =
- new ClientRunnable(service.getPort(portNameSales, HelloWorldPortType.class));
+ HelloWorldPortType portSales = service.getPort(portNameSales, HelloWorldPortType.class);
+ ClientRunnable salesClient = new ClientRunnable(portSales);
executeAsync(engClient, salesClient);
+ ((Closeable)portEng).close();
+ ((Closeable)portSales).close();
}
/* TO DO:
@@ -213,9 +216,9 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
*/
@Test
public void testTwoWayQueueAppCorrelationIDNoPrefix() throws Throwable {
- QName serviceName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName serviceName = new QName(SERVICE_NS,
"HelloWorldServiceAppCorrelationIDNoPrefix");
- QName portName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portName = new QName(SERVICE_NS,
"HelloWorldPortAppCorrelationIDNoPrefix");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldServiceAppCorrelationIDNoPrefix service =
@@ -228,6 +231,7 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
clients.add(new ClientRunnable(port));
}
executeAsync(clients);
+ ((Closeable)port).close();
}
/*
@@ -258,12 +262,12 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
*/
@Test
public void testTwoWayQueueRuntimeCorrelationIDStaticPrefix() throws Throwable {
- QName serviceName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName serviceName = new QName(SERVICE_NS,
"HelloWorldServiceRuntimeCorrelationIDStaticPrefix");
- QName portNameEng = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portNameEng = new QName(SERVICE_NS,
"HelloWorldPortRuntimeCorrelationIDStaticPrefixEng");
- QName portNameSales = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portNameSales = new QName(SERVICE_NS,
"HelloWorldPortRuntimeCorrelationIDStaticPrefixSales");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
@@ -279,16 +283,18 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
clients.add(new ClientRunnable(portSales, "com.mycompany.sales:"));
}
executeAsync(clients);
+ ((Closeable)portEng).close();
+ ((Closeable)portSales).close();
}
@Test
public void testTwoWayQueueRuntimeCorrelationDynamicPrefix() throws Throwable {
- QName serviceName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName serviceName = new QName(SERVICE_NS,
"HelloWorldServiceRuntimeCorrelationIDDynamicPrefix");
- QName portName = new QName("http://cxf.apache.org/hello_world_jms",
+ QName portName = new QName(SERVICE_NS,
"HelloWorldPortRuntimeCorrelationIDDynamicPrefix");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
@@ -301,6 +307,7 @@ public class JMSSharedQueueTest extends AbstractBusClientServerTestBase {
clients.add(new ClientRunnable(port));
}
executeAsync(clients);
+ ((Closeable)port).close();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSTestMtom.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSTestMtom.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSTestMtom.java
index e95de26..a87e20a 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSTestMtom.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSTestMtom.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.systest.jms;
+import java.io.Closeable;
import java.net.URL;
import javax.activation.DataHandler;
@@ -86,6 +87,7 @@ public class JMSTestMtom {
byte bytes[] = IOUtils.readBytesFromStream(handler1.value.getInputStream());
Assert.assertEquals("The response file is not same with the sent file.", size, bytes.length);
+ ((Closeable)mtom).close();
}
@@ -105,6 +107,7 @@ public class JMSTestMtom {
byte bytes[] = IOUtils.readBytesFromStream(ret.getInputStream());
Assert.assertEquals("The response file is not same with the original file.", size, bytes.length);
+ ((Closeable)mtom).close();
}
public static URL getWSDLURL(String s) throws Exception {
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JaxWsAPITest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JaxWsAPITest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JaxWsAPITest.java
index 61762cd..5c364ab 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JaxWsAPITest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JaxWsAPITest.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.systest.jms;
+import java.io.Closeable;
import java.net.URL;
import javax.xml.namespace.QName;
@@ -50,13 +51,13 @@ public class JaxWsAPITest {
@BeforeClass
public static void startServer() {
bus = BusFactory.getDefaultBus();
- ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://JaxWsAPITest?broker.persistent=false");
PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
cff = new ConnectionFactoryFeature(cfp);
- Object impleDoc = new GreeterImplDoc();
- EndpointImpl ep = (EndpointImpl)Endpoint.create(impleDoc);
+ EndpointImpl ep = (EndpointImpl)Endpoint.create(new GreeterImplDoc());
ep.getFeatures().add(cff);
+ ep.setBus(bus);
ep.publish();
}
@@ -79,6 +80,7 @@ public class JaxWsAPITest {
String greeting = greeter.greetMe("Chris");
Assert.assertEquals("Hello Chris", greeting);
+ ((Closeable)greeter).close();
}
public URL getWSDLURL(String s) throws Exception {
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
index 4e22e83..b4b3420 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
@@ -22,10 +22,8 @@ import javax.xml.ws.Endpoint;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
-import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
public class Server extends AbstractBusTestServerBase {
public static final String PORT = allocatePort(Server.class);
@@ -36,23 +34,6 @@ public class Server extends AbstractBusTestServerBase {
}
protected void run() {
- Object implementor = new GreeterImplTwoWayJMS();
- Object impl2 = new GreeterImplQueueOneWay();
- Object impl3 = new GreeterImplTopicOneWay();
- Object impleDoc = new GreeterImplDoc();
- Object impl4 = new GreeterByteMessageImpl();
- Object impl5 = new SoapService6SoapPort6Impl();
- Object impl6 = new JmsDestPubSubImpl();
- Object impl7 = new SoapService7SoapPort7Impl();
- Object i1 = new GreeterImplTwoWayJMSAppCorrelationIDNoPrefix();
- Object i2 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixEng();
- Object i3 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixSales();
- Object i4 = new GreeterImplTwoWayJMSRuntimeCorrelationIDDynamicPrefix();
- Object i5 = new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixEng();
- Object i6 = new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixSales();
- Object i7 = new GreeterImplTwoWayJMSAppCorrelationIDEng();
- Object i8 = new GreeterImplTwoWayJMSAppCorrelationIDSales();
-
Bus bus = BusFactory.getDefaultBus();
setBus(bus);
@@ -60,63 +41,26 @@ public class Server extends AbstractBusTestServerBase {
broker.updateWsdl(bus, "testutils/jms_test.wsdl");
broker.updateWsdl(bus, "testutils/jms_test_mtom.wsdl");
- Endpoint.publish(null, impleDoc);
+ Endpoint.publish(null, new GreeterImplDoc());
String address = null;
- Endpoint.publish(address, implementor);
- Endpoint.publish(null, impl2);
- Endpoint.publish(null, impl3);
- Endpoint.publish(null, impl4);
- Endpoint.publish(null, impl5);
- Endpoint.publish(null, impl6);
+ Endpoint.publish(address, new GreeterImplTwoWayJMS());
+ Endpoint.publish(null, new GreeterImplQueueOneWay());
+ Endpoint.publish(null, new GreeterImplTopicOneWay());
+ Endpoint.publish(null, new GreeterByteMessageImpl());
+ Endpoint.publish(null, new SoapService6SoapPort6Impl());
+ Endpoint.publish(null, new JmsDestPubSubImpl());
- Endpoint.publish(null, impl7);
- Endpoint.publish(null, i1);
- Endpoint.publish(null, i2);
- Endpoint.publish(null, i3);
- Endpoint.publish(null, i4);
- Endpoint.publish(null, i5);
- Endpoint.publish(null, i6);
- Endpoint.publish(null, i7);
- Endpoint.publish(null, i8);
+ Endpoint.publish(null, new SoapService7SoapPort7Impl());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSAppCorrelationIDNoPrefix());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixEng());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixSales());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSRuntimeCorrelationIDDynamicPrefix());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixEng());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixSales());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSAppCorrelationIDEng());
+ Endpoint.publish(null, new GreeterImplTwoWayJMSAppCorrelationIDSales());
- Object spec1 = new GreeterSpecImpl();
- String address1 = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue2"
- + "?jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
- + broker.getEncodedBrokerURL();
- Endpoint.publish(address1, spec1);
-
- Object spec2 = new GreeterSpecWithPortError();
- String address2 = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue5"
- + "?jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
- + broker.getEncodedBrokerURL();
- Endpoint.publish(address2, spec2);
-
- initNoWsdlServer();
}
-
- /**
- *
- */
- private void initNoWsdlServer() {
- String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3"
- + "?jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
- + broker.getEncodedBrokerURL();
- Hello implementor = new HelloImpl();
- JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
- svrFactory.setServiceClass(Hello.class);
- svrFactory.setAddress(address);
- svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
- svrFactory.setServiceBean(implementor);
- svrFactory.create();
- }
-
-
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsClientServerTest.java
index bcc47d6..515f6c9 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsClientServerTest.java
@@ -53,6 +53,7 @@ public class HelloWorldContinuationsClientServerTest {
cff = new ConnectionFactoryFeature(cfp);
Object implementor = new HelloWorldWithContinuationsJMS();
EndpointImpl ep = (EndpointImpl)Endpoint.create(null, implementor);
+ ep.setBus(bus);
ep.getFeatures().add(cff);
ep.publish();
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsThrottleTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsThrottleTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsThrottleTest.java
index c1af7ce..329d823 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsThrottleTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HelloWorldContinuationsThrottleTest.java
@@ -53,6 +53,7 @@ public class HelloWorldContinuationsThrottleTest {
String address = "jms:queue:test.jmstransport.text?replyToQueueName=test.jmstransport.text.reply";
EndpointImpl ep = (EndpointImpl)Endpoint.create(address, implementor);
ep.getFeatures().add(cff);
+ ep.setBus(bus);
ep.publish();
}
@@ -83,10 +84,11 @@ public class HelloWorldContinuationsThrottleTest {
executor.execute(new HelloWorker(helloPort, "Harry", "", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "Rob", "Davidson", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "James", "ServiceMix", startSignal, helloDoneSignal));
-
helloDoneSignal.await(60, TimeUnit.SECONDS);
+ ((java.io.Closeable)helloPort).close();
executor.shutdownNow();
+
Assert.assertEquals("Some invocations are still running", 0, helloDoneSignal.getCount());
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/JMSContinuationsClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/JMSContinuationsClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/JMSContinuationsClientServerTest.java
index 3bec3df..c7c7666 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/JMSContinuationsClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/JMSContinuationsClientServerTest.java
@@ -49,6 +49,7 @@ public class JMSContinuationsClientServerTest {
Object implementor = new GreeterImplWithContinuationsJMS();
String address = "jms:queue:test.jmstransport.text?replyToQueueName=test.jmstransport.text.reply";
EndpointImpl ep = (EndpointImpl)Endpoint.create(implementor);
+ ep.setBus(bus);
ep.getFeatures().add(cff);
ep.publish(address);
}
@@ -73,6 +74,7 @@ public class JMSContinuationsClientServerTest {
HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class, cff);
Assert.assertEquals("Hi Fred Ruby", greeter.greetMe("Fred"));
+ ((java.io.Closeable)greeter).close();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/ProviderJMSContinuationTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/ProviderJMSContinuationTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/ProviderJMSContinuationTest.java
index 95be743..eb49ff7 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/ProviderJMSContinuationTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/ProviderJMSContinuationTest.java
@@ -50,6 +50,7 @@ public class ProviderJMSContinuationTest {
String address = "jms:queue:test.jmstransport.text?replyToQueueName=test.jmstransport.text.reply";
EndpointImpl ep = (EndpointImpl)Endpoint.create(address, implementor);
ep.getInInterceptors().add(new IncomingMessageCounterInterceptor());
+ ep.setBus(bus);
ep.getFeatures().add(cff);
ep.publish();
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/multitransport/MultiTransportClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/multitransport/MultiTransportClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/multitransport/MultiTransportClientServerTest.java
index d43228d..2c7bb37 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/multitransport/MultiTransportClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/multitransport/MultiTransportClientServerTest.java
@@ -61,6 +61,7 @@ public class MultiTransportClientServerTest {
String address = "http://localhost:" + PORT + "/SOAPDocLitService/SoapPort";
Endpoint.publish(address, new HTTPGreeterImpl());
EndpointImpl ep1 = (EndpointImpl)Endpoint.create(new JMSGreeterImpl());
+ ep1.setBus(bus);
ep1.getFeatures().add(cff);
ep1.publish();
}
@@ -101,7 +102,7 @@ public class MultiTransportClientServerTest {
}
}
-
+ ((java.io.Closeable)greeter).close();
greeter = null;
greeter = service.getPort(portName2, Greeter.class, cff);
@@ -123,6 +124,7 @@ public class MultiTransportClientServerTest {
}
}
+ ((java.io.Closeable)greeter).close();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl b/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
index 74fc7d3..6604c32 100644
--- a/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
+++ b/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
@@ -273,10 +273,8 @@
</wsdl:port>
</wsdl:service>
<wsdl:service name="SOAPService8">
- <jms:jndiURL>tcp://localhost:61500</jms:jndiURL>
- <jms:jndiInitialContextFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</jms:jndiInitialContextFactory>
<wsdl:port name="SoapPort8" binding="tns:Greeter_SOAPBinding_soap12">
- <soap:address location="jms:jndi:dynamicQueues/routertest.SOAPService2Q.text" />
+ <soap:address location="jms:queue:routertest.SOAPService2Q.text" />
</wsdl:port>
</wsdl:service>
<!-- XML Binding based Services-->
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/testutils/src/main/resources/wsdl/jms_spec_test.wsdl
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/jms_spec_test.wsdl b/testutils/src/main/resources/wsdl/jms_spec_test.wsdl
index 1b81264..4322b29 100644
--- a/testutils/src/main/resources/wsdl/jms_spec_test.wsdl
+++ b/testutils/src/main/resources/wsdl/jms_spec_test.wsdl
@@ -95,13 +95,6 @@
<wsdl:binding name="JMSGreeterPortBinding" type="tns:JMSGreeterPortType">
<soap:binding style="document" transport="http://www.w3.org/2010/soapjms/"/>
<soapjms:jndiContextParameter name="name" value="value"/>
- <soapjms:jndiConnectionFactoryName>ConnectionFactory
- </soapjms:jndiConnectionFactoryName>
- <soapjms:jndiInitialContextFactory>
- org.apache.activemq.jndi.ActiveMQInitialContextFactory
- </soapjms:jndiInitialContextFactory>
- <soapjms:jndiURL>tcp://localhost:61500
- </soapjms:jndiURL>
<soapjms:deliveryMode>PERSISTENT</soapjms:deliveryMode>
<soapjms:priority>5</soapjms:priority>
<soapjms:timeToLive>1000</soapjms:timeToLive>
@@ -133,21 +126,14 @@
</wsdl:binding>
<wsdl:service name="JMSGreeterService">
<soapjms:jndiContextParameter name="name2" value="value2"/>
- <soapjms:jndiConnectionFactoryName>ConnectionFactory</soapjms:jndiConnectionFactoryName>
- <soapjms:jndiInitialContextFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</soapjms:jndiInitialContextFactory>
- <soapjms:jndiURL>tcp://localhost:61500
- </soapjms:jndiURL>
<soapjms:deliveryMode>NON_PERSISTENT
</soapjms:deliveryMode>
<soapjms:priority>6</soapjms:priority>
<soapjms:timeToLive>2000</soapjms:timeToLive>
<!--<soapjms:replyToName>replytoname2</soapjms:replyToName>-->
<wsdl:port binding="tns:JMSGreeterPortBinding" name="GreeterPort">
- <soap:address location="jms:jndi:dynamicQueues/test.cxf.jmstransport.queue2?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61500"/>
+ <soap:address location="jms:queue:test.cxf.jmstransport.queue2"/>
<soapjms:jndiContextParameter name="name3" value="value3"/>
- <soapjms:jndiConnectionFactoryName>ConnectionFactory</soapjms:jndiConnectionFactoryName>
- <soapjms:jndiInitialContextFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</soapjms:jndiInitialContextFactory>
- <soapjms:jndiURL>tcp://localhost:61500</soapjms:jndiURL>
<soapjms:deliveryMode>PERSISTENT</soapjms:deliveryMode>
<soapjms:priority>7</soapjms:priority>
<soapjms:timeToLive>3000</soapjms:timeToLive>
@@ -158,10 +144,6 @@
</wsdl:service>
<wsdl:service name="JMSGreeterService2">
<soapjms:jndiContextParameter name="name2" value="value2"/>
- <soapjms:jndiConnectionFactoryName>ConnectionFactory</soapjms:jndiConnectionFactoryName>
- <soapjms:jndiInitialContextFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</soapjms:jndiInitialContextFactory>
- <soapjms:jndiURL>tcp://localhost:61500
- </soapjms:jndiURL>
<soapjms:deliveryMode>NON_PERSISTENT
</soapjms:deliveryMode>
<soapjms:priority>6</soapjms:priority>
@@ -169,10 +151,8 @@
<!--<soapjms:replyToName>replytoname2</soapjms:replyToName>-->
<wsdl:port binding="tns:JMSGreeterPortBinding" name="GreeterPort2">
<soapjms:jndiConnectionFactoryName>ConnectionFactory</soapjms:jndiConnectionFactoryName>
- <soap:address location="jms:jndi:dynamicQueues/test.cxf.jmstransport.queue5?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61500"/>
+ <soap:address location="jms:queue:test.cxf.jmstransport.queue5"/>
<soapjms:jndiContextParameter name="name3" value="value3"/>
- <soapjms:jndiInitialContextFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</soapjms:jndiInitialContextFactory>
- <soapjms:jndiURL>tcp://localhost:61500</soapjms:jndiURL>
<soapjms:deliveryMode>PERSISTENT</soapjms:deliveryMode>
<soapjms:priority>7</soapjms:priority>
<soapjms:timeToLive>3000</soapjms:timeToLive>
[2/2] git commit: Making jms tests more robust
Posted by cs...@apache.org.
Making jms tests more robust
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/97929715
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/97929715
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/97929715
Branch: refs/heads/master
Commit: 9792971587e7aec6fc0f452d05803813fb2a30d4
Parents: 30d6e81
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Mar 4 13:34:29 2014 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Mar 4 13:34:29 2014 +0100
----------------------------------------------------------------------
.../transport/jms/ConnectionFactoryFeature.java | 7 +-
systests/transport-jms/Readme.txt | 4 +
.../jms/testsuite/services/GreeterSpecImpl.java | 44 +++
.../services/GreeterSpecWithPortError.java | 45 +++
.../cxf/jms/testsuite/services/Server.java | 132 -------
.../jms/testsuite/services/TestSuiteServer.java | 132 +++++++
.../testcases/JavaFirstNoWsdlTest.java | 91 +++++
.../testcases/SOAPJMSTestSuiteTest.java | 4 +-
.../testsuite/testcases/SoapJmsSpecTest.java | 268 +++++++--------
.../apache/cxf/systest/jms/GreeterSpecImpl.java | 44 ---
.../systest/jms/GreeterSpecWithPortError.java | 45 ---
.../systest/jms/JMSClientServerGzipTest.java | 124 -------
.../systest/jms/JMSClientServerSoap12Test.java | 125 +++----
.../cxf/systest/jms/JMSClientServerTest.java | 342 +++++++++----------
.../cxf/systest/jms/JMSSharedQueueTest.java | 61 ++--
.../org/apache/cxf/systest/jms/JMSTestMtom.java | 3 +
.../apache/cxf/systest/jms/JaxWsAPITest.java | 8 +-
.../java/org/apache/cxf/systest/jms/Server.java | 88 +----
...HelloWorldContinuationsClientServerTest.java | 1 +
.../HelloWorldContinuationsThrottleTest.java | 4 +-
.../JMSContinuationsClientServerTest.java | 2 +
.../ProviderJMSContinuationTest.java | 1 +
.../MultiTransportClientServerTest.java | 4 +-
.../resources/wsdl/hello_world_doc_lit.wsdl | 4 +-
.../src/main/resources/wsdl/jms_spec_test.wsdl | 24 +-
25 files changed, 712 insertions(+), 895 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ConnectionFactoryFeature.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ConnectionFactoryFeature.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ConnectionFactoryFeature.java
index 5d9a790..ac3774a 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ConnectionFactoryFeature.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ConnectionFactoryFeature.java
@@ -18,13 +18,10 @@
*/
package org.apache.cxf.transport.jms;
-import java.util.logging.Logger;
-
import javax.jms.ConnectionFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.AbstractFeature;
@@ -38,9 +35,7 @@ import org.apache.cxf.transport.Destination;
*/
@NoJSR250Annotations
public class ConnectionFactoryFeature extends AbstractFeature {
- static final Logger LOG = LogUtils.getL7dLogger(ConnectionFactoryFeature.class);
-
- ConnectionFactory connectionFactory;
+ private ConnectionFactory connectionFactory;
public ConnectionFactoryFeature(ConnectionFactory cf) {
this.connectionFactory = cf;
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/Readme.txt
----------------------------------------------------------------------
diff --git a/systests/transport-jms/Readme.txt b/systests/transport-jms/Readme.txt
new file mode 100644
index 0000000..b1962bd
--- /dev/null
+++ b/systests/transport-jms/Readme.txt
@@ -0,0 +1,4 @@
+When creating tests make sure you close the destinations and conduits after use.
+
+Destinations are closed automatically when their bus is shut down. Conduits have to be closed by casting the
+service proxy to Closeable and closing it.
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecImpl.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecImpl.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecImpl.java
new file mode 100644
index 0000000..1815099
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecImpl.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.cxf.jms.testsuite.services;
+
+import org.apache.cxf.jms_greeter.JMSGreeterPortType;
+
+@javax.jws.WebService(portName = "GreeterPort",
+ serviceName = "JMSGreeterService",
+ targetNamespace = "http://cxf.apache.org/jms_greeter",
+ endpointInterface = "org.apache.cxf.jms_greeter.JMSGreeterPortType")
+public class GreeterSpecImpl implements JMSGreeterPortType {
+
+ public String greetMe(String me) {
+ //System.out.println("Executing operation greetMe");
+ //System.out.println("Message received: " + me + "\n");
+ return "Hello " + me;
+ }
+
+ public String sayHi() {
+ //System.out.println("Executing operation sayHi" + "\n");
+ return "Bonjour";
+ }
+
+ public void greetMeOneWay(String me) {
+ //System.out.println("Executing operation greetMeOneWay\n");
+ //System.out.println("Hello there " + me);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecWithPortError.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecWithPortError.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecWithPortError.java
new file mode 100644
index 0000000..691fa71
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/GreeterSpecWithPortError.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.cxf.jms.testsuite.services;
+
+import org.apache.cxf.jms_greeter.JMSGreeterPortType;
+
+@javax.jws.WebService(portName = "GreeterPort2",
+ serviceName = "JMSGreeterService2",
+ targetNamespace = "http://cxf.apache.org/jms_greeter",
+ endpointInterface = "org.apache.cxf.jms_greeter.JMSGreeterPortType",
+ wsdlLocation = "testutils/jms_spec_test.wsdl")
+public class GreeterSpecWithPortError implements JMSGreeterPortType {
+
+ public String greetMe(String me) {
+ //System.out.println("Executing operation greetMe");
+ //System.out.println("Message received: " + me + "\n");
+ return "Hello " + me;
+ }
+
+ public String sayHi() {
+ //System.out.println("Executing operation sayHi" + "\n");
+ return "Bonjour";
+ }
+
+ public void greetMeOneWay(String me) {
+ //System.out.println("Executing operation greetMeOneWay\n");
+ //System.out.println("Hello there " + me);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/Server.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/Server.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/Server.java
deleted file mode 100644
index e266fbb..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/Server.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.cxf.jms.testsuite.services;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.ws.Endpoint;
-
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.jms.testsuite.util.JMSTestUtil;
-import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-
-public class Server extends AbstractBusTestServerBase {
- List<Endpoint> endpoints = new LinkedList<Endpoint>();
- protected void run() {
- setBus(BusFactory.getDefaultBus());
- Test0001Impl t0001 = new Test0001Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0001").getAddress().trim(), t0001));
- Test0101Impl t0101 = new Test0101Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0101").getAddress().trim(), t0101));
-
- Test0003Impl t0003 = new Test0003Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0003").getAddress().trim(), t0003));
-
- Test0005Impl t0005 = new Test0005Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0005").getAddress().trim(), t0005));
-
- Test0006Impl t0006 = new Test0006Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0006").getAddress().trim(), t0006));
-
- Test0008Impl t0008 = new Test0008Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0008").getAddress().trim(), t0008));
-
- Test0009Impl t0009 = new Test0009Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0009").getAddress().trim(), t0009));
-
- Test0010Impl t0010 = new Test0010Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0010").getAddress().trim(), t0010));
-
- Test0011Impl t0011 = new Test0011Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0011").getAddress().trim(), t0011));
-
- Test0012Impl t0012 = new Test0012Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0012").getAddress().trim(), t0012));
-
- Test0013Impl t0013 = new Test0013Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0013").getAddress().trim(), t0013));
-
- Test0014Impl t0014 = new Test0014Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0014").getAddress().trim(), t0014));
-
- Test1001Impl t1001 = new Test1001Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1001").getAddress().trim(), t1001));
-
- Test1002Impl t1002 = new Test1002Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1002").getAddress().trim(), t1002));
-
- Test1003Impl t1003 = new Test1003Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1003").getAddress().trim(), t1003));
-
- Test1004Impl t1004 = new Test1004Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1004").getAddress().trim(), t1004));
-
- Test1006Impl t1006 = new Test1006Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1006").getAddress().trim(), t1006));
-
- Test1007Impl t1007 = new Test1007Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1007").getAddress().trim(), t1007));
-
- Test1008Impl t1008 = new Test1008Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1008").getAddress().trim(), t1008));
-
- Test1101Impl t1101 = new Test1101Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1101").getAddress().trim(), t1101));
-
- Test1102Impl t1102 = new Test1102Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1102").getAddress().trim(), t1102));
-
- Test1103Impl t1103 = new Test1103Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1103").getAddress().trim(), t1103));
-
- Test1104Impl t1104 = new Test1104Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1104").getAddress().trim(), t1104));
-
- Test1105Impl t1105 = new Test1105Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1105").getAddress().trim(), t1105));
-
- Test1106Impl t1106 = new Test1106Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1106").getAddress().trim(), t1106));
-
- Test1107Impl t1107 = new Test1107Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1107").getAddress().trim(), t1107));
-
- Test1108Impl t1108 = new Test1108Impl();
- endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1108").getAddress().trim(), t1108));
- }
-
- public void tearDown() {
- for (Endpoint ep : endpoints) {
- ep.stop();
- }
- endpoints.clear();
- }
- public static void main(String[] args) {
- try {
- Server s = new Server();
- s.start();
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(-1);
- } finally {
- System.out.println("done!");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/TestSuiteServer.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/TestSuiteServer.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/TestSuiteServer.java
new file mode 100644
index 0000000..e68c71f
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/services/TestSuiteServer.java
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.cxf.jms.testsuite.services;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jms.testsuite.util.JMSTestUtil;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class TestSuiteServer extends AbstractBusTestServerBase {
+ List<Endpoint> endpoints = new LinkedList<Endpoint>();
+ protected void run() {
+ setBus(BusFactory.getDefaultBus());
+ Test0001Impl t0001 = new Test0001Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0001").getAddress().trim(), t0001));
+ Test0101Impl t0101 = new Test0101Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0101").getAddress().trim(), t0101));
+
+ Test0003Impl t0003 = new Test0003Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0003").getAddress().trim(), t0003));
+
+ Test0005Impl t0005 = new Test0005Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0005").getAddress().trim(), t0005));
+
+ Test0006Impl t0006 = new Test0006Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0006").getAddress().trim(), t0006));
+
+ Test0008Impl t0008 = new Test0008Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0008").getAddress().trim(), t0008));
+
+ Test0009Impl t0009 = new Test0009Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0009").getAddress().trim(), t0009));
+
+ Test0010Impl t0010 = new Test0010Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0010").getAddress().trim(), t0010));
+
+ Test0011Impl t0011 = new Test0011Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0011").getAddress().trim(), t0011));
+
+ Test0012Impl t0012 = new Test0012Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0012").getAddress().trim(), t0012));
+
+ Test0013Impl t0013 = new Test0013Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0013").getAddress().trim(), t0013));
+
+ Test0014Impl t0014 = new Test0014Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test0014").getAddress().trim(), t0014));
+
+ Test1001Impl t1001 = new Test1001Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1001").getAddress().trim(), t1001));
+
+ Test1002Impl t1002 = new Test1002Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1002").getAddress().trim(), t1002));
+
+ Test1003Impl t1003 = new Test1003Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1003").getAddress().trim(), t1003));
+
+ Test1004Impl t1004 = new Test1004Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1004").getAddress().trim(), t1004));
+
+ Test1006Impl t1006 = new Test1006Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1006").getAddress().trim(), t1006));
+
+ Test1007Impl t1007 = new Test1007Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1007").getAddress().trim(), t1007));
+
+ Test1008Impl t1008 = new Test1008Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1008").getAddress().trim(), t1008));
+
+ Test1101Impl t1101 = new Test1101Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1101").getAddress().trim(), t1101));
+
+ Test1102Impl t1102 = new Test1102Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1102").getAddress().trim(), t1102));
+
+ Test1103Impl t1103 = new Test1103Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1103").getAddress().trim(), t1103));
+
+ Test1104Impl t1104 = new Test1104Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1104").getAddress().trim(), t1104));
+
+ Test1105Impl t1105 = new Test1105Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1105").getAddress().trim(), t1105));
+
+ Test1106Impl t1106 = new Test1106Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1106").getAddress().trim(), t1106));
+
+ Test1107Impl t1107 = new Test1107Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1107").getAddress().trim(), t1107));
+
+ Test1108Impl t1108 = new Test1108Impl();
+ endpoints.add(Endpoint.publish(JMSTestUtil.getTestCase("test1108").getAddress().trim(), t1108));
+ }
+
+ public void tearDown() {
+ for (Endpoint ep : endpoints) {
+ ep.stop();
+ }
+ endpoints.clear();
+ }
+ public static void main(String[] args) {
+ try {
+ TestSuiteServer s = new TestSuiteServer();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/JavaFirstNoWsdlTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/JavaFirstNoWsdlTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/JavaFirstNoWsdlTest.java
new file mode 100644
index 0000000..e7bbe01
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/JavaFirstNoWsdlTest.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.cxf.jms.testsuite.testcases;
+
+import java.io.Closeable;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.systest.jms.Hello;
+import org.apache.cxf.systest.jms.HelloImpl;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
+import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JavaFirstNoWsdlTest {
+ private static final String SERVICE_ADDRESS = "jms:queue:test.cxf.jmstransport.queue3?receivetTimeOut=5000";
+ private static Bus bus;
+ private static ConnectionFactoryFeature cff;
+
+ @BeforeClass
+ public static void startServer() {
+ bus = BusFactory.getDefaultBus();
+ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
+ cff = new ConnectionFactoryFeature(cfp);
+
+ JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
+ svrFactory.setBus(bus);
+ svrFactory.getFeatures().add(cff);
+ svrFactory.setServiceClass(Hello.class);
+ svrFactory.setAddress(SERVICE_ADDRESS);
+ svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
+ svrFactory.setServiceBean(new HelloImpl());
+ svrFactory.create();
+ }
+
+ @AfterClass
+ public static void stopServers() {
+ bus.shutdown(false);
+ }
+
+ @Test
+ public void testSpecNoWsdlService() throws Exception {
+ specNoWsdlService(null);
+ }
+
+ @Test
+ public void testSpecNoWsdlServiceWithDifferentMessageType() throws Exception {
+ specNoWsdlService("text");
+ specNoWsdlService("byte");
+ specNoWsdlService("binary");
+ }
+
+ private void specNoWsdlService(String messageType) throws Exception {
+ String address = SERVICE_ADDRESS + ((messageType != null) ? "&messageType=" + messageType : "");
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+ factory.setBus(bus);
+ factory.getFeatures().add(cff);
+ factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
+ factory.setServiceClass(Hello.class);
+ factory.setAddress(address);
+ Hello client = (Hello)factory.create();
+ String reply = client.sayHi(" HI");
+ Assert.assertEquals("get HI", reply);
+ ((Closeable)client).close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
index 3d5fb0d..b6edb01 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SOAPJMSTestSuiteTest.java
@@ -37,7 +37,7 @@ import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.jms.testsuite.services.Server;
+import org.apache.cxf.jms.testsuite.services.TestSuiteServer;
import org.apache.cxf.jms.testsuite.util.JMSTestUtil;
import org.apache.cxf.jms_simple.JMSSimplePortType;
import org.apache.cxf.jms_simple.JMSSimpleService0001;
@@ -88,7 +88,7 @@ public class SOAPJMSTestSuiteTest extends AbstractBusClientServerTestBase {
broker = new EmbeddedJMSBrokerLauncher();
launchServer(broker);
JMSTestUtil.setJndiUrl(broker.getEncodedBrokerURL());
- assertTrue("server did not launch correctly", launchServer(Server.class, true));
+ assertTrue("server did not launch correctly", launchServer(TestSuiteServer.class, true));
createStaticBus();
}
@After
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
index b18344f..d45fc31 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
@@ -18,228 +18,204 @@
*/
package org.apache.cxf.jms.testsuite.testcases;
-import java.lang.reflect.UndeclaredThrowableException;
+import java.io.Closeable;
import java.net.URL;
import java.util.Map;
+import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
import javax.xml.ws.soap.SOAPFaultException;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jms.testsuite.services.GreeterSpecImpl;
+import org.apache.cxf.jms.testsuite.services.GreeterSpecWithPortError;
import org.apache.cxf.jms_greeter.JMSGreeterPortType;
import org.apache.cxf.jms_greeter.JMSGreeterService;
import org.apache.cxf.jms_greeter.JMSGreeterService2;
-import org.apache.cxf.systest.jms.Hello;
-import org.apache.cxf.systest.jms.Server;
-import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
-import org.apache.cxf.transport.jms.JMSConfigFactory;
-import org.apache.cxf.transport.jms.JMSConfiguration;
+import org.apache.cxf.transport.common.gzip.GZIPFeature;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
import org.apache.cxf.transport.jms.JMSConstants;
import org.apache.cxf.transport.jms.JMSMessageHeadersType;
-import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
-import org.apache.cxf.transport.jms.uri.JMSEndpoint;
-import org.apache.cxf.transport.jms.util.TestReceiver;
-import org.apache.hello_world_doc_lit.Greeter;
-import org.apache.hello_world_doc_lit.SOAPService7;
+import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-public class SoapJmsSpecTest extends AbstractBusClientServerTestBase {
+public class SoapJmsSpecTest {
+ private static final String SERVICE_NS = "http://cxf.apache.org/jms_greeter";
+ private static final String WSDL = "/wsdl/jms_spec_test.wsdl";
+ private static Bus bus;
+ private static ConnectionFactoryFeature cff;
+ private static ConnectionFactory cf;
- private static EmbeddedJMSBrokerLauncher broker;
- private String wsdlString;
-
public URL getWSDLURL(String s) throws Exception {
URL u = getClass().getResource(s);
if (u == null) {
throw new IllegalArgumentException("WSDL classpath resource not found " + s);
}
- wsdlString = u.toString().intern();
- broker.updateWsdl(getBus(), wsdlString);
return u;
}
-
@BeforeClass
public static void startServers() throws Exception {
- broker = new EmbeddedJMSBrokerLauncher();
- launchServer(broker);
- launchServer(new Server(broker));
- createStaticBus();
+ bus = BusFactory.getDefaultBus();
+ ActiveMQConnectionFactory cf1 = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ cf = new PooledConnectionFactory(cf1);
+ cff = new ConnectionFactoryFeature(cf);
+
+ publish("jms:queue:test.cxf.jmstransport.queue2", new GreeterSpecImpl());
+ publish("jms:queue:test.cxf.jmstransport.queue5", new GreeterSpecWithPortError());
+
+ EndpointImpl ep = (EndpointImpl)Endpoint.create(null, new GreeterSpecImpl());
+ ep.setBus(bus);
+ ep.getFeatures().add(new GZIPFeature());
+ ep.getFeatures().add(cff);
+ ep.publish("jms:queue:test.cxf.jmstransport.queue6");
}
+ private static void publish(String address, Object impl) {
+ EndpointImpl ep = (EndpointImpl)Endpoint.create(impl);
+ ep.setBus(bus);
+ ep.getFeatures().add(cff);
+ ep.publish(address);
+ }
+
+ @AfterClass
+ public static void stopServers() {
+ bus.shutdown(false);
+ }
+
@Test
public void testSpecJMS() throws Exception {
- QName serviceName = new QName("http://cxf.apache.org/jms_greeter", "JMSGreeterService");
- QName portName = new QName("http://cxf.apache.org/jms_greeter", "GreeterPort");
- URL wsdl = getWSDLURL("/wsdl/jms_spec_test.wsdl");
+ QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
+ QName portName = new QName(SERVICE_NS, "GreeterPort");
+ URL wsdl = getWSDLURL(WSDL);
JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
String response1 = new String("Hello Milestone-");
- String response2 = new String("Bonjour");
- JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class);
+ JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class, cff);
for (int idx = 0; idx < 5; idx++) {
greeter.greetMeOneWay("test String");
String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ Assert.assertEquals(response1 + idx, greeting);
String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
+ Assert.assertEquals(new String("Bonjour"), reply);
}
+ ((Closeable)greeter).close();
}
-
+
@Test
public void testWsdlExtensionSpecJMS() throws Exception {
- QName serviceName = new QName("http://cxf.apache.org/jms_greeter", "JMSGreeterService");
- QName portName = new QName("http://cxf.apache.org/jms_greeter", "GreeterPort");
- URL wsdl = getWSDLURL("/wsdl/jms_spec_test.wsdl");
- assertNotNull(wsdl);
-
+ QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
+ QName portName = new QName(SERVICE_NS, "GreeterPort");
+ URL wsdl = getWSDLURL(WSDL);
JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
- assertNotNull(service);
+ JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class, cff);
+ Map<String, Object> requestContext = ((BindingProvider)greeter).getRequestContext();
+ JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+ requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
- String response = new String("Bonjour");
- try {
- JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class);
- Map<String, Object> requestContext = ((BindingProvider)greeter).getRequestContext();
- JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
- requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
-
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response, reply);
-
- requestContext = ((BindingProvider)greeter).getRequestContext();
- requestHeader = (JMSMessageHeadersType)requestContext
- .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
- assertEquals(requestHeader.getSOAPJMSBindingVersion(), "1.0");
- assertEquals(requestHeader.getSOAPJMSSOAPAction(), "\"test\"");
- assertEquals(requestHeader.getTimeToLive(), 3000);
- assertEquals(requestHeader.getJMSDeliveryMode(), DeliveryMode.PERSISTENT);
- assertEquals(requestHeader.getJMSPriority(), 7);
-
- Map<String, Object> responseContext = ((BindingProvider)greeter).getResponseContext();
- JMSMessageHeadersType responseHeader = (JMSMessageHeadersType)responseContext
- .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
- assertEquals(responseHeader.getSOAPJMSBindingVersion(), "1.0");
- assertEquals(responseHeader.getSOAPJMSSOAPAction(), null);
- assertEquals(responseHeader.getJMSDeliveryMode(), DeliveryMode.PERSISTENT);
- assertEquals(responseHeader.getJMSPriority(), 7);
-
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
- }
+ String reply = greeter.sayHi();
+ Assert.assertEquals("Bonjour", reply);
+
+ requestContext = ((BindingProvider)greeter).getRequestContext();
+ requestHeader = (JMSMessageHeadersType)requestContext.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
+ Assert.assertEquals("1.0", requestHeader.getSOAPJMSBindingVersion());
+ Assert.assertEquals("\"test\"", requestHeader.getSOAPJMSSOAPAction());
+ Assert.assertEquals(3000, requestHeader.getTimeToLive());
+ Assert.assertEquals(DeliveryMode.PERSISTENT, requestHeader.getJMSDeliveryMode());
+ Assert.assertEquals(7, requestHeader.getJMSPriority());
+
+ Map<String, Object> responseContext = ((BindingProvider)greeter).getResponseContext();
+ JMSMessageHeadersType responseHeader = (JMSMessageHeadersType)responseContext
+ .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
+ Assert.assertEquals("1.0", responseHeader.getSOAPJMSBindingVersion());
+ Assert.assertEquals(null, responseHeader.getSOAPJMSSOAPAction());
+ Assert.assertEquals(DeliveryMode.PERSISTENT, responseHeader.getJMSDeliveryMode());
+ Assert.assertEquals(7, responseHeader.getJMSPriority());
+ ((Closeable)greeter).close();
}
@Test
public void testWsdlExtensionSpecJMSPortError() throws Exception {
- QName serviceName = new QName("http://cxf.apache.org/jms_greeter", "JMSGreeterService2");
- QName portName = new QName("http://cxf.apache.org/jms_greeter", "GreeterPort2");
- URL wsdl = getWSDLURL("/wsdl/jms_spec_test.wsdl");
- assertNotNull(wsdl);
-
+ QName serviceName = new QName(SERVICE_NS, "JMSGreeterService2");
+ QName portName = new QName(SERVICE_NS, "GreeterPort2");
+ URL wsdl = getWSDLURL(WSDL);
JMSGreeterService2 service = new JMSGreeterService2(wsdl, serviceName);
- assertNotNull(service);
+ JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class, cff);
- String response = new String("Bonjour");
- JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class);
String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response, reply);
- }
-
- @Test
- public void testSpecNoWsdlService() throws Exception {
- specNoWsdlService(null);
- }
-
- @Test
- public void testSpecNoWsdlServiceWithDifferentMessageType() throws Exception {
- specNoWsdlService("text");
- specNoWsdlService("byte");
- specNoWsdlService("binary");
+ ((Closeable)greeter).close();
+ Assert.assertEquals("Bonjour", reply);
}
-
- private void specNoWsdlService(String messageType) throws Exception {
- String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3"
- + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=" + broker.getEncodedBrokerURL();
- if (messageType != null) {
- address = address + "&messageType=" + messageType;
- }
- JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
- factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
- factory.setServiceClass(Hello.class);
- factory.setAddress(address);
- Hello client = (Hello)factory.create();
- String reply = client.sayHi(" HI");
- assertEquals(reply, "get HI");
- }
-
@Test
public void testBindingVersionError() throws Exception {
- QName serviceName = new QName("http://cxf.apache.org/jms_greeter", "JMSGreeterService");
- QName portName = new QName("http://cxf.apache.org/jms_greeter", "GreeterPort");
- URL wsdl = getWSDLURL("/wsdl/jms_spec_test.wsdl");
-
+ QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
+ QName portName = new QName(SERVICE_NS, "GreeterPort");
+ URL wsdl = getWSDLURL(WSDL);
JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
- JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class);
- BindingProvider bp = (BindingProvider)greeter;
-
+ JMSGreeterPortType greeter = service.getPort(portName, JMSGreeterPortType.class, cff);
+ BindingProvider bp = (BindingProvider)greeter;
+
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setSOAPJMSBindingVersion("0.3");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
-
+
try {
greeter.greetMe("Milestone-");
- fail("Should have thrown a fault");
+ Assert.fail("Should have thrown a fault");
} catch (SOAPFaultException ex) {
- assertTrue(ex.getMessage().contains("0.3"));
+ Assert.assertTrue(ex.getMessage().contains("0.3"));
Map<String, Object> responseContext = bp.getResponseContext();
- JMSMessageHeadersType responseHdr =
- (JMSMessageHeadersType)responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
+ JMSMessageHeadersType responseHdr = (JMSMessageHeadersType)responseContext
+ .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
if (responseHdr == null) {
- fail("response Header should not be null");
+ Assert.fail("response Header should not be null");
}
- assertTrue(responseHdr.isSOAPJMSIsFault());
+ Assert.assertTrue(responseHdr.isSOAPJMSIsFault());
+ } finally {
+ ((Closeable)greeter).close();
}
}
@Test
- public void testReplyToConfig() throws Exception {
- JMSEndpoint endpoint = new JMSEndpoint("");
- endpoint.setJndiInitialContextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
- endpoint.setJndiURL(broker.getBrokerURL());
- endpoint.setJndiConnectionFactoryName("ConnectionFactory");
-
- final JMSConfiguration jmsConfig = new JMSConfiguration();
- jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
- jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
-
- TestReceiver receiver = new TestReceiver(jmsConfig.getConnectionFactory(),
- "dynamicQueues/SoapService7.replyto.queue", false);
- receiver.setStaticReplyQueue("dynamicQueues/SoapService7.reply.queue");
- receiver.runAsync();
+ public void testGzip() throws Exception {
+ URL wsdl = getWSDLURL(WSDL);
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+ factory.setBus(bus);
+ factory.setServiceClass(JMSGreeterPortType.class);
+ factory.setWsdlURL(wsdl.toExternalForm());
+ factory.getFeatures().add(cff);
+ factory.getFeatures().add(new GZIPFeature());
+ factory.setAddress("jms:queue:test.cxf.jmstransport.queue6");
+ JMSGreeterPortType greeter = (JMSGreeterPortType)factory.create();
- QName serviceName = new QName("http://apache.org/hello_world_doc_lit", "SOAPService7");
- QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort7");
- URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
- SOAPService7 service = new SOAPService7(wsdl, serviceName);
- Greeter greeter = service.getPort(portName, Greeter.class);
- String name = "FooBar";
- String reply = greeter.greetMe(name);
- assertEquals(reply, "Hello " + name);
+ for (int idx = 0; idx < 5; idx++) {
+
+ greeter.greetMeOneWay("test String");
+
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ Assert.assertEquals("Hello Milestone-" + idx, greeting);
+
+ String reply = greeter.sayHi();
+ Assert.assertEquals("Bonjour", reply);
+ }
+ ((Closeable)greeter).close();
}
+
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecImpl.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecImpl.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecImpl.java
deleted file mode 100644
index 4cd9414..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.cxf.systest.jms;
-
-import org.apache.cxf.jms_greeter.JMSGreeterPortType;
-
-@javax.jws.WebService(portName = "GreeterPort",
- serviceName = "JMSGreeterService",
- targetNamespace = "http://cxf.apache.org/jms_greeter",
- endpointInterface = "org.apache.cxf.jms_greeter.JMSGreeterPortType")
-public class GreeterSpecImpl implements JMSGreeterPortType {
-
- public String greetMe(String me) {
- //System.out.println("Executing operation greetMe");
- //System.out.println("Message received: " + me + "\n");
- return "Hello " + me;
- }
-
- public String sayHi() {
- //System.out.println("Executing operation sayHi" + "\n");
- return "Bonjour";
- }
-
- public void greetMeOneWay(String me) {
- //System.out.println("Executing operation greetMeOneWay\n");
- //System.out.println("Hello there " + me);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecWithPortError.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecWithPortError.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecWithPortError.java
deleted file mode 100644
index 802a214..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/GreeterSpecWithPortError.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.cxf.systest.jms;
-
-import org.apache.cxf.jms_greeter.JMSGreeterPortType;
-
-@javax.jws.WebService(portName = "GreeterPort2",
- serviceName = "JMSGreeterService2",
- targetNamespace = "http://cxf.apache.org/jms_greeter",
- endpointInterface = "org.apache.cxf.jms_greeter.JMSGreeterPortType",
- wsdlLocation = "testutils/jms_spec_test.wsdl")
-public class GreeterSpecWithPortError implements JMSGreeterPortType {
-
- public String greetMe(String me) {
- //System.out.println("Executing operation greetMe");
- //System.out.println("Message received: " + me + "\n");
- return "Hello " + me;
- }
-
- public String sayHi() {
- //System.out.println("Executing operation sayHi" + "\n");
- return "Bonjour";
- }
-
- public void greetMeOneWay(String me) {
- //System.out.println("Executing operation greetMeOneWay\n");
- //System.out.println("Hello there " + me);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
deleted file mode 100644
index 265f4f5..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.cxf.systest.jms;
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Endpoint;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.jaxws.EndpointImpl;
-import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
-import org.apache.cxf.transport.common.gzip.GZIPFeature;
-import org.apache.hello_world_doc_lit.Greeter;
-import org.apache.hello_world_doc_lit.PingMeFault;
-import org.apache.hello_world_doc_lit.SOAPService2;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JMSClientServerGzipTest extends AbstractBusClientServerTestBase {
- private static EmbeddedJMSBrokerLauncher broker;
- private String wsdlString;
-
-
- public static class GzipServer extends AbstractBusTestServerBase {
- EndpointImpl ep;
- protected void run() {
- Object impleDoc = new GreeterImplDoc();
- Bus bus = BusFactory.getDefaultBus();
- bus.getFeatures().add(new GZIPFeature());
- setBus(bus);
- broker.updateWsdl(bus, "testutils/hello_world_doc_lit.wsdl");
- ep = (EndpointImpl)Endpoint.create(null, impleDoc);
- ep.getFeatures().add(new GZIPFeature());
- ep.publish();
- }
- public void tearDown() {
- ep.stop();
- }
- }
- @BeforeClass
- public static void startServers() throws Exception {
- broker = new EmbeddedJMSBrokerLauncher();
- launchServer(broker);
- assertTrue("server did not launch correctly",
- launchServer(GzipServer.class, true));
-
- }
-
- public URL getWSDLURL(String s) throws Exception {
- URL u = getClass().getResource(s);
- wsdlString = u.toString().intern();
- broker.updateWsdl(getBus(), wsdlString);
- System.gc();
- System.gc();
- return u;
- }
- public QName getServiceName(QName q) {
- return q;
- }
- public QName getPortName(QName q) {
- return q;
- }
-
- @Test
- public void testGzipEncodingWithJms() throws Exception {
- QName serviceName = getServiceName(new QName("http://apache.org/hello_world_doc_lit",
- "SOAPService2"));
- QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort2"));
- URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
- assertNotNull(wsdl);
- SOAPService2 service = new SOAPService2(wsdl, serviceName);
-
- String response1 = new String("Hello Milestone-");
- String response2 = new String("Bonjour");
- try {
- Greeter greeter = service.getPort(portName, Greeter.class, new GZIPFeature());
-
- for (int idx = 0; idx < 5; idx++) {
-
- greeter.greetMeOneWay("test String");
-
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
-
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
-
- try {
- greeter.pingMe();
- fail("Should have thrown FaultException");
- } catch (PingMeFault ex) {
- assertNotNull(ex.getFaultInfo());
- }
- }
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerSoap12Test.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerSoap12Test.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerSoap12Test.java
index 538bef2..36ab54a 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerSoap12Test.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerSoap12Test.java
@@ -18,122 +18,81 @@
*/
package org.apache.cxf.systest.jms;
-import java.lang.reflect.UndeclaredThrowableException;
+import java.io.Closeable;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
import org.apache.hello_world_doc_lit.Greeter;
import org.apache.hello_world_doc_lit.PingMeFault;
import org.apache.hello_world_doc_lit.SOAPService2;
+import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-public class JMSClientServerSoap12Test extends AbstractBusClientServerTestBase {
+public class JMSClientServerSoap12Test {
private static final String BROKER_URI = "vm://JMSClientServerSoap12Test?broker.persistent=false";
- private static EmbeddedJMSBrokerLauncher broker;
- private String wsdlString;
-
- public static class Soap12Server extends AbstractBusTestServerBase {
- public static final String PORT = allocatePort(Soap12Server.class);
-
- protected void run() {
- Object impleDoc = new GreeterImplSoap12();
- SpringBusFactory bf = new SpringBusFactory();
- Bus bus = bf.createBus("org/apache/cxf/systest/jms/soap12Bus.xml");
- BusFactory.setDefaultBus(bus);
- setBus(bus);
- broker.updateWsdl(bus, "testutils/hello_world_doc_lit.wsdl");
- Endpoint.publish("jms:queue:routertest.SOAPService2Q.text", impleDoc);
- }
- }
-
-
+ private static Bus bus;
+ private static ConnectionFactoryFeature cff;
@BeforeClass
public static void startServers() throws Exception {
- broker = new EmbeddedJMSBrokerLauncher(BROKER_URI);
- assertTrue("server did not launch correctly",
- launchServer(Soap12Server.class, true));
+ bus = BusFactory.getDefaultBus();
+ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(BROKER_URI);
+ PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
+ cff = new ConnectionFactoryFeature(cfp);
+
+ EndpointImpl ep = (EndpointImpl)Endpoint.create(new GreeterImplSoap12());
+ ep.setBus(bus);
+ ep.getFeatures().add(cff);
+ ep.publish("jms:queue:routertest.SOAPService2Q.text");
}
- public URL getWSDLURL(String s) throws Exception {
- URL u = getClass().getResource(s);
- wsdlString = u.toString().intern();
- broker.updateWsdl(getBus(), wsdlString);
- System.gc();
- System.gc();
- return u;
+ @AfterClass
+ public static void stopServers() throws Exception {
+ bus.shutdown(false);
}
- public QName getServiceName(QName q) {
- return q;
- }
- public QName getPortName(QName q) {
- return q;
+
+ public URL getWSDLURL(String s) throws Exception {
+ return getClass().getResource(s);
}
@Test
public void testGzipEncodingWithJms() throws Exception {
- SpringBusFactory bf = new SpringBusFactory();
- Bus bus = bf.createBus("org/apache/cxf/systest/jms/soap12Bus.xml");
- BusFactory.setDefaultBus(bus);
- QName serviceName = getServiceName(new QName("http://apache.org/hello_world_doc_lit",
- "SOAPService8"));
- QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort8"));
+ QName serviceName = new QName("http://apache.org/hello_world_doc_lit",
+ "SOAPService8");
+ QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort8");
URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
- assertNotNull(wsdl);
-
SOAPService2 service = new SOAPService2(wsdl, serviceName);
- assertNotNull(service);
-
String response1 = new String("Hello Milestone-");
- String response2 = new String("Bonjour");
- try {
- Greeter greeter = service.getPort(portName, Greeter.class);
- /*
- Client client = ClientProxy.getClient(greeter);
- EndpointInfo ei = client.getEndpoint().getEndpointInfo();
- AddressType address = ei.getTraversedExtensor(new AddressType(), AddressType.class);
- JMSNamingPropertyType name = new JMSNamingPropertyType();
- JMSNamingPropertyType password = new JMSNamingPropertyType();
- name.setName("java.naming.security.principal");
- name.setValue("ivan");
- password.setName("java.naming.security.credentials");
- password.setValue("the-terrible");
- address.getJMSNamingProperty().add(name);
- address.getJMSNamingProperty().add(password);
- */
- for (int idx = 0; idx < 5; idx++) {
+ Greeter greeter = service.getPort(portName, Greeter.class, cff);
- greeter.greetMeOneWay("test String");
+ for (int idx = 0; idx < 5; idx++) {
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ greeter.greetMeOneWay("test String");
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ Assert.assertEquals(response1 + idx, greeting);
- try {
- greeter.pingMe();
- fail("Should have thrown FaultException");
- } catch (PingMeFault ex) {
- assertNotNull(ex.getFaultInfo());
- }
+ String reply = greeter.sayHi();
+ Assert.assertEquals("Bonjour", reply);
+ try {
+ greeter.pingMe();
+ Assert.fail("Should have thrown FaultException");
+ } catch (PingMeFault ex) {
+ Assert.assertNotNull(ex.getFaultInfo());
}
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+
}
- bus.shutdown(true);
+ ((Closeable)greeter).close();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/97929715/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
index 22b259c..1c099ec 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.systest.jms;
+import java.io.Closeable;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.URL;
import java.util.Map;
@@ -31,6 +32,7 @@ import javax.xml.ws.Endpoint;
import javax.xml.ws.Response;
import javax.xml.ws.soap.AddressingFeature;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.binding.soap.interceptor.TibcoSoapActionInterceptor;
@@ -53,22 +55,26 @@ import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
import org.apache.cxf.transport.jms.JMSConstants;
import org.apache.cxf.transport.jms.JMSMessageHeadersType;
import org.apache.cxf.transport.jms.JMSPropertyType;
+import org.apache.cxf.transport.jms.util.TestReceiver;
import org.apache.hello_world_doc_lit.Greeter;
import org.apache.hello_world_doc_lit.PingMeFault;
import org.apache.hello_world_doc_lit.SOAPService2;
+import org.apache.hello_world_doc_lit.SOAPService7;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class JMSClientServerTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = allocatePort(JMSClientServerTest.class);
private static EmbeddedJMSBrokerLauncher broker;
private String wsdlString;
@BeforeClass
public static void startServers() throws Exception {
- broker = new EmbeddedJMSBrokerLauncher();
+ broker = new EmbeddedJMSBrokerLauncher("tcp://localhost:" + PORT);
launchServer(broker);
launchServer(new Server(broker));
createStaticBus();
@@ -93,40 +99,34 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
- try {
- Greeter greeter = service.getPort(portName, Greeter.class);
-
- Client client = ClientProxy.getClient(greeter);
- client.getEndpoint().getOutInterceptors().add(new TibcoSoapActionInterceptor());
- client.getOutInterceptors().add(new LoggingOutInterceptor());
- client.getInInterceptors().add(new LoggingInInterceptor());
- for (int idx = 0; idx < 5; idx++) {
+ Greeter greeter = service.getPort(portName, Greeter.class);
- greeter.greetMeOneWay("test String");
-
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ Client client = ClientProxy.getClient(greeter);
+ client.getEndpoint().getOutInterceptors().add(new TibcoSoapActionInterceptor());
+ client.getOutInterceptors().add(new LoggingOutInterceptor());
+ client.getInInterceptors().add(new LoggingInInterceptor());
+ for (int idx = 0; idx < 5; idx++) {
+ greeter.greetMeOneWay("test String");
-
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
-
- try {
- greeter.pingMe();
- fail("Should have thrown FaultException");
- } catch (PingMeFault ex) {
- assertNotNull(ex.getFaultInfo());
- }
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ assertNotNull("no response received from service", greeting);
+ String exResponse = response1 + idx;
+ assertEquals(exResponse, greeting);
+
+ String reply = greeter.sayHi();
+ assertNotNull("no response received from service", reply);
+ assertEquals(response2, reply);
+
+ try {
+ greeter.pingMe();
+ fail("Should have thrown FaultException");
+ } catch (PingMeFault ex) {
+ assertNotNull(ex.getFaultInfo());
}
-
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
}
+
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -136,39 +136,26 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
SOAPService2 service = new SOAPService2(wsdl, serviceName);
- assertNotNull(service);
+ Greeter greeter = service.getPort(portName, Greeter.class);
+ for (int idx = 0; idx < 5; idx++) {
- String response1 = new String("Hello Milestone-");
- String response2 = new String("Bonjour");
- try {
- Greeter greeter = service.getPort(portName, Greeter.class);
- for (int idx = 0; idx < 5; idx++) {
+ greeter.greetMeOneWay("test String");
- greeter.greetMeOneWay("test String");
-
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ assertEquals("Hello Milestone-" + idx, greeting);
+ String reply = greeter.sayHi();
+ assertEquals("Bonjour", reply);
-
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
-
- try {
- greeter.pingMe();
- fail("Should have thrown FaultException");
- } catch (PingMeFault ex) {
- assertNotNull(ex.getFaultInfo());
- }
-
+ try {
+ greeter.pingMe();
+ fail("Should have thrown FaultException");
+ } catch (PingMeFault ex) {
+ assertNotNull(ex.getFaultInfo());
}
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+
}
+ ((java.io.Closeable)greeter).close();
}
@Ignore
@@ -243,6 +230,7 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
System.gc();
}
+ @Ignore
@Test
public void testBasicConnection() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService");
@@ -252,38 +240,34 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
- try {
- HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
- for (int idx = 0; idx < 5; idx++) {
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
+ for (int idx = 0; idx < 5; idx++) {
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ assertNotNull("no response received from service", greeting);
+ String exResponse = response1 + idx;
+ assertEquals(exResponse, greeting);
+
+ String reply = greeter.sayHi();
+ assertNotNull("no response received from service", reply);
+ assertEquals(response2, reply);
+
+ try {
+ greeter.testRpcLitFault("BadRecordLitFault");
+ fail("Should have thrown BadRecoedLitFault");
+ } catch (BadRecordLitFault ex) {
+ assertNotNull(ex.getFaultInfo());
+ }
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
-
- try {
- greeter.testRpcLitFault("BadRecordLitFault");
- fail("Should have thrown BadRecoedLitFault");
- } catch (BadRecordLitFault ex) {
- assertNotNull(ex.getFaultInfo());
- }
-
- try {
- greeter.testRpcLitFault("NoSuchCodeLitFault");
- fail("Should have thrown NoSuchCodeLitFault exception");
- } catch (NoSuchCodeLitFault nslf) {
- assertNotNull(nslf.getFaultInfo());
- assertNotNull(nslf.getFaultInfo().getCode());
- }
-
+ try {
+ greeter.testRpcLitFault("NoSuchCodeLitFault");
+ fail("Should have thrown NoSuchCodeLitFault exception");
+ } catch (NoSuchCodeLitFault nslf) {
+ assertNotNull(nslf.getFaultInfo());
+ assertNotNull(nslf.getFaultInfo().getCode());
}
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+
}
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -294,22 +278,18 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
- try {
- HelloWorldPortType greeter = service.getHWSByteMsgPort();
- for (int idx = 0; idx < 2; idx++) {
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
- assertEquals(exResponse, greeting);
+ HelloWorldPortType greeter = service.getHWSByteMsgPort();
+ for (int idx = 0; idx < 2; idx++) {
+ String greeting = greeter.greetMe("Milestone-" + idx);
+ assertNotNull("no response received from service", greeting);
+ String exResponse = response1 + idx;
+ assertEquals(exResponse, greeting);
- String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
- }
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+ String reply = greeter.sayHi();
+ assertNotNull("no response received from service", reply);
+ assertEquals(response2, reply);
}
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -319,17 +299,13 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldPubSubService service = new HelloWorldPubSubService(wsdl, serviceName);
- try {
- HelloWorldPubSubPort greeter = service.getPort(portName, HelloWorldPubSubPort.class);
- for (int idx = 0; idx < 5; idx++) {
- greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
- }
- //Give some time to complete one-way calls.
- Thread.sleep(50L);
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+ HelloWorldPubSubPort greeter = service.getPort(portName, HelloWorldPubSubPort.class);
+ for (int idx = 0; idx < 5; idx++) {
+ greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
}
+ // Give some time to complete one-way calls.
+ Thread.sleep(50L);
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -339,17 +315,13 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldPubSubService service = new HelloWorldPubSubService(wsdl, serviceName);
- try {
- HelloWorldPubSubPort greeter = service.getPort(portName, HelloWorldPubSubPort.class);
- for (int idx = 0; idx < 5; idx++) {
- greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
- }
- //Give some time to complete one-way calls.
- Thread.sleep(50L);
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+ HelloWorldPubSubPort greeter = service.getPort(portName, HelloWorldPubSubPort.class);
+ for (int idx = 0; idx < 5; idx++) {
+ greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
}
+ // Give some time to complete one-way calls.
+ Thread.sleep(50L);
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -363,21 +335,17 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
broker.updateWsdl((Bus)ctx.getBean("cxf"), wsdlString2);
HelloWorldPortType greeter = (HelloWorldPortType)ctx.getBean("jmsRPCClient");
- assertNotNull(greeter);
- String response1 = new String("Hello Milestone-");
- String response2 = new String("Bonjour");
try {
for (int idx = 0; idx < 5; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
- String exResponse = response1 + idx;
+ String exResponse = "Hello Milestone-" + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
- assertNotNull("no response received from service", reply);
- assertEquals(response2, reply);
+ assertEquals("Bonjour", reply);
try {
greeter.testRpcLitFault("BadRecordLitFault");
@@ -418,18 +386,14 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldOneWayQueueService service = new HelloWorldOneWayQueueService(wsdl, serviceName);
- try {
- HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class,
- new AddressingFeature(true, true));
- for (int idx = 0; idx < 5; idx++) {
- greeter.greetMeOneWay("JMS:Queue:Milestone-" + idx);
- }
- //Give some time to complete one-way calls.
- Thread.sleep(100L);
- ((java.io.Closeable)greeter).close();
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
+ HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class,
+ new AddressingFeature(true, true));
+ for (int idx = 0; idx < 5; idx++) {
+ greeter.greetMeOneWay("JMS:Queue:Milestone-" + idx);
}
+ // Give some time to complete one-way calls.
+ Thread.sleep(100L);
+ ((java.io.Closeable)greeter).close();
}
@Test
@@ -443,11 +407,10 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
HelloWorldQueueDecoupledOneWaysService service =
new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
- assertNotNull(service);
Endpoint requestEndpoint = null;
Endpoint replyEndpoint = null;
+ HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
try {
- HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
requestEndpoint = Endpoint.publish("", requestServant);
GreeterImplQueueDecoupledOneWaysDeferredReply replyServant =
@@ -488,7 +451,6 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
}
}
assertEquals(expectedReply, reply);
- ((java.io.Closeable)greeter).close();
} catch (Exception ex) {
throw ex;
} finally {
@@ -498,6 +460,7 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
if (replyEndpoint != null) {
replyEndpoint.stop();
}
+ ((java.io.Closeable)greeter).close();
}
}
@@ -516,8 +479,8 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
assertNotNull(service);
Endpoint requestEndpoint = null;
+ HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
try {
- HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays(true);
requestEndpoint = Endpoint.publish(null, requestServant);
@@ -546,15 +509,14 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
fail("The decoupled one-way reply was sent");
}
}
- ((java.io.Closeable)greeter).close();
} catch (Exception ex) {
throw ex;
} finally {
if (requestEndpoint != null) {
requestEndpoint.stop();
}
+ ((java.io.Closeable)greeter).close();
}
-
}
@Test
@@ -565,53 +527,65 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldService service = new HelloWorldService(wsdl, serviceName);
+ HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
- try {
- HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
- Map<String, Object> requestContext = ((BindingProvider)greeter).getRequestContext();
- JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
- requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID");
- requestHeader.setJMSExpiration(3600000L);
- JMSPropertyType propType = new JMSPropertyType();
- propType.setName(testReturnPropertyName);
- propType.setValue("mustReturn");
- requestHeader.getProperty().add(propType);
- propType = new JMSPropertyType();
- propType.setName(testIgnoredPropertyName);
- propType.setValue("mustNotReturn");
- requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
-
- String greeting = greeter.greetMe("Milestone-");
- assertNotNull("no response received from service", greeting);
+ Map<String, Object> requestContext = ((BindingProvider)greeter).getRequestContext();
+ JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+ requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID");
+ requestHeader.setJMSExpiration(3600000L);
+ JMSPropertyType propType = new JMSPropertyType();
+ propType.setName(testReturnPropertyName);
+ propType.setValue("mustReturn");
+ requestHeader.getProperty().add(propType);
+ propType = new JMSPropertyType();
+ propType.setName(testIgnoredPropertyName);
+ propType.setValue("mustNotReturn");
+ requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
+
+ String greeting = greeter.greetMe("Milestone-");
+ assertNotNull("no response received from service", greeting);
+
+ assertEquals("Hello Milestone-", greeting);
+
+ Map<String, Object> responseContext = ((BindingProvider)greeter).getResponseContext();
+ JMSMessageHeadersType responseHdr = (JMSMessageHeadersType)responseContext
+ .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
+ if (responseHdr == null) {
+ fail("response Header should not be null");
+ }
- assertEquals("Hello Milestone-", greeting);
+ assertTrue("CORRELATION ID should match :",
+ "JMS_SAMPLE_CORRELATION_ID".equals(responseHdr.getJMSCorrelationID()));
+ assertTrue("response Headers must conain the app property set in request context.",
+ responseHdr.getProperty() != null);
- Map<String, Object> responseContext = ((BindingProvider)greeter).getResponseContext();
- JMSMessageHeadersType responseHdr =
- (JMSMessageHeadersType)responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
- if (responseHdr == null) {
- fail("response Header should not be null");
- }
-
- assertTrue("CORRELATION ID should match :",
- "JMS_SAMPLE_CORRELATION_ID".equals(responseHdr.getJMSCorrelationID()));
- assertTrue("response Headers must conain the app property set in request context.",
- responseHdr.getProperty() != null);
-
- boolean found = false;
- for (JMSPropertyType p : responseHdr.getProperty()) {
- if (testReturnPropertyName.equals(p.getName())) {
- found = true;
- }
+ boolean found = false;
+ for (JMSPropertyType p : responseHdr.getProperty()) {
+ if (testReturnPropertyName.equals(p.getName())) {
+ found = true;
}
- assertTrue("response Headers must match the app property set in request context.",
- found);
- } catch (UndeclaredThrowableException ex) {
- throw (Exception)ex.getCause();
}
+ assertTrue("response Headers must match the app property set in request context.", found);
+ ((Closeable)greeter).close();
}
-
-
+ @Test
+ public void testReplyToConfig() throws Exception {
+ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(broker.getBrokerURL());
+ TestReceiver receiver = new TestReceiver(cf, "SoapService7.replyto.queue", false);
+ receiver.setStaticReplyQueue("SoapService7.reply.queue");
+ receiver.runAsync();
+
+ QName serviceName = new QName("http://apache.org/hello_world_doc_lit", "SOAPService7");
+ QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort7");
+ URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
+ SOAPService7 service = new SOAPService7(wsdl, serviceName);
+ Greeter greeter = service.getPort(portName, Greeter.class);
+
+ String name = "FooBar";
+ String reply = greeter.greetMe(name);
+ Assert.assertEquals("Hello " + name, reply);
+ ((Closeable)greeter).close();
+ }
}