From feca69ae06aa2d8d29e819d5109c699363030c6d Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Sun, 5 May 2024 22:05:15 -0400 Subject: [PATCH] Add a test-module for JPMS --- module-test/pom.xml | 70 +++++++++++++++++++ module-test/src/main/java/module-info.java | 20 ++++++ .../src/main/java/org/mymodule/App.java | 35 ++++++++++ .../src/test/java/org/mymodule/AppTest.java | 19 +++++ pom.xml | 17 ++++- 5 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 module-test/pom.xml create mode 100644 module-test/src/main/java/module-info.java create mode 100644 module-test/src/main/java/org/mymodule/App.java create mode 100644 module-test/src/test/java/org/mymodule/AppTest.java diff --git a/module-test/pom.xml b/module-test/pom.xml new file mode 100644 index 000000000..9b461f0da --- /dev/null +++ b/module-test/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.objenesis + objenesis-parent + 3.4-SNAPSHOT + + + objenesis-module-test + Objenesis Module Test + Test the Objenesis works with the module system + + + 9 + + + + + org.objenesis + objenesis + ${project.version} + + + + + + + com.keyboardsamurais.maven + maven-timestamp-plugin + + + com.mycila + license-maven-plugin + + + maven-remote-resources-plugin + + + maven-surefire-plugin + + --add-opens java.base/java.util=org.objenesis + + + + maven-deploy-plugin + + true + + + + + diff --git a/module-test/src/main/java/module-info.java b/module-test/src/main/java/module-info.java new file mode 100644 index 000000000..e04d84e32 --- /dev/null +++ b/module-test/src/main/java/module-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2006-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.mymodule { + requires org.objenesis; + exports org.mymodule; +} diff --git a/module-test/src/main/java/org/mymodule/App.java b/module-test/src/main/java/org/mymodule/App.java new file mode 100644 index 000000000..a138c3f42 --- /dev/null +++ b/module-test/src/main/java/org/mymodule/App.java @@ -0,0 +1,35 @@ +/* + * Copyright 2006-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mymodule; + +import org.objenesis.Objenesis; +import org.objenesis.ObjenesisSerializer; +import org.objenesis.ObjenesisStd; + +import java.util.ArrayList; +import java.util.List; + +public class App { + public List newObject() { + Objenesis o = new ObjenesisStd(false); + return o.newInstance(ArrayList.class); + } + + public List newSerializable() { + Objenesis o = new ObjenesisSerializer(false); + return o.newInstance(ArrayList.class); + } +} diff --git a/module-test/src/test/java/org/mymodule/AppTest.java b/module-test/src/test/java/org/mymodule/AppTest.java new file mode 100644 index 000000000..ad5d200f4 --- /dev/null +++ b/module-test/src/test/java/org/mymodule/AppTest.java @@ -0,0 +1,19 @@ +import org.junit.jupiter.api.Test; +import org.mymodule.App; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class AppTest { + + App app = new App(); + + @Test + void testObject() { + assertNotNull(app.newObject()); + } + + @Test + void testSerializable() { + assertNotNull(app.newSerializable()); + } +} diff --git a/pom.xml b/pom.xml index c6a3111c0..c16889564 100644 --- a/pom.xml +++ b/pom.xml @@ -84,9 +84,11 @@ - org.junit.jupiter - junit-jupiter + org.junit + junit-bom ${junit5.version} + pom + import @@ -94,7 +96,7 @@ org.junit.jupiter - junit-jupiter + junit-jupiter-engine test @@ -528,6 +530,15 @@ benchmark + + module-test + + [9, + + + module-test + + release