[aries-jax-rs-whiteboard] branch master updated: [ARIES-2002] better IT test for unproxying, thanks csierra for the catch

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
 new 9f7d741  [ARIES-2002] better IT test for unproxying, thanks csierra 
for the catch
9f7d741 is described below

commit 9f7d741c5293898527fa25abdbd062beccfe5148
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 18:34:13 2020 +0200

[ARIES-2002] better IT test for unproxying, thanks csierra for the catch
---
 jax-rs.itests/src/main/java/test/JaxrsTest.java|  2 +-
 .../java/test/types/TestApplicationWithSingletons.java | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java 
b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 26fc4ef..5f8ef66 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -153,7 +153,7 @@ public class JaxrsTest extends TestHelper {
 assertArrayEquals(
 new String[]{MediaType.TEXT_PLAIN},
 resourceMethod.producingMimeType);
-assertNull(resourceMethod.nameBindings);
+assertArrayEquals(new 
String[]{TestApplicationWithSingletons.Bind.class.getName()}, 
resourceMethod.nameBindings);
 }
 
 @Test
diff --git 
a/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java 
b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
index 0fd34cf..4ff9ba0 100644
--- a/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
+++ b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
@@ -18,12 +18,19 @@
 package test.types;
 
 import javax.ws.rs.GET;
+import javax.ws.rs.NameBinding;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Application;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
 import java.util.Collections;
 import java.util.Set;
 
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 public class TestApplicationWithSingletons extends Application {
 
 @Override
@@ -31,6 +38,7 @@ public class TestApplicationWithSingletons extends 
Application {
 return Collections.singleton(new MyResource$$Proxy());
 }
 
+@Bind
 @Path("my")
 @Produces("text/plain")
 public static class MyResource {
@@ -40,6 +48,12 @@ public class TestApplicationWithSingletons extends 
Application {
 }
 }
 
+@NameBinding
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+public @interface Bind {
+}
+
 public static class MyResource$$Proxy extends MyResource {
 }
 }



[aries-jax-rs-whiteboard] branch master updated: [ARIES-2002] better IT test for unproxying, thanks csierra for the catch

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
 new 9f7d741  [ARIES-2002] better IT test for unproxying, thanks csierra 
for the catch
9f7d741 is described below

commit 9f7d741c5293898527fa25abdbd062beccfe5148
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 18:34:13 2020 +0200

[ARIES-2002] better IT test for unproxying, thanks csierra for the catch
---
 jax-rs.itests/src/main/java/test/JaxrsTest.java|  2 +-
 .../java/test/types/TestApplicationWithSingletons.java | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java 
b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 26fc4ef..5f8ef66 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -153,7 +153,7 @@ public class JaxrsTest extends TestHelper {
 assertArrayEquals(
 new String[]{MediaType.TEXT_PLAIN},
 resourceMethod.producingMimeType);
-assertNull(resourceMethod.nameBindings);
+assertArrayEquals(new 
String[]{TestApplicationWithSingletons.Bind.class.getName()}, 
resourceMethod.nameBindings);
 }
 
 @Test
diff --git 
a/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java 
b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
index 0fd34cf..4ff9ba0 100644
--- a/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
+++ b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java
@@ -18,12 +18,19 @@
 package test.types;
 
 import javax.ws.rs.GET;
+import javax.ws.rs.NameBinding;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Application;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
 import java.util.Collections;
 import java.util.Set;
 
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 public class TestApplicationWithSingletons extends Application {
 
 @Override
@@ -31,6 +38,7 @@ public class TestApplicationWithSingletons extends 
Application {
 return Collections.singleton(new MyResource$$Proxy());
 }
 
+@Bind
 @Path("my")
 @Produces("text/plain")
 public static class MyResource {
@@ -40,6 +48,12 @@ public class TestApplicationWithSingletons extends 
Application {
 }
 }
 
+@NameBinding
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+public @interface Bind {
+}
+
 public static class MyResource$$Proxy extends MyResource {
 }
 }



[aries-jax-rs-whiteboard] branch master updated (a1d59be -> eb41442)

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git.


from a1d59be  [ARIES-2002] test for unproxying of getSingletons
 new db1cb1b  [ARIES-2003] ensure @ApplicationPath is always ignored
 new eb41442  [ARIES-2002][ARIES-2003] IT for auto unproxying and 
@ApplicationPath ignore logic

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jax-rs.itests/src/main/java/test/JaxrsTest.java| 47 ++
 .../test/types/TestApplicationWithAppPath.java | 27 ++---
 .../test/types/TestApplicationWithSingletons.java  | 26 ++--
 .../internal/cxf/CxfJaxrsServiceRegistrator.java   |  3 +-
 .../cxf/CxfJaxrsServiceRegistratorTest.java| 12 ++
 5 files changed, 85 insertions(+), 30 deletions(-)
 copy 
integrations/openapi/openapi-itest/src/main/java/test/types/TestApplicationWithClasses.java
 => jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java (77%)
 copy 
integrations/openapi/openapi-itest/src/main/java/test/types/TestApplicationWithClasses.java
 => jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java 
(76%)



[aries-jax-rs-whiteboard] 01/02: [ARIES-2003] ensure @ApplicationPath is always ignored

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git

commit db1cb1bff8d76104f55007d9b6801559bc4086fa
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 17:56:24 2020 +0200

[ARIES-2003] ensure @ApplicationPath is always ignored
---
 .../whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java  |  3 ++-
 .../internal/cxf/CxfJaxrsServiceRegistratorTest.java | 12 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index 760a94a..9debe73 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -246,6 +246,7 @@ public class CxfJaxrsServiceRegistrator {
 }
 
 String address = "/";
+/* spec ignores @ApplicationPath
 ApplicationPath appPath = 
ResourceUtils.locateApplicationPath(app.getClass());
 if (appPath != null) {
 address = appPath.value();
@@ -253,7 +254,7 @@ public class CxfJaxrsServiceRegistrator {
 if (!address.startsWith("/")) {
 address = "/" + address;
 }
-// todo resolve conflicts between @ApplicationPath and 
@JaxrsApplicationBase (if same  value -> use only one?)
+ */
 bean.setAddress(address);
 bean.setStaticSubresourceResolution(false);
 bean.setResourceClasses(resourceClasses);
diff --git 
a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
index 3013cdd..902a4ba 100644
--- 
a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
+++ 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
@@ -21,6 +21,7 @@ import 
org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.junit.Test;
 
+import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.Application;
@@ -52,6 +53,17 @@ public class CxfJaxrsServiceRegistratorTest {
 
assertTrue(SingletonResourceProvider.class.isInstance(cri.getResourceProvider()));
 }
 
+@Test
+public void ignoreAppPAth() {
+final JAXRSServerFactoryBean bean = new CxfJaxrsServiceRegistrator(
+null, null, emptyMap(), null
+).createEndpoint(new MyApp(), JAXRSServerFactoryBean.class);
+assertEquals("/", bean.getAddress());
+}
+
+@ApplicationPath("foo")
+public static class MyApp extends Application {}
+
 @Path("my")
 public static class MyResource {
 @GET



[aries-jax-rs-whiteboard] 01/02: [ARIES-2003] ensure @ApplicationPath is always ignored

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git

commit db1cb1bff8d76104f55007d9b6801559bc4086fa
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 17:56:24 2020 +0200

[ARIES-2003] ensure @ApplicationPath is always ignored
---
 .../whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java  |  3 ++-
 .../internal/cxf/CxfJaxrsServiceRegistratorTest.java | 12 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index 760a94a..9debe73 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -246,6 +246,7 @@ public class CxfJaxrsServiceRegistrator {
 }
 
 String address = "/";
+/* spec ignores @ApplicationPath
 ApplicationPath appPath = 
ResourceUtils.locateApplicationPath(app.getClass());
 if (appPath != null) {
 address = appPath.value();
@@ -253,7 +254,7 @@ public class CxfJaxrsServiceRegistrator {
 if (!address.startsWith("/")) {
 address = "/" + address;
 }
-// todo resolve conflicts between @ApplicationPath and 
@JaxrsApplicationBase (if same  value -> use only one?)
+ */
 bean.setAddress(address);
 bean.setStaticSubresourceResolution(false);
 bean.setResourceClasses(resourceClasses);
diff --git 
a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
index 3013cdd..902a4ba 100644
--- 
a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
+++ 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
@@ -21,6 +21,7 @@ import 
org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.junit.Test;
 
+import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.Application;
@@ -52,6 +53,17 @@ public class CxfJaxrsServiceRegistratorTest {
 
assertTrue(SingletonResourceProvider.class.isInstance(cri.getResourceProvider()));
 }
 
+@Test
+public void ignoreAppPAth() {
+final JAXRSServerFactoryBean bean = new CxfJaxrsServiceRegistrator(
+null, null, emptyMap(), null
+).createEndpoint(new MyApp(), JAXRSServerFactoryBean.class);
+assertEquals("/", bean.getAddress());
+}
+
+@ApplicationPath("foo")
+public static class MyApp extends Application {}
+
 @Path("my")
 public static class MyResource {
 @GET



[aries-jax-rs-whiteboard] branch master updated (a1d59be -> eb41442)

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git.


from a1d59be  [ARIES-2002] test for unproxying of getSingletons
 new db1cb1b  [ARIES-2003] ensure @ApplicationPath is always ignored
 new eb41442  [ARIES-2002][ARIES-2003] IT for auto unproxying and 
@ApplicationPath ignore logic

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jax-rs.itests/src/main/java/test/JaxrsTest.java| 47 ++
 .../test/types/TestApplicationWithAppPath.java | 27 ++---
 .../test/types/TestApplicationWithSingletons.java  | 26 ++--
 .../internal/cxf/CxfJaxrsServiceRegistrator.java   |  3 +-
 .../cxf/CxfJaxrsServiceRegistratorTest.java| 12 ++
 5 files changed, 85 insertions(+), 30 deletions(-)
 copy 
integrations/openapi/openapi-itest/src/main/java/test/types/TestApplicationWithClasses.java
 => jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java (77%)
 copy 
integrations/openapi/openapi-itest/src/main/java/test/types/TestApplicationWithClasses.java
 => jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java 
(76%)



[aries-jax-rs-whiteboard] 02/02: [ARIES-2002][ARIES-2003] IT for auto unproxying and @ApplicationPath ignore logic

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git

commit eb41442bcdd4823b3ad6f023dc0d83e3718d6345
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 18:04:04 2020 +0200

[ARIES-2002][ARIES-2003] IT for auto unproxying and @ApplicationPath ignore 
logic
---
 jax-rs.itests/src/main/java/test/JaxrsTest.java| 47 ++
 .../test/types/TestApplicationWithAppPath.java | 44 
 .../test/types/TestApplicationWithSingletons.java  | 45 +
 3 files changed, 136 insertions(+)

diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java 
b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 32688b8..26fc4ef 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -78,7 +78,9 @@ import test.types.TestAddonConflict;
 import test.types.TestAddonConflict2;
 import test.types.TestApplication;
 import test.types.TestApplicationConflict;
+import test.types.TestApplicationWithAppPath;
 import test.types.TestApplicationWithException;
+import test.types.TestApplicationWithSingletons;
 import test.types.TestAsyncResource;
 import test.types.TestCxfExtension;
 import test.types.TestFilter;
@@ -110,6 +112,51 @@ import static org.junit.Assert.assertNull;
 public class JaxrsTest extends TestHelper {
 
 @Test
+public void testApplicationWithAppPath() throws InterruptedException {
+registerApplication(new TestApplicationWithAppPath());
+assertEquals(1, getRuntimeDTO().applicationDTOs.length);
+
+WebTarget webTarget = 
createDefaultTarget().path("/test-application/my");
+Response response = webTarget.request().get();
+assertEquals("ok", response.readEntity(String.class));
+
+RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
+ApplicationDTO[] applicationDTOs = runtimeDTO.applicationDTOs;
+assertEquals(1, applicationDTOs.length);
+
+ApplicationDTO applicationDTO = applicationDTOs[0];
+assertEquals("/test-application", applicationDTO.base);
+}
+
+@Test
+public void testApplicationWithSingletonProxy() throws 
InterruptedException {
+registerApplication(new TestApplicationWithSingletons());
+assertEquals(1, getRuntimeDTO().applicationDTOs.length);
+
+WebTarget webTarget = 
createDefaultTarget().path("/test-application/my");
+Response response = webTarget.request().get();
+assertEquals("ok", response.readEntity(String.class));
+
+RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
+ApplicationDTO[] applicationDTOs = runtimeDTO.applicationDTOs;
+assertEquals(1, applicationDTOs.length);
+
+ApplicationDTO applicationDTO = applicationDTOs[0];
+ResourceMethodInfoDTO[] resourceMethods =
+applicationDTO.resourceMethods;
+assertEquals(1, resourceMethods.length);
+
+ResourceMethodInfoDTO resourceMethod = resourceMethods[0];
+assertEquals(HttpMethod.GET, resourceMethod.method);
+assertEquals("/my", resourceMethod.path);
+assertNull(resourceMethod.consumingMimeType);
+assertArrayEquals(
+new String[]{MediaType.TEXT_PLAIN},
+resourceMethod.producingMimeType);
+assertNull(resourceMethod.nameBindings);
+}
+
+@Test
 public void testApplication() throws InterruptedException {
 assertEquals(0, getRuntimeDTO().applicationDTOs.length);
 
diff --git 
a/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java 
b/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java
new file mode 100644
index 000..02c9479
--- /dev/null
+++ b/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java
@@ -0,0 +1,44 @@
+/*
+ * 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 test.types;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Application;
+import java.util.Collections;
+import java.util.Set;
+
+@ApplicationPath("foo")

[aries-jax-rs-whiteboard] 02/02: [ARIES-2002][ARIES-2003] IT for auto unproxying and @ApplicationPath ignore logic

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git

commit eb41442bcdd4823b3ad6f023dc0d83e3718d6345
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 18:04:04 2020 +0200

[ARIES-2002][ARIES-2003] IT for auto unproxying and @ApplicationPath ignore 
logic
---
 jax-rs.itests/src/main/java/test/JaxrsTest.java| 47 ++
 .../test/types/TestApplicationWithAppPath.java | 44 
 .../test/types/TestApplicationWithSingletons.java  | 45 +
 3 files changed, 136 insertions(+)

diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java 
b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 32688b8..26fc4ef 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -78,7 +78,9 @@ import test.types.TestAddonConflict;
 import test.types.TestAddonConflict2;
 import test.types.TestApplication;
 import test.types.TestApplicationConflict;
+import test.types.TestApplicationWithAppPath;
 import test.types.TestApplicationWithException;
+import test.types.TestApplicationWithSingletons;
 import test.types.TestAsyncResource;
 import test.types.TestCxfExtension;
 import test.types.TestFilter;
@@ -110,6 +112,51 @@ import static org.junit.Assert.assertNull;
 public class JaxrsTest extends TestHelper {
 
 @Test
+public void testApplicationWithAppPath() throws InterruptedException {
+registerApplication(new TestApplicationWithAppPath());
+assertEquals(1, getRuntimeDTO().applicationDTOs.length);
+
+WebTarget webTarget = 
createDefaultTarget().path("/test-application/my");
+Response response = webTarget.request().get();
+assertEquals("ok", response.readEntity(String.class));
+
+RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
+ApplicationDTO[] applicationDTOs = runtimeDTO.applicationDTOs;
+assertEquals(1, applicationDTOs.length);
+
+ApplicationDTO applicationDTO = applicationDTOs[0];
+assertEquals("/test-application", applicationDTO.base);
+}
+
+@Test
+public void testApplicationWithSingletonProxy() throws 
InterruptedException {
+registerApplication(new TestApplicationWithSingletons());
+assertEquals(1, getRuntimeDTO().applicationDTOs.length);
+
+WebTarget webTarget = 
createDefaultTarget().path("/test-application/my");
+Response response = webTarget.request().get();
+assertEquals("ok", response.readEntity(String.class));
+
+RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
+ApplicationDTO[] applicationDTOs = runtimeDTO.applicationDTOs;
+assertEquals(1, applicationDTOs.length);
+
+ApplicationDTO applicationDTO = applicationDTOs[0];
+ResourceMethodInfoDTO[] resourceMethods =
+applicationDTO.resourceMethods;
+assertEquals(1, resourceMethods.length);
+
+ResourceMethodInfoDTO resourceMethod = resourceMethods[0];
+assertEquals(HttpMethod.GET, resourceMethod.method);
+assertEquals("/my", resourceMethod.path);
+assertNull(resourceMethod.consumingMimeType);
+assertArrayEquals(
+new String[]{MediaType.TEXT_PLAIN},
+resourceMethod.producingMimeType);
+assertNull(resourceMethod.nameBindings);
+}
+
+@Test
 public void testApplication() throws InterruptedException {
 assertEquals(0, getRuntimeDTO().applicationDTOs.length);
 
diff --git 
a/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java 
b/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java
new file mode 100644
index 000..02c9479
--- /dev/null
+++ b/jax-rs.itests/src/main/java/test/types/TestApplicationWithAppPath.java
@@ -0,0 +1,44 @@
+/*
+ * 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 test.types;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Application;
+import java.util.Collections;
+import java.util.Set;
+
+@ApplicationPath("foo")

[aries-jax-rs-whiteboard] branch master updated: [ARIES-2002] test for unproxying of getSingletons

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
 new a1d59be  [ARIES-2002] test for unproxying of getSingletons
a1d59be is described below

commit a1d59beeb65264322846d25093f1a0b32fa2188c
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 17:50:18 2020 +0200

[ARIES-2002] test for unproxying of getSingletons
---
 .../internal/cxf/CxfJaxrsServiceRegistrator.java   |  5 +-
 .../cxf/CxfJaxrsServiceRegistratorTest.java| 65 ++
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index 22dfc88..760a94a 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -30,7 +30,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,6 @@ import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Feature;
 import javax.ws.rs.core.FeatureContext;
 import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.RuntimeDelegate;
 
 import org.apache.aries.component.dsl.CachingServiceReference;
 import org.apache.aries.component.dsl.OSGi;
@@ -269,6 +267,9 @@ public class CxfJaxrsServiceRegistrator {
 bean.getProperties(true).putAll(appProps);
 }
 bean.setApplication(app);
+if (_bus != null) {
+bean.setBus(_bus);
+}
 
 if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
 return endpointType.cast(bean);
diff --git 
a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
new file mode 100644
index 000..3013cdd
--- /dev/null
+++ 
b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.aries.jax.rs.whiteboard.internal.cxf;
+
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.junit.Test;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+import java.util.Set;
+
+import static java.util.Collections.emptyMap;
+import static java.util.Collections.singleton;
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CxfJaxrsServiceRegistratorTest {
+@Test
+public void unproxy() {
+final JAXRSServerFactoryBean bean = new CxfJaxrsServiceRegistrator(
+null, null, emptyMap(), null
+).createEndpoint(new Application() {
+@Override
+public Set getSingletons() {
+return singleton(new MyResource$$Proxy());
+}
+}, JAXRSServerFactoryBean.class);
+bean.setStart(false);
+bean.create();
+assertEquals(singletonList(MyResource.class), 
bean.getResourceClasses());
+final ClassResourceInfo cri = 
bean.getServiceFactory().getClassResourceInfo().iterator().next();
+assertEquals(MyResource.class, cri.getServiceClass());
+assertEquals(MyResource.class, cri.getResourceClass());
+
assertTrue(SingletonResourceProvider.class.isInstance(cri.getResourceProvider()));
+}
+
+@Path("my")
+public static class MyResource {
+ 

[aries-jax-rs-whiteboard] branch master updated: [ARIES-2002] ensure proxies are unwrapped for jaxrs resources

2020-09-22 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
 new 9bc35a6  [ARIES-2002] ensure proxies are unwrapped for jaxrs resources
9bc35a6 is described below

commit 9bc35a623ed0cf0c4a0e1f583d5be60027a23f49
Author: Romain Manni-Bucau 
AuthorDate: Tue Sep 22 16:50:53 2020 +0200

[ARIES-2002] ensure proxies are unwrapped for jaxrs resources
---
 .../internal/cxf/CxfJaxrsServiceRegistrator.java   | 85 --
 .../internal/cxf/PromiseAwareJAXRSInvoker.java | 12 +--
 .../internal/introspection/ClassIntrospector.java  | 12 ++-
 .../whiteboard/internal/introspection/Proxies.java | 31 
 4 files changed, 129 insertions(+), 11 deletions(-)

diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index f1ba154..22dfc88 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -23,6 +23,7 @@ import static 
org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.SUPPORTED_E
 import static 
org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.canonicalize;
 import static 
org.apache.cxf.jaxrs.provider.ProviderFactory.DEFAULT_FILTER_NAME_BINDING;
 
+import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -34,16 +35,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
+import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.RuntimeType;
 import javax.ws.rs.container.DynamicFeature;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Feature;
 import javax.ws.rs.core.FeatureContext;
+import javax.ws.rs.ext.Provider;
 import javax.ws.rs.ext.RuntimeDelegate;
 
 import org.apache.aries.component.dsl.CachingServiceReference;
@@ -51,6 +53,7 @@ import org.apache.aries.component.dsl.OSGi;
 import org.apache.aries.jax.rs.whiteboard.ApplicationClasses;
 import org.apache.aries.jax.rs.whiteboard.internal.AriesJaxrsServiceRuntime;
 import org.apache.aries.jax.rs.whiteboard.internal.ServiceReferenceRegistry;
+import org.apache.aries.jax.rs.whiteboard.internal.introspection.Proxies;
 import org.apache.aries.jax.rs.whiteboard.internal.utils.ServiceTuple;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.util.ClassHelper;
@@ -61,7 +64,9 @@ import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 import org.apache.cxf.jaxrs.ext.ContextProvider;
 import org.apache.cxf.jaxrs.ext.ResourceContextProvider;
 import org.apache.cxf.jaxrs.impl.ConfigurableImpl;
+import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.ApplicationInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import 
org.apache.cxf.jaxrs.provider.ProviderFactory.ProviderInfoClassComparator;
@@ -69,6 +74,7 @@ import 
org.apache.cxf.jaxrs.provider.ServerConfigurableFactory;
 import org.apache.cxf.jaxrs.sse.SseContextProvider;
 import org.apache.cxf.jaxrs.sse.SseEventSinkContextProvider;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 
 public class CxfJaxrsServiceRegistrator {
@@ -196,19 +202,88 @@ public class CxfJaxrsServiceRegistrator {
 }
 
 public  T createEndpoint(Application app, Class endpointType) {
-JAXRSServerFactoryBean bean =
-RuntimeDelegate.getInstance().createEndpoint(
-app, JAXRSServerFactoryBean.class);
+// final JAXRSServerFactoryBean bean = 
ResourceUtils.createApplication(app, false, false, false, null);
+final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
+Set singletons = app.getSingletons();
+if (!singletons.isEmpty() && 
singletons.stream().map(Object::getClass).count() < singletons.size()) {
+throw new IllegalArgumentException("More than one instance of the 
same singleton class is available: " + singletons);
+}
+
+final List> resourceClasses = new ArrayList<>();
+final List providers = new ArrayList<>();
+final List features = new 
ArrayList<>();
+final Map, ResourceProvider> map = new HashMap<>();
+
+// Note, app.getClasses() returns a list of