Search in sources :

Example 1 with EnumerationAdapter

use of org.mule.runtime.core.internal.util.EnumerationAdapter in project mule by mulesoft.

the class ClasspathModuleDiscovererTestCase method discoversModule.

@Test
public void discoversModule() throws Exception {
    List<URL> moduleProperties = new ArrayList();
    moduleProperties.add(getClass().getClassLoader().getResource("invalidModule.properties"));
    when(classLoader.getResources(ClasspathModuleDiscoverer.MODULE_PROPERTIES)).thenReturn(new EnumerationAdapter(moduleProperties));
    expectedException.expect(IllegalArgumentException.class);
    moduleDiscoverer.discover();
}
Also used : ArrayList(java.util.ArrayList) EnumerationAdapter(org.mule.runtime.core.internal.util.EnumerationAdapter) URL(java.net.URL) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with EnumerationAdapter

use of org.mule.runtime.core.internal.util.EnumerationAdapter in project mule by mulesoft.

the class ClasspathModuleDiscovererTestCase method discoversModuleWithExportedJavaPackages.

@Test
public void discoversModuleWithExportedJavaPackages() 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> muleModules = moduleDiscoverer.discover();
    assertThat(muleModules, hasSize(1));
    MuleModule muleModule = muleModules.get(0);
    assertThat(muleModule.getName(), is("moduleJavaPackages"));
    assertThat(muleModule.getExportedPackages(), contains("org.foo", "org.bar"));
    assertThat(muleModule.getExportedPaths(), is(empty()));
    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 3 with EnumerationAdapter

use of org.mule.runtime.core.internal.util.EnumerationAdapter 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 4 with EnumerationAdapter

use of org.mule.runtime.core.internal.util.EnumerationAdapter 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 5 with EnumerationAdapter

use of org.mule.runtime.core.internal.util.EnumerationAdapter 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)

Aggregations

URL (java.net.URL)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 EnumerationAdapter (org.mule.runtime.core.internal.util.EnumerationAdapter)6 SmallTest (org.mule.tck.size.SmallTest)6 MuleModule (org.mule.runtime.container.api.MuleModule)5