JBossWS SVN: r16693 - in stack/cxf/trunk/modules: testsuite/cxf-tests/scripts and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-09-04 11:21:03 -0400 (Tue, 04 Sep 2012)
New Revision: 16693
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/
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/Endpoint.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/EndpointImpl.java
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/TestUtils.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/META-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/META-INF/jaxws-client-config.xml
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3529] Adding more tests + removing props from former configuration when setting up those of a new one
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java 2012-09-03 15:43:54 UTC (rev 16692)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -22,8 +22,10 @@
package org.jboss.wsf.stack.cxf.client.configuration;
import java.util.Map;
+import java.util.Set;
import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.ClientProxy;
import org.jboss.ws.common.configuration.ConfigHelper;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
@@ -37,13 +39,37 @@
*/
public class CXFClientConfigurer extends ConfigHelper
{
+ private static final String JBOSSWS_CXF_CLIENT_CONF_PROPS = "jbossws.cxf.client.conf.props";
+
@Override
public void setConfigProperties(Object proxy, String configFile, String configName) {
ClientConfig config = readConfig(configFile, configName);
- setConfigProperties(ClientProxy.getClient(proxy), config.getProperties());
+ Client client = ClientProxy.getClient(proxy);
+ cleanupPreviousProps(client);
+ Map<String, String> props = config.getProperties();
+ if (props != null && !props.isEmpty()) {
+ savePropList(client, props);
+ }
+ setConfigProperties(client, props);
}
public void setConfigProperties(Client client, Map<String, String> properties) {
client.getEndpoint().putAll(properties);
}
+
+ private void savePropList(Client client, Map<String, String> props) {
+ final Set<String> keys = props.keySet();
+ client.getEndpoint().put(JBOSSWS_CXF_CLIENT_CONF_PROPS, (String[])keys.toArray(new String[keys.size()]));
+ }
+
+ private void cleanupPreviousProps(Client client) {
+ Endpoint ep = client.getEndpoint();
+ String[] previousProps = (String[])ep.get(JBOSSWS_CXF_CLIENT_CONF_PROPS);
+ if (previousProps != null) {
+ for (String p : previousProps) {
+ ep.remove(p);
+ }
+ ep.remove(JBOSSWS_CXF_CLIENT_CONF_PROPS);
+ }
+ }
}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-09-03 15:43:54 UTC (rev 16692)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-09-04 15:21:03 UTC (rev 16693)
@@ -84,6 +84,37 @@
prefix="WEB-INF/wsdl"/>
</war>
+ <!-- jaxws-cxf-clientConfig -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-cxf-clientConfig.war" needxmlfile="false">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/cxf/clientConfig/Endpoint*.class" />
+ </classes>
+ </war>
+
+ <!-- jaxws-cxf-clientConfig-inContainer-client -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-cxf-clientConfig-inContainer-client.war" needxmlfile="false">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/cxf/clientConfig/Endpoint.class" />
+ <include name="org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.class" />
+ <include name="org/jboss/test/ws/jaxws/cxf/clientConfig/TestUtils.class" />
+ <include name="org/jboss/wsf/test/TestServlet.class"/>
+ <include name="org/jboss/wsf/test/ClientHelper.class"/>
+ </classes>
+ <classes dir="${tests.output.dir}/test-resources/jaxws/cxf/clientConfig">
+ <include name="META-INF/jaxws-client-config.xml"/>
+ </classes>
+ <manifest>
+ <attribute name="Dependencies" value="org.apache.cxf.impl"/> <!-- Apache CXF impl required for testing purposes -->
+ </manifest>
+ </war>
+
+ <!-- jaxws-cxf-clientConfig-client -->
+ <jar destfile="${tests.output.dir}/test-libs/jaxws-cxf-clientConfig-client.jar">
+ <metainf dir="${tests.output.dir}/test-resources/jaxws/cxf/clientConfig/META-INF">
+ <include name="jaxws-client-config.xml" />
+ </metainf>
+ </jar>
+
<!-- jaxws-cxf-continuations -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-continuations.war" webxml="${tests.output.dir}/test-resources/jaxws/cxf/continuations/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added: 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 (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.clientConfig;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Verifies client configuration setup
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 31-May-2012
+ */
+public class CXFClientConfigurationTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(CXFClientConfigurationTestCase.class, "jaxws-cxf-clientConfig.war,jaxws-cxf-clientConfig-client.jar,jaxws-cxf-clientConfig-inContainer-client.war");
+ }
+
+ /**
+ * Verifies a custom client configuration can be read from conf file and set
+ *
+ * @throws Exception
+ */
+ public void testCustomClientConfigurationFromFile() throws Exception {
+ assertTrue(getHelper().testCustomClientConfigurationFromFile());
+ }
+
+ public void testCustomClientConfigurationFromFileInContainer() throws Exception {
+ assertEquals("1", runTestInContainer("testCustomClientConfigurationFromFile"));
+ }
+
+ /**
+ * Verifies a client configuration can be changed after another one has been set
+ *
+ * @throws Exception
+ */
+ public void testConfigurationChange() throws Exception {
+ assertTrue(getHelper().testConfigurationChange());
+ }
+
+ public void testConfigurationChangeInContainer() throws Exception {
+ assertEquals("1", runTestInContainer("testConfigurationChange"));
+ }
+
+ /**
+ * Verifies the default client configuration from AS model is used
+ *
+ * @throws Exception
+ */
+ public void testDefaultClientConfigurationInContainer() throws Exception {
+ if (!isTargetJBoss71()) {
+ assertEquals("1", runTestInContainer("testDefaultClientConfiguration"));
+ }
+ }
+
+ /**
+ * Verifies a client configuration from AS model can be set
+ *
+ * @throws Exception
+ */
+ public void testCustomClientConfigurationInContainer() throws Exception {
+ assertEquals("1", runTestInContainer("testCustomClientConfiguration"));
+ }
+
+ // -------------------------
+
+ private Helper getHelper() {
+ Helper helper = new Helper();
+ helper.setTargetEndpoint("http://" + getServerHost() + ":8080/jaxws-cxf-clientConfig/EndpointImpl");
+ return helper;
+ }
+
+ private String runTestInContainer(String test) throws Exception
+ {
+ URL url = new URL("http://" + getServerHost()
+ + ":8080/jaxws-cxf-clientConfig-inContainer-client?path=/jaxws-cxf-clientConfig/EndpointImpl&method=" + test
+ + "&helper=" + Helper.class.getName());
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ return br.readLine();
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Endpoint.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Endpoint.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Endpoint.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.clientConfig;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService(name="Endpoint")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Endpoint
+{
+ public String echo(String input);
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/EndpointImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/EndpointImpl.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/EndpointImpl.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.clientConfig;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.logging.Logger;
+
+@WebService(name="Endpoint")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public class EndpointImpl
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(EndpointImpl.class);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ log.info("echo: " + input);
+ return input;
+ }
+}
Added: 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 (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.clientConfig;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.frontend.ClientProxy;
+import org.jboss.ws.api.configuration.ClientConfigUtil;
+import org.jboss.ws.api.configuration.ClientConfigurer;
+import org.jboss.wsf.test.ClientHelper;
+
+/**
+ * Verifies client configuration setup
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 04-Sep-2012
+ */
+public class Helper implements ClientHelper
+{
+ private final QName serviceName = new QName("http://clientConfig.cxf.jaxws.ws.test.jboss.org/", "EndpointImplService");
+ private String address;
+
+ public boolean testCustomClientConfigurationFromFile() throws Exception
+ {
+ Service service = Service.create(new URL(address + "?wsdl"), serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+
+ ClientConfigUtil.setConfigProperties((BindingProvider)port, "META-INF/jaxws-client-config.xml", "Custom Client Config");
+
+ return ClientProxy.getClient(port).getEndpoint().get("propA").equals("fileValueA");
+ }
+
+ public boolean testConfigurationChange() throws Exception
+ {
+ Service service = Service.create(new URL(address + "?wsdl"), serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+ org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(port).getEndpoint();
+ assert(ep.get("propA") == null);
+ assert(ep.get("propB") == null);
+ ep.put("propZ", "valueZ");
+ BindingProvider bp = (BindingProvider)port;
+
+ ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
+ configurer.setConfigProperties(bp, "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;
+ }
+
+ port.echo("Kermit");
+
+ configurer.setConfigProperties(bp, "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.
+ *
+ * @return
+ * @throws Exception
+ */
+ public boolean testDefaultClientConfiguration() throws Exception
+ {
+ final URL wsdlURL = new URL(address + "?wsdl");
+
+ // -- modify default conf --
+ try
+ {
+ TestUtils.getAndVerifyDefaultClientConfiguration().setProperty("propA", "valueA");
+ // --
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+
+ return (ClientProxy.getClient(port).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.
+ *
+ * @return
+ * @throws Exception
+ */
+ public boolean testCustomClientConfiguration() 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);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+ org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(port).getEndpoint();
+ ep.put("propZ", "valueZ");
+
+ ClientConfigUtil.setConfigProperties((BindingProvider)port, null, testConfigName);
+
+ 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)
+ {
+ this.address = address;
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/TestUtils.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/TestUtils.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/TestUtils.java 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.clientConfig;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.metadata.config.ClientConfig;
+
+/**
+ * Support utils for client config testcase
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 04-Sep-2012
+ */
+public class TestUtils
+{
+ public static ClientConfig getAndVerifyDefaultClientConfiguration() throws Exception {
+ ServerConfig sc = getServerConfig();
+ ClientConfig defaultConfig = null;
+ for (ClientConfig c : sc.getClientConfigs()) {
+ if (ClientConfig.STANDARD_CLIENT_CONFIG.equals(c.getConfigName())) {
+ defaultConfig = c;
+ }
+ }
+ if (defaultConfig == null) {
+ throw new Exception("Missing AS client config '" + ClientConfig.STANDARD_CLIENT_CONFIG + "'!");
+ }
+ Map<String, String> props = defaultConfig.getProperties();
+ if (props != null && !props.isEmpty()) {
+ throw new Exception("'" + ClientConfig.STANDARD_CLIENT_CONFIG + "' property set is not empty!");
+ }
+ return defaultConfig;
+ }
+
+ public static void cleanupClientConfig() throws Exception {
+ ServerConfig sc = getServerConfig();
+ ClientConfig defaultConfig = null;
+ for (ClientConfig c : sc.getClientConfigs()) {
+ if (ClientConfig.STANDARD_CLIENT_CONFIG.equals(c.getConfigName())) {
+ defaultConfig = c;
+ }
+ }
+ if (defaultConfig == null) {
+ throw new Exception("Missing AS client config '" + ClientConfig.STANDARD_CLIENT_CONFIG + "'!");
+ }
+ Map<String, String> props = defaultConfig.getProperties();
+ if (props == null || props.isEmpty()) {
+ throw new Exception("'" + ClientConfig.STANDARD_CLIENT_CONFIG + "' property set is already empty!");
+ }
+ props.clear();
+ }
+
+ public static void addTestCaseClientConfiguration(String testConfigName) {
+ ClientConfig config = new ClientConfig();
+ config.setConfigName(testConfigName);
+ config.setProperty("propT", "valueT");
+ getServerConfig().addClientConfig(config);
+ }
+
+ public static void removeTestCaseClientConfiguration(String testConfigName) {
+ Iterator<ClientConfig> it = getServerConfig().getClientConfigs().iterator();
+ while (it.hasNext()) {
+ ClientConfig c = it.next();
+ if (testConfigName.equals(c.getConfigName())) {
+ it.remove();
+ break;
+ }
+ }
+ }
+
+ private static ServerConfig getServerConfig()
+ {
+ final ClassLoader cl = ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
+ return spiProvider.getSPI(ServerConfigFactory.class, cl).getServerConfig();
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/META-INF/jaxws-client-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/META-INF/jaxws-client-config.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/clientConfig/META-INF/jaxws-client-config.xml 2012-09-04 15:21:03 UTC (rev 16693)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
+
+ <client-config>
+ <config-name>Custom Client Config</config-name>
+ <property>
+ <property-name>propA</property-name>
+ <property-value>fileValueA</property-value>
+ </property>
+ <property>
+ <property-name>propB</property-name>
+ <property-value>fileValueB</property-value>
+ </property>
+ </client-config>
+ <client-config>
+ <config-name>Another Client Config</config-name>
+ <property>
+ <property-name>propC</property-name>
+ <property-value>fileValueC</property-value>
+ </property>
+ </client-config>
+
+</jaxws-config>
\ No newline at end of file