cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r999649 - in /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security: JAXRSSpringSecurityClassTest.java SecureBookStoreNoInterface.java
Date Tue, 21 Sep 2010 21:23:55 GMT
Author: sergeyb
Date: Tue Sep 21 21:23:55 2010
New Revision: 999649

URL: http://svn.apache.org/viewvc?rev=999649&view=rev
Log:
Adding a test confirming post parameters can be retrieved from HttpServletContext

Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java?rev=999649&r1=999648&r2=999649&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
Tue Sep 21 21:23:55 2010
@@ -62,6 +62,19 @@ public class JAXRSSpringSecurityClassTes
     }
     
     @Test
+    public void testBookFromHttpRequestParameters() throws Exception {
+        
+        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstorestorage/bookforms2",

+                                        "foo", "bar", null);
+        
+        Response r = wc.form(new Form().set("name", "CXF Rocks").set("id", "123"));
+        
+        Book b = readBook((InputStream)r.getEntity());
+        assertEquals("CXF Rocks", b.getName());
+        assertEquals(123L, b.getId());
+    }
+    
+    @Test
     public void testGetBookUserAdmin() throws Exception {
         String endpointAddress =
             "http://localhost:" + PORT + "/bookstorestorage/thosebooks/123"; 

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java?rev=999649&r1=999648&r2=999649&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java
Tue Sep 21 21:23:55 2010
@@ -23,12 +23,16 @@ import java.util.HashMap;
 import java.util.Map;
 
 import javax.annotation.security.RolesAllowed;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.systest.jaxrs.Book;
 import org.apache.cxf.systest.jaxrs.BookNotFoundFault;
@@ -54,6 +58,15 @@ public class SecureBookStoreNoInterface 
         return new Book(name, id);
     }
     
+    @POST
+    @Path("/bookforms2")
+    @RolesAllowed({"ROLE_USER", "ROLE_ADMIN" })
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    public Book getBookFromHttpRequestParams(@Context HttpServletRequest request) {
+        Map<String, String[]> params = request.getParameterMap();
+        return getBookFromFormParams(params.get("name")[0], Long.valueOf(params.get("id")[0]));
+    }
+    
     @GET
     @Path("/thosebooks/{bookId}/{id}")
     @Produces("application/xml")



Mime
View raw message