axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r511541 - in /webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string: DispatchXMessageSource.java DispatchXPayloadSource.java
Date Sun, 25 Feb 2007 16:32:37 GMT
Author: scheu
Date: Sun Feb 25 08:32:36 2007
New Revision: 511541

URL: http://svn.apache.org/viewvc?view=rev&rev=511541
Log:
AXIS2-1783
Contributor: Rich Scheuerle
Adding missing tests

Added:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXMessageSource.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadSource.java
      - copied, changed from r510757, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadString.java

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXMessageSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXMessageSource.java?view=auto&rev=511541
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXMessageSource.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXMessageSource.java
Sun Feb 25 08:32:36 2007
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.xmlhttp.clientTests.dispatch.source;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.apache.axis2.jaxws.message.util.Reader2Writer;
+
+import junit.framework.TestCase;
+
+public class DispatchXMessageSource extends TestCase {
+
+    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+    
+    public String HOSTPORT = "http://localhost:8080";
+        
+    private String ENDPOINT_URL = HOSTPORT + "/axis2/services/XMessageSourceProvider";
+    private QName SERVICE_NAME  = new QName("http://ws.apache.org/axis2", "XMessageSourceProvider");
+    private QName PORT_NAME  = new QName("http://ws.apache.org/axis2", "XMessageSourceProviderPort");
+ 
+    String XML_TEXT = "<p:echo xmlns:p=\"http://sample\">hello world</p:echo>";
+    public Dispatch<Source> getDispatch() {
+       Service service = Service.create(SERVICE_NAME);
+       service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,ENDPOINT_URL);
+       Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class,
Service.Mode.MESSAGE);
+       return dispatch;
+    }
+    
+    /**
+     * Simple XML/HTTP Message Test
+     * @throws Exception
+     */
+    public void testSimple() throws Exception {
+        Dispatch<Source> dispatch = getDispatch();
+        String request = XML_TEXT;
+        StreamSource ss = new StreamSource(new ByteArrayInputStream(request.getBytes()));
+        Source outSS = dispatch.invoke(ss);
+        
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(outSS);
+        Reader2Writer r2w = new Reader2Writer(reader);
+        String response = r2w.getAsString();
+        
+        assertTrue(response != null);
+        assertTrue(request.equals(response));
+    }
+}

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadSource.java
(from r510757, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadString.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadSource.java?view=diff&rev=511541&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadString.java&r1=510757&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadSource.java&r2=511541
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadString.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/xmlhttp/clientTests/dispatch/string/DispatchXPayloadSource.java
Sun Feb 25 08:32:36 2007
@@ -14,42 +14,56 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.axis2.jaxws.xmlhttp.clientTests.dispatch.string;
+package org.apache.axis2.jaxws.xmlhttp.clientTests.dispatch.source;
+
+import java.io.ByteArrayInputStream;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
 import javax.xml.ws.http.HTTPBinding;
 
+import org.apache.axis2.jaxws.message.util.Reader2Writer;
+
 import junit.framework.TestCase;
 
-public class DispatchXPayloadString extends TestCase {
+public class DispatchXPayloadSource extends TestCase {
+    
+    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
 
     public String HOSTPORT = "http://localhost:8080";
         
-    private String ENDPOINT_URL = HOSTPORT + "/axis2/services/XPayloadStringProvider";
-    private QName SERVICE_NAME  = new QName("http://ws.apache.org/axis2", "XPayloadStringProvider");
-    private QName PORT_NAME  = new QName("http://ws.apache.org/axis2", "XPayloadStringProviderPort");
- 
+    private String ENDPOINT_URL = HOSTPORT + "/axis2/services/XPayloadSourceProvider";
+    private QName SERVICE_NAME  = new QName("http://ws.apache.org/axis2", "XPayloadSourceProvider");
+    private QName PORT_NAME  = new QName("http://ws.apache.org/axis2", "XPayloadSourceProviderPort");
+
     String XML_TEXT = "<p:echo xmlns:p=\"http://sample\">hello world</p:echo>";
-    public Dispatch<String> getDispatch() {
-       Service service = Service.create(SERVICE_NAME);
-       service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,ENDPOINT_URL);
-       Dispatch<String> dispatch = service.createDispatch(PORT_NAME, String.class,
Service.Mode.PAYLOAD);
-       return dispatch;
-    }
+    public Dispatch<Source> getDispatch() {
+        Service service = Service.create(SERVICE_NAME);
+        service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,ENDPOINT_URL);
+        Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class,
Service.Mode.PAYLOAD);
+        return dispatch;
+     }
     
     /**
-     * Simple XML/HTTP Payload Test
-     * @throws Exception
-     */
-    public void testSimple() throws Exception {
-        Dispatch<String> dispatch = getDispatch();
-        String request = XML_TEXT;
-        System.out.println("Request  = " + request);
-        String response = dispatch.invoke(request);
-        System.out.println("Response = " + response);
-        assertTrue(response != null);
-        assertTrue(request.equals(response));
-    }
+    * Simple XML/HTTP Message Test
+    * @throws Exception
+    */
+   public void testSimple() throws Exception {
+       Dispatch<Source> dispatch = getDispatch();
+       String request = XML_TEXT;
+       StreamSource ss = new StreamSource(new ByteArrayInputStream(request.getBytes()));
+       Source outSS = dispatch.invoke(ss);
+       
+       XMLStreamReader reader = inputFactory.createXMLStreamReader(outSS);
+       Reader2Writer r2w = new Reader2Writer(reader);
+       String response = r2w.getAsString();
+       
+       assertTrue(response != null);
+       assertTrue(request.equals(response));
+   }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message