cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1089440 - in /cxf/trunk: rt/testsupport/src/main/java/org/apache/cxf/systest/servlet/ rt/testsupport/src/main/java/org/apache/cxf/testsupport/ rt/testsupport/src/main/resources/org/apache/cxf/systest/servlet/ systests/jaxrs/src/test/java/o...
Date Wed, 06 Apr 2011 13:10:57 GMT
Author: cschneider
Date: Wed Apr  6 13:10:57 2011
New Revision: 1089440

URL: http://svn.apache.org/viewvc?rev=1089440&view=rev
Log:
Move all servlet related tests and support classes to the systest/transport project

Added:
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web.xml
Removed:
    cxf/trunk/rt/testsupport/src/main/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java
    cxf/trunk/rt/testsupport/src/main/java/org/apache/cxf/testsupport/AbstractServletTest.java
    cxf/trunk/rt/testsupport/src/main/java/org/apache/cxf/testsupport/TestUtilitiesWithBasicBus.java
    cxf/trunk/rt/testsupport/src/main/resources/org/apache/cxf/systest/servlet/web.xml
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
Modified:
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ErrorContextSerletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JsFrontEndServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java?rev=1089440&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
Wed Apr  6 13:10:57 2011
@@ -0,0 +1,96 @@
+/**
+ * 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 java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+
+import org.xml.sax.SAXException;
+
+import com.meterware.httpunit.HttpException;
+import com.meterware.httpunit.HttpNotFoundException;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+
+import org.apache.cxf.test.AbstractCXFTest;
+import org.junit.Before;
+
+public abstract class AbstractServletTest extends AbstractCXFTest {
+    public static final String CONTEXT = "/mycontext";
+    public static final String CONTEXT_URL = "http://localhost/mycontext";
+    protected ServletRunner sr;
+
+    @Before
+    public void setUp() throws Exception {
+        InputStream configurationStream = getResourceAsStream(getConfiguration());
+        sr = new ServletRunner(configurationStream, CONTEXT);
+        
+        try {
+            sr.newClient().getResponse(CONTEXT_URL + "/services");
+        } catch (HttpNotFoundException e) {
+            // ignore, we just want to boot up the servlet
+        }   
+        
+        HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);        
+    } 
+
+    /**
+     * @return The web.xml to use for testing.
+     */
+    protected String getConfiguration() {
+        return "/org/apache/cxf/systest/servlet/web.xml";
+    }
+
+    protected ServletUnitClient newClient() {
+        return sr.newClient();
+    }
+
+    /**
+     * Here we expect an errorCode other than 200, and look for it checking for
+     * text is omitted as it doesnt work. It would never work on java1.3, but
+     * one may have expected java1.4+ to have access to the error stream in
+     * responses. Clearly not.
+     * 
+     * @param request
+     * @param errorCode
+     * @param errorText optional text string to search for
+     * @throws MalformedURLException
+     * @throws IOException
+     * @throws SAXException
+     */
+    protected void expectErrorCode(WebRequest request, int errorCode, String errorText)
+        throws MalformedURLException, IOException, SAXException {
+        String failureText = "Expected error " + errorCode + " from " + request.getURL();
+
+        try {
+            newClient().getResponse(request);
+            fail(errorText + " -got success instead");
+        } catch (HttpException e) {
+            assertEquals(failureText, errorCode, e.getResponseCode());
+            /*
+             * checking for text omitted as it doesnt work. if(errorText!=null) {
+             * assertTrue( "Failed to find "+errorText+" in "+
+             * e.getResponseMessage(), e.getMessage().indexOf(errorText)>=0); }
+             */
+        }
+    }
+}

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
Wed Apr  6 13:10:57 2011
@@ -38,7 +38,6 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.testsupport.AbstractServletTest;
 import org.apache.hello_world_soap_http.BaseGreeterImpl;
 
 import org.junit.Before;

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ErrorContextSerletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ErrorContextSerletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ErrorContextSerletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ErrorContextSerletTest.java
Wed Apr  6 13:10:57 2011
@@ -21,7 +21,6 @@ package org.apache.cxf.systest.servlet;
 import com.meterware.servletunit.ServletRunner;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
-import org.apache.cxf.testsupport.AbstractServletTest;
 
 import org.junit.Before;
 import org.junit.Test;

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
Wed Apr  6 13:10:57 2011
@@ -34,7 +34,6 @@ import com.meterware.servletunit.Servlet
 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;
 

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java?rev=1089440&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/GetMethodQueryWebRequest.java
Wed Apr  6 13:10:57 2011
@@ -0,0 +1,43 @@
+/**
+ * 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 com.meterware.httpunit.GetMethodWebRequest;
+
+//Customer WebRequest for sending the "http://localhost/xxx?wsdl" request
+public class GetMethodQueryWebRequest extends GetMethodWebRequest {
+    private String urlString;
+    
+    public GetMethodQueryWebRequest(String urlStr) {        
+        super(urlStr);
+        urlString = urlStr;        
+    }
+    
+    public String getQueryString() {
+        int pos = urlString.indexOf('?');
+        if (pos > 0) {
+            return urlString.substring(pos + 1);
+        } else {
+            return "";
+        }                
+    }
+    
+    
+
+}

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/HttpBindingServletTest.java
Wed Apr  6 13:10:57 2011
@@ -31,7 +31,6 @@ import com.meterware.servletunit.Servlet
 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;
 

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java?rev=1089440&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
Wed Apr  6 13:10:57 2011
@@ -0,0 +1,81 @@
+/**
+ * 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 java.io.InputStream;
+
+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.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+
+import org.junit.Test;
+
+
+
+public class JaxRsServletTest extends AbstractServletTest {
+      
+
+    @Override
+    protected String getConfiguration() {
+        return "/org/apache/cxf/systest/servlet/web-jaxrs.xml";
+    }
+
+    @Override
+    protected Bus createBus() throws BusException {
+        // don't set up the bus, let the servlet do it
+        return null;
+    }
+    
+    @org.junit.Ignore // this doesn't work yet
+    @Test
+    public void testGetThatBook123() throws Exception {
+        testInvokingBookService("/jaxrs/bookstorestorage/thosebooks/123");
+    }   
+    
+    private void testInvokingBookService(String serviceAddress) throws Exception {
+        ServletUnitClient client = newClient();
+        client.setExceptionsThrownOnErrorStatus(false);
+        
+        WebRequest req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + serviceAddress);
+        
+        WebResponse response = client.getResponse(req);
+        InputStream in = response.getInputStream();        
+        InputStream expected = JaxRsServletTest.class
+            .getResourceAsStream("resources/expected_get_book123.txt");
+        
+        assertEquals(" Can't get the expected result ", 
+                     getStringFromInputStream(expected),
+                     getStringFromInputStream(in));
+     
+    }
+    
+    private String getStringFromInputStream(InputStream in) throws Exception {        
+        CachedOutputStream bos = new CachedOutputStream();
+        IOUtils.copy(in, bos);
+        in.close();
+        bos.close();            
+        return bos.getOut().toString();        
+    }
+}

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JsFrontEndServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JsFrontEndServletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JsFrontEndServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JsFrontEndServletTest.java
Wed Apr  6 13:10:57 2011
@@ -25,7 +25,6 @@ import com.meterware.httpunit.WebRequest
 import com.meterware.httpunit.WebResponse;
 
 import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.testsupport.AbstractServletTest;
 
 import org.junit.Test;
 

Modified: 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=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringAutoPublishServletTest.java
Wed Apr  6 13:10:57 2011
@@ -28,7 +28,6 @@ import com.meterware.servletunit.Servlet
 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;
 

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java?rev=1089440&r1=1089439&r2=1089440&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
Wed Apr  6 13:10:57 2011
@@ -31,7 +31,6 @@ import com.meterware.servletunit.Servlet
 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;
 

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web.xml?rev=1089440&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web.xml (added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/web.xml Wed
Apr  6 13:10:57 2011
@@ -0,0 +1,50 @@
+<?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>
+
+  <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>config-location</param-name> 
+      <param-value>classpath:/org/apache/cxf/systest/servlet/cxf-servlet.xml</param-value>

+    </init-param> 
+    <!--init-param> 
+      <param-name>bus.id</param-name> 
+      <param-value>servlet.systest.bus.id</param-value> 
+    </init-param--> 
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>CXFServlet</servlet-name>
+    <url-pattern>/services/*</url-pattern>
+  </servlet-mapping>
+
+
+</web-app>
\ No newline at end of file



Mime
View raw message