use of org.mule.tck.classlaoder.TestClassLoader.TestClassNotFoundException in project mule by mulesoft.
the class FineGrainedControlClassLoaderTestCase method usesParentFirstAndChildLookupAndFails.
@Test
public void usesParentFirstAndChildLookupAndFails() throws Exception {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
final ClassLoaderLookupPolicy lookupPolicy = mock(ClassLoaderLookupPolicy.class);
when(lookupPolicy.getClassLookupStrategy(TEST_CLASS_NAME)).thenReturn(PARENT_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(hasMessage(is(TEST_CLASS_NAME)), expressionMatches((e) -> ((TestClassNotFoundException) e).getClassLoader(), is((ClassLoader) ext)))));
invokeTestClassMethod(ext);
}
use of org.mule.tck.classlaoder.TestClassLoader.TestClassNotFoundException 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