cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1347011 [2/2] - in /cxf/branches/2.5.x-fixes/systests/transport-jms: ./ src/test/java/org/apache/cxf/jms/testsuite/services/ src/test/java/org/apache/cxf/jms/testsuite/testcases/ src/test/java/org/apache/cxf/jms/testsuite/util/ src/test/ja...
Date Wed, 06 Jun 2012 17:57:39 GMT
Modified: cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/swa/ClientServerSwaTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/swa/ClientServerSwaTest.java?rev=1347011&r1=1347010&r2=1347011&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/swa/ClientServerSwaTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/swa/ClientServerSwaTest.java
Wed Jun  6 17:57:38 2012
@@ -20,8 +20,6 @@ package org.apache.cxf.systest.jms.swa;
 
 import java.io.Closeable;
 import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
@@ -31,33 +29,54 @@ import javax.xml.ws.Holder;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 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.testutil.common.TestUtil;
 
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class ClientServerSwaTest extends AbstractBusClientServerTestBase {
-    static String brokerPort = EmbeddedJMSBrokerLauncher.PORT;
-    static String serverPort = TestUtil.getPortNumber(Server.class);
+    public static final String ADDRESS 
+        = "jms:jndi:dynamicQueues/test.cxf.jmstransport.swa.queue"
+            + "?jndiInitialContextFactory"
+            + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+            + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=";
     
+    static EmbeddedJMSBrokerLauncher broker;
+    
+    public static class Server extends AbstractBusTestServerBase {
+        protected void run() {
+            try {
+                JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+                factory.setWsdlLocation("classpath:wsdl/swa-mime.wsdl");
+                factory.setTransportId("http://cxf.apache.org/transports/jms");
+                factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
+                factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceHttpPort"));
+                factory.setAddress(ADDRESS + broker.getBrokerURL());
+                factory.setServiceBean(new SwAServiceImpl());
+                factory.create().start();
+            } catch (Exception e) {
+                e.printStackTrace();
+                Thread.currentThread().interrupt();
+            }
+        }
+    }
+
     @BeforeClass
     public static void startServers() throws Exception {
-        Map<String, String> props = new HashMap<String, String>();          
     
-        if (System.getProperty("org.apache.activemq.default.directory.prefix") != null) {
-            props.put("org.apache.activemq.default.directory.prefix",
-                      System.getProperty("org.apache.activemq.default.directory.prefix"));
-        }
-        props.put("java.util.logging.config.file", 
-                  System.getProperty("java.util.logging.config.file"));
-        
-        assertTrue("server did not launch correctly", 
-                   launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
-        
-        assertTrue("server did not launch correctly", launchServer(Server.class));
+        broker = new EmbeddedJMSBrokerLauncher("vm://ClientServerSwaTest");
+        System.setProperty("EmbeddedBrokerURL", broker.getBrokerURL());
+        launchServer(broker);
+        launchServer(new Server());
         createStaticBus();
     }
+    @AfterClass
+    public static void clearProperty() {
+        System.clearProperty("EmbeddedBrokerURL");
+    }    
     @Test
     public void testSwa() throws Exception {
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
@@ -65,7 +84,7 @@ public class ClientServerSwaTest extends
         factory.setTransportId("http://cxf.apache.org/transports/jms");
         factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
         factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceHttpPort"));
-        factory.setAddress(Server.ADDRESS);
+        factory.setAddress(ADDRESS + broker.getBrokerURL());
         factory.getOutInterceptors().add(new LoggingOutInterceptor());
         SwAService port = factory.create(SwAService.class);
         

Modified: cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java?rev=1347011&r1=1347010&r2=1347011&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
Wed Jun  6 17:57:38 2012
@@ -30,10 +30,10 @@ public class GreeterImplWithTransaction 
     private AtomicBoolean flag = new AtomicBoolean(true);
        
     public String greetMe(String requestType) {
-        System.out.println("Reached here :" + requestType);
+        //System.out.println("Reached here :" + requestType);
         if ("Bad guy".equals(requestType)) {
             if (flag.getAndSet(false)) {
-                System.out.println("Throw exception here :" + requestType);
+                //System.out.println("Throw exception here :" + requestType);
                 throw new RuntimeException("Got a bad guy call for greetMe");
             } else {
                 requestType = "[Bad guy]";

Modified: cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java?rev=1347011&r1=1347010&r2=1347011&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
Wed Jun  6 17:57:38 2012
@@ -20,49 +20,71 @@ package org.apache.cxf.systest.jms.tx;
 
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.jms.ConnectionFactory;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 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.jms.JMSConfigFeature;
 import org.apache.cxf.transport.jms.JMSConfiguration;
 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.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.jms.connection.JmsTransactionManager;
 
-public class JMSTransactionClientServerTest extends AbstractBusClientServerTestBase {
-    protected static boolean serversStarted;
-    static final String JMS_PORT = EmbeddedJMSBrokerLauncher.PORT;
 
+public class JMSTransactionClientServerTest extends AbstractBusClientServerTestBase {
+    static EmbeddedJMSBrokerLauncher broker;
 
-    @Before
-    public void startServers() throws Exception {
-        if (serversStarted) {
-            return;
-        }
-        Map<String, String> props = new HashMap<String, String>();          
     
-        if (System.getProperty("org.apache.activemq.default.directory.prefix") != null) {
-            props.put("org.apache.activemq.default.directory.prefix",
-                      System.getProperty("org.apache.activemq.default.directory.prefix"));
+    public static class Server extends AbstractBusTestServerBase {
+    
+        protected void run()  {
+            // create the application context
+            ClassPathXmlApplicationContext context = 
+                new ClassPathXmlApplicationContext("org/apache/cxf/systest/jms/tx/jms_server_config.xml");
+            context.start();
+            
+            EndpointImpl endpoint = new EndpointImpl(new GreeterImplWithTransaction());
+            endpoint.setAddress("jms://");
+            JMSConfiguration jmsConfig = new JMSConfiguration();
+    
+            ConnectionFactory connectionFactory
+                = context.getBean("jmsConnectionFactory", ConnectionFactory.class);
+            jmsConfig.setConnectionFactory(connectionFactory);
+            jmsConfig.setTargetDestination("greeter.queue.noaop");
+            jmsConfig.setSessionTransacted(true);
+            jmsConfig.setPubSubDomain(false);
+            jmsConfig.setUseJms11(true);
+            jmsConfig.setTransactionManager(new JmsTransactionManager(connectionFactory));
+            jmsConfig.setCacheLevel(3);
+    
+            JMSConfigFeature jmsConfigFeature = new JMSConfigFeature();
+            jmsConfigFeature.setJmsConfig(jmsConfig);
+            endpoint.getFeatures().add(jmsConfigFeature);
+            endpoint.publish();
         }
-        props.put("java.util.logging.config.file", 
-                  System.getProperty("java.util.logging.config.file"));
-        
-        assertTrue("server did not launch correctly", 
-                   launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
+    }
 
-        assertTrue("server did not launch correctly", 
-                   launchServer(Server.class, false));
-        serversStarted = true;
+    @BeforeClass
+    public static void startServers() throws Exception {
+        broker = new EmbeddedJMSBrokerLauncher("vm://JMSTransactionClientServerTest");
+        System.setProperty("EmbeddedBrokerURL", broker.getBrokerURL());
+        launchServer(broker);
+        launchServer(new Server());
+        createStaticBus();
+    }
+    @AfterClass
+    public static void clearProperty() {
+        System.clearProperty("EmbeddedBrokerURL");
     }
-    
     public URL getWSDLURL(String s) throws Exception {
         return getClass().getResource(s);
     }
@@ -82,7 +104,7 @@ public class JMSTransactionClientServerT
         assertNotNull(wsdl);
         String wsdlString = wsdl.toString();
         SOAPService2 service = new SOAPService2(wsdl, serviceName);
-        EmbeddedJMSBrokerLauncher.updateWsdlExtensors(getBus(), wsdlString);
+        broker.updateWsdl(getBus(), wsdlString);
         assertNotNull(service);
 
         Greeter greeter = service.getPort(portName, Greeter.class);
@@ -96,7 +118,7 @@ public class JMSTransactionClientServerT
 
         JMSConfiguration jmsConfig = new JMSConfiguration();
         ConnectionFactory connectionFactory
-            = new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:" + JMS_PORT);
+            = new org.apache.activemq.ActiveMQConnectionFactory(broker.getBrokerURL());
         jmsConfig.setConnectionFactory(connectionFactory);
         jmsConfig.setTargetDestination("greeter.queue.noaop");
         jmsConfig.setPubSubDomain(false);

Modified: cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml?rev=1347011&r1=1347010&r2=1347011&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
(original)
+++ cxf/branches/2.5.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
Wed Jun  6 17:57:38 2012
@@ -47,7 +47,7 @@ http://cxf.apache.org/jaxws http://cxf.a
     
   
   <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
-  	p:brokerURL="tcp://localhost:${testutil.ports.EmbeddedJMSBrokerLauncher}"
+  	p:brokerURL="${EmbeddedBrokerURL}"
   />
   
   <bean id="singleConnectionFactory"



Mime
View raw message