use of org.mule.runtime.container.api.MuleModule in project mule by mulesoft.
the class ClasspathModuleDiscovererTestCase method ignoresDuplicateModule.
@Test
public void ignoresDuplicateModule() throws Exception {
List<URL> moduleProperties = new ArrayList();
moduleProperties.add(getClass().getClassLoader().getResource("moduleJavaPackages.properties"));
when(classLoader.getResources(ClasspathModuleDiscoverer.MODULE_PROPERTIES)).thenReturn(new EnumerationAdapter(moduleProperties));
List<MuleModule> modules = moduleDiscoverer.discover();
assertThat(modules.size(), equalTo(1));
}
use of org.mule.runtime.container.api.MuleModule in project mule by mulesoft.
the class ClasspathModuleDiscovererTestCase method discoversModuleWithExportedPrivilegedApi.
@Test
public void discoversModuleWithExportedPrivilegedApi() throws Exception {
List<URL> moduleProperties = new ArrayList();
moduleProperties.add(getClass().getClassLoader().getResource("moduleJavaPrivilegedApi.properties"));
when(classLoader.getResources(ClasspathModuleDiscoverer.MODULE_PROPERTIES)).thenReturn(new EnumerationAdapter(moduleProperties));
List<MuleModule> muleModules = moduleDiscoverer.discover();
assertThat(muleModules, hasSize(1));
MuleModule muleModule = muleModules.get(0);
assertThat(muleModule.getName(), is("moduleJavaPrivilegedApi"));
assertThat(muleModule.getExportedPackages(), is(empty()));
assertThat(muleModule.getExportedPaths(), is(empty()));
assertThat(muleModule.getPrivilegedExportedPackages(), contains("org.foo", "org.bar"));
assertThat(muleModule.getPrivilegedArtifacts(), contains("privilegedArtifact1", "privilegedArtifact2"));
assertThat(muleModule.getExportedServices(), is(empty()));
}
use of org.mule.runtime.container.api.MuleModule in project mule by mulesoft.
the class ClasspathModuleDiscovererTestCase method discoversModuleWithExportedResourcePackages.
@Test
public void discoversModuleWithExportedResourcePackages() throws Exception {
List<URL> moduleProperties = new ArrayList();
moduleProperties.add(getClass().getClassLoader().getResource("moduleResourcePackages.properties"));
when(classLoader.getResources(ClasspathModuleDiscoverer.MODULE_PROPERTIES)).thenReturn(new EnumerationAdapter(moduleProperties));
List<MuleModule> muleModules = moduleDiscoverer.discover();
assertThat(muleModules, hasSize(1));
MuleModule muleModule = muleModules.get(0);
assertThat(muleModule.getName(), is("moduleResourcePackages"));
assertThat(muleModule.getExportedPackages(), is(empty()));
assertThat(muleModule.getExportedPaths(), containsInAnyOrder("META-INF/module.xsd", "README.txt"));
assertThat(muleModule.getPrivilegedExportedPackages(), is(empty()));
assertThat(muleModule.getPrivilegedArtifacts(), is(empty()));
assertThat(muleModule.getExportedServices(), is(empty()));
}
use of org.mule.runtime.container.api.MuleModule in project mule by mulesoft.
the class ClasspathModuleDiscovererTestCase method discoversModuleWithExportedServices.
@Test
public void discoversModuleWithExportedServices() throws Exception {
List<URL> moduleProperties = new ArrayList();
moduleProperties.add(getClass().getClassLoader().getResource("moduleExportedServices.properties"));
when(classLoader.getResources(ClasspathModuleDiscoverer.MODULE_PROPERTIES)).thenReturn(new EnumerationAdapter(moduleProperties));
List<MuleModule> muleModules = moduleDiscoverer.discover();
assertThat(muleModules, hasSize(1));
MuleModule muleModule = muleModules.get(0);
assertThat(muleModule.getName(), is("moduleExportedServices"));
assertThat(muleModule.getExportedPackages(), is(empty()));
assertThat(muleModule.getExportedPaths(), is(empty()));
assertThat(muleModule.getPrivilegedExportedPackages(), is(empty()));
assertThat(muleModule.getPrivilegedArtifacts(), is(empty()));
assertThat(muleModule.getExportedServices().size(), equalTo(3));
assertThat(muleModule.getExportedServices().get(0).getServiceInterface(), equalTo("org.foo.ServiceInterface"));
assertThat(muleModule.getExportedServices().get(1).getServiceInterface(), equalTo("org.foo.ServiceInterface"));
assertThat(muleModule.getExportedServices().get(2).getServiceInterface(), equalTo("org.bar.ServiceInterface"));
}
use of org.mule.runtime.container.api.MuleModule in project mule by mulesoft.
the class ContainerClassLoaderFactoryTestCase method createsClassLoaderLookupPolicy.
@Test
public void createsClassLoaderLookupPolicy() throws Exception {
final ModuleRepository moduleRepository = mock(ModuleRepository.class);
final ContainerClassLoaderFactory factory = new ContainerClassLoaderFactory(moduleRepository);
final List<MuleModule> modules = new ArrayList<>();
modules.add(new TestModuleBuilder("module1").exportingPackages("org.foo1", "org.foo1.bar").build());
modules.add(new TestModuleBuilder("module2").exportingPackages("org.foo2").build());
when(moduleRepository.getModules()).thenReturn(modules);
final ArtifactClassLoader containerClassLoader = factory.createContainerClassLoader(this.getClass().getClassLoader());
final ClassLoaderLookupPolicy classLoaderLookupPolicy = containerClassLoader.getClassLoaderLookupPolicy();
assertThat(classLoaderLookupPolicy.getClassLookupStrategy("org.foo1.Foo"), instanceOf(ContainerOnlyLookupStrategy.class));
assertThat(classLoaderLookupPolicy.getClassLookupStrategy("org.foo1.bar.Bar"), instanceOf(ContainerOnlyLookupStrategy.class));
assertThat(classLoaderLookupPolicy.getClassLookupStrategy("org.foo2.Fo"), instanceOf(ContainerOnlyLookupStrategy.class));
assertThat(classLoaderLookupPolicy.getClassLookupStrategy("org.foo2.bar.Bar"), sameInstance(CHILD_FIRST));
}
Aggregations