Author: asoldano
Date: 2014-10-01 08:27:58 -0400 (Wed, 01 Oct 2014)
New Revision: 18960
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/CustomBusServletTestCaseForked.java
Modified:
stack/cxf/trunk/modules/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/Helper.java
Log:
[JBWS-3832] Adding testcase
Modified:
stack/cxf/trunk/modules/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
---
stack/cxf/trunk/modules/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2014-10-01
12:23:59 UTC (rev 18959)
+++
stack/cxf/trunk/modules/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2014-10-01
12:27:58 UTC (rev 18960)
@@ -396,6 +396,11 @@
return getDeployer().setSystemProperty(propName, propValue);
}
+ public static void restartServer() throws Exception
+ {
+ getDeployer().restart();
+ }
+
public static abstract class BaseDeployment<T extends
org.jboss.shrinkwrap.api.Archive<T>>
{
protected T archive;
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/CustomBusServletTestCaseForked.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/CustomBusServletTestCaseForked.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/CustomBusServletTestCaseForked.java 2014-10-01
12:27:58 UTC (rev 18960)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.in_container_client;
+import static
org.jboss.wsf.stack.cxf.client.Constants.JBWS_CXF_JAXWS_CLIENT_BUS_SELECTOR;
+
+import java.io.File;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.jboss.ws.common.IOUtils;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
+
+/**
+ * [JBWS-3832] Different default Spring descriptor name
+ * for creating client and server Bus instances
+ *
+ */
+public class CustomBusServletTestCaseForked extends JBossWSTest
+{
+ public static BaseDeployment<?>[] createDeployments() {
+
+ List<BaseDeployment<?>> list = new
LinkedList<BaseDeployment<?>>();
+ list.add(new
JBossWSTestHelper.WarDeployment("jaxws-cxf-in_container_client-client_spring.war")
{ {
+ archive
+ .addManifest()
+ .addAsResource(new File(JBossWSTestHelper.getTestResourcesDir() +
"/jaxws/cxf/in_container_client/cxf.xml"), "cxf.xml")
+ .addAsResource(new File(JBossWSTestHelper.getTestResourcesDir() +
"/jaxws/cxf/in_container_client/cxf-client.xml"), "cxf-client.xml")
+
.addClass(org.jboss.test.ws.jaxws.cxf.in_container_client.HelloWorld.class)
+ .addClass(org.jboss.test.ws.jaxws.cxf.in_container_client.Helper.class)
+ .addClass(org.jboss.wsf.test.ClientHelper.class)
+ .addClass(org.jboss.wsf.test.TestServlet.class)
+ .addAsWebInfResource(new File(JBossWSTestHelper.getTestResourcesDir() +
"/jaxws/cxf/in_container_client/WEB-INF/jboss-deployment-structure.xml"),
"jboss-deployment-structure.xml");
+ }
+ });
+ list.add(new
JBossWSTestHelper.WarDeployment("jaxws-cxf-in_container_client_spring.war") { {
+ archive
+ .addManifest()
+
.addClass(org.jboss.test.ws.jaxws.cxf.in_container_client.HelloWorld.class)
+
.addClass(org.jboss.test.ws.jaxws.cxf.in_container_client.HelloWorldImpl.class);
+ }
+ });
+ return list.toArray(new BaseDeployment<?>[list.size()]);
+ }
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(CustomBusServletTestCaseForked.class,
JBossWSTestHelper.writeToFile(createDeployments())) {
+ /// see
https://issues.jboss.org/browse/JBWS-3832
+ private static final String PROPERTY_NAME =
JBWS_CXF_JAXWS_CLIENT_BUS_SELECTOR;
+ private static final String SPRING_BUS_SELECTOR =
"org.jboss.wsf.stack.cxf.client.SpringCustomClientBusSelector";
+
+ private String formerValue;
+
+ @Override
+ public void setUp() throws Exception {
+ formerValue = JBossWSTestHelper.setSystemProperty(PROPERTY_NAME,
SPRING_BUS_SELECTOR);
+ JBossWSTestHelper.restartServer();
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ JBossWSTestHelper.setSystemProperty(PROPERTY_NAME, formerValue);
+ JBossWSTestHelper.restartServer();
+ formerValue = null;
+ }
+ };
+ }
+
+ public void test() throws Exception
+ {
+ assertEquals("1", runTestInContainer("testSpringBus"));
+ }
+
+ private String runTestInContainer(String test) throws Exception
+ {
+ URL url = new URL("http://" + getServerHost()
+ +
":8080/jaxws-cxf-in_container_client-client_spring?path=/jaxws-cxf-in_container_client_spring/HelloWorldService&method="
+ test
+ + "&helper=" + Helper.class.getName());
+ return IOUtils.readAndCloseStream(url.openStream());
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/CustomBusServletTestCaseForked.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/Helper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/Helper.java 2014-10-01
12:23:59 UTC (rev 18959)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/in_container_client/Helper.java 2014-10-01
12:27:58 UTC (rev 18960)
@@ -30,6 +30,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.jboss.logging.Logger;
+import org.jboss.wsf.stack.cxf.client.ClientBusSelector;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory;
import org.jboss.wsf.test.ClientHelper;
@@ -56,6 +57,8 @@
return false;
}
Bus bus = ((JBossWSBusFactory)factory).createBus("cxf.xml"); //force
Spring bus construction
+ assert bus.getOutInterceptors().isEmpty() == true; // cxf-client.xml bus has at
least one outinterceptor
+
try
{
BusFactory.setThreadDefaultBus(bus);
@@ -70,6 +73,29 @@
}
+ public boolean testSpringBus() throws Exception
+ {
+ BusFactory factory = BusFactory.newInstance();
+ if (!(factory instanceof JBossWSBusFactory)) { //check jbossws-cxf integration is
on
+ log.error("Expected instance of " + JBossWSBusFactory.class + "
but got: " + factory.getClass());
+ return false;
+ }
+ Bus bus = ClientBusSelector.getInstance().createNewBus(); //force Spring bus
construction
+ assert bus.getOutInterceptors().isEmpty() == false; // cxf-client.xml bus has at
least one outinterceptor
+ try
+ {
+ BusFactory.setThreadDefaultBus(bus);
+
+ HelloWorld port = getPort();
+ return ("foo".equals(port.echo("foo")));
+ }
+ finally
+ {
+ bus.shutdown(true);
+ }
+
+ }
+
private HelloWorld getPort() throws MalformedURLException
{
URL wsdlURL = new URL(targetEndpointURL + "?wsdl");