cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1347023 - in /cxf/branches/2.4.x-fixes: ./ testutils/src/main/java/org/apache/cxf/testutil/common/
Date Wed, 06 Jun 2012 18:16:01 GMT
Author: dkulp
Date: Wed Jun  6 18:16:01 2012
New Revision: 1347023

URL: http://svn.apache.org/viewvc?rev=1347023&view=rev
Log:
Merged revisions 1347010 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

........
  r1347010 | dkulp | 2012-06-06 13:57:29 -0400 (Wed, 06 Jun 2012) | 9 lines
  
  Merged revisions 1346927 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1346927 | dkulp | 2012-06-06 10:58:32 -0400 (Wed, 06 Jun 2012) | 2 lines
  
    Add ability to launch in-process brokers with vm: URL's
  
  ........
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java
    cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
    cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java?rev=1347023&r1=1347022&r2=1347023&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java
(original)
+++ cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java
Wed Jun  6 18:16:01 2012
@@ -63,6 +63,21 @@ public abstract class AbstractClientServ
         assertTrue("server failed", passed);
     }
     
+    public static boolean launchServer(AbstractTestServerBase base) {
+        boolean ok = false;
+        try { 
+            ServerLauncher sl = new ServerLauncher(base);
+            ok = sl.launchServer();
+            assertTrue("server failed to launch", ok);
+            launchers.add(0, sl);
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to launch server " + base);
+        }
+        
+        return ok;
+    }
+    
     public static boolean launchServer(Class<?> clz) {
         boolean ok = false;
         try { 

Modified: cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java?rev=1347023&r1=1347022&r2=1347023&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
(original)
+++ cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java
Wed Jun  6 18:16:01 2012
@@ -36,12 +36,35 @@ import org.apache.cxf.wsdl.WSDLManager;
 
 public class EmbeddedJMSBrokerLauncher extends AbstractBusTestServerBase {
     public static final String PORT = allocatePort(EmbeddedJMSBrokerLauncher.class);
-    
+
+    String brokerUrl1;            
     BrokerService broker;
-    final String brokerUrl1 = "tcp://localhost:" + PORT;            
-            
+    String brokerName;
     
-    public static void updateWsdlExtensors(Bus bus, String wsdlLocation) {
+    public EmbeddedJMSBrokerLauncher() {
+        this(null);
+    }
+    public EmbeddedJMSBrokerLauncher(String url) {
+        if (url == null) {
+            url = "tcp://localhost:" + PORT;
+        }
+        brokerUrl1 = url;
+    }
+    
+    public String getBrokerURL() {
+        return brokerUrl1;
+    }
+    public void updateWsdl(Bus b, String wsdlLocation) { 
+        updateWsdlExtensors(b, wsdlLocation, brokerUrl1);
+    }
+    
+    public static void updateWsdlExtensors(Bus bus, 
+                                           String wsdlLocation) {
+        updateWsdlExtensors(bus, wsdlLocation, "tcp://localhost:" + PORT);
+    }
+    public static void updateWsdlExtensors(Bus bus, 
+                                           String wsdlLocation,
+                                           String url) {
         try {
             if (bus == null) {
                 bus = BusFactory.getThreadDefaultBus();
@@ -62,7 +85,7 @@ public class EmbeddedJMSBrokerLauncher e
                             if (idx != -1) {
                                 int idx2 = add.indexOf("&", idx);
                                 add = add.substring(0, idx)
-                                    + "jndiURL=tcp://localhost:" + PORT
+                                    + "jndiURL=" + url
                                     + (idx2 == -1 ? "" : add.substring(idx2));
                                 ((SOAPAddress)e).setLocationURI(add);
                             }
@@ -77,7 +100,7 @@ public class EmbeddedJMSBrokerLauncher e
                                     if ("java.naming.provider.url".equals(f.get(prop))) {
                                         f = prop.getClass().getDeclaredField("value");
                                         f.setAccessible(true);
-                                        f.set(prop, "tcp://localhost:" + PORT);
+                                        f.set(prop, url);
                                     }
                                 }
                             } catch (Exception ex) {
@@ -92,6 +115,9 @@ public class EmbeddedJMSBrokerLauncher e
         }
     }
     
+    public void stop() throws Exception {
+        tearDown();
+    }
     public void tearDown() throws Exception {
         if (broker != null) {
             broker.stop();
@@ -99,13 +125,17 @@ public class EmbeddedJMSBrokerLauncher e
     }
     
     //START SNIPPET: broker
-    public void run() {
-        try {                
+    public final void run() {
+        try {             
             broker = new BrokerService();
             broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
             broker.setTmpDataDirectory(new File("./target"));
-            broker.addConnector(brokerUrl1);
-            broker.start();            
+            broker.setUseJmx(false);
+            if (brokerName != null) {
+                broker.setBrokerName(brokerName);
+            }
+            broker.addConnector(brokerUrl1 + "?daemon=true");
+            broker.start();  
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -114,7 +144,11 @@ public class EmbeddedJMSBrokerLauncher e
 
     public static void main(String[] args) {
         try {
-            EmbeddedJMSBrokerLauncher s = new EmbeddedJMSBrokerLauncher();
+            String url = null;
+            if (args.length > 0) {
+                url = args[0];
+            }
+            EmbeddedJMSBrokerLauncher s = new EmbeddedJMSBrokerLauncher(url);
             s.start();
         } catch (Exception ex) {
             ex.printStackTrace();

Modified: cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?rev=1347023&r1=1347022&r2=1347023&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
(original)
+++ cxf/branches/2.4.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
Wed Jun  6 18:16:01 2012
@@ -69,6 +69,12 @@ public class ServerLauncher {
     public ServerLauncher(String theClassName) {
         this(theClassName, DEFAULT_IN_PROCESS);
     }
+    public ServerLauncher(AbstractTestServerBase b) {
+        inProcess = true;
+        inProcessServer = b;
+        javaExe = System.getProperty("java.home") + File.separator + "bin" + File.separator
+ "java";
+        className = null;
+    }
     public ServerLauncher(String theClassName, boolean inprocess) {
         inProcess = inprocess;
         className = theClassName;
@@ -174,16 +180,17 @@ public class ServerLauncher {
                         }
                     }
                 }
-                
-                cls = Class.forName(className);
-                Class<? extends AbstractTestServerBase> svcls = 
-                    cls.asSubclass(AbstractTestServerBase.class);
-                if (null == serverArgs) {
-                    inProcessServer = svcls.newInstance();
-                } else {
-                    Constructor<? extends AbstractTestServerBase> ctor
-                        = svcls.getConstructor(serverArgs.getClass());
-                    inProcessServer = ctor.newInstance(new Object[] {serverArgs});
+                if (inProcessServer == null) {
+                    cls = Class.forName(className);
+                    Class<? extends AbstractTestServerBase> svcls = 
+                        cls.asSubclass(AbstractTestServerBase.class);
+                    if (null == serverArgs) {
+                        inProcessServer = svcls.newInstance();
+                    } else {
+                        Constructor<? extends AbstractTestServerBase> ctor
+                            = svcls.getConstructor(serverArgs.getClass());
+                        inProcessServer = ctor.newInstance(new Object[] {serverArgs});
+                    }
                 }
                 inProcessServer.startInProcess();
                 serverIsReady = true;



Mime
View raw message