Skip to content

Commit

Permalink
Fixed some CDI/Weld integration tests to be runnable from maven and IDE
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed Jan 25, 2024
1 parent 1353cc2 commit 8b93a4c
Show file tree
Hide file tree
Showing 32 changed files with 232 additions and 108 deletions.
7 changes: 6 additions & 1 deletion core-client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -33,18 +33,23 @@

exports org.glassfish.jersey.client.innate to
org.glassfish.jersey.apache.connector,
org.glassfish.jersey.apache5.connector,
org.glassfish.jersey.netty.connector,
org.glassfish.jersey.grizzly.connector,
org.glassfish.jersey.jetty11.connector,
org.glassfish.jersey.jetty.connector;

exports org.glassfish.jersey.client.innate.http to
org.glassfish.jersey.apache.connector,
org.glassfish.jersey.apache5.connector,
org.glassfish.jersey.netty.connector,
org.glassfish.jersey.grizzly.connector,
org.glassfish.jersey.jetty.connector,
org.glassfish.jersey.jdk.connector;

exports org.glassfish.jersey.client.innate.inject to
org.glassfish.jersey.incubator.injectless.client;

opens org.glassfish.jersey.client;
opens org.glassfish.jersey.client.spi;
opens org.glassfish.jersey.client.filter;
Expand Down
7 changes: 3 additions & 4 deletions ext/bean-validation/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -27,11 +27,10 @@
requires org.glassfish.jersey.core.common;
requires org.glassfish.jersey.core.server;

requires org.glassfish.jersey.ext.cdi1x;
requires jakarta.cdi;
requires static org.glassfish.jersey.ext.cdi1x;
requires static jakarta.cdi;

exports org.glassfish.jersey.server.validation;
exports org.glassfish.jersey.server.validation.internal.hibernate;
exports org.glassfish.jersey.server.validation.internal;
opens org.glassfish.jersey.server.validation.internal;
opens org.glassfish.jersey.server.validation.internal.hibernate;
Expand Down
30 changes: 30 additions & 0 deletions incubator/injectless-client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 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
*/

module org.glassfish.jersey.incubator.injectless.client {

requires jakarta.annotation;
requires jakarta.inject;
requires jakarta.ws.rs;

requires org.glassfish.jersey.core.common;
requires org.glassfish.jersey.core.client;

exports org.glassfish.jersey.inject.injectless;

provides org.glassfish.jersey.internal.inject.InjectionManagerFactory
with org.glassfish.jersey.inject.injectless.NonInjectionManagerFactory;
}
6 changes: 3 additions & 3 deletions media/json-binding/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -17,10 +17,10 @@
module org.glassfish.jersey.media.jsonb {
requires jakarta.annotation;
requires jakarta.inject;
requires jakarta.ws.rs;
requires jakarta.json.bind;
requires jakarta.ws.rs;

requires osgi.resource.locator;
requires static osgi.resource.locator;

requires org.glassfish.jersey.core.common;

Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2024 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 @@ -2002,6 +2002,11 @@
</dependency>

<!-- Weld -->
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api</artifactId>
<version>${weld.api.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
Expand Down Expand Up @@ -2322,7 +2327,8 @@
<testng.version>7.8.0</testng.version>
<testng6.version>6.9.13.6</testng6.version>
<!-- Jakartified, eligible for CQ -->
<weld.version>5.1.1.Final</weld.version>
<weld.api.version>5.0.SP3</weld.api.version>
<weld.version>5.1.2.Final</weld.version>
<weld3.version>3.1.9.Final</weld3.version>
<validation.impl.version>8.0.1.Final</validation.impl.version>
<!-- END of Jakartified, eligible for CQ -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024 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 @@ -24,7 +24,8 @@

import org.junit.jupiter.api.DynamicContainer;
import org.junit.jupiter.api.DynamicTest;
import org.junit.platform.commons.util.ReflectionUtils;
import org.junit.platform.commons.support.HierarchyTraversalMode;
import org.junit.platform.commons.support.ReflectionSupport;

/**
* Helper class for Jersey Test Framework.
Expand Down Expand Up @@ -54,13 +55,16 @@ private TestHelper() {

public static DynamicContainer toTestContainer(Object test, String displayName) {
Class<?> klass = test.getClass();
List<Method> testMethods = ReflectionUtils.findMethods(klass,
List<Method> testMethods = ReflectionSupport.findMethods(klass,
method -> method.isAnnotationPresent(org.junit.jupiter.api.Test.class)
&& !method.isAnnotationPresent(org.junit.jupiter.api.Disabled.class));
List<Method> beforeEachMethods = ReflectionUtils.findMethods(klass,
method -> method.isAnnotationPresent(org.junit.jupiter.api.BeforeEach.class));
List<Method> afterEachMethods = ReflectionUtils.findMethods(klass,
method -> method.isAnnotationPresent(org.junit.jupiter.api.AfterEach.class));
&& !method.isAnnotationPresent(org.junit.jupiter.api.Disabled.class),
HierarchyTraversalMode.TOP_DOWN);
List<Method> beforeEachMethods = ReflectionSupport.findMethods(klass,
method -> method.isAnnotationPresent(org.junit.jupiter.api.BeforeEach.class),
HierarchyTraversalMode.TOP_DOWN);
List<Method> afterEachMethods = ReflectionSupport.findMethods(klass,
method -> method.isAnnotationPresent(org.junit.jupiter.api.AfterEach.class),
HierarchyTraversalMode.TOP_DOWN);
Collection<DynamicTest> children = new ArrayList<>();
for (Method method : testMethods) {
children.add(DynamicTest.dynamicTest(method.getName(), () -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2024 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 @@ -151,13 +151,4 @@
<build>
<finalName>${project.artifactId}</finalName>
</build>
<properties>
<surefire.coverage.argline>
--add-reads jakarta.validation=weld.api
--add-reads jakarta.validation=weld.core.impl
--add-opens jakarta.validation/jakarta.validation=weld.core.impl
--add-reads org.jboss.logging=java.logging
--add-modules=ALL-MODULE-PATH
</surefire.coverage.argline>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -21,6 +21,7 @@
requires jakarta.cdi;
requires jakarta.validation;

requires weld.api;
requires weld.core.impl;

requires org.glassfish.jersey.core.server;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -20,8 +20,10 @@
requires jakarta.validation;
requires jakarta.ws.rs;

requires weld.se.core;
requires weld.core.impl;
requires weld.environment.common;
requires weld.se.core;

requires org.glassfish.grizzly.http.server;
requires org.hibernate.validator;
requires org.hibernate.validator.cdi;
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/cdi-integration/cdi-client-on-server/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2024 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 @@ -70,12 +70,12 @@
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-util</artifactId>
<scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
Expand Down Expand Up @@ -115,6 +115,10 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api</artifactId>
</dependency>
</dependencies>

<profiles>
Expand All @@ -130,7 +134,6 @@
<jersey.config.test.container.factory>${external.container.factory}</jersey.config.test.container.factory>
<jersey.config.test.container.port>${external.container.port}</jersey.config.test.container.port>
</systemPropertyVariables>
<argLine>--add-reads java.logging=ALL-UNNAMED --add-exports java.logging/java.util.logging=ALL-UNNAMED --add-modules=ALL-MODULE-PATH</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -19,8 +19,10 @@
requires jakarta.xml.bind;
requires jakarta.inject;
requires jakarta.cdi;
requires weld.api;

requires org.glassfish.jersey.core.server;

opens org.glassfish.jersey.tests.cdi.client;
exports org.glassfish.jersey.tests.cdi.client;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024 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 @@ -18,8 +18,8 @@

import org.glassfish.jersey.server.ResourceConfig;

class CdiEnabledClientOnServerApplication extends ResourceConfig {
CdiEnabledClientOnServerApplication() {
public class CdiEnabledClientOnServerApplication extends ResourceConfig {
public CdiEnabledClientOnServerApplication() {
register(CdiEnabledClientOnServerResource.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 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 @@ -14,12 +14,14 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

module org.glassfish.jersey.tests.integration.cdi.client.on.server {
module org.glassfish.jersey.tests.integration.cdi.client.on.server.test {

requires jakarta.inject;
requires jakarta.ws.rs;
requires jakarta.cdi;

requires weld.core.impl;
requires weld.environment.common;
requires weld.se.core;
requires org.jboss.logging;

Expand All @@ -30,9 +32,10 @@
requires org.glassfish.jersey.tests.framework.provider.external;
requires org.glassfish.jersey.tests.framework.provider.grizzly;

requires org.glassfish.jersey.tests.integration.cdi.client.on.server;

requires org.junit.jupiter.api;
requires org.junit.jupiter.engine;

exports org.glassfish.jersey.tests.cdi.client;
opens org.glassfish.jersey.tests.cdi.client;
exports org.glassfish.jersey.tests.cdi.client.test to org.junit.platform.commons;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024 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 @@ -14,11 +14,12 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.tests.cdi.client;
package org.glassfish.jersey.tests.cdi.client.test;

import org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
import org.glassfish.jersey.tests.cdi.client.CdiEnabledClientOnServerApplication;
import org.jboss.weld.environment.se.Weld;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
Expand Down
7 changes: 1 addition & 6 deletions tests/integration/cdi-integration/cdi-client/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2021, 2024 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 @@ -92,9 +92,4 @@
</plugin>
</plugins>
</build>
<properties>
<surefire.coverage.argline>
--add-reads org.jboss.logging=java.logging --add-modules=ALL-MODULE-PATH
</surefire.coverage.argline>
</properties>
</project>
Loading

0 comments on commit 8b93a4c

Please sign in to comment.