cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r669132 - in /cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http: BareServer.java WSDLQueryTest.java
Date Wed, 18 Jun 2008 10:44:57 GMT
Author: eglynn
Date: Wed Jun 18 03:44:56 2008
New Revision: 669132

URL: http://svn.apache.org/viewvc?rev=669132&view=rev
Log:
Added test asserting tolerance for empty or bogus HTTP Host headers on "?wsdl" queries (as
set by some HTTP load balancers)


Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java   (with props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java   (with
props)

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java?rev=669132&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java Wed Jun 18
03:44:56 2008
@@ -0,0 +1,53 @@
+/**
+ * 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.http;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class BareServer extends AbstractBusTestServerBase {
+
+    @Override
+    protected void run() {
+        Bus bus = new SpringBusFactory().createBus();
+        SpringBusFactory.setDefaultBus(bus);
+        Object implementor = new GreeterImpl();
+        String address = "http://localhost:9020/SoapContext/GreeterPort";
+        Endpoint.publish(address, implementor);
+        
+    }
+    
+    public static void main(String[] args) {
+        try {
+            System.out.println("!!!!start");
+            BareServer s = new BareServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/BareServer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java?rev=669132&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java Wed Jun
18 03:44:56 2008
@@ -0,0 +1,85 @@
+/**
+ * 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.http;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WSDLQueryTest extends AbstractBusClientServerTestBase {
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly",
+                   launchServer(BareServer.class));
+    }
+    
+    @Test
+    public void testEmptyHostHeader() throws Exception {
+        sendQuery("", "HTTP/1.1 200 OK");
+    }
+
+    @Test
+    public void testCorrectHostHeader() throws Exception {
+        sendQuery("localhost:9020", "HTTP/1.1 200 OK");
+    }
+
+    @Test
+    public void testCorrectHostNoPortHeader() throws Exception {
+        sendQuery("localhost", "HTTP/1.1 200 OK");
+    }
+
+    @Test
+    public void testBogusHostHeader() throws Exception {
+        sendQuery("foobar:9020", "HTTP/1.1 200 OK");
+    }
+
+    @Test
+    public void testBogusHostBogusPortHeader() throws Exception {
+        sendQuery("foobar:666", "HTTP/1.1 200 OK");
+    }
+
+    @Test
+    public void testWithBogusHostNoPortHeader() throws Exception {
+        sendQuery("foobar", "HTTP/1.1 200 OK");
+    }
+
+    private void sendQuery(String hostHeader, String expectedResponseLine)
+        throws Exception {
+        Socket s = new Socket("localhost", 9020);
+        OutputStream os = s.getOutputStream();
+        os.write("GET /SoapContext/GreeterPort?wsdl HTTP/1.1\r\n".getBytes());
+        os.write(("Host:" + hostHeader + "\r\n\r\n").getBytes());
+        os.flush();
+        InputStream is = s.getInputStream();
+        BufferedReader reader =
+            new BufferedReader(new InputStreamReader(is));
+        String line = reader.readLine();
+        assertEquals("unexpected response", expectedResponseLine, line);
+        is.close();
+        os.close();
+        s.close();
+    }
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/WSDLQueryTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message