-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Ensure LICENSE file is present in Jar
Signed-off-by: Jorge Solórzano <[email protected]>
- Loading branch information
Showing
7 changed files
with
261 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2019 OnGres, Inc. | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
package test.nameprep; | ||
|
||
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) 2019 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.nameprep", moduleDescriptor.name()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2019 OnGres, Inc. | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
package test.saslprep; | ||
|
||
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) 2019 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.saslprep", moduleDescriptor.name()); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
stringprep/src/test/java/test/stringprep/JarFileCheckIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2019 OnGres, Inc. | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
package test.stringprep; | ||
|
||
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) 2019 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.stringprep", moduleDescriptor.name()); | ||
} | ||
} |