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 <rmannibu...@gmail.com> 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 0000000..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") +public class TestApplicationWithAppPath extends Application { + + @Override + public Set<Object> getSingletons() { + return Collections.<Object>singleton(new MyResource()); + } + + @Path("my") + @Produces("text/plain") + public static class MyResource { + @GET + public String get() { + return "ok"; + } + } +} diff --git a/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java new file mode 100644 index 0000000..0fd34cf --- /dev/null +++ b/jax-rs.itests/src/main/java/test/types/TestApplicationWithSingletons.java @@ -0,0 +1,45 @@ +/* + * 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.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; + +public class TestApplicationWithSingletons extends Application { + + @Override + public Set<Object> getSingletons() { + return Collections.<Object>singleton(new MyResource$$Proxy()); + } + + @Path("my") + @Produces("text/plain") + public static class MyResource { + @GET + public String get() { + return "ok"; + } + } + + public static class MyResource$$Proxy extends MyResource { + } +}