cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r897197 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/
Date Fri, 08 Jan 2010 13:26:57 GMT
Author: sergeyb
Date: Fri Jan  8 13:26:57 2010
New Revision: 897197

URL: http://svn.apache.org/viewvc?rev=897197&view=rev
Log:
Merged revisions 897196 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r897196 | sergeyb | 2010-01-08 13:16:28 +0000 (Fri, 08 Jan 2010) | 1 line
  
  JAX-RS : better parsing of http headers
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:897196

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=897197&r1=897196&r2=897197&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Fri Jan  8 13:26:57 2010
@@ -46,7 +46,7 @@
 
     // TODO : it can be optimized, "Mastering Regular Expressions" has the answers
     private static final String COMPLEX_HEADER_EXPRESSION = 
-        "((\"(([^\"])|(?<=\\\\)\")*\")|([^\",]*))(;[\\w]+)?";
+        "(([\\w]+=\"[^\"]*\")|([\\w]+=[\\w]+)|([\\w]+))(;(([\\w]+=\"[^\"]*\")|([\\w]+=[\\w]+)|([\\w]+)))?";
     private static final Pattern COMPLEX_HEADER_PATTERN =
         Pattern.compile(COMPLEX_HEADER_EXPRESSION);
     private static final String QUOTE = "\"";

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=897197&r1=897196&r2=897197&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Fri Jan  8 13:26:57 2010
@@ -279,7 +279,7 @@
         return resourceTagOpened;
     }
     
-    private boolean compareOperations(OperationResourceInfo ori1, OperationResourceInfo ori2)
{
+    protected boolean compareOperations(OperationResourceInfo ori1, OperationResourceInfo
ori2) {
         if (ori1 == null || ori2 == null
             || !ori1.getURITemplate().getValue().equals(ori2.getURITemplate().getValue()))
{
             return false;
@@ -314,7 +314,7 @@
         return true;
     }
     
-    private void handleDynamicSubresource(StringBuilder sb, Set<Class<?>> jaxbTypes,

+    protected void handleDynamicSubresource(StringBuilder sb, Set<Class<?>> jaxbTypes,

                  JAXBContextProxy jaxbProxy, Map<Class<?>, QName> clsMap, OperationResourceInfo
ori,
                  ClassResourceInfo subcri) {
         
@@ -382,7 +382,7 @@
         }
     }
     
-    private void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, String
paramName) {
+    protected void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, String
paramName) {
         
         sb.append("<param name=\"").append(paramName).append("\" ");
         String style = ParameterType.PATH == pm.getType() ? "template" 
@@ -431,7 +431,7 @@
         }
     }
     
-    private List<OperationResourceInfo> sortOperationsByPath(Set<OperationResourceInfo>
ops) {
+    protected List<OperationResourceInfo> sortOperationsByPath(Set<OperationResourceInfo>
ops) {
         List<OperationResourceInfo> opsWithSamePath = new LinkedList<OperationResourceInfo>(ops);
         Collections.sort(opsWithSamePath, new Comparator<OperationResourceInfo>() {
 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java?rev=897197&r1=897196&r2=897197&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
Fri Jan  8 13:26:57 2010
@@ -49,25 +49,47 @@
     }
 
     @Test
-    public void testGetHeaderWithQuotes1() throws Exception {
+    public void testGetHeaderNameValue() throws Exception {
         
         Message m = control.createMock(Message.class);
         m.get(Message.PROTOCOL_HEADERS);
         MetadataMap<String, String> headers = 
-            createHeader("COMPLEX_HEADER", 
-                         "\"a\", \"a\";param, b, b;param, \"c, d, e\", \"c, d, e\";param");
+            createHeader("COMPLEX_HEADER",  "b=c; param=c, a=b;param=b");
         EasyMock.expectLastCall().andReturn(headers);
         control.replay();
         HttpHeaders h = new HttpHeadersImpl(m);
         List<String> values = h.getRequestHeader("COMPLEX_HEADER");
         assertNotNull(values);
-        assertEquals(6, values.size());
-        assertEquals("\"a\"", values.get(0));
-        assertEquals("\"a\";param", values.get(1));
+        assertEquals(2, values.size());
+        assertEquals("b=c; param=c", values.get(0));
+        assertEquals("a=b;param=b", values.get(1));
+    }
+    
+    @Test
+    public void testGetHeaderWithQuotes1() throws Exception {
+        
+        Message m = control.createMock(Message.class);
+        m.get(Message.PROTOCOL_HEADERS);
+        MetadataMap<String, String> headers = createHeader("COMPLEX_HEADER", 
+            "a1=\"a\", a2=\"a\";param, b, b;param, c1=\"c, d, e\", "
+            + "c2=\"c, d, e\";param, a=b, a=b;p=p1, a2=\"a\";param=p,"
+            + "a3=\"a\";param=\"p,b\"");
+        EasyMock.expectLastCall().andReturn(headers);
+        control.replay();
+        HttpHeaders h = new HttpHeadersImpl(m);
+        List<String> values = h.getRequestHeader("COMPLEX_HEADER");
+        assertNotNull(values);
+        assertEquals(10, values.size());
+        assertEquals("a1=\"a\"", values.get(0));
+        assertEquals("a2=\"a\";param", values.get(1));
         assertEquals("b", values.get(2));
         assertEquals("b;param", values.get(3));
-        assertEquals("\"c, d, e\"", values.get(4));
-        assertEquals("\"c, d, e\";param", values.get(5));
+        assertEquals("c1=\"c, d, e\"", values.get(4));
+        assertEquals("c2=\"c, d, e\";param", values.get(5));
+        assertEquals("a=b", values.get(6));
+        assertEquals("a=b;p=p1", values.get(7));
+        assertEquals("a2=\"a\";param=p", values.get(8));
+        assertEquals("a3=\"a\";param=\"p,b\"", values.get(9));
     }
     
     @Test
@@ -76,18 +98,19 @@
         Message m = control.createMock(Message.class);
         m.get(Message.PROTOCOL_HEADERS);
         MetadataMap<String, String> headers = 
-            createHeader("COMPLEX_HEADER", 
-                         "\"a   \\\"b\\\"\", b;param=b");
+            createHeader("X-WSSE", "UsernameToken Username=\"Foo\", Nonce=\"bar\"");
         EasyMock.expectLastCall().andReturn(headers);
         control.replay();
         HttpHeaders h = new HttpHeadersImpl(m);
-        List<String> values = h.getRequestHeader("COMPLEX_HEADER");
+        List<String> values = h.getRequestHeader("X-WSSE");
         assertNotNull(values);
-        assertEquals(2, values.size());
-        assertEquals("\"a   \\\"b\\\"\"", values.get(0));
-        assertEquals("b;param=b", values.get(1));
+        assertEquals(3, values.size());
+        assertEquals("UsernameToken", values.get(0));
+        assertEquals("Username=\"Foo\"", values.get(1));
+        assertEquals("Nonce=\"bar\"", values.get(2));
     }
     
+    
     @Test
     public void testGetHeaders() throws Exception {
         



Mime
View raw message