Skip to content

Commit

Permalink
Added a test for a serverless resource testing
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol authored and senivam committed Feb 9, 2022
1 parent 9ad9f62 commit f995dde
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 101 deletions.
185 changes: 84 additions & 101 deletions tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,55 @@

<modules>
<module>asm</module>
<module>async-jersey-filter</module>
<module>cdi-integration</module>
<module>client-connector-provider</module>
<module>ejb-multimodule</module>
<module>ejb-multimodule-reload</module>
<module>ejb-test-webapp</module>
<module>externalproperties</module>
<module>jaxrs-component-inject</module>
<module>j-376</module>
<module>j-441</module>
<module>j-59</module>
<module>jersey-780</module>
<module>jersey-1107</module>
<module>jersey-1223</module>
<module>jersey-1604</module>
<module>jersey-1667</module>
<!-- <module>jersey-1829</module> Jakartification-->
<module>jersey-1883</module>
<module>jersey-1928</module>
<module>jersey-1960</module>
<module>jersey-1964</module>
<module>jersey-2031</module>
<module>jersey-2136</module>
<module>jersey-2137</module>
<module>jersey-2154</module>
<module>jersey-2160</module>
<module>jersey-2164</module>
<module>jersey-2167</module>
<module>jersey-2176</module>
<module>jersey-2184</module>
<module>jersey-2255</module>
<module>jersey-2322</module>
<module>jersey-2335</module>
<module>jersey-2421</module>
<module>jersey-2551</module>
<module>jersey-2612</module>
<module>jersey-2637</module>
<module>jersey-2654</module>
<module>jersey-2673</module>
<module>jersey-2689</module>
<module>jersey-2704</module>
<module>jersey-2776</module>
<module>jersey-2794</module>
<module>jersey-2846</module>
<module>jersey-2878</module>
<module>jersey-2892</module>
<module>jersey-3662</module>
<module>jersey-3670</module>
<module>jersey-3796</module>
<module>jersey-3992</module>
<module>jersey-4003</module>
<module>jersey-4099</module>
Expand All @@ -59,30 +93,62 @@
<module>jersey-4722</module>
<module>jersey-4949</module>
<module>microprofile</module>
<!-- <module>spring4</module>-->
<!-- <module>spring5</module>-->
<module>property-check</module>
<module>reactive-streams</module>
<module>security-digest</module>
<module>servlet-2.5-autodiscovery-1</module>
<module>servlet-2.5-autodiscovery-2</module>
<module>servlet-2.5-filter</module>
<module>servlet-2.5-inflector-1</module>
<module>servlet-2.5-init-1</module>
<module>servlet-2.5-init-2</module>
<module>servlet-2.5-init-3</module>
<module>servlet-2.5-init-4</module>
<module>servlet-2.5-init-5</module>
<module>servlet-2.5-init-6</module>
<module>servlet-2.5-init-7</module>
<module>servlet-2.5-init-8</module>
<module>servlet-2.5-mvc-1</module>
<module>servlet-2.5-mvc-2</module>
<module>servlet-2.5-mvc-3</module>
<module>servlet-2.5-reload</module>
<module>servlet-3-async</module>
<module>servlet-3-chunked-io</module>
<module>servlet-3-filter</module>
<module>servlet-3-gf-async</module>
<module>servlet-3-inflector-1</module>
<module>servlet-3-init-1</module>
<module>servlet-3-init-2</module>
<module>servlet-3-init-3</module>
<module>servlet-3-init-4</module>
<module>servlet-3-init-5</module>
<module>servlet-3-init-6</module>
<module>servlet-3-init-7</module>
<module>servlet-3-init-8</module>
<module>servlet-3-init-9</module>
<module>servlet-3-init-provider</module>
<module>servlet-3-params</module>
<module>servlet-3-sse-1</module>
<module>servlet-4.0-mvc-1</module>
<module>servlet-tests</module>
<module>servlet-request-wrapper-binding</module>
<module>servlet-request-wrapper-binding-2</module>
<!-- <module>spring4</module>-->
<!-- <module>spring5</module>-->
<module>sonar-test</module>
<module>thin-server</module>
<module>tracing-support</module>
</modules>

<properties>
<env>default</env>
<jersey.config.test.container.port>9998</jersey.config.test.container.port>
<jetty.log.file>${project.build.directory}/jetty-out.log</jetty.log.file>
</properties>

<profiles>
<profile>
<id>default</id>
<properties>
<env>default</env>
<jersey.config.test.container.port>9998</jersey.config.test.container.port>
</properties>
<activation>
<jdk>[1.8,)</jdk>
<!-- <activeByDefault>true</activeByDefault> does not work ?!-->
</activation>
</profile>
<profile>
<id>sonar</id>
<properties>
<env>default</env>
<jersey.config.test.container.port>9998</jersey.config.test.container.port>
<jetty.log.file>${project.build.directory}/jetty-out.log</jetty.log.file>
</properties>
<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -123,89 +189,6 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<modules>
<module>async-jersey-filter</module>
<module>externalproperties</module>
<module>jaxrs-component-inject</module>
<module>jersey-780</module>
<module>jersey-1107</module>
<module>jersey-1223</module>
<module>jersey-1604</module>
<module>jersey-1667</module>
<!-- <module>jersey-1829</module> Jakartification-->
<module>jersey-1883</module>
<module>jersey-1928</module>
<module>jersey-1960</module>
<module>jersey-1964</module>
<module>jersey-2031</module>
<module>jersey-2160</module>
<module>jersey-2164</module>
<module>jersey-2167</module>
<module>jersey-2176</module>
<module>jersey-2184</module>
<module>jersey-2255</module>
<module>jersey-2322</module>
<module>jersey-2335</module>
<module>jersey-2551</module>
<module>jersey-2612</module>
<module>jersey-2637</module>
<module>jersey-2654</module>
<module>jersey-2673</module>
<module>jersey-2689</module>
<module>jersey-2704</module>
<module>jersey-2794</module>
<module>jersey-2846</module>
<module>jersey-2878</module>
<module>jersey-2892</module>
<module>jersey-3796</module>
<module>property-check</module>
<module>security-digest</module>
<module>servlet-2.5-autodiscovery-1</module>
<module>servlet-2.5-autodiscovery-2</module>
<module>servlet-2.5-filter</module>
<module>servlet-2.5-inflector-1</module>
<module>servlet-2.5-init-1</module>
<module>servlet-2.5-init-2</module>
<module>servlet-2.5-init-3</module>
<module>servlet-2.5-init-4</module>
<module>servlet-2.5-init-5</module>
<module>servlet-2.5-init-6</module>
<module>servlet-2.5-init-7</module>
<module>servlet-2.5-init-8</module>
<module>servlet-2.5-mvc-1</module>
<module>servlet-2.5-mvc-2</module>
<module>servlet-2.5-mvc-3</module>
<module>servlet-2.5-reload</module>
<module>servlet-3-async</module>
<module>servlet-3-chunked-io</module>
<module>servlet-3-filter</module>
<module>servlet-3-gf-async</module>
<module>servlet-3-inflector-1</module>
<module>servlet-3-init-1</module>
<module>servlet-3-init-2</module>
<module>servlet-3-init-3</module>
<module>servlet-3-init-4</module>
<module>servlet-3-init-5</module>
<module>servlet-3-init-6</module>
<module>servlet-3-init-7</module>
<module>servlet-3-init-8</module>
<module>servlet-3-init-9</module>
<module>servlet-3-init-provider</module>
<module>servlet-3-params</module>
<module>servlet-3-sse-1</module>
<module>servlet-4.0-mvc-1</module>
<module>servlet-tests</module>
<module>servlet-request-wrapper-binding</module>
<module>servlet-request-wrapper-binding-2</module>
<module>sonar-test</module>
<module>tracing-support</module>
</modules>
</profile>
</profiles>

<build>
Expand Down
66 changes: 66 additions & 0 deletions tests/integration/thin-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>project</artifactId>
<groupId>org.glassfish.jersey.tests.integration</groupId>
<version>3.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>thin-server</artifactId>
<name>jersey-thin-server</name>
<description>
Run server without HTTP stack in tests.
</description>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit f995dde

Please sign in to comment.