Skip to content

Commit

Permalink
FORGE-1872: Ensuring the class is loaded through the correct classloader
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jun 6, 2014
1 parent 9a400ac commit 940fe92
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public void testServiceWithExpectedObjectsDifferentClassLoaders() throws Excepti
Assert.assertFalse(depOneServiceRegistry.hasService(Aa.class.getName()));
Assert.assertFalse(depTwoServiceRegistry.hasService(Aa.class));
Assert.assertFalse(depTwoServiceRegistry.hasService(Aa.class.getName()));
Assert.assertFalse(depOneServiceRegistry.hasService(BB.class));
Assert.assertFalse(depOneServiceRegistry.hasService(loadClass(BB.class, depTwo.getClassLoader())));
Assert.assertTrue(depOneServiceRegistry.hasService(BB.class.getName()));
Assert.assertTrue(depTwoServiceRegistry.hasService(BB.class));
Assert.assertTrue(depTwoServiceRegistry.hasService(loadClass(BB.class, depTwo.getClassLoader())));
Assert.assertTrue(depTwoServiceRegistry.hasService(BB.class.getName()));

Assert.assertNotNull(depTwoServiceRegistry.getExportedInstance(BB.class.getName()));
Expand All @@ -121,4 +121,9 @@ public void testServiceWithExpectedObjectsDifferentClassLoaders() throws Excepti
Assert.assertFalse(iterator2.hasNext());
}

private Class<?> loadClass(Class<?> clazz, ClassLoader cl) throws Exception
{
return cl.loadClass(clazz.getName());
}

}

0 comments on commit 940fe92

Please sign in to comment.