Skip to content

Commit

Permalink
Add a test-module for JPMS
Browse files Browse the repository at this point in the history
  • Loading branch information
henri-tremblay committed May 6, 2024
1 parent b3c25b3 commit feca69a
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 3 deletions.
70 changes: 70 additions & 0 deletions module-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
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.
-->
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.objenesis</groupId>
<artifactId>objenesis-parent</artifactId>
<version>3.4-SNAPSHOT</version>
</parent>

<artifactId>objenesis-module-test</artifactId>
<name>Objenesis Module Test</name>
<description>Test the Objenesis works with the module system</description>

<properties>
<java.version>9</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.keyboardsamurais.maven</groupId>
<artifactId>maven-timestamp-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.util=org.objenesis</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions module-test/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -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;
}
35 changes: 35 additions & 0 deletions module-test/src/main/java/org/mymodule/App.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
19 changes: 19 additions & 0 deletions module-test/src/test/java/org/mymodule/AppTest.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
17 changes: 14 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -528,6 +530,15 @@
<module>benchmark</module>
</modules>
</profile>
<profile>
<id>module-test</id>
<activation>
<jdk>[9,</jdk>
</activation>
<modules>
<module>module-test</module>
</modules>
</profile>
<profile>
<!-- Activate to create a complete release -->
<id>release</id>
Expand Down

0 comments on commit feca69a

Please sign in to comment.