You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2009/06/22 15:26:08 UTC

svn commit: r787232 - in /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src: main/java/org/apache/chemistry/atompub/server/jaxrs/ test/java/org/apache/chemistry/atompub/server/ test/resources/jaxrs/

Author: fguillaume
Date: Mon Jun 22 13:26:07 2009
New Revision: 787232

URL: http://svn.apache.org/viewvc?rev=787232&view=rev
Log:
Put explicit @Path("cmis") on the JAX-RS Resource, tests

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java?rev=787232&r1=787231&r2=787232&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java Mon Jun 22 13:26:07 2009
@@ -43,10 +43,8 @@
 /**
  * A JAX-RS Resource that dispatches to the underlying Abdera
  * {@link CMISProvider}.
- * <p>
- * In some contexts (Nuxeo WebEngine), the path of this resource is injected by
- * the framework, so no @Path annotation must be specified.
  */
+@Path("cmis")
 public class AbderaResource {
 
     private static final Log log = LogFactory.getLog(AbderaResource.class);
@@ -78,6 +76,10 @@
      * <p>
      * Wrapping is needed to fixup the servlet path to take include this
      * Resource's path.
+     * <p>
+     * We need to pass an explicit number of segments because
+     * UriInfo.getMatchedURIs is buggy for RESTEasy
+     * (https://jira.jboss.org/jira/browse/RESTEASY-100)
      *
      * @param segments the number of segments of the method invoking this, used
      *            to determine the Resource path

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java?rev=787232&r1=787231&r2=787232&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java Mon Jun 22 13:26:07 2009
@@ -67,7 +67,12 @@
     protected static final String CONTEXT_PATH = "/ctx";
 
     // also in web.xml for JAX-RS
-    protected static final String SERVLET_PATH = "/cmis";
+    protected static final String SERVLET_PATH = "/srv";
+
+    // additional path to use after the servlet, used by JAX-RS
+    protected String getResourcePath() {
+        return "";
+    }
 
     @Override
     public void setUp() throws Exception {
@@ -148,7 +153,7 @@
     }
 
     public void testConnect() throws Exception {
-        String base = "http://localhost:" + PORT + CONTEXT_PATH + SERVLET_PATH;
+        String base = "http://localhost:" + PORT + CONTEXT_PATH + SERVLET_PATH + getResourcePath();
         ClientResponse resp;
 
         resp = client.get(base + "/repository");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java?rev=787232&r1=787231&r2=787232&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java Mon Jun 22 13:26:07 2009
@@ -22,6 +22,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import javax.ws.rs.Path;
+
 import org.apache.chemistry.atompub.server.jaxrs.AbderaResource;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.IOUtils;
@@ -36,6 +38,19 @@
     private File tmpDir;
 
     @Override
+    protected String getResourcePath() {
+        Path pa = AbderaResource.class.getAnnotation(Path.class);
+        if (pa == null) {
+            return "";
+        }
+        String path = pa.value();
+        if (!path.startsWith("/")) {
+            path = '/' + path;
+        }
+        return path;
+    }
+
+    @Override
     public void startServer() throws Exception {
         AbderaResource.repository = repository; // TODO inject differently
         server = new Server(PORT);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml?rev=787232&r1=787231&r2=787232&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml Mon Jun 22 13:26:07 2009
@@ -14,6 +14,6 @@
 
   <servlet-mapping>
     <servlet-name>cxfjaxrs</servlet-name>
-    <url-pattern>/cmis/*</url-pattern> <!-- also in AtomPubServerTestCase -->
+    <url-pattern>/srv/*</url-pattern> <!-- also in AtomPubServerTestCase -->
   </servlet-mapping>
 </web-app>