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));
}
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);
}
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());
}
Aggregations