cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: More updates to try and get the JMS tests more stable
Date Thu, 13 Mar 2014 00:22:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5cc7e9068 -> b11ce27dc


More updates to try and get the JMS tests more stable


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b11ce27d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b11ce27d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b11ce27d

Branch: refs/heads/master
Commit: b11ce27dcaa1180249633d3f45583949cd698ee9
Parents: 5cc7e90
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 12 20:17:45 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Mar 12 20:18:04 2014 -0400

----------------------------------------------------------------------
 .../transport/jms/ConnectionFactoryFeature.java |  18 +++-
 .../cxf/systest/jms/JMSClientServerTest.java    | 107 +++++++++++--------
 .../systest/jms/shared/JMSSharedQueueTest.java  |   9 +-
 3 files changed, 85 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b11ce27d/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 ac3774a..dca3e43 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
@@ -25,6 +25,10 @@ import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
 
@@ -43,11 +47,15 @@ public class ConnectionFactoryFeature extends AbstractFeature {
 
     @Override
     public void initialize(Client client, Bus bus) {
-        Conduit conduit = client.getConduit();
-        if (conduit instanceof JMSConduit) {
-            JMSConduit jmsConduit = (JMSConduit)conduit;
-            jmsConduit.getJmsConfig().setConnectionFactory(connectionFactory);
-        }
+        client.getEndpoint().getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.PREPARE_SEND)
{
+            public void handleMessage(Message message) throws Fault {
+                Conduit conduit = message.getExchange().getConduit(message);
+                if (conduit instanceof JMSConduit) {
+                    JMSConduit jmsConduit = (JMSConduit)conduit;
+                    jmsConduit.getJmsConfig().setConnectionFactory(connectionFactory);
+                }
+            }
+        });
         super.initialize(client, bus);
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/b11ce27d/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 1c099ec..8e1af76 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
@@ -21,6 +21,8 @@ package org.apache.cxf.systest.jms;
 import java.io.Closeable;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -60,17 +62,21 @@ 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.After;
 import org.junit.Assert;
+import org.junit.Before;
 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;
+    private List<String> wsdlStrings = new ArrayList<String>();
     
     @BeforeClass
     public static void startServers() throws Exception {
@@ -80,12 +86,23 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase
{
         createStaticBus();
     }
     
+    @Before
+    public void setUp() throws Exception {
+        assertSame(getStaticBus(), BusFactory.getThreadDefaultBus(false));
+    }
+   
+    @After 
+    public void tearDown() throws Exception {
+        wsdlStrings.clear();
+    }
+    
     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();
+        String wsdlString = u.toString().intern();
+        wsdlStrings.add(wsdlString);
         broker.updateWsdl(getBus(), wsdlString);
         return u;
     }
@@ -230,7 +247,6 @@ 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");
@@ -332,51 +348,55 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase
{
         ClassPathXmlApplicationContext ctx = 
             new ClassPathXmlApplicationContext(
                 new String[] {"/org/apache/cxf/systest/jms/JMSClients.xml"});
-        String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
-        broker.updateWsdl((Bus)ctx.getBean("cxf"), wsdlString2);
-        HelloWorldPortType greeter = (HelloWorldPortType)ctx.getBean("jmsRPCClient");
-        
         try {
+            String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
+            wsdlStrings.add(wsdlString2);
+            broker.updateWsdl((Bus)ctx.getBean("cxf"), wsdlString2);
+            HelloWorldPortType greeter = (HelloWorldPortType)ctx.getBean("jmsRPCClient");
             
-            for (int idx = 0; idx < 5; idx++) {
-                String greeting = greeter.greetMe("Milestone-" + idx);
-                assertNotNull("no response received from service", greeting);
-                String exResponse = "Hello Milestone-" + idx;
-                assertEquals(exResponse, greeting);
-
-                String reply = greeter.sayHi();
-                assertEquals("Bonjour", reply);
+            try {
                 
-                try {
-                    greeter.testRpcLitFault("BadRecordLitFault");
-                    fail("Should have thrown BadRecoedLitFault");
-                } catch (BadRecordLitFault ex) {
-                    assertNotNull(ex.getFaultInfo());
+                for (int idx = 0; idx < 5; idx++) {
+                    String greeting = greeter.greetMe("Milestone-" + idx);
+                    assertNotNull("no response received from service", greeting);
+                    String exResponse = "Hello Milestone-" + idx;
+                    assertEquals(exResponse, greeting);
+    
+                    String reply = greeter.sayHi();
+                    assertEquals("Bonjour", 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());
-                } 
+            } catch (UndeclaredThrowableException ex) {
+                ctx.close();
+                throw (Exception)ex.getCause();
+            }
+            
+            HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort)ctx.getBean("jmsQueueOneWayServiceClient");
+            assertNotNull(greeter1);
+            try {
+                greeter1.greetMeOneWay("hello");
+            } catch (Exception ex) {
+                fail("There should not throw the exception" + ex);
             }
-        } catch (UndeclaredThrowableException ex) {
+        } finally {
             ctx.close();
-            throw (Exception)ex.getCause();
-        }
-        
-        HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort)ctx.getBean("jmsQueueOneWayServiceClient");
-        assertNotNull(greeter1);
-        try {
-            greeter1.greetMeOneWay("hello");
-        } catch (Exception ex) {
-            fail("There should not throw the exception" + ex);
+            BusFactory.setDefaultBus(getBus());
+            BusFactory.setThreadDefaultBus(getBus());
         }
-        ctx.close();
-        BusFactory.setDefaultBus(getBus());
-        BusFactory.setThreadDefaultBus(getBus());
     }
     
     @Test
@@ -403,7 +423,9 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase
{
                                       "HelloWorldQueueDecoupledOneWaysService");
         QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
         URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
-        broker.updateWsdl(getBus(), "testutils/jms_test.wsdl");
+        String wsdl2 = "testutils/jms_test.wsdl".intern();
+        wsdlStrings.add(wsdl2);
+        broker.updateWsdl(getBus(), wsdl2);
 
         HelloWorldQueueDecoupledOneWaysService service = 
             new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
@@ -473,6 +495,7 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase
{
         URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
         assertNotNull(wsdl);
         String wsdlString2 = "testutils/jms_test.wsdl";
+        wsdlStrings.add(wsdlString2);
         broker.updateWsdl(getBus(), wsdlString2);
 
         HelloWorldQueueDecoupledOneWaysService service = 

http://git-wip-us.apache.org/repos/asf/cxf/blob/b11ce27d/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
index 6871b0d..fc8553c 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
@@ -38,6 +39,7 @@ import org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStati
 import org.apache.cxf.systest.jms.AbstractVmJMSTest;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
+
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -67,7 +69,7 @@ public class JMSSharedQueueTest extends AbstractVmJMSTest {
         private HelloWorldPortType port;
         private CorrelationIDFactory corrFactory;
         private String prefix;
-        private Throwable ex;
+        private volatile Throwable ex;
 
         public ClientRunnable(HelloWorldPortType port) {
             this.port = port;
@@ -93,6 +95,7 @@ public class JMSSharedQueueTest extends AbstractVmJMSTest {
                     callGreetMe();
                 }
             } catch (Throwable e) {
+                //e.printStackTrace();
                 ex = e;
             }
         }
@@ -133,8 +136,10 @@ public class JMSSharedQueueTest extends AbstractVmJMSTest {
             executor.execute(client);
         }
         executor.shutdown();
+        executor.awaitTermination(10, TimeUnit.SECONDS);
         for (ClientRunnable client : clients) {
             if (client.getException() != null) {
+                client.getException().printStackTrace();
                 throw client.getException();
             }
         }
@@ -268,7 +273,7 @@ public class JMSSharedQueueTest extends AbstractVmJMSTest {
         URL wsdl = getWSDLURL(WSDL);
         HelloWorldServiceRuntimeCorrelationIDDynamicPrefix service = 
             new HelloWorldServiceRuntimeCorrelationIDDynamicPrefix(wsdl, serviceName);
-        HelloWorldPortType port = markForClose(service.getPort(portName, HelloWorldPortType.class));
+        HelloWorldPortType port = markForClose(service.getPort(portName, HelloWorldPortType.class,
cff));
 
         Collection<ClientRunnable> clients = new ArrayList<ClientRunnable>();
       
         for (int i = 0; i < 10; ++i) {


Mime
View raw message