cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r826349 - in /cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet: SpringAutoPublishServletTest.java spring-auto-launch.xml web-spring-auto-launch.xml
Date Sun, 18 Oct 2009 02:30:09 GMT
Author: bimargulies
Date: Sun Oct 18 02:30:09 2009
New Revision: 826349

URL: http://svn.apache.org/viewvc?rev=826349&view=rev
Log:
CXF-1355. Add actual test for the whole spring extravaganza. It seems to work, though I'm
not sure
how to test that all the fiddly bus stuff is working correctly.

Added:
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
  (with props)
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
  (with props)
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
  (with props)

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java?rev=826349&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
Sun Oct 18 02:30:09 2009
@@ -0,0 +1,165 @@
+/**
+ * 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.servlet;
+
+import javax.xml.ws.Endpoint;
+
+import org.w3c.dom.Document;
+
+import com.meterware.httpunit.HttpNotFoundException;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.ServletUnitClient;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.testsupport.AbstractServletTest;
+
+import org.junit.Test;
+
+public class SpringAutoPublishServletTest extends AbstractServletTest {
+    @Override
+    protected String getConfiguration() {
+        return "/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml";
+    }
+
+    @Override
+    protected Bus createBus() throws BusException {
+        // don't set up the bus, let the servlet do it
+        return null;
+    }
+
+    @Test
+    public void testInvokingSpringBeans() throws Exception {
+
+        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",
+            getClass().getResourceAsStream("GreeterMessage.xml"),
+            "text/xml; charset=utf-8");
+
+        invokingEndpoint(req);
+        
+        req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter1",
+            getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=utf-8");
+        
+        invokingEndpoint(req);
+    }
+    
+    public void invokingEndpoint(WebRequest req) throws Exception {
+        
+        WebResponse response = newClient().getResponse(req);
+        assertEquals("text/xml", response.getContentType());
+        assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet()));
+
+        Document doc = DOMUtils.readXml(response.getInputStream());
+        assertNotNull(doc);
+
+        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
+        assertValid("/s:Envelope/s:Body", doc);
+        assertValid("//h:sayHiResponse", doc);
+    }
+    
+    @Test
+    public void testGreetMeGetRequest() throws Exception {
+        ServletUnitClient client = newClient();
+        client.setExceptionsThrownOnErrorStatus(true);
+        
+        WebRequest req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter/greetMe?"
+                                         + "requestType=hello");
+        
+        WebResponse response = client.getResponse(req);        
+        Document doc = DOMUtils.readXml(response.getInputStream());
+        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
+        assertValid("/s:Envelope/s:Body", doc);
+        assertValid("//h:greetMeResponse", doc);
+        
+        req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter1/greetMe?"
+                                         + "requestType=hello");
+        
+        response = client.getResponse(req);        
+        doc = DOMUtils.readXml(response.getInputStream());
+        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
+        assertValid("/s:Envelope/s:Body", doc);
+        assertValid("//h:greetMeResponse", doc);
+    }
+    
+        
+    @Test
+    public void testGetWSDL() throws Exception {
+        ServletUnitClient client = newClient();
+        client.setExceptionsThrownOnErrorStatus(true);
+        
+        WebRequest req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter?wsdl"); 
+       
+        WebResponse res = client.getResponse(req);        
+        assertEquals(200, res.getResponseCode());
+        assertEquals("text/xml", res.getContentType());
+        
+        Document doc = DOMUtils.readXml(res.getInputStream());
+        assertNotNull(doc);
+        
+        assertValid("//wsdl:operation[@name='greetMe']", doc);
+        assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter']",
doc);
+        
+        req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter2?wsdl");
+        res = client.getResponse(req);    
+        assertEquals(200, res.getResponseCode());
+        assertEquals("text/xml", res.getContentType());
+        
+        doc = DOMUtils.readXml(res.getInputStream());
+        assertNotNull(doc);
+        
+        assertValid("//wsdl:operation[@name='greetMe']", doc);
+        assertValid("//wsdlsoap:address[@location='http://cxf.apache.org/Greeter']", doc);
+        
+        Endpoint.publish("/services/Greeter3", new org.apache.hello_world_soap_http.GreeterImpl());
+        req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter3?wsdl");
+        res = client.getResponse(req);    
+        assertEquals(200, res.getResponseCode());
+        assertEquals("text/xml", res.getContentType());
+        
+        doc = DOMUtils.readXml(res.getInputStream());
+        assertNotNull(doc);
+        
+        assertValid("//wsdl:operation[@name='greetMe']", doc);
+        assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter3']",
doc);
+
+    }
+    
+    @Test
+    public void testIgnoreServiceList() throws Exception {
+        ServletUnitClient client = newClient();
+        client.setExceptionsThrownOnErrorStatus(true);
+        
+        WebRequest req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/");
+        try {
+            client.getResponse(req);
+            fail();
+        } catch (HttpNotFoundException ex) {
+            // expected
+        }
+    }
+}

Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml?rev=826349&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
Sun Oct 18 02:30:09 2009
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:jaxws="http://cxf.apache.org/jaxws"
+      xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+  <import resource="classpath:META-INF/cxf/cxf.xml"/>
+  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
+  <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
+  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+  
+  
+  <bean id="greeterServerFactory"
+    class="org.apache.cxf.jaxws.JaxWsServerFactoryBean" init-method="create">
+    <property name="serviceClass" value="org.apache.hello_world_soap_http.GreeterImpl"
/>
+    <property name="serviceBean">
+      <bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
+    </property>
+    <property name="address" value="/services/Greeter"/>
+    <property name="bus" ref="cxf"/>
+    <property name="bindingId" value="http://apache.org/cxf/binding/http"/>
+  </bean>
+  
+   <jaxws:endpoint id="endpoint1" 
+              implementor="org.apache.hello_world_soap_http.GreeterImpl"
+              address="/services/Greeter1"
+              wsdlLocation="/wsdl/hello_world.wsdl"
+              />
+   
+    <jaxws:endpoint id="endpoint2" 
+              implementor="org.apache.hello_world_soap_http.GreeterImpl"
+              address="/services/Greeter2"
+              publishedEndpointUrl="http://cxf.apache.org/Greeter"
+              />     
+  
+</beans>

Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/spring-auto-launch.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml?rev=826349&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
Sun Oct 18 02:30:09 2009
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE web-app
+    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+    "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<!--
+	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.
+-->
+
+<web-app>
+	<context-param>
+		<param-name>contextConfigLocation</param-name>
+		<param-value>
+			classpath:org/apache/cxf/systest/servlet/spring.xml
+		</param-value>
+	</context-param>
+
+	<listener>
+		<listener-class>
+			org.springframework.web.context.ContextLoaderListener
+		</listener-class>
+	</listener>
+	
+	<servlet>
+		<servlet-name>CXFServlet</servlet-name>
+		<display-name>CXF Servlet</display-name>		
+		<servlet-class>
+			org.apache.cxf.transport.servlet.CXFServlet
+		</servlet-class>
+		<init-param> 
+            <param-name>hide-service-list-page</param-name> 
+            <param-value>true</param-value> 
+       </init-param> 
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>CXFServlet</servlet-name>
+		<url-pattern>/*</url-pattern>
+	</servlet-mapping>
+
+
+</web-app>
\ No newline at end of file

Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web-spring-auto-launch.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message