Author: jliu
Date: Wed Sep 13 06:33:54 2006
New Revision: 442982
URL: http://svn.apache.org/viewvc?view=rev&rev=442982
Log:
* Added test for http transport to make sure HTTP GET is handled properly.
* Added system test for XMLBinding provider. Hacked http transport extension
file to make XMLBinding's default transport is HTTP when wsdl file is not
available.
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
(with props)
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/bus-extensions.xml
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/TestHttpRequest.java
incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/bus-extensions.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/bus-extensions.xml?view=diff&rev=442982&r1=442981&r2=442982
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/bus-extensions.xml
(original)
+++
incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/bus-extensions.xml
Wed Sep 13 06:33:54 2006
@@ -24,5 +24,6 @@
<namespace>http://schemas.xmlsoap.org/wsdl/soap/http</namespace>
<namespace>http://schemas.xmlsoap.org/wsdl/http/</namespace>
<namespace>http://cxf.apache.org/transports/http/configuration</namespace>
+ <namespace>http://cxf.apache.org/bindings/xmlformat</namespace>
</extension>
</extensions>
Modified:
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java?view=diff&rev=442982&r1=442981&r2=442982
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
(original)
+++
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
Wed Sep 13 06:33:54 2006
@@ -67,7 +67,6 @@
private static final String NOWHERE = "http://nada.nothing.nowhere.null/";
private static final String PAYLOAD = "message payload";
- private static final String QUERY = "?name";
private static final String CHALLENGE_HEADER = "WWW-Authenticate";
private static final String BASIC_CHALLENGE = "Basic realm=terra";
private static final String DIGEST_CHALLENGE = "Digest realm=luna";
@@ -153,6 +152,24 @@
verifyDoService();
}
+ public void testDoServiceWithHttpGET() throws Exception {
+ destination = setUpDestination(false);
+ setUpDoService(false, false, false, "GET",
"?customerId=abc&cutomerAdd=def");
+ destination.doService(request, response);
+
+ assertNotNull("unexpected null message", inMessage);
+ assertEquals("unexpected method",
+ inMessage.get(MessageContext.HTTP_REQUEST_METHOD),
+ "GET");
+ assertEquals("unexpected path",
+ inMessage.get(MessageContext.PATH_INFO),
+ "bar/foo");
+ assertEquals("unexpected query",
+ inMessage.get(MessageContext.QUERY_STRING),
+ "?customerId=abc&cutomerAdd=def");
+
+ }
+
public void testGetAnonBackChannel() throws Exception {
destination = setUpDestination(false);
setUpDoService(false);
@@ -280,10 +297,20 @@
sendResponse,
false);
}
-
+
+ private void setUpDoService(boolean setRedirectURL,
+ boolean sendResponse,
+ boolean decoupled) throws Exception {
+ String method = "POST";
+ String query = "?name";
+ setUpDoService(setRedirectURL, sendResponse, decoupled, method, query);
+ }
+
private void setUpDoService(boolean setRedirectURL,
boolean sendResponse,
- boolean decoupled) throws Exception {
+ boolean decoupled,
+ String method,
+ String query) throws Exception {
control.verify();
control.reset();
@@ -297,7 +324,7 @@
//
//request = EasyMock.createMock(HttpRequest.class);
//response = EasyMock.createMock(HttpResponse.class);
- request = new TestHttpRequest("POST", is, "bar/foo", QUERY);
+ request = new TestHttpRequest(method, is, "bar/foo", query);
response = new TestHttpResponse(os);
config.getPolicy();
@@ -378,7 +405,7 @@
"bar/foo");
assertEquals("unexpected query",
inMessage.get(MessageContext.QUERY_STRING),
- QUERY);
+ "?name");
verifyRequestHeaders();
Modified:
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/TestHttpRequest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/TestHttpRequest.java?view=diff&rev=442982&r1=442981&r2=442982
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/TestHttpRequest.java
(original)
+++
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/TestHttpRequest.java
Wed Sep 13 06:33:54 2006
@@ -137,4 +137,9 @@
int getParametersCallCount() {
return callCounts[7];
}
+
+ public org.mortbay.util.URI getURI() {
+ return new org.mortbay.util.URI("http://localhost/" + path + query);
+ }
+
}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java?view=auto&rev=442982
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
Wed Sep 13 06:33:54 2006
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.systest.provider;
+
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+import org.w3c.dom.Document;
+
+//The following wsdl file is used.
+//wsdlLocation =
"/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
[EMAIL PROTECTED](portName = "XMLProviderPort",
+ serviceName = "SOAPServiceRPCLit2",
+ targetNamespace = "http://apache.org/hello_world_rpclit",
+ wsdlLocation = "/wsdl/hello_world_rpc_lit.wsdl")
[EMAIL PROTECTED](value = Service.Mode.PAYLOAD)
[EMAIL PROTECTED](value = "http://cxf.apache.org/bindings/xmlformat")
+public class HWDOMSourcePayloadXMLBindingProvider implements
+ Provider<DOMSource> {
+
+ public HWDOMSourcePayloadXMLBindingProvider() {
+ }
+
+ public DOMSource invoke(DOMSource request) {
+ DocumentBuilderFactory factory;
+ DocumentBuilder builder;
+ Document document = null;
+ DOMSource response = null;
+
+ try {
+ factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(true);
+ builder = factory.newDocumentBuilder();
+ InputStream greetMeResponse = getClass().getResourceAsStream(
+ "resources/XML_GreetMeDocLiteralResp.xml");
+
+ document = builder.parse(greetMeResponse);
+ response = new DOMSource(document);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadXMLBindingProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java?view=auto&rev=442982
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
Wed Sep 13 06:33:54 2006
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.systest.provider;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.systest.common.TestServerBase;
+import org.apache.hello_world_xml_http.wrapped.XMLService;
+
+public class ProviderXMLClientServerTest extends ClientServerTestBase {
+ private final QName serviceName = new QName(
+ "http://apache.org/hello_world_xml_http/wrapped", "XMLService");
+
+ private final QName portName = new QName(
+ "http://apache.org/hello_world_xml_http/wrapped",
"XMLProviderPort");
+
+ public static class Server extends TestServerBase {
+
+ protected void run() {
+ Object implementor = new HWDOMSourcePayloadXMLBindingProvider();
+ String address =
"http://localhost:9022/XMLService/XMLProviderPort";
+ Endpoint.publish(address, implementor);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ public static Test suite() throws Exception {
+ TestSuite suite = new TestSuite(ProviderXMLClientServerTest.class);
+ return new ClientServerSetupBase(suite) {
+ public void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
+ launchServer(Server.class));
+ }
+ };
+ }
+
+ public void testDOMSourcePAYLOAD() throws Exception {
+ URL wsdl =
getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
+ assertNotNull(wsdl);
+
+ XMLService service = new XMLService(wsdl, serviceName);
+ assertNotNull(service);
+
+ InputStream is = getClass().getResourceAsStream(
+ "/messages/XML_GreetMeDocLiteralReq.xml");
+ Document doc = XMLUtils.parse(is);
+ DOMSource reqMsg = new DOMSource(doc);
+ assertNotNull(reqMsg);
+
+ Dispatch<DOMSource> disp = service.createDispatch(portName,
+ DOMSource.class, Service.Mode.PAYLOAD);
+ DOMSource result = disp.invoke(reqMsg);
+ assertNotNull(result);
+
+ Node respDoc = result.getNode();
+ assertEquals("greetMeResponse",
respDoc.getFirstChild().getLocalName());
+ assertEquals("TestXMLBindingProviderMessage", respDoc.getFirstChild()
+ .getTextContent());
+ }
+
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml?view=auto&rev=442982
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
Wed Sep 13 06:33:54 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ns4:greetMeResponse
xmlns:ns4="http://apache.org/hello_world_soap_http/types"><ns4:responseType>TestXMLBindingProviderMessage</ns4:responseType></ns4:greetMeResponse>
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/XML_GreetMeDocLiteralResp.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl?view=diff&rev=442982&r1=442981&r2=442982
==============================================================================
---
incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl
(original)
+++
incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl
Wed Sep 13 06:33:54 2006
@@ -167,6 +167,11 @@
<wsdl:port binding="tns:Greeter_XMLBinding"
name="XMLDispatchPort">
<http:address
location="http://localhost:9007/XMLService/XMLDispatchPort" />
+ </wsdl:port>
+
+ <wsdl:port binding="tns:Greeter_XMLBinding"
name="XMLProviderPort">
+ <http:address
+
location="http://localhost:9022/XMLService/XMLProviderPort" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>