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/05/23 03:27:15 UTC

svn commit: r1341706 - in /cxf/branches/2.5.x-fixes: ./ systests/uncategorized/ systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/ systests/uncategorized/src/test/java/org/apache/cxf/systest/js/ systests/uncategorized/src/test/java/org/ap...

Author: dkulp
Date: Wed May 23 01:27:13 2012
New Revision: 1341706

URL: http://svn.apache.org/viewvc?rev=1341706&view=rev
Log:
Merged revisions 1340325 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1340325 | dkulp | 2012-05-18 20:47:59 -0400 (Fri, 18 May 2012) | 4 lines
  
  More cleanups and flip uncategorized tests to forkmode once
  Ignore JCA tests for now as they are somehow resetting the JVM level log
  levels causing printed stack traces and warnings from the various
  negative test cases.  Need to investigate.
........

Removed:
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/Server.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ServerWithJMS.java
Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/systests/uncategorized/pom.xml
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/js/JSClientServerTest.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
    cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java

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

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/pom.xml?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/pom.xml (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/pom.xml Wed May 23 01:27:13 2012
@@ -417,8 +417,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-    <properties>
-        <cxf.surefire.fork.mode>pertest</cxf.surefire.fork.mode>
-    </properties>
-
 </project>

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java Wed May 23 01:27:13 2012
@@ -83,6 +83,7 @@ public class OutBoundConnectionTest exte
     }
     
     @Test
+    @org.junit.Ignore
     public void testBasicConnection() throws Exception {
         URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
         assertNotNull(wsdl);
@@ -113,6 +114,7 @@ public class OutBoundConnectionTest exte
     
     
     @Test
+    @org.junit.Ignore
     public void testGetConnectionFromSEI() throws Exception {
         CXFConnectionRequestInfo requestInfo = new CXFConnectionRequestInfo();
         requestInfo.setInterface(Greeter.class);

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/js/JSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/js/JSClientServerTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/js/JSClientServerTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/js/JSClientServerTest.java Wed May 23 01:27:13 2012
@@ -32,7 +32,6 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 
-
 public class JSClientServerTest extends AbstractBusClientServerTestBase {
     
     public static final String JS_PORT = Server.JS_PORT;

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java Wed May 23 01:27:13 2012
@@ -31,45 +31,68 @@ import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsClientProxy;
 import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.mime.TestMtom;
 import org.apache.cxf.mime.types.XopStringType;
+import org.apache.cxf.mtom_xop.TestMtomImpl;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.test.TestUtilities;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.junit.AfterClass;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class ClientMtomXopTest extends AbstractBusClientServerTestBase {
-    public static final String PORT = Server.PORT;
+    public static final String PORT = allocatePort(ClientMtomXopTest.class);
     public static final QName MTOM_PORT = new QName("http://cxf.apache.org/mime", "TestMtomPort");
     public static final QName MTOM_SERVICE = new QName("http://cxf.apache.org/mime", "TestMtomService");
 
+    
+    public static class Server extends AbstractBusTestServerBase {
+        EndpointImpl jaxep;
+        protected void run() {
+            Object implementor = new TestMtomImpl();
+            String address = "http://localhost:" + PORT + "/mime-test";
+            try {
+                jaxep = (EndpointImpl) javax.xml.ws.Endpoint.publish(address, implementor);
+                Endpoint ep = jaxep.getServer().getEndpoint();
+                ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
+                ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
+                
+                SOAPBinding jaxWsSoapBinding = (SOAPBinding) jaxep.getBinding();
+                jaxWsSoapBinding.setMTOMEnabled(true);
+
+            } catch (Exception e) {
+                Thread.currentThread().interrupt();
+            }
+        }
+        public void tearDown() {
+            jaxep.stop();
+            jaxep = null;
+        }
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
-        TestUtilities.setKeepAliveSystemProperty(false);
+        createStaticBus();
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
 
-    @AfterClass
-    public static void cleanup() {
-        TestUtilities.recoverKeepAliveSystemProperty();
-    }
 
     @Test
     public void testMtomXop() throws Exception {
@@ -184,8 +207,8 @@ public class ClientMtomXopTest extends A
 
     private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface,
                                     boolean enableMTOM, boolean installInterceptors) throws Exception {
-        Bus bus = BusFactory.getDefaultBus();
         ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+        Bus bus = getStaticBus();
         serviceFactory.setBus(bus);
         serviceFactory.setServiceName(serviceName);
         serviceFactory.setServiceClass(serviceEndpointInterface);

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java Wed May 23 01:27:13 2012
@@ -36,6 +36,10 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsClientProxy;
 import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
@@ -44,11 +48,10 @@ import org.apache.cxf.mime.TestMtom;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.test.TestUtilities;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
 
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -58,6 +61,34 @@ public class ClientMtomXopWithJMSTest ex
     public static final QName MTOM_PORT = new QName("http://cxf.apache.org/mime", "TestMtomJMSPort");
     public static final QName MTOM_SERVICE = new QName("http://cxf.apache.org/mime", "TestMtomJMSService");
 
+    public static class ServerWithJMS extends AbstractBusTestServerBase {
+        EndpointImpl jaxep;
+        protected void run() {
+            Object implementor = new TestMtomJMSImpl();
+            String address = "http://not.required.for.jms";
+            try {
+                Bus bus = BusFactory.getDefaultBus();
+                setBus(bus);
+                EmbeddedJMSBrokerLauncher.updateWsdlExtensors(bus, "testutils/mtom_xop.wsdl");
+                
+                jaxep = (EndpointImpl) javax.xml.ws.Endpoint.publish(address, implementor);
+                Endpoint ep = jaxep.getServer().getEndpoint();
+                ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
+                ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
+                ep.getInInterceptors().add(new LoggingInInterceptor());
+                ep.getOutInterceptors().add(new LoggingOutInterceptor());
+                SOAPBinding jaxWsSoapBinding = (SOAPBinding) jaxep.getBinding();
+                jaxWsSoapBinding.setMTOMEnabled(true);
+
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+        public void tearDown() {
+            jaxep.stop();
+        }
+
+    }
 
     @BeforeClass
     public static void startServers() throws Exception {
@@ -71,15 +102,10 @@ public class ClientMtomXopWithJMSTest ex
         
         assertTrue("server did not launch correctly", 
                    launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
-        TestUtilities.setKeepAliveSystemProperty(false);
-        assertTrue("server did not launch correctly", launchServer(ServerWithJMS.class));
+        assertTrue("server did not launch correctly", launchServer(ServerWithJMS.class, true));
+        createStaticBus();
     }
     
-    @AfterClass
-    public static void cleanup() {
-        TestUtilities.recoverKeepAliveSystemProperty();
-    }
-
     
     @Test
     public void testMtomXop() throws Exception {
@@ -119,7 +145,7 @@ public class ClientMtomXopWithJMSTest ex
                                     Class<T> serviceEndpointInterface,
                                     boolean enableMTOM)
         throws Exception {
-        Bus bus = BusFactory.getDefaultBus();
+        Bus bus = getStaticBus();
         ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
         serviceFactory.setBus(bus);
         serviceFactory.setServiceName(serviceName);

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java Wed May 23 01:27:13 2012
@@ -30,9 +30,6 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.attachment.AttachmentDeserializer;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
@@ -42,8 +39,8 @@ import org.apache.cxf.message.ExchangeIm
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.test.AbstractCXFTest;
 import org.apache.cxf.test.TestUtilities;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
@@ -51,33 +48,33 @@ import org.apache.cxf.transport.ConduitI
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.WSPolicyFeature;
 import org.apache.cxf.ws.policy.selector.FirstAlternativeSelector;
-import org.junit.AfterClass;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class MtomPolicyTest extends AbstractCXFTest {
+public class MtomPolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = TestUtil.getPortNumber(MtomPolicyTest.class);
-    String address = "http://localhost:" + PORT + "/EchoService";
+    public static final String PORT2 = TestUtil.getPortNumber(MtomPolicyTest.class, 2);
     
+    static TestUtilities testUtilities = new TestUtilities(MtomPolicyTest.class);
+
     @BeforeClass
-    public static void setKeepAliveProperty() {
-        TestUtilities.setKeepAliveSystemProperty(false);
+    public static void createTheBus() throws Exception {
+        createStaticBus();
+        testUtilities.setBus(getStaticBus());
     }
     
-    @AfterClass
-    public static void cleanKeepAliveProperty() {
-        TestUtilities.recoverKeepAliveSystemProperty();
-    }
     
     @Test
     public void testRequiredMtom() throws Exception {
-        setupServer(true);
+        String address = "http://localhost:" + PORT + "/EchoService";
+        setupServer(true, address);
         
         sendMtomMessage(address);
         
-        Node res = invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
+        Node res = testUtilities.invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
         
-        NodeList list = assertValid("//faultstring", res);
+        NodeList list = testUtilities.assertValid("//faultstring", res);
         String text = list.item(0).getTextContent();
         assertTrue(text.contains("These policy alternatives can not be satisfied: "));
         assertTrue(text.contains("{http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization}"
@@ -86,21 +83,22 @@ public class MtomPolicyTest extends Abst
     
     @Test
     public void testOptionalMtom() throws Exception {
-        setupServer(false);
+        String address = "http://localhost:" + PORT2 + "/EchoService";
+        setupServer(false, address);
         
         sendMtomMessage(address);
         
-        Node res = invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
+        Node res = testUtilities.invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
         
-        assertNoFault(res);
+        testUtilities.assertNoFault(res);
     }
     
-    public void setupServer(boolean mtomRequired) throws Exception {
-        getBus().getExtension(PolicyEngine.class).setAlternativeSelector(
+    public void setupServer(boolean mtomRequired, String address) throws Exception {
+        getStaticBus().getExtension(PolicyEngine.class).setAlternativeSelector(
             new FirstAlternativeSelector());
         JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
         sf.setServiceBean(new EchoService());
-        sf.setBus(getBus());
+        sf.setBus(getStaticBus());
         sf.setAddress(address);
         
         WSPolicyFeature policyFeature = new WSPolicyFeature();
@@ -125,11 +123,11 @@ public class MtomPolicyTest extends Abst
         EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/wsdl/http");
         ei.setAddress(a);
 
-        ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
+        ConduitInitiatorManager conduitMgr = getStaticBus().getExtension(ConduitInitiatorManager.class);
         ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
         Conduit conduit = conduitInit.getConduit(ei);
 
-        TestMessageObserver obs = new TestMessageObserver();
+        TestUtilities.TestMessageObserver obs = new TestUtilities.TestMessageObserver();
         conduit.setMessageObserver(obs);
 
         Message m = new MessageImpl();
@@ -142,7 +140,7 @@ public class MtomPolicyTest extends Abst
         conduit.prepare(m);
 
         OutputStream os = m.getContent(OutputStream.class);
-        InputStream is = getResourceAsStream("request");
+        InputStream is = testUtilities.getResourceAsStream("request");
         if (is == null) {
             throw new RuntimeException("Could not find resource " + "request");
         }
@@ -172,9 +170,5 @@ public class MtomPolicyTest extends Abst
         assertEquals(37448, out.size());
     }
 
-    @Override
-    protected Bus createBus() throws BusException {
-        return BusFactory.getDefaultBus();
-    }
 
 }

Modified: cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java?rev=1341706&r1=1341705&r2=1341706&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java Wed May 23 01:27:13 2012
@@ -28,8 +28,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.attachment.AttachmentDeserializer;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.helpers.IOUtils;
@@ -39,8 +37,8 @@ import org.apache.cxf.message.ExchangeIm
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.test.AbstractCXFTest;
 import org.apache.cxf.test.TestUtilities;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
@@ -49,31 +47,30 @@ import org.apache.cxf.transport.Destinat
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.MessageObserver;
-import org.junit.AfterClass;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class MtomServerTest extends AbstractCXFTest {
-    public static final String PORT = TestUtil.getPortNumber(MtomServerTest.class);
+public class MtomServerTest extends AbstractBusClientServerTestBase {
+    public static final String PORT1 = TestUtil.getPortNumber(MtomServerTest.class);
+    public static final String PORT2 = TestUtil.getPortNumber(MtomServerTest.class, 2);
 
     private static final String HTTP_ID = "http://schemas.xmlsoap.org/wsdl/http/";
 
-    @BeforeClass
-    public static void setKeepAliveProperty() {
-        TestUtilities.setKeepAliveSystemProperty(false);
-    }
+    private static TestUtilities testUtilities = new TestUtilities(MtomPolicyTest.class);
 
-    @AfterClass
-    public static void cleanKeepAliveProperty() {
-        TestUtilities.recoverKeepAliveSystemProperty();
+    @BeforeClass
+    public static void createTheBus() throws Exception {
+        createStaticBus();
+        testUtilities.setBus(getStaticBus());
     }
-
+    
     @Test
     public void testMtomRequest() throws Exception {
         JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
         sf.setServiceBean(new EchoService());
-        sf.setBus(getBus());
-        String address = "http://localhost:" + PORT + "/EchoService";
+        sf.setBus(getStaticBus());
+        String address = "http://localhost:" + PORT1 + "/EchoService";
         sf.setAddress(address);
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(Message.MTOM_ENABLED, "true");
@@ -83,11 +80,11 @@ public class MtomServerTest extends Abst
         EndpointInfo ei = new EndpointInfo(null, HTTP_ID);
         ei.setAddress(address);
 
-        ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
+        ConduitInitiatorManager conduitMgr = getStaticBus().getExtension(ConduitInitiatorManager.class);
         ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
         Conduit conduit = conduitInit.getConduit(ei);
 
-        TestMessageObserver obs = new TestMessageObserver();
+        TestUtilities.TestMessageObserver obs = new TestUtilities.TestMessageObserver();
         conduit.setMessageObserver(obs);
 
         Message m = new MessageImpl();
@@ -100,7 +97,7 @@ public class MtomServerTest extends Abst
         conduit.prepare(m);
 
         OutputStream os = m.getContent(OutputStream.class);
-        InputStream is = getResourceAsStream("request");
+        InputStream is = testUtilities.getResourceAsStream("request");
         if (is == null) {
             throw new RuntimeException("Could not find resource " + "request");
         }
@@ -134,8 +131,8 @@ public class MtomServerTest extends Abst
     public void testURLBasedAttachment() throws Exception {
         JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
         sf.setServiceBean(new EchoService());
-        sf.setBus(getBus());
-        String address = "http://localhost:" + PORT + "/EchoService";
+        sf.setBus(getStaticBus());
+        String address = "http://localhost:" + PORT2 + "/EchoService";
         sf.setAddress(address);
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(Message.MTOM_ENABLED, "true");
@@ -144,16 +141,16 @@ public class MtomServerTest extends Abst
         server.getEndpoint().getService().getDataBinding().setMtomThreshold(0);
 
         servStatic(getClass().getResource("mtom-policy.xml"),
-                   "http://localhost:" + PORT + "/policy.xsd");
+                   "http://localhost:" + PORT2 + "/policy.xsd");
 
         EndpointInfo ei = new EndpointInfo(null, HTTP_ID);
         ei.setAddress(address);
 
-        ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
+        ConduitInitiatorManager conduitMgr = getStaticBus().getExtension(ConduitInitiatorManager.class);
         ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
         Conduit conduit = conduitInit.getConduit(ei);
 
-        TestMessageObserver obs = new TestMessageObserver();
+        TestUtilities.TestMessageObserver obs = new TestUtilities.TestMessageObserver();
         conduit.setMessageObserver(obs);
 
         Message m = new MessageImpl();
@@ -166,14 +163,14 @@ public class MtomServerTest extends Abst
         conduit.prepare(m);
 
         OutputStream os = m.getContent(OutputStream.class);
-        InputStream is = getResourceAsStream("request-url-attachment");
+        InputStream is = testUtilities.getResourceAsStream("request-url-attachment");
         if (is == null) {
             throw new RuntimeException("Could not find resource " + "request");
         }
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
         IOUtils.copy(is, bout);
         String s = bout.toString("UTF-8");
-        s = s.replaceAll(":9036/", ":" + PORT + "/");
+        s = s.replaceAll(":9036/", ":" + PORT2 + "/");
 
         os.write(s.getBytes("UTF-8"));
         os.flush();
@@ -199,12 +196,12 @@ public class MtomServerTest extends Abst
         assertTrue("Wrong size: " + out.size()
                    + "\n" + out.toString(),
                    out.size() > 970 && out.size() < 1020);
-        unregisterServStatic("http://localhost:" + PORT + "/policy.xsd");
+        unregisterServStatic("http://localhost:" + PORT2 + "/policy.xsd");
 
     }
 
     private void unregisterServStatic(String add) throws Exception {
-        Bus bus = getBus();
+        Bus bus = getStaticBus();
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
         DestinationFactory df = dfm
             .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
@@ -217,17 +214,12 @@ public class MtomServerTest extends Abst
 
     }
 
-    @Override
-    protected Bus createBus() throws BusException {
-        return BusFactory.getDefaultBus();
-    }
-
     /**
      * Serve static file
      */
     private void servStatic(final URL resource,
                                    final String add) throws Exception {
-        Bus bus = getBus();
+        Bus bus = getStaticBus();
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
         DestinationFactory df = dfm
             .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");