You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/11/16 16:39:10 UTC

svn commit: r1410402 - /cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/

Author: dkulp
Date: Fri Nov 16 15:39:08 2012
New Revision: 1410402

URL: http://svn.apache.org/viewvc?rev=1410402&view=rev
Log:
Make sure a bunch of tests attemp to cleanup some stuff, close ports, shutdown bus's, etc...

Modified:
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -52,6 +53,7 @@ public class AddressingAnonymousPolicyTe
 
     public static class Server extends AbstractBusTestServerBase {
         String tmpDir = TEMPDIR;
+        Endpoint ep;
         public Server() {
         }
         public Server(String dir) {
@@ -62,6 +64,7 @@ public class AddressingAnonymousPolicyTe
             System.setProperty("server.temp.location", tmpDir);
             SpringBusFactory bf = new SpringBusFactory();
             Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-anon-server.xml");
+            setBus(bus);
             BusFactory.setDefaultBus(bus);
             LoggingInInterceptor in = new LoggingInInterceptor();
             bus.getInInterceptors().add(in);
@@ -72,9 +75,13 @@ public class AddressingAnonymousPolicyTe
             
             GreeterImpl implementor = new GreeterImpl();
             String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";
-            Endpoint.publish(address, implementor);
+            ep = Endpoint.publish(address, implementor);
             LOG.info("Published greeter endpoint.");            
         }
+        public void tearDown() {
+            ep.stop();
+            ep = null;
+        }
         
 
         public static void main(String[] args) {
@@ -139,6 +146,8 @@ public class AddressingAnonymousPolicyTe
         } catch (PingMeFault ex) {
             assertEquals(2, ex.getFaultInfo().getMajor());
             assertEquals(1, ex.getFaultInfo().getMinor());
-        } 
+        }
+        ((Closeable)greeter).close();
+        
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.List;
 import java.util.logging.Logger;
 
@@ -36,6 +37,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.ws.policy.PolicyInInterceptor;
 import org.apache.cxf.ws.policy.PolicyOutInterceptor;
 import org.junit.BeforeClass;
@@ -48,23 +50,28 @@ import org.junit.Test;
  */
 public class AddressingInlinePolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
-    public static final String DECOUPLED = allocatePort("decoupled");
 
     private static final Logger LOG = LogUtils.getLogger(AddressingInlinePolicyTest.class);
 
     public static class Server extends AbstractBusTestServerBase {
     
+        Endpoint ep;
         protected void run()  {            
             SpringBusFactory bf = new SpringBusFactory();
             Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy.xml");
+            BusFactory.setDefaultBus(bus);
+            setBus(bus);
             
             GreeterImpl implementor = new GreeterImpl();
             String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";
-            Endpoint.publish(address, implementor);
+            ep = Endpoint.publish(address, implementor);
             LOG.info("Published greeter endpoint.");            
             testInterceptors(bus);
         }
         
+        public void tearDown() {
+            ep.stop();
+        }
 
         public static void main(String[] args) {
             try { 
@@ -81,6 +88,7 @@ public class AddressingInlinePolicyTest 
 
     @BeforeClass
     public static void startServers() throws Exception {
+        TestUtil.getNewPortNumber("decoupled");
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
     
@@ -125,6 +133,8 @@ public class AddressingInlinePolicyTest 
             assertEquals(2, ex.getFaultInfo().getMajor());
             assertEquals(1, ex.getFaultInfo().getMinor());
         } 
+        ((Closeable)greeter).close();
+        
     }
 
     private static void testInterceptors(Bus b) {

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -37,6 +38,7 @@ import org.apache.cxf.systest.ws.util.Co
 import org.apache.cxf.systest.ws.util.MessageFlow;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.testutil.recorders.InMessageRecorder;
 import org.apache.cxf.testutil.recorders.OutMessageRecorder;
 import org.apache.cxf.ws.policy.PolicyEngine;
@@ -52,7 +54,6 @@ import org.junit.Test;
  */
 public class AddressingOptionalPolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
-    public static final String DECOUPLED = allocatePort("decoupled");
     public static final String TEMPDIR = FileUtils.getDefaultTempDir().toURI().toString(); 
 
     private static final Logger LOG = LogUtils.getLogger(AddressingOptionalPolicyTest.class);
@@ -99,6 +100,7 @@ public class AddressingOptionalPolicyTes
 
     @BeforeClass
     public static void startServers() throws Exception {
+        TestUtil.getNewPortNumber("decoupled");
         PolicyTestHelper.updatePolicyRef("addr-optional-external.xml", ":9020", ":" + PORT);
         System.setProperty("temp.location", TEMPDIR);
         assertTrue("server did not launch correctly", launchServer(Server.class, null,
@@ -110,7 +112,6 @@ public class AddressingOptionalPolicyTes
     public void testUsingAddressing() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
-        Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
         BusFactory.setDefaultBus(bus);
         InMessageRecorder in = new InMessageRecorder();
         bus.getInInterceptors().add(in);
@@ -153,6 +154,8 @@ public class AddressingOptionalPolicyTes
             mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(), true, i);
             mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(), false, i);
         }
+        ((Closeable)greeter).close();
+        
     }
     
     @Test
@@ -203,5 +206,6 @@ public class AddressingOptionalPolicyTes
             mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(), true, i);
             mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(), false, i);
         }
+        ((Closeable)greeter).close();        
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -36,6 +37,8 @@ import org.apache.cxf.interceptor.Loggin
 import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -47,7 +50,6 @@ import org.junit.Test;
 public class AddressingPolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
     public static final String TEMPDIR = FileUtils.getDefaultTempDir().toURI().toString(); 
-    public static final String DECOUPLED = allocatePort("decoupled");
 
     private static final Logger LOG = LogUtils.getLogger(AddressingPolicyTest.class);
 
@@ -96,6 +98,7 @@ public class AddressingPolicyTest extend
 
     @BeforeClass
     public static void startServers() throws Exception {
+        TestUtil.getNewPortNumber("decoupled");
         PolicyTestHelper.updatePolicyRef("addr-external.xml", ":9020", ":" + PORT);
         System.setProperty("temp.location", TEMPDIR);
 
@@ -144,5 +147,7 @@ public class AddressingPolicyTest extend
             assertEquals(2, ex.getFaultInfo().getMajor());
             assertEquals(1, ex.getFaultInfo().getMinor());
         } 
+        ((Closeable)greeter).close();
+
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.util.logging.Logger;
@@ -164,6 +165,7 @@ public class HTTPClientPolicyTest extend
             assertEquals(2, ex.getFaultInfo().getMajor());
             assertEquals(1, ex.getFaultInfo().getMinor());
         } 
+        ((Closeable)greeter).close();
 
     }
     
@@ -195,5 +197,7 @@ public class HTTPClientPolicyTest extend
         assertEquals("unexpected DecoupledEndpoint", 
                      "http://localhost:9909/decoupled_endpoint",
                      c.getClient().getDecoupledEndpoint());
+        ((Closeable)greeter).close();
+
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -55,14 +56,14 @@ public class HTTPServerPolicyTest extend
     private static final Logger LOG = LogUtils.getLogger(HTTPServerPolicyTest.class);
 
     public static class Server extends AbstractBusTestServerBase {
-   
+        Endpoint ep;
         protected void run()  {            
             SpringBusFactory bf = new SpringBusFactory();
             Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/http-server.xml");
-            
+            setBus(bus);
             GreeterImpl implementor = new GreeterImpl();
             implementor.setThrowAlways(true);
-            Endpoint.publish("http://localhost:" + PORT + "/SoapContext/GreeterPort", implementor);
+            ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/GreeterPort", implementor);
 
             LOG.info("Published greeter endpoint."); 
             
@@ -74,6 +75,9 @@ public class HTTPServerPolicyTest extend
             bus.getOutFaultInterceptors().add(out);
         }
         
+        public void tearDown() {
+            ep.stop();
+        }
 
         public static void main(String[] args) {
             try { 
@@ -142,6 +146,6 @@ public class HTTPServerPolicyTest extend
             assertEquals(2, ex.getFaultInfo().getMajor());
             assertEquals(1, ex.getFaultInfo().getMinor());
         }
-
+        ((Closeable)greeter).close();
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -105,6 +106,7 @@ public class NestedAddressingPolicyTest 
             assertTrue("Addressing Header Required message is expected",
                        e.getMessage().contains("Addressing Property is not present"));
         }
+        ((Closeable)greeter).close();
 
     }
 }
\ No newline at end of file

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -37,6 +38,7 @@ import org.apache.cxf.systest.ws.util.Co
 import org.apache.cxf.systest.ws.util.MessageFlow;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.testutil.recorders.InMessageRecorder;
 import org.apache.cxf.testutil.recorders.MessageRecorder;
 import org.apache.cxf.testutil.recorders.OutMessageRecorder;
@@ -54,7 +56,6 @@ import org.junit.Test;
 public class RMPolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
     public static final String TEMPDIR = FileUtils.getDefaultTempDir().toURI().toString(); 
-    public static final String DECOUPLED = allocatePort("decoupled");
 
     private static final Logger LOG = LogUtils.getLogger(RMPolicyTest.class);
     private static final String GREETMEONEWAY_ACTION 
@@ -112,6 +113,7 @@ public class RMPolicyTest extends Abstra
 
     @BeforeClass
     public static void startServers() throws Exception {
+        TestUtil.getNewPortNumber("decoupled");
         PolicyTestHelper.updatePolicyRef("rm-external.xml", ":9020", ":" + PORT);
         System.setProperty("temp.location", TEMPDIR);
 
@@ -192,6 +194,7 @@ public class RMPolicyTest extends Abstra
         mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, false);
         mf.verifyLastMessage(new boolean[] {false, false, false, false}, false);
         mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false);
-         
+        ((Closeable)greeter).close();
+
     }
 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java?rev=1410402&r1=1410401&r2=1410402&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java (original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java Fri Nov 16 15:39:08 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.ws.policy;
 
+import java.io.Closeable;
 import java.util.List;
 import java.util.logging.Logger;
 
@@ -35,6 +36,7 @@ import org.apache.cxf.systest.ws.util.Co
 import org.apache.cxf.systest.ws.util.MessageFlow;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.testutil.recorders.InMessageRecorder;
 import org.apache.cxf.testutil.recorders.MessageRecorder;
 import org.apache.cxf.testutil.recorders.OutMessageRecorder;
@@ -54,8 +56,7 @@ import org.junit.Test;
  */
 public class RMPolicyWsdlTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
-    public static final String DECOUPLED = allocatePort("decoupled");
-
+       
     private static final Logger LOG = LogUtils.getLogger(RMPolicyWsdlTest.class);
     private static final String GREETMEONEWAY_ACTION 
         = "http://cxf.apache.org/greeter_control/Greeter/greetMeOneWayRequest";
@@ -71,11 +72,11 @@ public class RMPolicyWsdlTest extends Ab
 
 
     public static class Server extends AbstractBusTestServerBase {
-    
         protected void run()  {            
             SpringBusFactory bf = new SpringBusFactory();
             Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/rmwsdl_server.xml");
             BusFactory.setDefaultBus(bus);
+            setBus(bus);
             
             ServerRegistry sr = bus.getExtension(ServerRegistry.class);
             PolicyEngine pe = bus.getExtension(PolicyEngine.class);
@@ -117,6 +118,7 @@ public class RMPolicyWsdlTest extends Ab
     
     @BeforeClass
     public static void startServers() throws Exception {
+        TestUtil.getNewPortNumber("decoupled");
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
          
@@ -197,6 +199,6 @@ public class RMPolicyWsdlTest extends Ab
         mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, false);
         mf.verifyLastMessage(new boolean[] {false, false, false, false}, false);
         mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false);
-        
+        ((Closeable)greeter).close();
     }
 }