Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
<project.jdk.min-version>${project.target.release}</project.jdk.min-version>
<project.maven.min-version>3.5.0</project.maven.min-version>

<maven.compiler.source>${project.target.release}</maven.compiler.source>
<maven.compiler.target>${project.target.release}</maven.compiler.target>
<maven.compiler.release>${project.target.release}</maven.compiler.release>

<!-- bundle plugin requires JDK8 from 4.0.0, JDK15 requires 5.1.1 for issue FELIX-6259 -->
<maven.bundle.plugin.version>5.1.1</maven.bundle.plugin.version>
Expand Down Expand Up @@ -191,6 +190,17 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>

<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
Expand Down Expand Up @@ -259,6 +269,11 @@
</Export-Package>
<Private-Package>!java.*,!sun.*</Private-Package>
<Import-Package>*</Import-Package>
<Multi-Release>true</Multi-Release>
<Include-Resource>
{maven-resources},
META-INF/versions/=${project.build.outputDirectory}/META-INF/versions/
</Include-Resource>
</instructions>
</configuration>
<executions>
Expand All @@ -274,6 +289,34 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.9.1</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<postBuildHookScript>verify</postBuildHookScript>
<streamLogs>false</streamLogs>
<streamLogsOnFailures>true</streamLogsOnFailures>
<goals>
<goal>clean</goal>
<goal>test</goal>
</goals>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>run</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down Expand Up @@ -309,13 +352,29 @@
<profile>
<id>jdk9+-profile</id>
<activation>
<jdk>[9,21)</jdk>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>${project.target.release}</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-java9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
Expand Down
66 changes: 66 additions & 0 deletions src/it/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
= Integration Tests

This directory contains integration tests for the Zero-Allocation-Hashing library using the Maven Invoker Plugin and JUnit 4.

== Test Cases

=== 1. simple-usage

Tests basic usage of the hashing library without modules.

- Tests various hash functions (XxHash, CityHash, MurmurHash3, FarmHash)
- Verifies hash consistency across byte arrays, ByteBuffers, and CharSequences
- Ensures public API is accessible
- Uses JUnit 4 assertions

=== 2. module-test

Tests proper module encapsulation on Java 9+.

- Uses `module-info.java` to require the `net.openhft.hashing` module
- Verifies that only exported packages are accessible
- Tests are compiled and run with module path
- Demonstrates module system working correctly
- Uses JUnit 4 assertions

== Running Integration Tests

Integration tests run automatically during the build with:

[source,bash]
----
./mvnw clean verify
----

Or run them separately with:

[source,bash]
----
./mvnw invoker:run
----

== Module Encapsulation

The library exports only the `net.openhft.hashing` package via module-info.java:

[source,java]
----
module net.openhft.hashing {
requires jdk.unsupported;
exports net.openhft.hashing;
}
----

Internal packages (like sun.nio.ch) are not exported and cannot be accessed by consuming modules.

== Multi-Release JAR

The library is built as a multi-release JAR with module-info.class in META-INF/versions/9/:

- Java 8: Works as a regular JAR without module system
- Java 9+: Works as a named module with proper encapsulation

== Test Framework

All integration tests use JUnit 4 (same as the main project tests) and do not print to System.out.
Test results are reported through Maven Surefire plugin output only.
2 changes: 2 additions & 0 deletions src/it/module-test/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean test
invoker.buildResult=success
42 changes: 42 additions & 0 deletions src/it/module-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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>

<groupId>net.openhft.it</groupId>
<artifactId>module-test</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
</plugins>
</build>
</project>
9 changes: 9 additions & 0 deletions src/it/module-test/src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright 2013-2025 chronicle.software; SPDX-License-Identifier: Apache-2.0
*/
module net.openhft.it.module {
requires net.openhft.hashing;
requires junit;
exports net.openhft.it.module;
opens net.openhft.it.module to junit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2013-2025 chronicle.software; SPDX-License-Identifier: Apache-2.0
*/
package net.openhft.it.module;

import net.openhft.hashing.LongHashFunction;
import org.junit.Test;

import java.nio.charset.StandardCharsets;

import static org.junit.Assert.*;

/**
* Integration test verifying proper module encapsulation.
* This test ensures that only exported packages are accessible.
*/
public class ModuleTest {

private static final String TEST_DATA = "Module Test Data";
private static final byte[] TEST_BYTES = TEST_DATA.getBytes(StandardCharsets.UTF_8);

@Test
public void testPublicAPIAccessible() {
long xxHash = LongHashFunction.xx().hashBytes(TEST_BYTES);
long cityHash = LongHashFunction.city_1_1().hashBytes(TEST_BYTES);
long murmurHash = LongHashFunction.murmur_3().hashBytes(TEST_BYTES);

assertTrue("XxHash should produce non-zero result", xxHash != 0);
assertTrue("CityHash should produce non-zero result", cityHash != 0);
assertTrue("MurmurHash should produce non-zero result", murmurHash != 0);
}

@Test
public void testMainAPIClassAccessible() {
try {
Class.forName("net.openhft.hashing.LongHashFunction");
} catch (ClassNotFoundException e) {
fail("Public API net.openhft.hashing.LongHashFunction should be accessible");
}
}
}
6 changes: 6 additions & 0 deletions src/it/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>@localRepositoryPath@</localRepository>
</settings>
2 changes: 2 additions & 0 deletions src/it/simple-usage/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean test
invoker.buildResult=success
42 changes: 42 additions & 0 deletions src/it/simple-usage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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>

<groupId>net.openhft.it</groupId>
<artifactId>simple-usage</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
</plugins>
</build>
</project>
Loading