use of org.mule.runtime.module.artifact.api.classloader.ChildFirstLookupStrategy.CHILD_FIRST in project mule by mulesoft.
the class FineGrainedControlClassLoaderTestCase method usesChildFirstThenParentLookupAndFails.
@Test
public void usesChildFirstThenParentLookupAndFails() throws Exception {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
final ClassLoaderLookupPolicy lookupPolicy = mock(ClassLoaderLookupPolicy.class);
when(lookupPolicy.getClassLookupStrategy(TEST_CLASS_NAME)).thenReturn(CHILD_FIRST);
expected.expect(CompositeClassNotFoundException.class);
expected.expectMessage(startsWith("Cannot load class '" + TEST_CLASS_NAME + "': ["));
FineGrainedControlClassLoader ext = buildFineGrainedControlClassLoader(parent, lookupPolicy);
expected.expect(expressionMatches((e) -> ((CompositeClassNotFoundException) e).getExceptions(), contains(expressionMatches((e) -> ((TestClassNotFoundException) e).getClassLoader(), is((ClassLoader) ext)), hasMessage(is(TEST_CLASS_NAME)))));
invokeTestClassMethod(ext);
}
Aggregations