use of org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy in project mule by mulesoft.
the class MuleClassLoaderLookupPolicyProviderTestCase method extendsPolicy.
@Test
public void extendsPolicy() throws Exception {
ClassLoaderLookupPolicy lookupPolicy = new MuleClassLoaderLookupPolicy(emptyMap(), emptySet());
final ClassLoaderLookupPolicy extendedPolicy = lookupPolicy.extend(singletonMap(FOO_PACKAGE, PARENT_FIRST));
assertThat(extendedPolicy.getClassLookupStrategy(FOO_CLASS), sameInstance(PARENT_FIRST));
}
use of org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy in project mule by mulesoft.
the class MuleClassLoaderLookupPolicyProviderTestCase method maintainsOriginalLookupStrategy.
@Test
public void maintainsOriginalLookupStrategy() throws Exception {
ClassLoaderLookupPolicy lookupPolicy = new MuleClassLoaderLookupPolicy(singletonMap(FOO_PACKAGE, new ContainerOnlyLookupStrategy(getClass().getClassLoader())), emptySet());
final ClassLoaderLookupPolicy extendedPolicy = lookupPolicy.extend(singletonMap(FOO_PACKAGE, PARENT_FIRST));
assertThat(extendedPolicy.getClassLookupStrategy(FOO_CLASS), instanceOf(ContainerOnlyLookupStrategy.class));
assertThat(extendedPolicy.getClassLookupStrategy(FOO_CLASS).getClassLoaders(getClass().getClassLoader()), contains(getClass().getClassLoader()));
}
use of org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy in project mule by mulesoft.
the class MuleClassLoaderLookupPolicyProviderTestCase method normalizesLookupStrategies.
@Test
public void normalizesLookupStrategies() throws Exception {
ClassLoaderLookupPolicy lookupPolicy = new MuleClassLoaderLookupPolicy(singletonMap(FOO_PACKAGE, new ContainerOnlyLookupStrategy(getClass().getClassLoader())), emptySet());
final ClassLoaderLookupPolicy extendedPolicy = lookupPolicy.extend(singletonMap(FOO_PACKAGE_PREFIX, PARENT_FIRST));
assertThat(extendedPolicy.getClassLookupStrategy(FOO_CLASS), instanceOf(ContainerOnlyLookupStrategy.class));
assertThat(extendedPolicy.getClassLookupStrategy(FOO_CLASS).getClassLoaders(getClass().getClassLoader()), contains(getClass().getClassLoader()));
}
use of org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy in project mule by mulesoft.
the class MuleClassLoaderLookupPolicyProviderTestCase method cannotExtendPolicyWithSystemPackage.
@Test
public void cannotExtendPolicyWithSystemPackage() throws Exception {
ClassLoaderLookupPolicy lookupPolicy = new MuleClassLoaderLookupPolicy(emptyMap(), singleton(SYSTEM_PACKAGE));
final String overrideClassName = Object.class.getName();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage(invalidLookupPolicyOverrideError(overrideClassName, PARENT_FIRST));
lookupPolicy.extend(singletonMap(overrideClassName, PARENT_FIRST));
}
use of org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy in project mule by mulesoft.
the class MuleClassLoaderLookupPolicyProviderTestCase method usesParentOnlyForSystemPackage.
@Test
public void usesParentOnlyForSystemPackage() throws Exception {
ClassLoaderLookupPolicy lookupPolicy = new MuleClassLoaderLookupPolicy(emptyMap(), singleton(SYSTEM_PACKAGE));
assertThat(lookupPolicy.getClassLookupStrategy(Object.class.getName()), sameInstance(PARENT_ONLY));
lookupPolicy = new MuleClassLoaderLookupPolicy(emptyMap(), singleton(JAVA_PACKAGE));
assertThat(lookupPolicy.getClassLookupStrategy(Object.class.getName()), sameInstance(PARENT_ONLY));
}
Aggregations