use of org.mule.tck.classlaoder.TestClassLoader in project mule by mulesoft.
the class FilteringArtifactClassLoaderTestCase method loadsExportedClass.
@Test
public void loadsExportedClass() throws ClassNotFoundException {
TestClassLoader classLoader = new TestClassLoader(null);
Class expectedClass = this.getClass();
classLoader.addClass(CLASS_NAME, expectedClass);
when(filter.exportsClass(CLASS_NAME)).thenReturn(true);
when(artifactClassLoader.getClassLoader()).thenReturn(classLoader);
filteringArtifactClassLoader = doCreateClassLoader(emptyList());
Class<?> aClass = filteringArtifactClassLoader.loadClass(CLASS_NAME);
assertThat(aClass, equalTo(expectedClass));
}
use of org.mule.tck.classlaoder.TestClassLoader in project mule by mulesoft.
the class FilteringArtifactClassLoaderTestCase method filtersResources.
@Test
public void filtersResources() throws Exception {
TestClassLoader classLoader = new TestClassLoader(null);
URL blockedResource = new URL("file:///app.txt");
classLoader.addResource(RESOURCE_NAME, blockedResource);
when(filter.exportsResource(RESOURCE_NAME)).thenReturn(false);
when(artifactClassLoader.getClassLoader()).thenReturn(classLoader);
filteringArtifactClassLoader = doCreateClassLoader(emptyList());
Enumeration<URL> resources = filteringArtifactClassLoader.getResources(RESOURCE_NAME);
assertThat(resources, equalTo(Collections.EMPTY_LIST));
}
use of org.mule.tck.classlaoder.TestClassLoader in project mule by mulesoft.
the class FilteringContainerClassLoaderTestCase method loadsExportedResource.
@Test
@Override
public void loadsExportedResource() throws ClassNotFoundException, MalformedURLException {
TestClassLoader classLoader = new TestClassLoader(null);
URL expectedResource = new URL("file:///app.txt");
classLoader.addResource(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME, expectedResource);
when(filter.exportsResource(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME)).thenReturn(true);
when(artifactClassLoader.getClassLoader()).thenReturn(classLoader);
filteringArtifactClassLoader = doCreateClassLoader(emptyList());
URL resource = filteringArtifactClassLoader.getResource(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME);
assertThat(resource, equalTo(expectedResource));
}
use of org.mule.tck.classlaoder.TestClassLoader in project mule by mulesoft.
the class FilteringContainerClassLoaderTestCase method getsExportedResources.
@Test
@Override
public void getsExportedResources() throws Exception {
TestClassLoader classLoader = new TestClassLoader(null);
URL resource = new URL("file:/app.txt");
classLoader.addResource(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME, resource);
when(filter.exportsResource(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME)).thenReturn(true);
when(artifactClassLoader.getClassLoader()).thenReturn(classLoader);
filteringArtifactClassLoader = doCreateClassLoader(emptyList());
Enumeration<URL> resources = filteringArtifactClassLoader.getResources(FilteringArtifactClassLoaderTestCase.RESOURCE_NAME);
assertThat(resources, EnumerationMatcher.equalTo(Collections.singletonList(resource)));
}
Aggregations