diff --git a/CHANGELOG.md b/CHANGELOG.md index 990d16e..97acfde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### :building_construction: Improvements +- Ensure the LICENSE file is included in the Jar file. ## 3.0 - 2024-04-03 ### :boom: Breaking changes @@ -24,6 +26,7 @@ All notable changes to this project will be documented in this file. ### :ghost: Maintenance - Migrate the main repo back to GitHub. +- Remove the shaded Bouncy Castle pbkdf2 and base64 implementation used for Java 7 support. # 2.1 diff --git a/scram-client/pom.xml b/scram-client/pom.xml index 4285680..8e7b93d 100644 --- a/scram-client/pom.xml +++ b/scram-client/pom.xml @@ -36,11 +36,25 @@ false - - org.apache.maven.plugins - maven-invoker-plugin - + + + run-its + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.apache.maven.plugins + maven-invoker-plugin + + + + + + \ No newline at end of file diff --git a/scram-client/src/test/java/com/ongres/scram/JarFileCheckIT.java b/scram-client/src/test/java/com/ongres/scram/JarFileCheckIT.java new file mode 100644 index 0000000..cd0e115 --- /dev/null +++ b/scram-client/src/test/java/com/ongres/scram/JarFileCheckIT.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2017 OnGres, Inc. + * SPDX-License-Identifier: BSD-2-Clause + */ + +package com.ongres.scram; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.module.ModuleDescriptor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class JarFileCheckIT { + + private static JarFile jarFile; + private static Path buildJarPath; + + @BeforeAll + static void beforeAll() throws IOException { + buildJarPath = Paths.get(System.getProperty("buildJar")); + assertTrue(Files.exists(buildJarPath)); + jarFile = new JarFile(buildJarPath.toFile(), true); + } + + @AfterAll + static void afterAll() throws IOException { + jarFile.close(); + } + + @Test + void checkLicense() throws IOException { + JarEntry jarLicense = jarFile.getJarEntry("META-INF/LICENSE"); + assertNotNull(jarLicense, "LICENSE file should be present in the final JAR file"); + try (InputStream is = jarFile.getInputStream(jarLicense); + BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { + String line = reader.readLine(); + assertEquals("Copyright (c) 2017 OnGres, Inc.", line); + } + } + + @Test + void checkMultiReleaseManifest() throws IOException { + Attributes mainAttributes = jarFile.getManifest().getMainAttributes(); + String multiReleaseValue = mainAttributes.getValue(new Attributes.Name("Multi-Release")); + assertNotNull(multiReleaseValue); + assertEquals("true", multiReleaseValue); + } + + @Test + void checkModuleInfoPresent() throws IOException { + JarEntry jarModuleInfo = jarFile.getJarEntry("META-INF/versions/9/module-info.class"); + ModuleDescriptor moduleDescriptor = ModuleDescriptor.read(jarFile.getInputStream(jarModuleInfo)); + assertNotNull(moduleDescriptor); + assertEquals("com.ongres.scram.client", moduleDescriptor.name()); + } +} diff --git a/scram-common/pom.xml b/scram-common/pom.xml index 274fa55..1c8260b 100644 --- a/scram-common/pom.xml +++ b/scram-common/pom.xml @@ -39,4 +39,22 @@ + + + run-its + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.apache.maven.plugins + maven-invoker-plugin + + + + + + \ No newline at end of file diff --git a/scram-common/src/test/java/com/ongres/scram/JarFileCheckIT.java b/scram-common/src/test/java/com/ongres/scram/JarFileCheckIT.java new file mode 100644 index 0000000..3ebdf38 --- /dev/null +++ b/scram-common/src/test/java/com/ongres/scram/JarFileCheckIT.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2017 OnGres, Inc. + * SPDX-License-Identifier: BSD-2-Clause + */ + +package com.ongres.scram; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.module.ModuleDescriptor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class JarFileCheckIT { + + private static JarFile jarFile; + private static Path buildJarPath; + + @BeforeAll + static void beforeAll() throws IOException { + buildJarPath = Paths.get(System.getProperty("buildJar")); + assertTrue(Files.exists(buildJarPath)); + jarFile = new JarFile(buildJarPath.toFile(), true); + } + + @AfterAll + static void afterAll() throws IOException { + jarFile.close(); + } + + @Test + void checkLicense() throws IOException { + JarEntry jarLicense = jarFile.getJarEntry("META-INF/LICENSE"); + assertNotNull(jarLicense, "LICENSE file should be present in the final JAR file"); + try (InputStream is = jarFile.getInputStream(jarLicense); + BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { + String line = reader.readLine(); + assertEquals("Copyright (c) 2017 OnGres, Inc.", line); + } + } + + @Test + void checkMultiReleaseManifest() throws IOException { + Attributes mainAttributes = jarFile.getManifest().getMainAttributes(); + String multiReleaseValue = mainAttributes.getValue(new Attributes.Name("Multi-Release")); + assertNotNull(multiReleaseValue); + assertEquals("true", multiReleaseValue); + } + + @Test + void checkModuleInfoPresent() throws IOException { + JarEntry jarModuleInfo = jarFile.getJarEntry("META-INF/versions/9/module-info.class"); + ModuleDescriptor moduleDescriptor = ModuleDescriptor.read(jarFile.getInputStream(jarModuleInfo)); + assertNotNull(moduleDescriptor); + assertEquals("com.ongres.scram.common", moduleDescriptor.name()); + } +} diff --git a/scram-parent/pom.xml b/scram-parent/pom.xml index db020a4..0841ef1 100644 --- a/scram-parent/pom.xml +++ b/scram-parent/pom.xml @@ -154,6 +154,15 @@ true + + default-testCompile + + testCompile + + + 11 + + @@ -298,6 +307,9 @@ **/*Test.java **/*IT.java + + ${project.build.directory}/${project.build.finalName}.jar +