[jbossws-commits] JBossWS SVN: r10837 - in stack/native/branches/ropalka/modules/testsuite/native-tests/src/test: java/org/jboss/test/ws/jaxws/endpoint/jse and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Oct 6 02:55:31 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-10-06 02:55:31 -0400 (Tue, 06 Oct 2009)
New Revision: 10837

Added:
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/resources/jaxws/endpoint/attachment.txt
Modified:
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/interop/wsa/AddressingTestCase.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java
Log:
[JBWS-2674][JBWS-2754] providing attachment test case (WIP)

Modified: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/interop/wsa/AddressingTestCase.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/interop/wsa/AddressingTestCase.java	2009-10-06 06:41:37 UTC (rev 10836)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/interop/wsa/AddressingTestCase.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -35,7 +35,6 @@
 import javax.xml.ws.addressing.*;
 import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
 import javax.xml.ws.soap.SOAPFaultException;
-import java.io.File;
 import java.net.URI;
 import java.net.URL;
 import java.util.List;
@@ -90,12 +89,12 @@
 
          ((BindingProvider)echoPort).getRequestContext().put(
 					BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
-					"http://"+getServerHost()+":8080/wsa10/echo"
+					"http://"+getInteropServerHost()+":8080/wsa10/echo"
 			);
 
 			((BindingProvider)notifyPort).getRequestContext().put(
 					BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
-					"http://"+getServerHost()+":8080/wsa10/notify"
+					"http://"+getInteropServerHost()+":8080/wsa10/notify"
 			);
 
          configureClient();
@@ -112,11 +111,11 @@
    private void configureClient() {
 
       ((BindingProvider)echoPort).getRequestContext().put(
-         BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://"+getServerHost()+":8080/wsa10/echo"         
+         BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://"+getInteropServerHost()+":8080/wsa10/echo"         
       );
 
       ((BindingProvider)notifyPort).getRequestContext().put(
-         BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://"+getServerHost()+":8080/wsa10/notify"
+         BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://"+getInteropServerHost()+":8080/wsa10/notify"
       );
 
       /*
@@ -146,7 +145,7 @@
    }
 
 
-   public String getServerHost()
+   private String getInteropServerHost()
    {
       String host = null;
       if("true".equals( System.getProperty("interop") ) )

Modified: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java	2009-10-06 06:41:37 UTC (rev 10836)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -21,15 +21,26 @@
  */
 package org.jboss.test.ws.jaxws.endpoint.jse;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URL;
 
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Iface;
 import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Impl;
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.DHRequest;
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.DHResponse;
 import org.jboss.wsf.test.JBossWSTest;
 
 /**
@@ -39,8 +50,12 @@
  */
 public final class UsecasesTestCase extends JBossWSTest
 {
-   private int port1 = 8871;
-   private int port2 = 8872;
+   private static String fs = System.getProperty("file.separator");
+   private static File attachmentFile = JBossWSTest.getResourceFile("jaxws" + fs + "endpoint" + fs + "attachment.txt");
+   private static WebServiceFeature[] mtomEnabled = new WebServiceFeature[] { new MTOMFeature(true) };
+   
+   private static int port1 = 8871;
+   private static int port2 = 8872;
 
    public void testTwoPorts() throws Exception
    {
@@ -106,18 +121,20 @@
    {
       String publishURL = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1";
       Endpoint endpoint = publishEndpoint(Endpoint1Impl.class, publishURL);
-
       invokeEndpoint3(publishURL);
-
       endpoint.stop();
    }
 
-   /*
    public void testAttachments() throws Exception
    {
-      // TODO: provide test case where client sends attachment
+      for (int i = 0; i < 2; i++)
+      {
+         String publishURL = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1";
+         Endpoint endpoint = publishEndpoint(Endpoint1Impl.class, publishURL);
+         invokeEndpoint4(publishURL);
+         endpoint.stop();
+      }
    }
-   */
 
    private Endpoint publishEndpoint(Object epImpl, String publishURL)
    {
@@ -163,13 +180,53 @@
          log.debug(e.getMessage());
       }
    }
+   
+   private void invokeEndpoint4(String publishURL) throws Exception
+   {
+      Endpoint1Iface port = this.getProxy(publishURL, mtomEnabled);
 
+      FileDataSource fds = new FileDataSource(attachmentFile);
+      DataHandler dh = new DataHandler(fds);
+      DHResponse response = port.echoDataHandler(new DHRequest(dh));
+      assertNotNull(response);
+
+      Object content = getContent(response.getDataHandler());
+      String contentType = response.getDataHandler().getContentType();
+
+      assertEquals("Server data", content);
+      assertEquals("text/plain", contentType);
+   }
+
    private Endpoint1Iface getProxy(String publishURL) throws Exception
    {
+      return this.getProxy(publishURL, null);
+   }
+
+   private Endpoint1Iface getProxy(String publishURL, WebServiceFeature[] features) throws Exception
+   {
       URL wsdlURL = new URL(publishURL + "?wsdl");
       QName qname = new QName("http://org.jboss.ws/jaxws/endpoint/jse/endpoints/", "Endpoint1Impl");
       Service service = Service.create(wsdlURL, qname);
-      return (Endpoint1Iface)service.getPort(Endpoint1Iface.class);
+      return (Endpoint1Iface)service.getPort(Endpoint1Iface.class, features);
    }
 
+   private Object getContent(DataHandler dh) throws IOException
+   {
+      Object content = dh.getContent();
+
+      // Metro returns an ByteArrayInputStream
+      if (content instanceof InputStream)
+      {
+         try
+         {
+            BufferedReader br = new BufferedReader(new InputStreamReader((InputStream)content));
+            return br.readLine();
+         }
+         finally
+         {
+            ((InputStream)content).close();
+         }
+      }
+      return content;
+   }
 }

Added: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java	                        (rev 0)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+ at XmlType
+(
+   name = "dataRequest",
+   namespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/"
+)
+public class DHRequest
+{
+
+   private DataHandler dataHandler;
+
+   public DHRequest()
+   {
+   }
+
+   public DHRequest(DataHandler dataHandler)
+   {
+      this.dataHandler = dataHandler;
+   }
+
+   @XmlMimeType("text/plain")
+   public DataHandler getDataHandler()
+   {
+      return dataHandler;
+   }
+
+   public void setDataHandler(DataHandler dataHandler)
+   {
+      this.dataHandler = dataHandler;
+   }
+
+}

Added: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java	                        (rev 0)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+ at XmlType
+(
+   name="dataResponse",
+   namespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/"
+)
+public class DHResponse {
+
+
+   private DataHandler dataHandler;
+
+
+   public DHResponse() {
+   }
+
+   public DHResponse(DataHandler dataHandler) {
+      this.dataHandler = dataHandler;
+   }
+
+   @XmlMimeType("text/plain")
+   public DataHandler getDataHandler() {
+      return dataHandler;
+   }
+
+   public void setDataHandler(DataHandler dataHandler) {
+      this.dataHandler = dataHandler;
+   }
+}

Modified: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java	2009-10-06 06:41:37 UTC (rev 10836)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -30,10 +30,11 @@
  * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
  */
 @WebService(targetNamespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/")
- at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE)
 public interface Endpoint1Iface
 {
    String echo(String input);
    int getCount();
    void getException();
+   DHResponse echoDataHandler(DHRequest request);
 }

Modified: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java	2009-10-06 06:41:37 UTC (rev 10836)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java	2009-10-06 06:55:31 UTC (rev 10837)
@@ -21,9 +21,17 @@
  */
 package org.jboss.test.ws.jaxws.endpoint.jse.endpoints;
 
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
 import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
 
+import org.jboss.logging.Logger;
+
 /**
  * Service implementation.
  *
@@ -35,9 +43,12 @@
    targetNamespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/",
    endpointInterface = "org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Iface"
 )
+ at SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+ at MTOM
 public class Endpoint1Impl implements Endpoint1Iface
 {
 
+   private Logger log = Logger.getLogger(Endpoint1Impl.class);
    private int count;
 
    public String echo(String input)
@@ -56,4 +67,27 @@
       throw new WebServiceException("Ooops");
    }
 
+   public DHResponse echoDataHandler(DHRequest request)
+   {
+      DataHandler dataHandler = request.getDataHandler();
+
+      try
+      {
+         log.info("Content type: " + dataHandler.getContentType());
+         Object dataContent = dataHandler.getContent();
+         log.info("Content class: " + dataContent);
+         if ( dataContent instanceof InputStream )
+         {
+            ((InputStream)dataContent).close();
+         }
+      }
+      catch (IOException e)
+      {
+         throw new WebServiceException(e);
+      }
+      
+      DataHandler responseData = new DataHandler("Server data", "text/plain");
+      return new DHResponse(responseData);
+   }
+
 }

Added: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/resources/jaxws/endpoint/attachment.txt
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/resources/jaxws/endpoint/attachment.txt	                        (rev 0)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/resources/jaxws/endpoint/attachment.txt	2009-10-06 06:55:31 UTC (rev 10837)
@@ -0,0 +1 @@
+This is the file content
\ No newline at end of file



More information about the jbossws-commits mailing list