cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1208743 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/ systests/jaxrs/src/test/resources/jaxrs_cors/ systests/jaxrs/src/test/resources/jaxrs_cors/...
Date Wed, 30 Nov 2011 20:03:42 GMT
Author: bimargulies
Date: Wed Nov 30 20:03:41 2011
New Revision: 1208743

URL: http://svn.apache.org/viewvc?rev=1208743&view=rev
Log:
Start testing for CXF-3943 and run into CXF-3944.

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
  (with props)
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
  (with props)
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml   (with props)
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml   (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/CorsHeaderConstants.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/CorsHeaderConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/CorsHeaderConstants.java?rev=1208743&r1=1208742&r2=1208743&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/CorsHeaderConstants.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/cors/CorsHeaderConstants.java
Wed Nov 30 20:03:41 2011
@@ -24,7 +24,7 @@ package org.apache.cxf.jaxrs.cors;
  */
 public final class CorsHeaderConstants {
 
-    public static final String HEADER_ORIGIN = "origin";
+    public static final String HEADER_ORIGIN = "Origin";
     public static final String HEADER_AC_REQUEST_METHOD = "Access-Control-Request-Method";
     public static final String HEADER_AC_REQUEST_HEADERS = "Access-Control-Request-Headers";
     public static final String HEADER_AC_ALLOW_METHODS = "Access-Control-Allow-Methods";

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java?rev=1208743&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
Wed Nov 30 20:03:41 2011
@@ -0,0 +1,77 @@
+/**
+ * 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.jaxrs.cors;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.cors.CorsHeaderConstants;
+import org.apache.cxf.systest.jaxrs.AbstractSpringServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class BasicCrossOriginTest extends AbstractBusClientServerTestBase {
+    public static final String PORT = SpringServer.PORT;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
+                   launchServer(SpringServer.class, true));
+    }
+    
+    @org.junit.Ignore
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSimpleGet() throws Exception {
+        String origin = "http://localhost:" + PORT;
+        WebClient wc = WebClient.create(origin + "/");
+        WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
+        // Since our WebClient doesn't know from Origin, we need to do this ourselves.
+        wc.header("Origin", origin);
+        Response r = wc.replacePath("/simpleGet/HelloThere").accept("text/plain").get();
+        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+        String echo = IOUtils.toString((InputStream)r.getEntity());
+        assertEquals("HelloThere", echo);
+        MultivaluedMap<String, Object> m = r.getMetadata();
+        Object acAllowed = m.get(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN);
+        assertNotNull(acAllowed);
+        List<String> origins = (List<String>)acAllowed;
+        assertEquals(1, origins.size());
+        assertEquals(origin, origins.get(0));
+    }
+    
+    @Ignore
+    public static class SpringServer extends AbstractSpringServer {
+        public static final String PORT = AbstractSpringServer.PORT;
+        
+        public SpringServer() {
+            super("/jaxrs_cors");
+        }
+    }
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/BasicCrossOriginTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java?rev=1208743&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
Wed Nov 30 20:03:41 2011
@@ -0,0 +1,38 @@
+/**
+ * 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.jaxrs.cors;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+/**
+ * 
+ */
+public class CorsServer {
+
+    @GET
+    @Produces("text/plain")
+    @Path("/simpleGet/{echo}")
+    public String simpleGet(@PathParam("echo") String echo) {
+        return echo;
+    }
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/cors/CorsServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml?rev=1208743&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml (added)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml Wed Nov 30 20:03:41
2011
@@ -0,0 +1,44 @@
+<?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:jaxrs="http://cxf.apache.org/jaxrs"
+	xmlns:cxf="http://cxf.apache.org/core" 
+	xsi:schemaLocation="
+http://www.springframework.org/schema/beans 
+http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/jaxrs
+http://cxf.apache.org/schemas/jaxrs.xsd
+http://cxf.apache.org/core 
+      http://cxf.apache.org/schemas/core.xsd">
+	<import resource="classpath:/META-INF/cxf/cxf.xml" />
+
+	<bean id="cors-input" class="org.apache.cxf.jaxrs.cors.CrossOriginInputFilter">
+		<property name="allowAllOrigins" value="true" />
+	</bean>
+	<bean id="cors-output" class="org.apache.cxf.jaxrs.cors.CrossOriginOutputFilter">
+	</bean>
+
+	<jaxrs:server id="cors-service" address="/">
+		<jaxrs:serviceBeans>
+			<ref bean="cors-server" />
+		</jaxrs:serviceBeans>
+		<jaxrs:providers>
+			<ref bean="cors-input" />
+			<ref bean="cors-output" />
+		</jaxrs:providers>
+		<jaxrs:features>
+			<cxf:logging />
+		</jaxrs:features>
+	</jaxrs:server>
+	<bean id="cors-server" scope="prototype"
+		class="org.apache.cxf.systest.jaxrs.cors.CorsServer" />
+</beans>

Propchange: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml?rev=1208743&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml (added)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml Wed Nov 30 20:03:41
2011
@@ -0,0 +1,46 @@
+<?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.
+-->
+<!-- START SNIPPET: webxml -->
+<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>/WEB-INF/beans.xml</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>
+<!-- END SNIPPET: webxml -->
\ No newline at end of file

Propchange: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_cors/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message