Author: alessio.soldano(a)jboss.com
Date: 2012-06-08 05:57:54 -0400 (Fri, 08 Jun 2012)
New Revision: 16400
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/Helper.java
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/clientConfig/META-INF/jaxws-client-config.xml
Log:
[JBWS-3335] Adding testcase for client configuration change
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 2012-06-08
09:57:08 UTC (rev 16399)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/ClientConfigurationTestCase.java 2012-06-08
09:57:54 UTC (rev 16400)
@@ -43,25 +43,48 @@
return new JBossWSTestSetup(ClientConfigurationTestCase.class,
"jaxws-clientConfig.war,jaxws-clientConfig-client.jar,
jaxws-clientConfig-inContainer-client.war");
}
+ /**
+ * Verifies the client configurer is properly resolved
+ */
public void testClientConfigurer() {
- Helper helper = new Helper();
- assertTrue(helper.testClientConfigurer());
+ assertTrue(getHelper().testClientConfigurer());
}
-
- public void testCustomClientConfiguration() throws Exception {
- Helper helper = new Helper();
- helper.setTargetEndpoint("http://" + getServerHost() +
":8080/jaxws-clientConfig/EndpointImpl");
- assertTrue(helper.testCustomClientConfigurationFromFile());
- }
public void testClientConfigurerInContainer() throws Exception {
assertEquals("1", runTestInContainer("testClientConfigurer"));
}
+ /**
+ * 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 (true) {
System.out.println("FIXME: [JBWS-3335] Add client-configuration to AS7
domain model");
@@ -70,10 +93,23 @@
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-clientConfig/EndpointImpl");
+ return helper;
+ }
+
private String runTestInContainer(String test) throws Exception
{
URL url = new URL("http://" + getServerHost()
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 2012-06-08
09:57:08 UTC (rev 16399)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/clientConfig/Helper.java 2012-06-08
09:57:54 UTC (rev 16400)
@@ -87,6 +87,34 @@
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");
+ URL wsdlURL = new URL(address + "?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Endpoint port = (Endpoint)service.getPort(Endpoint.class);
+
+ BindingProvider bp = (BindingProvider)port;
+ @SuppressWarnings("rawtypes")
+ List<Handler> hc = bp.getBinding().getHandlerChain();
+ hc.add(new UserHandler());
+ bp.getBinding().setHandlerChain(hc);
+
+ ClientConfigurer configurer =
ServiceLoader.load(ClientConfigurer.class).iterator().next();
+ configurer.addConfigHandlers(bp, "META-INF/jaxws-client-config.xml",
"Custom Client Config");
+
+ String resStr = port.echo("Kermit");
+ if
(!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr))
{
+ return false;
+ }
+
+ configurer.addConfigHandlers(bp, "META-INF/jaxws-client-config.xml",
"Another Client Config");
+
+ resStr = port.echo("Kermit");
+ 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
Modified:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/clientConfig/META-INF/jaxws-client-config.xml
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/clientConfig/META-INF/jaxws-client-config.xml 2012-06-08
09:57:08 UTC (rev 16399)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/clientConfig/META-INF/jaxws-client-config.xml 2012-06-08
09:57:54 UTC (rev 16400)
@@ -26,5 +26,16 @@
</javaee:handler-chain>
</post-handler-chains>
</client-config>
+ <client-config>
+ <config-name>Another Client Config</config-name>
+ <pre-handler-chains>
+ <javaee:handler-chain>
+ <javaee:handler>
+ <javaee:handler-name>Routing Handler</javaee:handler-name>
+
<javaee:handler-class>org.jboss.test.ws.jaxws.clientConfig.RoutingHandler</javaee:handler-class>
+ </javaee:handler>
+ </javaee:handler-chain>
+ </pre-handler-chains>
+ </client-config>
</jaxws-config>
\ No newline at end of file