Author: asoldano
Date: 2014-01-16 10:04:35 -0500 (Thu, 16 Jan 2014)
New Revision: 18249
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCaseForked.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCaseForked.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
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
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/samples/schemavalidation/Helper.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/TestUtils.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java
Log:
[JBWS-3739][JBWS-3708][JBWS-3707][JBWS-3689] svn merge -r 18113:18144
https://svn.jboss.org/repos/jbossws/stack/cxf/branches/JBWS-3739 .
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -589,12 +589,11 @@
if (jbossModulesEnv) { //optimization for avoiding checking for a server config
when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
if (sc != null) {
- for (ClientConfig config : sc.getClientConfigs()) {
- if (config.getConfigName().equals(ClientConfig.STANDARD_CLIENT_CONFIG))
{
- CXFClientConfigurer helper = new CXFClientConfigurer();
- helper.setupConfigHandlers(binding, config);
- helper.setConfigProperties(client, config.getProperties());
- }
+ ClientConfig config =
sc.getClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG);
+ if (config != null) {
+ CXFClientConfigurer helper = new CXFClientConfigurer();
+ helper.setupConfigHandlers(binding, config);
+ helper.setConfigProperties(client, config.getProperties());
}
}
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, 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.
*
@@ -135,18 +135,10 @@
{
//use endpoint configs from AS domain
ServerConfig sc = AbstractServerConfig.getServerIntegrationServerConfig();
- boolean isSetEndpointConfig = false;
- for (org.jboss.wsf.spi.metadata.config.EndpointConfig config :
sc.getEndpointConfigs())
- {
- if (config.getConfigName().equals(configName))
- {
- endpoint.setEndpointConfig(config);
- isSetEndpointConfig = true;
- break;
- }
- }
-
- if (!isSetEndpointConfig){
+ org.jboss.wsf.spi.metadata.config.EndpointConfig config =
sc.getEndpointConfig(configName);
+ if (config != null) {
+ endpoint.setEndpointConfig(config);
+ } else {
throw Messages.MESSAGES.couldNotFindEndpointConfigName(configName);
}
}
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 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCase.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -100,41 +100,7 @@
public void testConfigurationChangeOnDispatchInContainer() throws Exception {
assertEquals("1",
runTestInContainer("testConfigurationChangeOnDispatch"));
}
-
- /**
- * Verifies the default client configuration from AS model is used
- *
- * @throws Exception
- */
- public void testDefaultClientConfigurationInContainer() throws Exception {
- assertEquals("1",
runTestInContainer("testDefaultClientConfiguration"));
- }
- public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
- assertEquals("1",
runTestInContainer("testDefaultClientConfigurationOnDispatch"));
- }
-
- /**
- * Verifies a client configuration from AS model can be set
- *
- * @throws Exception
- */
- public void testCustomClientConfigurationInContainer() throws Exception {
- 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() {
Copied:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCaseForked.java
(from rev 18144,
stack/cxf/branches/JBWS-3739/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCaseForked.java)
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCaseForked.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/CXFClientConfigurationTestCaseForked.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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 (in-container tests, relying on AS model)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 31-May-2012
+ */
+public class CXFClientConfigurationTestCaseForked extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(CXFClientConfigurationTestCaseForked.class,
"jaxws-cxf-clientConfig.war,jaxws-cxf-clientConfig-client.jar,jaxws-cxf-clientConfig-inContainer-client.war");
+ }
+
+ /**
+ * Verifies the default client configuration from AS model is used
+ *
+ * @throws Exception
+ */
+ public void testDefaultClientConfigurationInContainer() throws Exception {
+ assertEquals("1",
runTestInContainer("testDefaultClientConfiguration"));
+ }
+
+ public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
+ assertEquals("1",
runTestInContainer("testDefaultClientConfigurationOnDispatch"));
+ }
+
+ /**
+ * Verifies a client configuration from AS model can be set
+ *
+ * @throws Exception
+ */
+ public void testCustomClientConfigurationInContainer() throws Exception {
+ 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 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();
+ }
+}
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 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/Helper.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -22,6 +22,8 @@
package org.jboss.test.ws.jaxws.cxf.clientConfig;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
@@ -34,6 +36,7 @@
import org.jboss.ws.api.configuration.ClientConfigFeature;
import org.jboss.ws.api.configuration.ClientConfigUtil;
import org.jboss.ws.api.configuration.ClientConfigurer;
+import org.jboss.wsf.spi.metadata.config.ClientConfig;
import org.jboss.wsf.test.ClientHelper;
/**
@@ -139,11 +142,15 @@
public boolean testDefaultClientConfiguration() throws Exception
{
final URL wsdlURL = new URL(address + "?wsdl");
+ final ClientConfig defaultClientConfig =
TestUtils.getAndVerifyDefaultClientConfiguration();
// -- modify default conf --
try
{
-
TestUtils.getAndVerifyDefaultClientConfiguration().setProperty("propA",
"valueA");
+
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put("propA", "valueA");
+ TestUtils.registerClientConfigAndReload(new
ClientConfig(defaultClientConfig.getConfigName(), null, null, props, null));
// --
Service service = Service.create(wsdlURL, serviceName);
@@ -154,7 +161,7 @@
finally
{
// -- restore default conf --
- TestUtils.cleanupClientConfig();
+ TestUtils.registerClientConfigAndReload(defaultClientConfig);
// --
}
}
@@ -162,11 +169,14 @@
public boolean testDefaultClientConfigurationOnDispatch() throws Exception
{
final URL wsdlURL = new URL(address + "?wsdl");
+ final ClientConfig defaultClientConfig =
TestUtils.getAndVerifyDefaultClientConfiguration();
// -- modify default conf --
try
{
-
TestUtils.getAndVerifyDefaultClientConfiguration().setProperty("propA",
"valueA");
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put("propA", "valueA");
+ TestUtils.registerClientConfigAndReload(new
ClientConfig(defaultClientConfig.getConfigName(), null, null, props, null));
// --
Service service = Service.create(wsdlURL, serviceName);
@@ -177,7 +187,7 @@
finally
{
// -- restore default conf --
- TestUtils.cleanupClientConfig();
+ TestUtils.registerClientConfigAndReload(defaultClientConfig);
// --
}
}
Modified:
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 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/clientConfig/TestUtils.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, 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.
*
@@ -21,7 +21,7 @@
*/
package org.jboss.test.ws.jaxws.cxf.clientConfig;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.Map;
import org.jboss.wsf.spi.SPIProvider;
@@ -41,12 +41,7 @@
{
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;
- }
- }
+ ClientConfig defaultConfig =
sc.getClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG);
if (defaultConfig == null) {
throw new Exception("Missing AS client config '" +
ClientConfig.STANDARD_CLIENT_CONFIG + "'!");
}
@@ -57,45 +52,21 @@
return defaultConfig;
}
- public static void cleanupClientConfig() throws Exception {
+ public static void registerClientConfigAndReload(ClientConfig config) {
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();
+ sc.registerClientConfig(config);
+ sc.reloadClientConfigs();
}
public static void addTestCaseClientConfiguration(String testConfigName) {
- ClientConfig config = new ClientConfig();
- config.setConfigName(testConfigName);
- config.setProperty("propT", "valueT");
- getServerConfig().addClientConfig(config);
+ ClientConfig config = new ClientConfig(testConfigName, null, null,
Collections.singletonMap("propT", "valueT"), null);
+ registerClientConfigAndReload(config);
}
public static void removeTestCaseClientConfiguration(String testConfigName) {
ServerConfig sc = getServerConfig();
- Iterator<ClientConfig> it = sc.getClientConfigs().iterator();
- ClientConfig toBeRemoved = null;
- while (it.hasNext()) {
- ClientConfig c = it.next();
- if (testConfigName.equals(c.getConfigName())) {
- toBeRemoved = c;
- break;
- }
- }
- if (toBeRemoved != null) {
- sc.getClientConfigs().remove(toBeRemoved);
- }
+ sc.unregisterClientConfig(new ClientConfig(testConfigName, null, null, null,
null));
+ sc.reloadClientConfigs();
}
private static ServerConfig getServerConfig()
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/Helper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/Helper.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/Helper.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -22,7 +22,7 @@
package org.jboss.test.ws.jaxws.samples.schemavalidation;
import java.net.URL;
-import java.util.List;
+import java.util.HashMap;
import java.util.Map;
import javax.xml.namespace.QName;
@@ -48,6 +48,8 @@
{
private String address;
+ private static final EndpointConfig defaultEndpointConfig =
getServerConfig().getEndpointConfig(EndpointConfig.STANDARD_ENDPOINT_CONFIG);
+
public boolean testDefaultClientValidation() throws Exception
{
// first verify schema validation is not enabled yet: a wsdl with schema
restrictions is used on client side,
@@ -69,10 +71,11 @@
return false;
}
+ final ClientConfig defClientConfig =
(ClientConfig)getAndVerifyDefaultConfiguration(true);
// then modify default conf to enable default client schema validation
try
{
- modifyDefaultClientConfiguration(getAndVerifyDefaultConfiguration(true));
+ modifyDefaultConfiguration(true);
service = Service.create(wsdlURL, serviceName);
proxy = (Hello) service.getPort(portName, Hello.class);
@@ -95,18 +98,19 @@
finally
{
// -- restore default conf --
- cleanupConfig(true);
+ registerClientConfigAndReload(defClientConfig);
// --
}
}
public boolean enableDefaultEndpointSchemaValidation() throws Exception {
- modifyDefaultClientConfiguration(getAndVerifyDefaultConfiguration(false));
+ getAndVerifyDefaultConfiguration(false);
+ modifyDefaultConfiguration(false);
return true;
}
public boolean disableDefaultEndpointSchemaValidation() throws Exception {
- cleanupConfig(false);
+ registerEndpointConfigAndReload(defaultEndpointConfig);
return true;
}
@@ -116,16 +120,9 @@
this.address = address;
}
- protected static AbstractCommonConfig getAndVerifyDefaultConfiguration(boolean client)
throws Exception {
- ServerConfig sc = getServerConfig();
- AbstractCommonConfig defaultConfig = null;
- final List<? extends AbstractCommonConfig> cfgs = client ?
sc.getClientConfigs() : sc.getEndpointConfigs();
+ protected AbstractCommonConfig getAndVerifyDefaultConfiguration(boolean client) throws
Exception {
final String DEFCFG = client ? ClientConfig.STANDARD_CLIENT_CONFIG :
EndpointConfig.STANDARD_ENDPOINT_CONFIG;
- for (AbstractCommonConfig c : cfgs) {
- if (DEFCFG.equals(c.getConfigName())) {
- defaultConfig = c;
- }
- }
+ final AbstractCommonConfig defaultConfig = client ?
getServerConfig().getClientConfig(DEFCFG) : defaultEndpointConfig;
if (defaultConfig == null) {
throw new Exception("Missing AS config '" + DEFCFG +
"'!");
}
@@ -136,30 +133,28 @@
return defaultConfig;
}
- protected static void modifyDefaultClientConfiguration(AbstractCommonConfig
defaultConfig) {
- defaultConfig.setProperty("schema-validation-enabled",
"true");
+ protected static void modifyDefaultConfiguration(final boolean client) {
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put("schema-validation-enabled", "true");
+ if (client) {
+ registerClientConfigAndReload(new
ClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG, null, null, props, null));
+ } else {
+ registerEndpointConfigAndReload(new
EndpointConfig(EndpointConfig.STANDARD_ENDPOINT_CONFIG, null, null, props, null));
+ }
}
- protected static void cleanupConfig(boolean client) throws Exception {
+ protected static void registerClientConfigAndReload(ClientConfig config) {
ServerConfig sc = getServerConfig();
- AbstractCommonConfig defaultConfig = null;
- final List<? extends AbstractCommonConfig> cfgs = client ?
sc.getClientConfigs() : sc.getEndpointConfigs();
- final String DEFCFG = client ? ClientConfig.STANDARD_CLIENT_CONFIG :
EndpointConfig.STANDARD_ENDPOINT_CONFIG;
- for (AbstractCommonConfig c : cfgs) {
- if (DEFCFG.equals(c.getConfigName())) {
- defaultConfig = c;
- }
- }
- if (defaultConfig == null) {
- throw new Exception("Missing AS config '" + DEFCFG +
"'!");
- }
- Map<String, String> props = defaultConfig.getProperties();
- if (props == null || props.isEmpty()) {
- throw new Exception("'" + DEFCFG + "' is already
empty!");
- }
- props.clear();
+ sc.registerClientConfig(config);
+ sc.reloadClientConfigs();
}
+ protected static void registerEndpointConfigAndReload(EndpointConfig config) {
+ ServerConfig sc = getServerConfig();
+ sc.registerEndpointConfig(config);
+ sc.reloadEndpointConfigs();
+ }
+
private static ServerConfig getServerConfig()
{
final ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, 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.
*
@@ -116,40 +116,6 @@
assertEquals("1",
runTestInContainer("testConfigurationChangeOnDispatch"));
}
- /**
- * Verifies the default client configuration from AS model is used
- *
- * @throws Exception
- */
- public void testDefaultClientConfigurationInContainer() throws Exception {
- assertEquals("1",
runTestInContainer("testDefaultClientConfiguration"));
- }
-
- public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
- assertEquals("1",
runTestInContainer("testDefaultClientConfigurationOnDispatch"));
- }
-
- /**
- * Verifies a client configuration from AS model can be set
- *
- * @throws Exception
- */
- public void testCustomClientConfigurationInContainer() throws Exception {
- 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() {
Copied:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCaseForked.java
(from rev 18144,
stack/cxf/branches/JBWS-3739/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCaseForked.java)
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCaseForked.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCaseForked.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.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 (in-container tests, relying on AS model)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 31-May-2012
+ */
+public class ClientConfigurationTestCaseForked extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(ClientConfigurationTestCaseForked.class,
"jaxws-clientConfig.war,jaxws-clientConfig-client.jar,
jaxws-clientConfig-inContainer-client.war");
+ }
+
+ /**
+ * Verifies the default client configuration from AS model is used
+ *
+ * @throws Exception
+ */
+ public void testDefaultClientConfigurationInContainer() throws Exception {
+ assertEquals("1",
runTestInContainer("testDefaultClientConfiguration"));
+ }
+
+ public void testDefaultClientConfigurationOnDispatchInContainer() throws Exception {
+ assertEquals("1",
runTestInContainer("testDefaultClientConfigurationOnDispatch"));
+ }
+
+ /**
+ * Verifies a client configuration from AS model can be set
+ *
+ * @throws Exception
+ */
+ public void testCustomClientConfigurationInContainer() throws Exception {
+ 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 String runTestInContainer(String test) throws Exception
+ {
+ URL url = new URL("http://" + getServerHost()
+ +
":8080/jaxws-clientConfig-inContainer-client?path=/jaxws-clientConfig/EndpointImpl&method="
+ test
+ + "&helper=" + Helper.class.getName());
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ return br.readLine();
+ }
+}
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -38,6 +38,7 @@
import org.jboss.ws.api.configuration.ClientConfigUtil;
import org.jboss.ws.api.configuration.ClientConfigurer;
import org.jboss.ws.common.DOMUtils;
+import org.jboss.wsf.spi.metadata.config.ClientConfig;
/**
* Verifies client configuration setup
@@ -213,11 +214,12 @@
{
QName serviceName = new
QName("http://clientConfig.jaxws.ws.test.jboss.org/",
"EndpointImplService");
URL wsdlURL = new URL(address + "?wsdl");
+ final ClientConfig defaultClientConfig =
TestUtils.getAndVerifyDefaultClientConfiguration();
// -- modify default conf --
try
{
-
TestUtils.modifyDefaultClientConfiguration(TestUtils.getAndVerifyDefaultClientConfiguration());
+ TestUtils.changeDefaultClientConfiguration();
// --
Service service = Service.create(wsdlURL, serviceName);
@@ -235,7 +237,7 @@
finally
{
// -- restore default conf --
- TestUtils.cleanupClientConfig();
+ TestUtils.setClientConfigAndReload(defaultClientConfig);
// --
}
}
@@ -246,11 +248,12 @@
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 ClientConfig defaultClientConfig =
TestUtils.getAndVerifyDefaultClientConfiguration();
// -- modify default conf --
try
{
-
TestUtils.modifyDefaultClientConfiguration(TestUtils.getAndVerifyDefaultClientConfiguration());
+ TestUtils.changeDefaultClientConfiguration();
// --
Service service = Service.create(wsdlURL, serviceName);
@@ -269,7 +272,7 @@
finally
{
// -- restore default conf --
- TestUtils.cleanupClientConfig();
+ TestUtils.setClientConfigAndReload(defaultClientConfig);
// --
}
}
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/TestUtils.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/TestUtils.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/clientConfig/TestUtils.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2013, 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.
*
@@ -21,7 +21,7 @@
*/
package org.jboss.test.ws.jaxws.clientConfig;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -46,12 +46,7 @@
{
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;
- }
- }
+ ClientConfig defaultConfig =
sc.getClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG);
if (defaultConfig == null) {
throw new Exception("Missing AS client config '" +
ClientConfig.STANDARD_CLIENT_CONFIG + "'!");
}
@@ -63,65 +58,33 @@
return defaultConfig;
}
- public static void modifyDefaultClientConfiguration(ClientConfig defaultConfig) {
- UnifiedHandlerChainMetaData uhcmd = new UnifiedHandlerChainMetaData();
- UnifiedHandlerMetaData handler = new UnifiedHandlerMetaData();
-
handler.setHandlerClass("org.jboss.test.ws.jaxws.clientConfig.LogHandler");
- handler.setHandlerName("Log Handler");
- uhcmd.addHandler(handler);
- List<UnifiedHandlerChainMetaData> postHC = new
LinkedList<UnifiedHandlerChainMetaData>();
- postHC.add(uhcmd);
- defaultConfig.setPostHandlerChains(postHC);
+ public static void changeDefaultClientConfiguration() {
+ UnifiedHandlerMetaData handler = new
UnifiedHandlerMetaData("org.jboss.test.ws.jaxws.clientConfig.LogHandler",
"Log Handler", null, null, null, null);
+ UnifiedHandlerChainMetaData uhcmd = new UnifiedHandlerChainMetaData(null, null,
null, Collections.singletonList(handler), false, null);
+ List<UnifiedHandlerChainMetaData> postHC = Collections.singletonList(uhcmd);
+
+ ClientConfig newDefaultClientConfig = new
ClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG, null, postHC, null, null);
+ setClientConfigAndReload(newDefaultClientConfig);
}
- public static void cleanupClientConfig() throws Exception {
+ public static void setClientConfigAndReload(ClientConfig config) {
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 + "'!");
- }
- List<UnifiedHandlerChainMetaData> preHC =
defaultConfig.getPreHandlerChains();
- List<UnifiedHandlerChainMetaData> postHC =
defaultConfig.getPostHandlerChains();
- if ((preHC == null || preHC.isEmpty()) && (postHC == null ||
postHC.isEmpty())) {
- throw new Exception("'" + ClientConfig.STANDARD_CLIENT_CONFIG +
"' is already empty!");
- }
- defaultConfig.setPostHandlerChains(null);
- defaultConfig.setPreHandlerChains(null);
+ sc.registerClientConfig(config);
+ sc.reloadClientConfigs();
}
public static void addTestCaseClientConfiguration(String testConfigName) {
- UnifiedHandlerChainMetaData uhcmd = new UnifiedHandlerChainMetaData();
- UnifiedHandlerMetaData handler = new UnifiedHandlerMetaData();
-
handler.setHandlerClass("org.jboss.test.ws.jaxws.clientConfig.RoutingHandler");
- handler.setHandlerName("Routing Handler");
- uhcmd.addHandler(handler);
- ClientConfig config = new ClientConfig();
- config.setConfigName(testConfigName);
+ UnifiedHandlerMetaData handler = new
UnifiedHandlerMetaData("org.jboss.test.ws.jaxws.clientConfig.RoutingHandler",
"Routing Handler", null, null, null, null);
+ UnifiedHandlerChainMetaData uhcmd = new UnifiedHandlerChainMetaData(null, null,
null, Collections.singletonList(handler), false, null);
List<UnifiedHandlerChainMetaData> preHC = new
LinkedList<UnifiedHandlerChainMetaData>();
preHC.add(uhcmd);
- config.setPreHandlerChains(preHC);
- getServerConfig().addClientConfig(config);
+ setClientConfigAndReload(new ClientConfig(testConfigName, preHC, null, null,
null));
}
public static void removeTestCaseClientConfiguration(String testConfigName) {
ServerConfig sc = getServerConfig();
- Iterator<ClientConfig> it = sc.getClientConfigs().iterator();
- ClientConfig toBeRemoved = null;
- while (it.hasNext()) {
- ClientConfig c = it.next();
- if (testConfigName.equals(c.getConfigName())) {
- toBeRemoved = c;
- break;
- }
- }
- if (toBeRemoved != null) {
- sc.getClientConfigs().remove(toBeRemoved);
- }
+ sc.unregisterClientConfig(new ClientConfig(testConfigName, null, null, null,
null));
+ sc.reloadClientConfigs();
}
private static ServerConfig getServerConfig()
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java 2014-01-16
14:50:38 UTC (rev 18248)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java 2014-01-16
15:04:35 UTC (rev 18249)
@@ -144,31 +144,28 @@
// | /some/complex/pattern/* | foo.Bar | some.complex.pattern | used pattern
url with dots instead of / and removed all wildcards |
//
+-------------------------+----------------+----------------------+-------------------------------------------------------------------+
private WebservicesMetaData createMetaData() {
- WebservicesMetaData metadata = new WebservicesMetaData();
- WebserviceDescriptionMetaData webserviceDescription = new
WebserviceDescriptionMetaData(metadata);
- metadata.addWebserviceDescription(webserviceDescription);
- webserviceDescription.setWsdlFile("WEB-INF/wsdl/EndpointImpl4.xml");
- PortComponentMetaData portComponent = new
PortComponentMetaData(webserviceDescription);
- portComponent.setPortComponentName("PortComponent4"); //unique ID
-
portComponent.setServiceEndpointInterface("org.jboss.test.ws.publish.EndpointImpl4");
- portComponent.setWsdlPort(new
QName("http://publish.ws.test.jboss.org/",
"EndpointPort4"));
- portComponent.setWsdlService(new
QName("http://publish.ws.test.jboss.org/", "EndpointService4"));
- // mandatory servlet link (because endpoint is POJO) - needed for proper matching
of endpoint with WebservicesMD
- portComponent.setServletLink("pattern4");
- // if endpoint ^ would be EJB, users have to use setEjbLink() method instead
- webserviceDescription.addPortComponent(portComponent);
- WebserviceDescriptionMetaData webserviceDescription2 = new
WebserviceDescriptionMetaData(metadata);
- metadata.addWebserviceDescription(webserviceDescription2);
-
webserviceDescription2.setWsdlFile("org/jboss/test/ws/publish/EndpointImpl5.xml");
//test JBWS-3540
- PortComponentMetaData portComponent2 = new
PortComponentMetaData(webserviceDescription2);
- portComponent2.setPortComponentName("PortComponent5"); //unique ID
-
portComponent2.setServiceEndpointInterface("org.jboss.test.ws.publish.EndpointImpl5");
- portComponent2.setWsdlPort(new
QName("http://publish.ws.test.jboss.org/",
"EndpointPort5"));
- portComponent2.setWsdlService(new
QName("http://publish.ws.test.jboss.org/", "EndpointService5"));
- // mandatory servlet link (because endpoint is POJO) - needed for proper matching
of endpoint with WebservicesMD
- portComponent2.setServletLink("pattern5");
- // if endpoint ^ would be EJB, users have to use setEjbLink() method instead
- webserviceDescription2.addPortComponent(portComponent2);
+ PortComponentMetaData portComponent = new
PortComponentMetaData("PortComponent4", //unique ID
+ new
QName("http://publish.ws.test.jboss.org/","EndpointPort4&q...,
+ "org.jboss.test.ws.publish.EndpointImpl4",
+ null, // if endpoint ^ was an EJB, user would have to use this parameter to
set ejbLink
+ "pattern4", // mandatory servlet link (because endpoint is POJO) -
needed for proper matching of endpoint with WebservicesMD
+ null, null,
+ new
QName("http://publish.ws.test.jboss.org/",
"EndpointService4"),
+ null, null);
+ WebserviceDescriptionMetaData webserviceDescription = new
WebserviceDescriptionMetaData(null, "WEB-INF/wsdl/EndpointImpl4.xml", null,
portComponent);
+
+ PortComponentMetaData portComponent2 = new
PortComponentMetaData("PortComponent5", //unique ID
+ new
QName("http://publish.ws.test.jboss.org/","EndpointPort5&q...,
+ "org.jboss.test.ws.publish.EndpointImpl5",
+ null, // if endpoint ^ was an EJB, user would have to use this parameter to
set ejbLink
+ "pattern5", // mandatory servlet link (because endpoint is POJO) -
needed for proper matching of endpoint with WebservicesMD
+ null, null,
+ new
QName("http://publish.ws.test.jboss.org/",
"EndpointService5"),
+ null, null);
+ WebserviceDescriptionMetaData webserviceDescription2 = new
WebserviceDescriptionMetaData(null,
"org/jboss/test/ws/publish/EndpointImpl5.xml", //test JBWS-3540
+ null, portComponent2);
+
+ WebservicesMetaData metadata = new WebservicesMetaData(null, new
WebserviceDescriptionMetaData[]{webserviceDescription, webserviceDescription2});
return metadata;
}