< prev index next >

test/java/lang/module/ModuleFinderTest.java

Print this page

        

@@ -469,45 +469,37 @@
 
     /**
      * Test ModuleFinder.of with a file path to a directory containing a file
      * that will not be recognized as a module.
      */
-    public void testOfWithUnrecognizedEntryInDirectory() throws Exception {
+    public void testOfWithUnrecognizedEntryInDirectory1() throws Exception {
         Path dir = Files.createTempDirectory(USER_DIR, "mods");
         Files.createTempFile(dir, "m", ".junk");
 
         ModuleFinder finder = ModuleFinder.of(dir);
-        try {
-            finder.find("java.rhubarb");
-            assertTrue(false);
-        } catch (FindException e) {
-            // expected
-        }
+        assertFalse(finder.find("java.rhubarb").isPresent());
 
         finder = ModuleFinder.of(dir);
-        try {
-            finder.findAll();
-            assertTrue(false);
-        } catch (FindException e) {
-            // expected
-        }
+        assertTrue(finder.findAll().isEmpty());
     }
 
 
     /**
      * Test ModuleFinder.of with a file path to a directory containing a file
-     * starting with ".", the file should be ignored.
+     * that will not be recognized as a module.
      */
-    public void testOfWithHiddenEntryInDirectory() throws Exception {
+    public void testOfWithUnrecognizedEntryInDirectory2() throws Exception {
         Path dir = Files.createTempDirectory(USER_DIR, "mods");
-        Files.createTempFile(dir, ".marker", "");
+        createModularJar(dir.resolve("m1.jar"), "m1");
+        Files.createTempFile(dir, "m2", ".junk");
 
         ModuleFinder finder = ModuleFinder.of(dir);
-        assertFalse(finder.find("java.rhubarb").isPresent());
+        assertTrue(finder.find("m1").isPresent());
+        assertFalse(finder.find("m2").isPresent());
 
         finder = ModuleFinder.of(dir);
-        assertTrue(finder.findAll().isEmpty());
+        assertTrue(finder.findAll().size() == 1);
     }
 
 
     /**
      * Test ModuleFinder.of with a directory that contains two

@@ -746,11 +738,11 @@
         } else {
             mn = mid.substring(0, i);
             vs = mid.substring(i+1);
         }
         ModuleDescriptor.Builder builder
-            = ModuleDescriptor.module(mn).requires("java.base");
+            = ModuleDescriptor.newModule(mn).requires("java.base");
         if (vs != null)
             builder.version(vs);
         return builder.build();
     }
 
< prev index next >