[jbossws-commits] JBossWS SVN: r19217 - in stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws: samples/soapbinding and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Dec 23 03:57:53 EST 2014


Author: jim.ma
Date: 2014-12-23 03:57:53 -0500 (Tue, 23 Dec 2014)
New Revision: 19217

Modified:
   stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
   stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/soapbinding/SOAPBindingTestCase.java
Log:
Convert tests to run with Arquillian

Modified: stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
===================================================================
--- stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java	2014-12-23 02:24:26 UTC (rev 19216)
+++ stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java	2014-12-23 08:57:53 UTC (rev 19217)
@@ -24,7 +24,6 @@
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.LinkedList;
 import java.util.List;
 
 import javax.wsdl.Binding;
@@ -40,12 +39,16 @@
 import javax.xml.ws.Service;
 import javax.xml.ws.handler.Handler;
 
-import junit.framework.Test;
-
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.jboss.wsf.test.JBossWSTest;
 import org.jboss.wsf.test.JBossWSTestHelper;
-import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
-import org.jboss.wsf.test.JBossWSTestSetup;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 /**
  * Test SOAP12 binding type
@@ -53,34 +56,29 @@
  * @author Thomas.Diesler at jboss.org
  * @since 12-Aug-2006
  */
+ at RunWith(Arquillian.class)
 public class SOAPBindingTestCase extends JBossWSTest
 {
-   public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-binding";
-
-   public static BaseDeployment<?>[] createDeployments() {
-      List<BaseDeployment<?>> list = new LinkedList<BaseDeployment<?>>();
-      list.add(new JBossWSTestHelper.WarDeployment("jaxws-binding.war") { {
-         archive
-               .addManifest()
-               .addClass(org.jboss.test.ws.jaxws.binding.SOAPEndpoint.class)
-               .addClass(org.jboss.test.ws.jaxws.binding.SOAPEndpointBean.class)
-               .addClass(org.jboss.test.ws.jaxws.binding.ServerHandler.class)
-               .addAsResource("org/jboss/test/ws/jaxws/binding/jaxws-server-handlers.xml")
-               .setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/binding/WEB-INF/web.xml"));
-         }
-      });
-      return list.toArray(new BaseDeployment<?>[list.size()]);
-   }
-   
-   public static Test suite()
-   {
-      return new JBossWSTestSetup(SOAPBindingTestCase.class, JBossWSTestHelper.writeToFile(createDeployments()));
-   }
-
+   @ArquillianResource
+   private URL baseURL;
+   @Deployment(testable = false)
+   public static WebArchive createDeployment() {
+      WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxws-binding.war");
+      archive
+            .addManifest()
+            .addClass(org.jboss.test.ws.jaxws.binding.SOAPEndpoint.class)
+            .addClass(org.jboss.test.ws.jaxws.binding.SOAPEndpointBean.class)
+            .addClass(org.jboss.test.ws.jaxws.binding.ServerHandler.class)
+            .addAsResource("org/jboss/test/ws/jaxws/binding/jaxws-server-handlers.xml")
+            .setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/binding/WEB-INF/web.xml"));
+      return archive;
+   }   
    // [JBWS-1761] - WSProvide ignores SOAPBinding declaration
+   @Test
+   @RunAsClient
    public void testWSDLAccess() throws Exception
    {
-      URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+      URL wsdlURL = new URL(baseURL + "?wsdl");
 
       WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
       Definition wsdl = wsdlReader.readWSDL(wsdlURL.toString());
@@ -114,10 +112,11 @@
          assertEquals("Invalid transport uri", "http://schemas.xmlsoap.org/soap/http", transport);
       }
    }
-
+   @Test
+   @RunAsClient
    public void testClientAccess() throws Exception
    {
-      URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+      URL wsdlURL = new URL(baseURL + "?wsdl");
       QName qname = new QName("http://org.jboss.ws/jaxws/binding", "SOAPEndpointService");
       Service service = Service.create(wsdlURL, qname);
       SOAPEndpoint port = service.getPort(SOAPEndpoint.class);

Modified: stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/soapbinding/SOAPBindingTestCase.java
===================================================================
--- stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/soapbinding/SOAPBindingTestCase.java	2014-12-23 02:24:26 UTC (rev 19216)
+++ stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/soapbinding/SOAPBindingTestCase.java	2014-12-23 08:57:53 UTC (rev 19217)
@@ -24,8 +24,6 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.net.URL;
-import java.util.LinkedList;
-import java.util.List;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
@@ -38,12 +36,16 @@
 import javax.xml.ws.Service;
 import javax.xml.ws.Service.Mode;
 
-import junit.framework.Test;
-
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.jboss.wsf.test.JBossWSTest;
 import org.jboss.wsf.test.JBossWSTestHelper;
-import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
-import org.jboss.wsf.test.JBossWSTestSetup;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 /**
  * Test the JSR-181 annotation: javax.jws.SOAPBinding
@@ -52,42 +54,42 @@
  * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
  * @since 17-Oct-2005
  */
+ at RunWith(Arquillian.class)
 public class SOAPBindingTestCase extends JBossWSTest
 {
+   @ArquillianResource
+   private URL baseURL;	
    private final String targetNS = "http://soapbinding.samples.jaxws.ws.test.jboss.org/";
 
-   public static BaseDeployment<?>[] createDeployments() {
-      List<BaseDeployment<?>> list = new LinkedList<BaseDeployment<?>>();
-      list.add(new JBossWSTestHelper.WarDeployment("jaxws-samples-soapbinding.war") { {
-         archive
-               .addManifest()
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocBare.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocBareServiceImpl.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocWrapped.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocWrappedServiceImpl.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.ExampleSEI.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.ExampleServiceImpl.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.SubmitBareRequest.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.SubmitBareResponse.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitNamespacedPO.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitNamespacedPOResponse.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitPO.class)
-               .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitPOResponse.class)
-               .setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/soapbinding/WEB-INF/web.xml"));
-         }
-      });
-      return list.toArray(new BaseDeployment<?>[list.size()]);
-   }
 
-   public static Test suite()
-   {
-      return new JBossWSTestSetup(SOAPBindingTestCase.class, JBossWSTestHelper.writeToFile(createDeployments()));
-   }
+   @Deployment(testable = false)
+   public static WebArchive createDeployment() {
+      WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxws-samples-soapbinding.war");
+      archive
+            .addManifest()
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocBare.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocBareServiceImpl.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocWrapped.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.DocWrappedServiceImpl.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.ExampleSEI.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.ExampleServiceImpl.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.SubmitBareRequest.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.SubmitBareResponse.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitNamespacedPO.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitNamespacedPOResponse.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitPO.class)
+            .addClass(org.jboss.test.ws.jaxws.samples.soapbinding.jaxws.SubmitPOResponse.class)
+            .setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/soapbinding/WEB-INF/web.xml"));
 
+      return archive;
+   } 
+
+   @Test
+   @RunAsClient
    public void testExampleService() throws Exception
    {
       QName serviceName = new QName(targetNS, "ExampleService");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/ExampleService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/ExampleService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       ExampleSEI port = service.getPort(ExampleSEI.class);
@@ -95,11 +97,12 @@
       Object retObj = port.concat("first", "second", "third");
       assertEquals("first|second|third", retObj);
    }
-
+   @Test
+   @RunAsClient
    public void testDocBareService() throws Exception
    {
       QName serviceName = new QName(targetNS, "DocBareService");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocBareService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       DocBare port = service.getPort(DocBare.class);
@@ -108,12 +111,13 @@
       SubmitBareResponse poRes = port.submitPO(poReq);
       assertEquals("Ferrari", poRes.getProduct());
    }
-
+   @Test
+   @RunAsClient
    public void testDocBareDispatchService() throws Exception
    {
       QName serviceName = new QName(targetNS, "DocBareService");
       QName portName = new QName(targetNS, "DocBarePort");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocBareService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       JAXBContext jbc = JAXBContext.newInstance(new Class[] { SubmitBareRequest.class, SubmitBareResponse.class });
@@ -125,12 +129,13 @@
       SubmitBareResponse poRes = (SubmitBareResponse)dispatch.invoke(poReq);
       assertEquals("Ferrari", poRes.getProduct());
    }
-
+   @Test
+   @RunAsClient
    public void testDocBareServiceMessageAccess() throws Exception
    {
       QName serviceName = new QName(targetNS, "DocBareService");
       QName portName = new QName(targetNS, "DocBarePort");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocBareService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
@@ -153,12 +158,13 @@
       soapElement = (SOAPElement)soapElement.getChildElements(new QName(targetNS, "product")).next();
       assertEquals("Ferrari", soapElement.getValue());
    }
-
+   @Test
+   @RunAsClient
    public void testNamespacedDocBareServiceMessageAccess() throws Exception
    {
       QName serviceName = new QName(targetNS, "DocBareService");
       QName portName = new QName(targetNS, "DocBarePort");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocBareService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
@@ -184,11 +190,12 @@
       soapElement = (SOAPElement)soapElement.getChildElements(new QName(targetNS, "product")).next();
       assertEquals("Ferrari", soapElement.getValue());
    }
-
+   @Test
+   @RunAsClient
    public void testDocWrappedService() throws Exception
    {
       QName serviceName = new QName(targetNS, "DocWrappedService");
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocWrappedService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocWrappedService?wsdl");
 
       Service service = Service.create(wsdlURL, serviceName);
       DocWrapped port = service.getPort(DocWrapped.class);
@@ -199,7 +206,8 @@
       poRes = port.submitNamespacedPO("Ferrari", "message");
       assertEquals("Ferrari", poRes);
    }
-
+   @Test
+   @RunAsClient
    public void testDocWrappedServiceMessageAccess() throws Exception
    {
       MessageFactory msgFactory = MessageFactory.newInstance();
@@ -215,7 +223,7 @@
       "</env:Envelope>";
       SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
 
-      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocWrappedService?wsdl");
+      URL wsdlURL = new URL(baseURL + "/DocWrappedService?wsdl");
       QName serviceName = new QName(targetNS, "DocWrappedService");
       QName portName = new QName(targetNS, "DocWrappedPort");
       Service service = Service.create(wsdlURL, serviceName);
@@ -228,7 +236,8 @@
       soapElement = (SOAPElement)soapElement.getChildElements(new QName("PurchaseOrderAck")).next();
       assertEquals("Ferrari", soapElement.getValue());
    }
-
+   @Test
+   @RunAsClient
    public void testNamespacedDocWrappedServiceMessageAccess() throws Exception
    {
       MessageFactory msgFactory = MessageFactory.newInstance();
@@ -249,7 +258,7 @@
       " </env:Body>" +
       "</env:Envelope>";
       SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
-      URL epURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocWrappedService");
+      URL epURL = new URL(baseURL + "/DocWrappedService");
 
       SOAPMessage resMsg = con.call(reqMsg, epURL);
 



More information about the jbossws-commits mailing list