[jbossws-commits] JBossWS SVN: r17350 - in shared-testsuite/trunk/testsuite/src/test: java/org/jboss/test/ws/jaxws/clientConfig and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Feb 26 12:28:28 EST 2013


Author: alessio.soldano at jboss.com
Date: 2013-02-26 12:28:27 -0500 (Tue, 26 Feb 2013)
New Revision: 17350

Modified:
   shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml
   shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java
   shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
Log:
[JBWS-3603] Further tests


Modified: shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml	2013-02-26 16:35:29 UTC (rev 17349)
+++ shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml	2013-02-26 17:28:27 UTC (rev 17350)
@@ -132,6 +132,9 @@
 			<classes dir="${tests.output.dir}/test-resources/jaxws/clientConfig">
 				<include name="META-INF/jaxws-client-config.xml"/>
 			</classes>
+                        <manifest>
+                                <attribute name="Dependencies" value="org.jboss.ws.common"/>
+                        </manifest>
 		</war>
 		
         <!-- jaxws-clientConfig-client -->

Modified: shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java	2013-02-26 16:35:29 UTC (rev 17349)
+++ shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java	2013-02-26 17:28:27 UTC (rev 17350)
@@ -67,18 +67,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().testCustomClientConfigurationFromFile());
+      assertTrue(getHelper().testCustomClientConfigurationFromFileUsingFeature());
    }
 
+   public void testCustomClientConfigurationFromFileUsingFeatureOnDispatch() throws Exception {
+      assertTrue(getHelper().testCustomClientConfigurationFromFileUsingFeatureOnDispatch());
+   }
+
    public void testCustomClientConfigurationFromFileUsingFeatureInContainer() throws Exception {
       assertEquals("1", runTestInContainer("testCustomClientConfigurationFromFileUsingFeature"));
    }
    
+   public void testCustomClientConfigurationFromFileUsingFeatureOnDispatchInContainer() throws Exception {
+      assertEquals("1", runTestInContainer("testCustomClientConfigurationFromFileUsingFeatureOnDispatch"));
+   }
+   
    /**
     * Verifies a client configuration can be changed after another one has been set
     * 
@@ -88,10 +104,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
     * 
@@ -103,6 +127,12 @@
       }
    }
    
+   public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
+      if (!isTargetJBoss71()) {
+         assertEquals("1", runTestInContainer("testDefaultClientConfigurationOnDispatch"));
+      }
+   }
+   
    /**
     * Verifies a client configuration from AS model can be set
     * 
@@ -112,10 +142,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: shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java	2013-02-26 16:35:29 UTC (rev 17349)
+++ shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java	2013-02-26 17:28:27 UTC (rev 17350)
@@ -25,14 +25,20 @@
 import java.util.List;
 
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
 import javax.xml.ws.handler.Handler;
 
 import org.jboss.test.helper.ClientHelper;
 import org.jboss.ws.api.configuration.ClientConfigFeature;
 import org.jboss.ws.api.configuration.ClientConfigUtil;
 import org.jboss.ws.api.configuration.ClientConfigurer;
+import org.jboss.ws.common.DOMUtils;
+import org.w3c.dom.Element;
 
 /**
  * Verifies client configuration setup
@@ -73,6 +79,29 @@
       return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
    }
    
+   public boolean testCustomClientConfigurationOnDispatchFromFile() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      URL wsdlURL = new URL(address + "?wsdl");
+
+      Service service = Service.create(wsdlURL, serviceName);
+      Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+      
+      BindingProvider bp = (BindingProvider)dispatch;
+      @SuppressWarnings("rawtypes")
+      List<Handler> hc = bp.getBinding().getHandlerChain();
+      hc.add(new UserHandler());
+      bp.getBinding().setHandlerChain(hc);
+      
+      ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
+
+      Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+      String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+      return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
+   }
+   
    public boolean testCustomClientConfigurationFromFileUsingFeature() throws Exception
    {
       QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
@@ -91,6 +120,28 @@
       return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
    }
    
+   public boolean testCustomClientConfigurationFromFileUsingFeatureOnDispatch() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      URL wsdlURL = new URL(address + "?wsdl");
+
+      Service service = Service.create(wsdlURL, serviceName);
+      Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD,
+            new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));
+      
+      BindingProvider bp = (BindingProvider)dispatch;
+      @SuppressWarnings("rawtypes")
+      List<Handler> hc = bp.getBinding().getHandlerChain();
+      hc.add(new UserHandler());
+      bp.getBinding().setHandlerChain(hc);
+      
+      Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+      String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+      return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
+   }
+   
    public boolean testConfigurationChange() throws Exception
    {
       QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
@@ -119,6 +170,38 @@
       return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
    }
    
+   public boolean testConfigurationChangeOnDispatch() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      URL wsdlURL = new URL(address + "?wsdl");
+
+      Service service = Service.create(wsdlURL, serviceName);
+      Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+      
+      BindingProvider bp = (BindingProvider)dispatch;
+      @SuppressWarnings("rawtypes")
+      List<Handler> hc = bp.getBinding().getHandlerChain();
+      hc.add(new UserHandler());
+      bp.getBinding().setHandlerChain(hc);
+      
+      ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
+      configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
+
+      Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+      String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+      if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
+         return false;
+      }
+      
+      configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Another Client Config");
+      
+      resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+      resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+      return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
+   }
+   
    /**
     * This test hacks the current ServerConfig temporarily adding an handler from this testcase deployment
     * into the AS default client configuration, verifies the handler is picked up and finally restores the
@@ -158,6 +241,40 @@
       }
    }
    
+   public boolean testDefaultClientConfigurationOnDispatch() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      URL wsdlURL = new URL(address + "?wsdl");
+      
+      // -- modify default conf --
+      try
+      {
+         TestUtils.modifyDefaultClientConfiguration(TestUtils.getAndVerifyDefaultClientConfiguration());
+         // --
+         
+         Service service = Service.create(wsdlURL, serviceName);
+         Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+         
+         BindingProvider bp = (BindingProvider)dispatch;
+         @SuppressWarnings("rawtypes")
+         List<Handler> hc = bp.getBinding().getHandlerChain();
+         hc.add(new UserHandler());
+         bp.getBinding().setHandlerChain(hc);
+         
+         Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+         String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+         return ("Kermit|UserOut|LogOut|endpoint|LogIn|UserIn".equals(resStr));
+      }
+      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.
@@ -199,6 +316,43 @@
       }
    }
    
+   public boolean testCustomClientConfigurationOnDispatch() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      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<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+         
+         BindingProvider bp = (BindingProvider)dispatch;
+         @SuppressWarnings("rawtypes")
+         List<Handler> hc = bp.getBinding().getHandlerChain();
+         hc.add(new UserHandler());
+         bp.getBinding().setHandlerChain(hc);
+         
+         ClientConfigUtil.setConfigHandlers(bp, null, testConfigName);
+         
+         Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+         String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+         return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
+      }
+      finally
+      {
+         // -- remove test client configuration --
+         TestUtils.removeTestCaseClientConfiguration(testConfigName);
+         // --
+      }
+   }
+   
    public boolean testCustomClientConfigurationUsingFeature() throws Exception
    {
       QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
@@ -231,6 +385,41 @@
       }
    }
    
+   public boolean testCustomClientConfigurationOnDispatchUsingFeature() throws Exception
+   {
+      final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
+      QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
+      QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
+      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<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD, new ClientConfigFeature(null, testConfigName));
+         
+         BindingProvider bp = (BindingProvider)dispatch;
+         @SuppressWarnings("rawtypes")
+         List<Handler> hc = bp.getBinding().getHandlerChain();
+         hc.add(new UserHandler());
+         bp.getBinding().setHandlerChain(hc);
+         
+         Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
+         String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
+         return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
+      }
+      finally
+      {
+         // -- remove test client configuration --
+         TestUtils.removeTestCaseClientConfiguration(testConfigName);
+         // --
+      }
+   }
+   
    @Override
    public void setTargetEndpoint(String address)
    {



More information about the jbossws-commits mailing list