--- old/test/java/lang/module/ModuleReader/ModuleReaderTest.java 2017-03-21 13:44:28.230151065 +0000 +++ new/test/java/lang/module/ModuleReader/ModuleReaderTest.java 2017-03-21 13:44:28.034137615 +0000 @@ -79,17 +79,21 @@ "java/lang/Object.class" }; + // (directory) resources that may be in the base module + private static final String[] MAYBE_BASE_RESOURCES = { + "java", + "java/", + "java/lang", + "java/lang/", + }; + // resource names that should not be found in the base module - private static final String[] BAD_BASE_RESOURCES = { + private static final String[] NOT_BASE_RESOURCES = { "NotFound", - "java", "/java", "//java", - "java/", - "java/lang", "/java/lang", "//java/lang", - "java/lang/", "java//lang", "/java/lang/Object.class", "//java/lang/Object.class", @@ -109,13 +113,17 @@ "p/Main.class" }; + // (directory) resources that may be in the test module + private static final String[] MAYBE_TEST_RESOURCES = { + "p", + "p/" + }; + // resource names that should not be found in the test module - private static final String[] BAD_TEST_RESOURCES = { + private static final String[] NOT_TEST_RESOURCES = { "NotFound", - "p", "/p", "//p", - "p/", "/p/Main.class", "//p/Main.class", "p/Main.class/", @@ -160,11 +168,19 @@ testOpen(reader, name, expectedBytes); testRead(reader, name, expectedBytes); testList(reader, name); + } + // test resources that may be in the base module + for (String name : MAYBE_BASE_RESOURCES) { + Optional ouri = reader.find(name); + ouri.ifPresent(uri -> { + if (name.endsWith("/")) + assertTrue(uri.toString().endsWith("/")); + }); } - // test "not found" - for (String name : BAD_BASE_RESOURCES) { + // test "not found" in java.base module + for (String name : NOT_BASE_RESOURCES) { assertFalse(reader.find(name).isPresent()); assertFalse(reader.open(name).isPresent()); assertFalse(reader.read(name).isPresent()); @@ -261,7 +277,7 @@ try (reader) { - // test each of the known resources in the module + // test resources in test module for (String name : TEST_RESOURCES) { byte[] expectedBytes = Files.readAllBytes(MODS_DIR @@ -274,8 +290,18 @@ testList(reader, name); } - // test "not found" - for (String name : BAD_TEST_RESOURCES) { + // test resources that may be in the test module + for (String name : MAYBE_TEST_RESOURCES) { + System.out.println(name); + Optional ouri = reader.find(name); + ouri.ifPresent(uri -> { + if (name.endsWith("/")) + assertTrue(uri.toString().endsWith("/")); + }); + } + + // test "not found" in test module + for (String name : NOT_TEST_RESOURCES) { assertFalse(reader.find(name).isPresent()); assertFalse(reader.open(name).isPresent()); assertFalse(reader.read(name).isPresent()); @@ -394,9 +420,6 @@ for (String e : names) { assertTrue(reader.find(e).isPresent()); } - - // should not contain directories - names.forEach(e -> assertFalse(e.endsWith("/"))); } }