cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r890271 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/
Date Mon, 14 Dec 2009 11:02:21 GMT
Author: sergeyb
Date: Mon Dec 14 11:02:21 2009
New Revision: 890271

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

........
  r890268 | sergeyb | 2009-12-14 10:51:30 +0000 (Mon, 14 Dec 2009) | 1 line
  
  Minor update to WADLGenerator to ensure no duplicate forward slashes get concatenated by
some tools
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java
      - copied unchanged from r890268, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java
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/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 14 11:02:21 2009
@@ -1 +1 @@
-/cxf/trunk:889426,889595,889601,889740,889790-889796,889885
+/cxf/trunk:889426,889595,889601,889740,889790-889796,889885,890268

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/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=890271&r1=890270&r2=890271&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
Mon Dec 14 11:02:21 2009
@@ -212,6 +212,13 @@
         String path = ori.getURITemplate().getValue();
         boolean useResource = useResource(ori);
         if (useResource) {
+            URITemplate template = ori.getClassResourceInfo().getURITemplate();
+            if (template != null) {
+                String parentPath = template.getValue();
+                if (parentPath.endsWith("/") && path.startsWith("/") && path.length()
> 1) {
+                    path = path.substring(1); 
+                }
+            }
             sb.append("<resource path=\"").append(path).append("\">");
             handleDocs(ori.getAnnotatedMethod().getAnnotations(), sb);
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=890271&r1=890270&r2=890271&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Mon Dec 14 11:02:21 2009
@@ -18,8 +18,6 @@
  */
 package org.apache.cxf.jaxrs.model.wadl;
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
@@ -80,18 +78,39 @@
         
     }
     
+    @Test
+    public void testRootResourceWithSingleSlash() throws Exception {
+        WadlGenerator wg = new WadlGenerator();
+        ClassResourceInfo cri = 
+            ResourceUtils.createClassResourceInfo(BookStoreWithSingleSlash.class, 
+                                                  BookStoreWithSingleSlash.class, true, true);
+        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY,
null);
+        
+        Response r = wg.handleRequest(m, cri);
+        checkResponse(r);
+        Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
+        List<Element> rootEls = getWadlResourcesInfo(doc, "http://localhost:8080/baz",
1);
+        assertEquals(1, rootEls.size());
+        Element resource = rootEls.get(0);
+        assertEquals("/", resource.getAttribute("path"));
+        List<Element> resourceEls = DOMUtils.getChildrenWithName(resource, 
+                                                                 WadlGenerator.WADL_NS, "resource");
+        assertEquals(1, resourceEls.size());        
+        assertEquals("book", resourceEls.get(0).getAttribute("path"));
+    }
+    
     private void checkResponse(Response r) throws Exception {
         assertNotNull(r);
         assertEquals(WadlGenerator.WADL_TYPE.toString(),
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
-        File f = new File("test.xml");
-        f.delete();
-        f.createNewFile();
-        System.out.println(f.getAbsolutePath());
-        FileOutputStream fos = new FileOutputStream(f);
-        fos.write(r.getEntity().toString().getBytes());
-        fos.flush();
-        fos.close();
+//        File f = new File("test.xml");
+//        f.delete();
+//        f.createNewFile();
+//        System.out.println(f.getAbsolutePath());
+//        FileOutputStream fos = new FileOutputStream(f);
+//        fos.write(r.getEntity().toString().getBytes());
+//        fos.flush();
+//        fos.close();
     }
     
     @Test



Mime
View raw message