Search in sources :

Example 11 with MuleModule

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));
}
Also used : ArrayList(java.util.ArrayList) EnumerationAdapter(org.mule.runtime.core.internal.util.EnumerationAdapter) URL(java.net.URL) MuleModule(org.mule.runtime.container.api.MuleModule) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 12 with MuleModule

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()));
}
Also used : ArrayList(java.util.ArrayList) EnumerationAdapter(org.mule.runtime.core.internal.util.EnumerationAdapter) URL(java.net.URL) MuleModule(org.mule.runtime.container.api.MuleModule) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 13 with MuleModule

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()));
}
Also used : ArrayList(java.util.ArrayList) EnumerationAdapter(org.mule.runtime.core.internal.util.EnumerationAdapter) URL(java.net.URL) MuleModule(org.mule.runtime.container.api.MuleModule) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 14 with MuleModule

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"));
}
Also used : ArrayList(java.util.ArrayList) EnumerationAdapter(org.mule.runtime.core.internal.util.EnumerationAdapter) URL(java.net.URL) MuleModule(org.mule.runtime.container.api.MuleModule) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 15 with MuleModule

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));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) ClassLoaderLookupPolicy(org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy) ArrayList(java.util.ArrayList) ModuleRepository(org.mule.runtime.container.api.ModuleRepository) MuleModule(org.mule.runtime.container.api.MuleModule) Test(org.junit.Test)

Aggregations

MuleModule (org.mule.runtime.container.api.MuleModule)21 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)11 URL (java.net.URL)5 EnumerationAdapter (org.mule.runtime.core.internal.util.EnumerationAdapter)5 SmallTest (org.mule.tck.size.SmallTest)5 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)4 LookupStrategy (org.mule.runtime.module.artifact.api.classloader.LookupStrategy)4 HashMap (java.util.HashMap)3 ModuleRepository (org.mule.runtime.container.api.ModuleRepository)3 ContainerOnlyLookupStrategy (org.mule.runtime.container.internal.ContainerOnlyLookupStrategy)3 ClassLoaderFilter (org.mule.runtime.module.artifact.api.classloader.ClassLoaderFilter)3 ClassLoaderLookupPolicy (org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)2 DelegateOnlyLookupStrategy (org.mule.runtime.module.artifact.api.classloader.DelegateOnlyLookupStrategy)2 ArtifactDescriptor (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor)2 IOException (java.io.IOException)1