Search in sources :

Example 1 with ClassLoaderModelLoader

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader in project mule by mulesoft.

the class ServiceRegistryDescriptorLoaderRepositoryTestCase method findsLoader.

@Test
public void findsLoader() throws Exception {
    ClassLoaderModelLoader expectedClassLoaderModelLoader = mock(ClassLoaderModelLoader.class);
    when(expectedClassLoaderModelLoader.getId()).thenReturn(LOADER_ID);
    when(expectedClassLoaderModelLoader.supportsArtifactType(PLUGIN)).thenReturn(true);
    Collection<ClassLoaderModelLoader> classLoaderModelLoaders = singleton(expectedClassLoaderModelLoader);
    when(serviceRegistry.lookupProviders(ClassLoaderModelLoader.class, getClass().getClassLoader())).thenReturn(classLoaderModelLoaders);
    ClassLoaderModelLoader classLoaderModelLoader = repository.get(LOADER_ID, PLUGIN, ClassLoaderModelLoader.class);
    assertThat(classLoaderModelLoader, is(expectedClassLoaderModelLoader));
}
Also used : ClassLoaderModelLoader(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with ClassLoaderModelLoader

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader in project mule by mulesoft.

the class ServiceRegistryDescriptorLoaderRepositoryTestCase method findsLoaderIdWithType.

@Test
public void findsLoaderIdWithType() throws Exception {
    ClassLoaderModelLoader classLoaderModelLoader = mock(ClassLoaderModelLoader.class);
    when(classLoaderModelLoader.getId()).thenReturn(LOADER_ID);
    Collection<ClassLoaderModelLoader> classLoaderModelLoaders = singleton(classLoaderModelLoader);
    when(serviceRegistry.lookupProviders(ClassLoaderModelLoader.class, getClass().getClassLoader())).thenReturn(classLoaderModelLoaders);
    expectedException.expect(LoaderNotFoundException.class);
    expectedException.expectMessage(noRegisteredLoaderError(LOADER_ID, BundleDescriptorLoader.class));
    repository.get(LOADER_ID, PLUGIN, BundleDescriptorLoader.class);
}
Also used : BundleDescriptorLoader(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader) ClassLoaderModelLoader(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 3 with ClassLoaderModelLoader

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader in project mule by mulesoft.

the class ServiceRegistryDescriptorLoaderRepositoryTestCase method initializesClassLoaderModelLoadersOnce.

@Test
public void initializesClassLoaderModelLoadersOnce() throws Exception {
    ClassLoaderModelLoader expectedClassLoaderModelLoader = mock(ClassLoaderModelLoader.class);
    when(expectedClassLoaderModelLoader.getId()).thenReturn(LOADER_ID);
    Collection<ClassLoaderModelLoader> classLoaderModelLoaders = singleton(expectedClassLoaderModelLoader);
    when(serviceRegistry.lookupProviders(ClassLoaderModelLoader.class, getClass().getClassLoader())).thenReturn(classLoaderModelLoaders);
    when(expectedClassLoaderModelLoader.supportsArtifactType(PLUGIN)).thenReturn(true);
    repository.get(LOADER_ID, PLUGIN, ClassLoaderModelLoader.class);
    repository.get(LOADER_ID, PLUGIN, ClassLoaderModelLoader.class);
    verify(serviceRegistry).lookupProviders(ClassLoaderModelLoader.class, getClass().getClassLoader());
    verify(serviceRegistry).lookupProviders(BundleDescriptorLoader.class, getClass().getClassLoader());
    verify(serviceRegistry, never()).lookupProvider(ClassLoaderModelLoader.class, getClass().getClassLoader());
    verify(serviceRegistry, never()).lookupProvider(BundleDescriptorLoader.class, getClass().getClassLoader());
}
Also used : ClassLoaderModelLoader(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

Test (org.junit.Test)3 ClassLoaderModelLoader (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModelLoader)3 SmallTest (org.mule.tck.size.SmallTest)3 BundleDescriptorLoader (org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader)1