sdedic commented on a change in pull request #976: [NETBEANS-1481] Fix handling 
of module fragments (regression 9.0)
URL: https://github.com/apache/incubator-netbeans/pull/976#discussion_r226933757
 
 

 ##########
 File path: 
platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java
 ##########
 @@ -2760,6 +2760,189 @@ public void testMissingSpecVersion() throws Exception {
         Module client = mgr.create(jar, null, false, false, false);
         assertEquals(1, client.getProblems().size());
     }
+
+    public void testEnableHostWithDefautFragment() throws Exception {
+        MockModuleInstaller installer = new MockModuleInstaller();
+        MockEvents ev = new MockEvents();
+        ModuleManager mgr = new ModuleManager(installer, ev);
+        mgr.mutexPrivileged().enterWriteAccess();
+
+        Module host = mgr.create(new File(jars, "host-module.jar"), null, 
false, false, false);
+        Module fragment = mgr.create(new File(jars, "fragment-module.jar"), 
null, false, false, false);
+
+        assertTrue("Host is known", mgr.getModules().contains(host));
+        assertTrue("Fragment is known", mgr.getModules().contains(fragment));
+
+        mgr.enable(new HashSet<>(Arrays.asList(host, fragment)));
+
+        assertTrue("Host must be enabled", 
mgr.getEnabledModules().contains(host));
+        assertTrue("Fragment must be enabled", 
mgr.getEnabledModules().contains(fragment));
+    }
+
+    public void testEnableHostWithDefautFragmentUnsatisfied() throws Exception 
{
+        MockModuleInstaller installer = new MockModuleInstaller();
+        MockEvents ev = new MockEvents();
+        ModuleManager mgr = new ModuleManager(installer, ev);
+        mgr.mutexPrivileged().enterWriteAccess();
+
+        createTestJAR(data, jars, "fragment-module-missing-token", null);
+
+        Module host = mgr.create(new File(jars, "host-module.jar"), null, 
false, false, false);
+        Module fragment = mgr.create(new File(jars, 
"fragment-module-missing-token.jar"), null, false, false, false);
+
+        assertTrue("Host is known", mgr.getModules().contains(host));
+        assertTrue("Fragment is known", mgr.getModules().contains(fragment));
+
+        boolean expectedExceptionCatched = false;
+        try {
+            mgr.enable(fragment);
+        } catch (IllegalArgumentException e) {
+            expectedExceptionCatched = e.getMessage().startsWith("Not all 
requested modules can be enabled:");
+            if (!expectedExceptionCatched) {
+                throw e;
+            }
+        }
+        assertTrue(expectedExceptionCatched);
 
 Review comment:
   just put `fail after `mgr.enable()`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to