[jbossws-commits] JBossWS SVN: r17347 - stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Feb 26 11:33:54 EST 2013


Author: alessio.soldano at jboss.com
Date: 2013-02-26 11:33:54 -0500 (Tue, 26 Feb 2013)
New Revision: 17347

Modified:
   stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java
   stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java
Log:
[JBWS-3603] Adding some tests...


Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java	2013-02-26 16:32:57 UTC (rev 17346)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java	2013-02-26 16:33:54 UTC (rev 17347)
@@ -52,18 +52,34 @@
       assertTrue(getHelper().testCustomClientConfigurationFromFile());
    }
 
+   public void testCustomClientConfigurationOnDispatchFromFile() throws Exception {
+      assertTrue(getHelper().testCustomClientConfigurationOnDispatchFromFile());
+   }
+
    public void testCustomClientConfigurationFromFileInContainer() throws Exception {
       assertEquals("1", runTestInContainer("testCustomClientConfigurationFromFile"));
    }
    
+   public void testCustomClientConfigurationOnDispatchFromFileInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testCustomClientConfigurationOnDispatchFromFile"));
+   }
+   
    public void testCustomClientConfigurationFromFileUsingFeature() throws Exception {
       assertTrue(getHelper().testCustomClientConfigurationFromFileUsingFeature());
    }
 
+   public void testCustomClientConfigurationOnDispatchFromFileUsingFeature() throws Exception {
+      assertTrue(getHelper().testCustomClientConfigurationOnDispatchFromFileUsingFeature());
+   }
+
    public void testCustomClientConfigurationFromFileUsingFeatureInContainer() throws Exception {
       assertEquals("1", runTestInContainer("testCustomClientConfigurationFromFileUsingFeature"));
    }
    
+   public void testCustomClientConfigurationOnDispatchFromFileUsingFeatureInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testCustomClientConfigurationOnDispatchFromFileUsingFeature"));
+   }
+   
    /**
     * Verifies a client configuration can be changed after another one has been set
     * 
@@ -73,10 +89,18 @@
       assertTrue(getHelper().testConfigurationChange());
    }
 
+   public void testConfigurationChangeOnDispatch() throws Exception {
+      assertTrue(getHelper().testConfigurationChangeOnDispatch());
+   }
+
    public void testConfigurationChangeInContainer() throws Exception {
       assertEquals("1", runTestInContainer("testConfigurationChange"));
    }
 
+   public void testConfigurationChangeOnDispatchInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testConfigurationChangeOnDispatch"));
+   }
+
    /**
     * Verifies the default client configuration from AS model is used
     * 
@@ -88,6 +112,12 @@
       }
    }
    
+   public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
+      if (!isTargetJBoss71()) {
+         assertEquals("1", runTestInContainer("testDefaultClientConfigurationOnDispatch"));
+      }
+   }
+   
    /**
     * Verifies a client configuration from AS model can be set
     * 
@@ -97,10 +127,18 @@
       assertEquals("1", runTestInContainer("testCustomClientConfiguration"));
    }
    
+   public void testCustomClientConfigurationOnDispatchInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testCustomClientConfigurationOnDispatch"));
+   }
+   
    public void testCustomClientConfigurationUsingFeatureInContainer() throws Exception {
       assertEquals("1", runTestInContainer("testCustomClientConfigurationUsingFeature"));
    }
    
+   public void testCustomClientConfigurationOnDispatchUsingFeatureInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testCustomClientConfigurationOnDispatchUsingFeature"));
+   }
+   
    // -------------------------
    
    private Helper getHelper() {

Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java	2013-02-26 16:32:57 UTC (rev 17346)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java	2013-02-26 16:33:54 UTC (rev 17347)
@@ -24,9 +24,13 @@
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
 
 import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.jaxws.DispatchImpl;
 import org.jboss.ws.api.configuration.ClientConfigFeature;
 import org.jboss.ws.api.configuration.ClientConfigUtil;
 import org.jboss.ws.api.configuration.ClientConfigurer;
@@ -41,6 +45,7 @@
 public class Helper implements ClientHelper
 {
    private final QName serviceName = new QName("http://clientConfig.cxf.jaxws.ws.test.jboss.org/", "EndpointImplService");
+   private final QName portName = new QName("http://clientConfig.cxf.jaxws.ws.test.jboss.org/", "EndpointPort");
    private String address;
    
    public boolean testCustomClientConfigurationFromFile() throws Exception
@@ -53,6 +58,16 @@
       return ClientProxy.getClient(port).getEndpoint().get("propA").equals("fileValueA");
    }
    
+   public boolean testCustomClientConfigurationOnDispatchFromFile() throws Exception
+   {
+      Service service = Service.create(new URL(address + "?wsdl"), serviceName);
+      Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
+      
+      ClientConfigUtil.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Custom Client Config");
+      
+      return ((DispatchImpl<?>)dispatch).getClient().getEndpoint().get("propA").equals("fileValueA");
+   }
+   
    public boolean testCustomClientConfigurationFromFileUsingFeature() throws Exception
    {
       Service service = Service.create(new URL(address + "?wsdl"), serviceName);
@@ -61,6 +76,15 @@
       return ClientProxy.getClient(port).getEndpoint().get("propA").equals("fileValueA");
    }
    
+   public boolean testCustomClientConfigurationOnDispatchFromFileUsingFeature() throws Exception
+   {
+      Service service = Service.create(new URL(address + "?wsdl"), serviceName);
+      Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE,
+            new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config", true));
+      
+      return ((DispatchImpl<?>)dispatch).getClient().getEndpoint().get("propA").equals("fileValueA");
+   }
+   
    public boolean testConfigurationChange() throws Exception
    {
       Service service = Service.create(new URL(address + "?wsdl"), serviceName);
@@ -84,6 +108,27 @@
       return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
    }
    
+   public boolean testConfigurationChangeOnDispatch() throws Exception
+   {
+      Service service = Service.create(new URL(address + "?wsdl"), serviceName);
+      Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
+      org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
+      assert(ep.get("propA") == null);
+      assert(ep.get("propB") == null);
+      ep.put("propZ", "valueZ");
+      
+      ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
+      configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Custom Client Config");
+
+      if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
+         return false;
+      }
+      
+      configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Another Client Config");
+      
+      return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
+   }
+   
    /**
     * This test hacks the current ServerConfig temporarily adding a property into the AS default client configuration,
     * verifies the handler is picked up and finally restores the original default client configuration. 
@@ -114,6 +159,29 @@
       }
    }
    
+   public boolean testDefaultClientConfigurationOnDispatch() throws Exception
+   {
+      final URL wsdlURL = new URL(address + "?wsdl");
+      
+      // -- modify default conf --
+      try
+      {
+         TestUtils.getAndVerifyDefaultClientConfiguration().setProperty("propA", "valueA");
+         // --
+         
+         Service service = Service.create(wsdlURL, serviceName);
+         Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
+         
+         return (((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint().get("propA").equals("valueA"));
+      }
+      finally
+      {
+         // -- restore default conf --
+         TestUtils.cleanupClientConfig();
+         // --
+      }
+   }
+   
    /**
     * This test hacks the current ServerConfig temporarily adding a test client configuration, uses that
     * for the test client and finally removes it from the ServerConfig.
@@ -148,6 +216,33 @@
       }
    }
    
+   public boolean testCustomClientConfigurationOnDispatch() throws Exception
+   {
+      final URL wsdlURL = new URL(address + "?wsdl");
+      final String testConfigName = "MyTestConfig";
+      try
+      {
+         //-- add test client configuration
+         TestUtils.addTestCaseClientConfiguration(testConfigName);
+         // --
+         
+         Service service = Service.create(wsdlURL, serviceName);
+         Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
+         org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
+         ep.put("propZ", "valueZ");
+         
+         ClientConfigUtil.setConfigProperties(dispatch, null, testConfigName);
+         
+         return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
+      }
+      finally
+      {
+         // -- remove test client configuration --
+         TestUtils.removeTestCaseClientConfiguration(testConfigName);
+         // --
+      }
+   }
+   
    public boolean testCustomClientConfigurationUsingFeature() throws Exception
    {
       final URL wsdlURL = new URL(address + "?wsdl");
@@ -173,6 +268,31 @@
       }
    }
    
+   public boolean testCustomClientConfigurationOnDispatchUsingFeature() throws Exception
+   {
+      final URL wsdlURL = new URL(address + "?wsdl");
+      final String testConfigName = "MyTestConfig";
+      try
+      {
+         //-- add test client configuration
+         TestUtils.addTestCaseClientConfiguration(testConfigName);
+         // --
+         
+         Service service = Service.create(wsdlURL, serviceName);
+         Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE, new ClientConfigFeature(null, testConfigName, true));
+         org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
+         ep.put("propZ", "valueZ");
+         
+         return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
+      }
+      finally
+      {
+         // -- remove test client configuration --
+         TestUtils.removeTestCaseClientConfiguration(testConfigName);
+         // --
+      }
+   }
+   
    @Override
    public void setTargetEndpoint(String address)
    {



More information about the jbossws-commits mailing list