Skip to content

Commit

Permalink
Adds initial module tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Jan 17, 2025
1 parent 2f27e66 commit d3bbca3
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package nl.jqno.equalsverifier.integration.operational;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

public class ModuleTest {
@Test
void sanity() {
// We want the tests in this module to be run on the class path, not the module path.
assertThat(getClass().getModule().isNamed()).isFalse();
}
}
51 changes: 51 additions & 0 deletions equalsverifier-test-jpms/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-parent</artifactId>
<version>3.18.2-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

<artifactId>equalsverifier-test-jpms</artifactId>
<name>EqualsVerifier | test JPMS</name>

<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useModulePath>true</useModulePath>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${version.junit-jupiter}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${version.assertj}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package it;

import java.util.Objects;

import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;

public class EverythingWorksInTheModularWorldTest {

@Test
void classCanBeVerified() {
EqualsVerifier.forClass(ClassPoint.class).verify();
}

final class ClassPoint {
private final int x;
private final int y;

private ClassPoint(int x, int y) {
this.x = x;
this.y = y;
}

@Override
public boolean equals(Object obj) {
return obj instanceof ClassPoint other && x == other.x && y == other.y;
}

@Override
public int hashCode() {
return Objects.hash(x, y);
}
}
}
14 changes: 14 additions & 0 deletions equalsverifier-test-jpms/src/test/java/it/SanityTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package it;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

public class SanityTest {
@Test
void sanity() {
assertThat(getClass().getModule())
.extracting(Module::isNamed, Module::getName)
.containsExactly(true, "equalsverifier_jpms_test");
}
}
6 changes: 6 additions & 0 deletions equalsverifier-test-jpms/src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
open module equalsverifier_jpms_test {
requires nl.jqno.equalsverifier;

requires org.junit.jupiter.api;
requires org.assertj.core;
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@
<module>equalsverifier-16</module>
<module>equalsverifier-17</module>
<module>equalsverifier-21</module>
<module>equalsverifier-test-jpms</module>
<module>equalsverifier-test-kotlin</module>
<module>equalsverifier-aggregator</module>
<module>equalsverifier-release-main</module>
Expand Down

0 comments on commit d3bbca3

Please sign in to comment.