Skip to content

Commit

Permalink
JerseyTest is not compatible with JUnit 5
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos authored and jansupol committed Sep 2, 2021
1 parent 209b6a2 commit 3d131db
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,12 @@
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions test-framework/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
<artifactId>testng</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021 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
Expand Down Expand Up @@ -55,6 +55,8 @@

import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

/**
* Parent class for testing JAX-RS and Jersey-based applications using Jersey test framework.
Expand Down Expand Up @@ -614,6 +616,7 @@ public final Client client() {
* @throws Exception if an exception is thrown during setting up the test environment.
*/
@Before
@BeforeEach
public void setUp() throws Exception {
final TestContainer testContainer = createTestContainer(context);

Expand All @@ -634,6 +637,7 @@ public void setUp() throws Exception {
* @throws Exception if an exception is thrown during tearing down the test environment.
*/
@After
@AfterEach
public void tearDown() throws Exception {
if (isLogRecordingEnabled()) {
unregisterLogHandler();
Expand Down
55 changes: 55 additions & 0 deletions tests/integration/jersey-3662/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021 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>2.35-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<description>
Reproducer of JERSEY-3662
</description>

<artifactId>jersey-3662</artifactId>

<dependencies>

<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2021 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.tests.integration.jersey3662;

import static org.junit.jupiter.api.Assertions.assertEquals;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.jupiter.api.Test;

public class Junit5Test extends JerseyTest {

@Path("test")
public static class TestResource {
@GET
public String get() {
return "test";
}
}

@Override
protected Application configure() {
return new ResourceConfig(TestResource.class);
}

@Test
public void success() {
Response response = target().path("test").request().get();
assertEquals(200, response.getStatus());
assertEquals("test", response.readEntity(String.class));
}

}
3 changes: 2 additions & 1 deletion tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
<module>jersey-2846</module>
<module>jersey-2878</module>
<module>jersey-2892</module>
<module>jersey-3796</module>
<module>jersey-3662</module>
<module>jersey-3796</module>
<module>jersey-780</module>
<module>jersey-3670</module>
<module>jersey-3992</module>
Expand Down

0 comments on commit 3d131db

Please sign in to comment.