Skip to content

Commit

Permalink
Enable tests on JDK 8
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Supol <jan.supol@oracle.com>
  • Loading branch information
jansupol authored and senivam committed Oct 22, 2020
1 parent f84fc04 commit ca7c570
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# maven noise
target/
target-*/
target11/

# gradle noise
.gradle
Expand Down
20 changes: 5 additions & 15 deletions test-framework/providers/bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,10 @@
<artifactId>jersey-test-framework-provider-netty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
44 changes: 5 additions & 39 deletions tests/e2e-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
<artifactId>jersey-jdk-connector</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.security</groupId>
<artifactId>oauth1-signature</artifactId>
Expand Down Expand Up @@ -217,45 +222,6 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>JettyExclude</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/HttpPatchTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/RequestHeaderModificationsTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorConfigurationTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorHostnameVerifierTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/ssl/SslHttpUrlConnectorTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/ShutdownHookMemoryLeakTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/client/connector/ssl/AbstractConnectorServerTest.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;

import org.glassfish.jersey.tests.e2e.client.connector.ProviderFiltering;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -72,12 +73,12 @@ public ShutdownHookMemoryLeakTest(final ConnectorProvider cp) {

@Parameterized.Parameters
public static List<ConnectorProvider[]> connectionProviders() {
return Arrays.asList(new ConnectorProvider[][] {
return Arrays.asList(ProviderFiltering.filterProviders(new ConnectorProvider[][] {
{new GrizzlyConnectorProvider()},
{new JettyConnectorProvider()},
{new ApacheConnectorProvider()},
{new HttpUrlConnectorProvider()}
});
}));
}

@Path(PATH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public class HttpPatchTest extends JerseyTest {

@Parameterized.Parameters(name = "{index}: {0}")
public static List<Object[]> testData() {
return Arrays.asList(new Object[][]{
return Arrays.asList(ProviderFiltering.filterProviders(new Object[][]{
// {HttpUrlConnectorProvider.class}, // cannot process PATCH without additional configuration
{GrizzlyConnectorProvider.class},
{JettyConnectorProvider.class}, // unstable.
{ApacheConnectorProvider.class},
{GrizzlyConnectorProvider.class},
{NettyConnectorProvider.class},
{JdkConnectorProvider.class},
});
}));
}

private final ConnectorProvider connectorProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 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.e2e.client.connector;

import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;

import java.util.LinkedList;
import java.util.List;

public class ProviderFiltering {
public static <T> T[][] filterProviders(T[][] tofilter) {
final List<Object[]> filtered = new LinkedList<>();
final JdkVersion version = JdkVersion.getJdkVersion();
final boolean isJdk8 = version.getMajor() == 1;
for (Object[] provider : tofilter) {
if (!isJdk8
|| (provider[0] != JettyConnectorProvider.class && !JettyConnectorProvider.class.isInstance(provider[0]))) {
filtered.add(provider);
}
}
return filtered.toArray(
(T[][]) java.lang.reflect.Array.newInstance(tofilter.getClass().getComponentType(),
filtered.size())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class RequestHeaderModificationsTest extends JerseyTest {

@Parameterized.Parameters(name = "{index}: {0} / modificationSupported= {1} / addHeader= {2}")
public static List<Object[]> testData() {
return Arrays.asList(new Object[][] {
return Arrays.asList(ProviderFiltering.filterProviders(new Object[][] {
{HttpUrlConnectorProvider.class, true, false},
{GrizzlyConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed
{JettyConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed
Expand All @@ -107,7 +107,7 @@ public static List<Object[]> testData() {
{GrizzlyConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed
{JettyConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed
{ApacheConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed
});
}));
}

private final ConnectorProvider connectorProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020 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 @@ -29,6 +29,7 @@
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;

import org.glassfish.jersey.tests.e2e.client.connector.ProviderFiltering;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -56,12 +57,12 @@ public abstract class AbstractConnectorServerTest {
*/
@Parameterized.Parameters(name = "{index}: {0}")
public static Iterable<Object[]> testData() {
return Arrays.asList(new Object[][] {
return Arrays.asList(ProviderFiltering.filterProviders(new Object[][] {
{new HttpUrlConnectorProvider()},
{new GrizzlyConnectorProvider()},
{new JettyConnectorProvider()},
{new ApacheConnectorProvider()}
});
}));
}

@Parameterized.Parameter(0)
Expand Down
14 changes: 0 additions & 14 deletions tests/e2e-entity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,6 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
30 changes: 6 additions & 24 deletions tests/e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
<artifactId>jersey-jdk-connector</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.security</groupId>
<artifactId>oauth1-signature</artifactId>
Expand Down Expand Up @@ -211,37 +217,13 @@
<configuration>
<testExcludes>
<testExclude>org/glassfish/jersey/tests/e2e/container/Jersey2462Test.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/EscapedUriTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/GzipContentEncodingTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/HeadTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/JettyEmptyHeaderParamTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/LeadingSlashesTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/MatrixParamTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/QueryParamTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/ResponseWriterMetadataTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/ResponseWriterOutputStreamTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/TrailingSlashTest.java</testExclude>
<testExclude>org/glassfish/jersey/tests/e2e/container/JerseyContainerTest.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>sonar</id>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -50,11 +49,12 @@
@RunWith(Parameterized.class)
public class HeadTest extends JerseyContainerTest {

private static final List<TestContainerFactory> FACTORIES = Arrays.asList(
private static final List<TestContainerFactory> FACTORIES = listContainerFactories(
new GrizzlyTestContainerFactory(),
new InMemoryTestContainerFactory(),
new SimpleTestContainerFactory(),
new JettyTestContainerFactory());
new JettyTestContainerFactory()
);

@Parameterized.Parameters(name = "{0}")
public static Collection<TestContainerFactory[]> parameters() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020 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 All @@ -16,11 +16,12 @@

package org.glassfish.jersey.tests.e2e.container;

import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory;
Expand All @@ -39,7 +40,7 @@
@RunWith(Parameterized.class)
public abstract class JerseyContainerTest extends JerseyTest {

private static final List<TestContainerFactory> FACTORIES = Arrays.asList(
private static final List<TestContainerFactory> FACTORIES = listContainerFactories(
new GrizzlyTestContainerFactory(),
new InMemoryTestContainerFactory(),
new SimpleTestContainerFactory(),
Expand All @@ -61,4 +62,16 @@ public static Collection<TestContainerFactory[]> parameters() throws Exception {
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return factory;
}

protected static List<TestContainerFactory> listContainerFactories(TestContainerFactory...factories) {
final JdkVersion version = JdkVersion.getJdkVersion();
boolean isJDK8 = version.getMajor() == 1;
final List<TestContainerFactory> filtered = new LinkedList<>();
for (TestContainerFactory factory : factories) {
if (!isJDK8 || !JettyTestContainerFactory.class.isInstance(factory)) {
filtered.add(factory);
}
}
return filtered;
}
}

0 comments on commit ca7c570

Please sign in to comment.