Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 63111 invoked from network); 14 Dec 2009 10:51:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Dec 2009 10:51:56 -0000 Received: (qmail 61968 invoked by uid 500); 14 Dec 2009 10:51:56 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 61852 invoked by uid 500); 14 Dec 2009 10:51:55 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 61837 invoked by uid 99); 14 Dec 2009 10:51:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 10:51:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2009 10:51:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8C12323889D2; Mon, 14 Dec 2009 10:51:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r890268 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/wadl/ test/java/org/apache/cxf/jaxrs/model/wadl/ Date: Mon, 14 Dec 2009 10:51:31 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091214105131.8C12323889D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Mon Dec 14 10:51:30 2009 New Revision: 890268 URL: http://svn.apache.org/viewvc?rev=890268&view=rev Log: Minor update to WADLGenerator to ensure no duplicate forward slashes get concatenated by some tools Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java (with props) Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=890268&r1=890267&r2=890268&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Mon Dec 14 10:51:30 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(""); handleDocs(ori.getAnnotatedMethod().getAnnotations(), sb); } Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java?rev=890268&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java (added) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java Mon Dec 14 10:51:30 2009 @@ -0,0 +1,32 @@ +/** + * 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.jaxrs.model.wadl; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +@Path("/") +public class BookStoreWithSingleSlash { + + @GET + @Path("book") + public String getBookName() { + return "book"; + } +} Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStoreWithSingleSlash.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=890268&r1=890267&r2=890268&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java Mon Dec 14 10:51:30 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 rootEls = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 1); + assertEquals(1, rootEls.size()); + Element resource = rootEls.get(0); + assertEquals("/", resource.getAttribute("path")); + List 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