Skip to content

Commit

Permalink
Rename resources of test data
Browse files Browse the repository at this point in the history
When we have test data in standard resources
it will be copied to test-classes and available for other tools, but eg. it can be not correct classes
  • Loading branch information
slawekjaranowski committed Sep 24, 2024
1 parent 61e68b6 commit 216e33d
Show file tree
Hide file tree
Showing 49 changed files with 78 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ public abstract class AbstractFilenameModuleNameExtractorTest {

@Test
void testJarWithoutManifest() throws Exception {
String name = getExtractor().extract(Paths.get("src/test/resources/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));
String name = getExtractor().extract(Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));
assertEquals("plexus.java", name);
}

@Test
void testJarWithManifest() throws Exception {
String name = getExtractor()
.extract(Paths.get("src/test/resources/jar.manifest.with/plexus-java-1.0.0-SNAPSHOT.jar"));
.extract(Paths.get("src/test/test-data/jar.manifest.with/plexus-java-1.0.0-SNAPSHOT.jar"));
assertEquals("org.codehaus.plexus.languages.java", name);
}

@Test
void testJarUnsupported() throws Exception {
String name = getExtractor().extract(Paths.get("src/test/resources/jar.unsupported/jdom-1.0.jar"));
String name = getExtractor().extract(Paths.get("src/test/test-data/jar.unsupported/jdom-1.0.jar"));
assertNull(name);
}

@Test
void testJarWithSpacesInPath() throws Exception {
String name = getExtractor()
.extract(Paths.get("src/test/resources/jar with spaces in path/plexus-java-1.0.0-SNAPSHOT.jar"));
.extract(Paths.get("src/test/test-data/jar with spaces in path/plexus-java-1.0.0-SNAPSHOT.jar"));
assertEquals("org.codehaus.plexus.languages.java", name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BinaryModuleInfoParserTest {
@Test
void testJarDescriptor() throws Exception {
JavaModuleDescriptor descriptor =
parser.getModuleDescriptor(Paths.get("src/test/resources/jar.descriptor/asm-6.0_BETA.jar"));
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.descriptor/asm-6.0_BETA.jar"));

assertNotNull(descriptor);
assertThat(descriptor.name()).isEqualTo("org.objectweb.asm");
Expand All @@ -69,7 +69,7 @@ void testJarDescriptor() throws Exception {
@Test
void testMultiReleaseJarDescriptor() throws Exception {
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
Paths.get("src/test/resources/jar.mr.descriptor/jloadr-1.0-SNAPSHOT.jar"), JavaVersion.parse("17"));
Paths.get("src/test/test-data/jar.mr.descriptor/jloadr-1.0-SNAPSHOT.jar"), JavaVersion.parse("17"));

assertNotNull(descriptor);
assertEquals("de.adito.jloadr", descriptor.name());
Expand All @@ -80,23 +80,23 @@ void testMultiReleaseJarDescriptor() throws Exception {
void testIncompleteMultiReleaseJarDescriptor() throws Exception {
// this jar is missing the Multi-Release: true entry in the Manifest
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
Paths.get("src/test/resources/jar.mr.incomplete.descriptor/jloadr-1.0-SNAPSHOT.jar"));
Paths.get("src/test/test-data/jar.mr.incomplete.descriptor/jloadr-1.0-SNAPSHOT.jar"));

assertNull(descriptor);
}

@Test
void testClassicJar() throws Exception {
JavaModuleDescriptor descriptor =
parser.getModuleDescriptor(Paths.get("src/test/resources/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));

assertNull(descriptor);
}

@Test
void testOutputDirectoryDescriptor() throws Exception {
JavaModuleDescriptor descriptor =
parser.getModuleDescriptor(Paths.get("src/test/resources/dir.descriptor/out"));
parser.getModuleDescriptor(Paths.get("src/test/test-data/dir.descriptor/out"));

assertNotNull(descriptor);
assertEquals("org.codehaus.plexus.languages.java.demo", descriptor.name());
Expand All @@ -118,13 +118,13 @@ void testOutputDirectoryDescriptor() throws Exception {
void testClassicOutputDirectory() {
assertThrows(
NoSuchFileException.class,
() -> parser.getModuleDescriptor(Paths.get("src/test/resources/dir.empty/out")));
() -> parser.getModuleDescriptor(Paths.get("src/test/test-data/dir.empty/out")));
}

@Test
void testJModDescriptor() throws Exception {
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
Paths.get("src/test/resources/jmod.descriptor/first-jmod-1.0-SNAPSHOT.jmod"));
Paths.get("src/test/test-data/jmod.descriptor/first-jmod-1.0-SNAPSHOT.jmod"));

assertNotNull(descriptor);
assertEquals("com.corporate.project", descriptor.name());
Expand All @@ -141,13 +141,13 @@ void testJModDescriptor() throws Exception {
@Test
void testInvalidFile() {
assertThrows(
IOException.class, () -> parser.getModuleDescriptor(Paths.get("src/test/resources/nonjar/pom.xml")));
IOException.class, () -> parser.getModuleDescriptor(Paths.get("src/test/test-data/nonjar/pom.xml")));
}

@Test
void testUses() throws Exception {
try (InputStream is =
Files.newInputStream(Paths.get("src/test/resources/dir.descriptor.uses/out/module-info.class"))) {
Files.newInputStream(Paths.get("src/test/test-data/dir.descriptor.uses/out/module-info.class"))) {
JavaModuleDescriptor descriptor = parser.parse(is);

assertNotNull(descriptor);
Expand All @@ -163,7 +163,7 @@ void testUses() throws Exception {
@Test
void testProvides() throws Exception {
JavaModuleDescriptor descriptor =
parser.getModuleDescriptor(Paths.get("src/test/resources/jar.service/threeten-extra-1.4.jar"));
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.service/threeten-extra-1.4.jar"));

assertNotNull(descriptor);
assertEquals(1, descriptor.provides().size());
Expand All @@ -188,7 +188,7 @@ void testProvides() throws Exception {
@Test
void testRequires() throws Exception {
try (InputStream is =
Files.newInputStream(Paths.get("src/test/resources/dir.descriptor.requires/out/module-info.class"))) {
Files.newInputStream(Paths.get("src/test/test-data/dir.descriptor.requires/out/module-info.class"))) {
JavaModuleDescriptor descriptor = parser.parse(is);

assertNotNull(descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LocationManagerIT {

private LocationManager locationManager;

final Path mockModuleInfoJava = Paths.get("src/test/resources/mock/module-info.java");
final Path mockModuleInfoJava = Paths.get("src/test/test-data/mock/module-info.java");

@BeforeEach
void onSetup() {
Expand All @@ -68,7 +68,7 @@ ModuleInfoParser getBinaryModuleInfoParser(Path jdkHome) {

@Test
void testManifestWithoutReflectRequires() throws Exception {
Path abc = Paths.get("src/test/resources/manifest.without/out");
Path abc = Paths.get("src/test/test-data/manifest.without/out");
JavaModuleDescriptor descriptor =
JavaModuleDescriptor.newModule("base").requires("any").build();
when(qdoxParser.fromSourcePath(any(Path.class))).thenReturn(descriptor);
Expand All @@ -86,7 +86,7 @@ void testManifestWithoutReflectRequires() throws Exception {

@Test
void testEmptyWithReflectRequires() throws Exception {
Path abc = Paths.get("src/test/resources/empty/out");
Path abc = Paths.get("src/test/test-data/empty/out");
JavaModuleDescriptor descriptor =
JavaModuleDescriptor.newModule("base").requires("a.b.c").build();
when(qdoxParser.fromSourcePath(any(Path.class))).thenReturn(descriptor);
Expand All @@ -105,7 +105,7 @@ void testEmptyWithReflectRequires() throws Exception {
@Test
void testResolvePathWithException() {
assertThrows(RuntimeException.class, () -> {
Path p = Paths.get("src/test/resources/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
Path p = Paths.get("src/test/test-data/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
ResolvePathRequest<Path> request = ResolvePathRequest.ofPath(p);

locationManager.resolvePath(request);
Expand All @@ -114,7 +114,7 @@ void testResolvePathWithException() {

@Test
void testClassicJarNameStartsWithNumber() throws Exception {
Path p = Paths.get("src/test/resources/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
Path p = Paths.get("src/test/test-data/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
ResolvePathsRequest<Path> request =
ResolvePathsRequest.ofPaths(Arrays.asList(p)).setMainModuleDescriptor(mockModuleInfoJava);

Expand Down
Loading

0 comments on commit 216e33d

Please sign in to comment.