Author: sergeyb
Date: Wed Nov 27 21:32:27 2013
New Revision: 1546200
URL: http://svn.apache.org/r1546200
Log:
Fixing a regression on the trunk to do with listing all JAX-RS resources
Modified:
cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
Modified:
cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1546200&r1=1546199&r2=1546200&view=diff
==============================================================================
---
cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++
cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Wed Nov 27 21:32:27 2013
@@ -140,7 +140,8 @@ public class WadlGenerator implements Co
private boolean supportCollections = true;
private boolean supportJaxbXmlType = true;
private boolean supportJaxbSubstitutions = true;
-
+ private boolean checkAbsolutePathSlash;
+
private List<String> externalSchemasCache;
private List<URI> externalSchemaLinks;
private Map<String, List<String>> externalQnamesMap;
@@ -153,7 +154,7 @@ public class WadlGenerator implements Co
private String nsPrefix = DEFAULT_NS_PREFIX;
private MediaType defaultMediaType = DEFAULT_MEDIA_TYPE;
private Bus bus;
-
+
public WadlGenerator() {
}
@@ -895,7 +896,8 @@ public class WadlGenerator implements Co
}
List<ClassResourceInfo> all =
((JAXRSServiceImpl)m.getExchange().get(Service.class))
.getClassResourceInfos();
- if (slash.equals(path) &&
!ui.getAbsolutePath().getPath().endsWith(slash)) {
+ boolean absolutePathSlashOn = checkAbsolutePathSlash &&
ui.getAbsolutePath().getPath().endsWith(slash);
+ if (slash.equals(path) && !absolutePathSlashOn) {
return all;
}
List<ClassResourceInfo> cris = new LinkedList<ClassResourceInfo>();
@@ -1787,6 +1789,10 @@ public class WadlGenerator implements Co
this.supportJaxbSubstitutions = supportJaxbSubstitutions;
}
+ public void setCheckAbsolutePathSlash(boolean checkAbsolutePathSlash) {
+ this.checkAbsolutePathSlash = checkAbsolutePathSlash;
+ }
+
private static class SchemaConverter extends DelegatingXMLStreamWriter {
private static final String SCHEMA_LOCATION = "schemaLocation";
private Map<String, String> locsMap;
Modified:
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=1546200&r1=1546199&r2=1546200&view=diff
==============================================================================
---
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
(original)
+++
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
Wed Nov 27 21:32:27 2013
@@ -20,14 +20,22 @@
package org.apache.cxf.systest.jaxrs;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
+import java.util.List;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.junit.BeforeClass;
@@ -45,6 +53,26 @@ public class JAXRSClientServerProxySprin
}
@Test
+ public void testGetWadlResourcesInfo() throws Exception {
+ WebClient client = WebClient.create("http://localhost:" + PORT +
"/test/" + "?_wadl&_type=xml");
+
WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000);
+ Document doc = StaxUtils.read(new
InputStreamReader(client.get(InputStream.class), "UTF-8"));
+ StaxUtils.writeTo(doc.getDocumentElement(), System.out);
+ Element root = doc.getDocumentElement();
+ assertEquals(WadlGenerator.WADL_NS, root.getNamespaceURI());
+ assertEquals("application", root.getLocalName());
+ List<Element> resourcesEls = DOMUtils.getChildrenWithName(root,
+
WadlGenerator.WADL_NS, "resources");
+ assertEquals(1, resourcesEls.size());
+ Element resourcesEl = resourcesEls.get(0);
+ assertEquals("http://localhost:" + PORT + "/test/",
resourcesEl.getAttribute("base"));
+ List<Element> resourceEls =
+ DOMUtils.getChildrenWithName(resourcesEl,
+ WadlGenerator.WADL_NS, "resource");
+ assertEquals(2, resourceEls.size());
+ }
+
+ @Test
public void testGetBookNotFound() throws Exception {
String endpointAddress =