You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/04/06 21:54:20 UTC

tomee git commit: TOMEE-1542 handling @AppPath trailing star

Repository: tomee
Updated Branches:
  refs/heads/master ad896c6d5 -> 2bc607255


TOMEE-1542 handling @AppPath trailing star


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2bc60725
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2bc60725
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2bc60725

Branch: refs/heads/master
Commit: 2bc607255b785f8530cbb5478cd8ec8304fb1212
Parents: ad896c6
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon Apr 6 21:54:11 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon Apr 6 21:54:11 2015 +0200

----------------------------------------------------------------------
 .../server/cxf/rs/ApplicationStarTest.java      | 61 ++++++++++++++++++++
 .../apache/openejb/server/rest/RESTService.java | 17 +++---
 2 files changed, 71 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2bc60725/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationStarTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationStarTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationStarTest.java
new file mode 100644
index 0000000..156eea9
--- /dev/null
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/ApplicationStarTest.java
@@ -0,0 +1,61 @@
+/*
+ *     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.openejb.server.cxf.rs;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.RandomPort;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices("jaxrs")
+@RunWith(ApplicationComposer.class)
+@Classes({ ApplicationStarTest.MyEndpoint.class, ApplicationStarTest.MyApp.class })
+public class ApplicationStarTest {
+    @RandomPort("http")
+    private int port;
+
+    @Test
+    public void checkStarIsNotAnIssue() {
+        assertEquals("ok", WebClient.create("http://localhost:" + port + "/openejb/").path("test").get(String.class));
+    }
+
+    @Path("test")
+    public static class MyEndpoint {
+        @GET
+        public String get() {
+            return "ok";
+        }
+    }
+
+    @ApplicationPath("/*")
+    public static class MyApp extends Application {
+        @GET
+        public String get() {
+            return "ok";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/2bc60725/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
----------------------------------------------------------------------
diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
index 7d6bc32..6f58737 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
@@ -51,12 +51,6 @@ import org.apache.openejb.util.Logger;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.xbean.finder.MetaAnnotatedClass;
 
-import javax.naming.Context;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.ext.Provider;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -73,6 +67,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import javax.naming.Context;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.ext.Provider;
 
 @SuppressWarnings("UnusedDeclaration")
 public abstract class RESTService implements ServerService, SelfManaging {
@@ -515,7 +515,10 @@ public abstract class RESTService implements ServerService, SelfManaging {
         // annotation
         final ApplicationPath path = appClazz.getAnnotation(ApplicationPath.class);
         if (path != null) {
-            final String appPath = path.value();
+            String appPath = path.value();
+            if (appPath.endsWith("*")) {
+                appPath = appPath.substring(0, appPath.length() - 1);
+            }
 
             if (builder == null) {
                 builder = new StringBuilder();