From f995ddeb103a605ddc96240662e75782b0bfc1fb Mon Sep 17 00:00:00 2001 From: jansupol Date: Tue, 8 Feb 2022 21:06:10 +0100 Subject: [PATCH] Added a test for a serverless resource testing Signed-off-by: jansupol --- tests/integration/pom.xml | 185 ++++++++---------- tests/integration/thin-server/pom.xml | 66 +++++++ .../ThinServerResource.java | 29 +++ .../thinserver/ThinServerTest.java | 47 +++++ 4 files changed, 226 insertions(+), 101 deletions(-) create mode 100644 tests/integration/thin-server/pom.xml create mode 100644 tests/integration/thin-server/src/main/java/org.glassfish.jersey.integration.thinserver/ThinServerResource.java create mode 100644 tests/integration/thin-server/src/test/java/org/glassfish/jersey/integration/thinserver/ThinServerTest.java diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml index a356b1b14e..dc7210877f 100644 --- a/tests/integration/pom.xml +++ b/tests/integration/pom.xml @@ -34,21 +34,55 @@ asm + async-jersey-filter cdi-integration client-connector-provider ejb-multimodule ejb-multimodule-reload ejb-test-webapp + externalproperties + jaxrs-component-inject j-376 j-441 j-59 + jersey-780 + jersey-1107 + jersey-1223 + jersey-1604 + jersey-1667 + + jersey-1883 + jersey-1928 + jersey-1960 + jersey-1964 + jersey-2031 jersey-2136 jersey-2137 jersey-2154 + jersey-2160 + jersey-2164 + jersey-2167 + jersey-2176 + jersey-2184 + jersey-2255 + jersey-2322 + jersey-2335 jersey-2421 + jersey-2551 + jersey-2612 + jersey-2637 + jersey-2654 + jersey-2673 + jersey-2689 + jersey-2704 jersey-2776 + jersey-2794 + jersey-2846 + jersey-2878 + jersey-2892 jersey-3662 jersey-3670 + jersey-3796 jersey-3992 jersey-4003 jersey-4099 @@ -59,30 +93,62 @@ jersey-4722 jersey-4949 microprofile - - + property-check reactive-streams + security-digest + servlet-2.5-autodiscovery-1 + servlet-2.5-autodiscovery-2 + servlet-2.5-filter + servlet-2.5-inflector-1 + servlet-2.5-init-1 + servlet-2.5-init-2 + servlet-2.5-init-3 + servlet-2.5-init-4 + servlet-2.5-init-5 + servlet-2.5-init-6 + servlet-2.5-init-7 + servlet-2.5-init-8 + servlet-2.5-mvc-1 + servlet-2.5-mvc-2 + servlet-2.5-mvc-3 + servlet-2.5-reload + servlet-3-async + servlet-3-chunked-io + servlet-3-filter + servlet-3-gf-async + servlet-3-inflector-1 + servlet-3-init-1 + servlet-3-init-2 + servlet-3-init-3 + servlet-3-init-4 + servlet-3-init-5 + servlet-3-init-6 + servlet-3-init-7 + servlet-3-init-8 + servlet-3-init-9 + servlet-3-init-provider + servlet-3-params + servlet-3-sse-1 + servlet-4.0-mvc-1 + servlet-tests + servlet-request-wrapper-binding + servlet-request-wrapper-binding-2 + + + sonar-test + thin-server + tracing-support + + default + 9998 + ${project.build.directory}/jetty-out.log + + - - default - - default - 9998 - - - [1.8,) - - - sonar - - default - 9998 - ${project.build.directory}/jetty-out.log - @@ -123,89 +189,6 @@ - - Jetty11 - - [11,) - - - async-jersey-filter - externalproperties - jaxrs-component-inject - jersey-780 - jersey-1107 - jersey-1223 - jersey-1604 - jersey-1667 - - jersey-1883 - jersey-1928 - jersey-1960 - jersey-1964 - jersey-2031 - jersey-2160 - jersey-2164 - jersey-2167 - jersey-2176 - jersey-2184 - jersey-2255 - jersey-2322 - jersey-2335 - jersey-2551 - jersey-2612 - jersey-2637 - jersey-2654 - jersey-2673 - jersey-2689 - jersey-2704 - jersey-2794 - jersey-2846 - jersey-2878 - jersey-2892 - jersey-3796 - property-check - security-digest - servlet-2.5-autodiscovery-1 - servlet-2.5-autodiscovery-2 - servlet-2.5-filter - servlet-2.5-inflector-1 - servlet-2.5-init-1 - servlet-2.5-init-2 - servlet-2.5-init-3 - servlet-2.5-init-4 - servlet-2.5-init-5 - servlet-2.5-init-6 - servlet-2.5-init-7 - servlet-2.5-init-8 - servlet-2.5-mvc-1 - servlet-2.5-mvc-2 - servlet-2.5-mvc-3 - servlet-2.5-reload - servlet-3-async - servlet-3-chunked-io - servlet-3-filter - servlet-3-gf-async - servlet-3-inflector-1 - servlet-3-init-1 - servlet-3-init-2 - servlet-3-init-3 - servlet-3-init-4 - servlet-3-init-5 - servlet-3-init-6 - servlet-3-init-7 - servlet-3-init-8 - servlet-3-init-9 - servlet-3-init-provider - servlet-3-params - servlet-3-sse-1 - servlet-4.0-mvc-1 - servlet-tests - servlet-request-wrapper-binding - servlet-request-wrapper-binding-2 - sonar-test - tracing-support - - diff --git a/tests/integration/thin-server/pom.xml b/tests/integration/thin-server/pom.xml new file mode 100644 index 0000000000..4a26ef055c --- /dev/null +++ b/tests/integration/thin-server/pom.xml @@ -0,0 +1,66 @@ + + + + + + project + org.glassfish.jersey.tests.integration + 3.1.0-SNAPSHOT + + 4.0.0 + + thin-server + jersey-thin-server + + Run server without HTTP stack in tests. + + + + + org.glassfish.jersey.core + jersey-common + + + org.glassfish.jersey.core + jersey-server + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.test-framework + jersey-test-framework-util + test + + + junit + junit + test + + + org.hamcrest + hamcrest-library + test + + + + diff --git a/tests/integration/thin-server/src/main/java/org.glassfish.jersey.integration.thinserver/ThinServerResource.java b/tests/integration/thin-server/src/main/java/org.glassfish.jersey.integration.thinserver/ThinServerResource.java new file mode 100644 index 0000000000..9cb3cb7450 --- /dev/null +++ b/tests/integration/thin-server/src/main/java/org.glassfish.jersey.integration.thinserver/ThinServerResource.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.jersey.integration.thinserver; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; + +@Path("/") +public class ThinServerResource { + @GET + @Path("someget") + public String get() { + return ThinServerResource.class.getName(); + } +} diff --git a/tests/integration/thin-server/src/test/java/org/glassfish/jersey/integration/thinserver/ThinServerTest.java b/tests/integration/thin-server/src/test/java/org/glassfish/jersey/integration/thinserver/ThinServerTest.java new file mode 100644 index 0000000000..c64bce5222 --- /dev/null +++ b/tests/integration/thin-server/src/test/java/org/glassfish/jersey/integration/thinserver/ThinServerTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.jersey.integration.thinserver; + +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.core.Response; +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.message.internal.OutboundJaxrsResponse; +import org.glassfish.jersey.message.internal.OutboundMessageContext; +import org.glassfish.jersey.server.ApplicationHandler; +import org.glassfish.jersey.server.ContainerRequest; +import org.glassfish.jersey.server.ContainerResponse; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.util.server.ContainerRequestBuilder; +import org.junit.Assert; +import org.junit.Test; + +import java.net.URI; +import java.util.concurrent.ExecutionException; + +public class ThinServerTest { + @Test + public void testGet() throws ExecutionException, InterruptedException { + ContainerRequest request = + ContainerRequestBuilder.from(URI.create("/someget"), HttpMethod.GET, new ClientConfig()).build(); + + ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ThinServerResource.class)); + ContainerResponse containerResponse = applicationHandler.apply(request).get(); + OutboundMessageContext outboundMessageContext = containerResponse.getWrappedMessageContext(); + Response response = new OutboundJaxrsResponse(containerResponse.getStatusInfo(), outboundMessageContext); + Assert.assertEquals(ThinServerResource.class.getName(), response.getEntity()); + } +}