use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerTestCase method resolvesCoreExtensionDependencies.
@Test
public void resolvesCoreExtensionDependencies() throws Exception {
List<MuleCoreExtension> extensions = new LinkedList<>();
MuleCoreExtension extension = mock(MuleCoreExtension.class);
extensions.add(extension);
when(coreExtensionDiscoverer.discover()).thenReturn(extensions);
coreExtensionManager.initialise();
verify(coreExtensionDependencyResolver).resolveDependencies(extensions);
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerTestCase method injectsServiceOnExtension.
@Test
public void injectsServiceOnExtension() throws Exception {
List<MuleCoreExtension> extensions = new LinkedList<>();
InjectedTestServiceExtension extension = mock(InjectedTestServiceExtension.class);
extensions.add(extension);
TestService service = mock(TestService.class);
when(service.getName()).thenReturn("testService");
ServiceRepository serviceRepository = mock(ServiceRepository.class);
when(serviceRepository.getServices()).thenReturn(Collections.singletonList(service));
when(coreExtensionDiscoverer.discover()).thenReturn(extensions);
when(coreExtensionDependencyResolver.resolveDependencies(extensions)).thenReturn(extensions);
coreExtensionManager.setServiceRepository(serviceRepository);
coreExtensionManager.initialise();
verify(extension).setService(service);
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerTestCase method disposesCoreExtensionsAfterStartFail.
@Test
public void disposesCoreExtensionsAfterStartFail() throws Exception {
List<MuleCoreExtension> extensions = new LinkedList<>();
MuleCoreExtension extension1 = mock(MuleCoreExtension.class);
MuleCoreExtension extension2 = mock(MuleCoreExtension.class);
Exception firstStartFailure = new RuntimeException();
doThrow(firstStartFailure).when(extension1).initialise();
when(coreExtensionDiscoverer.discover()).thenReturn(extensions);
extensions.add(extension1);
extensions.add(extension2);
List<MuleCoreExtension> orderedExtensions = new LinkedList<>();
orderedExtensions.add(extension1);
orderedExtensions.add(extension2);
when(coreExtensionDependencyResolver.resolveDependencies(extensions)).thenReturn(orderedExtensions);
try {
coreExtensionManager.initialise();
fail();
} catch (Exception e) {
assertThat(e.getCause(), sameInstance(firstStartFailure));
}
coreExtensionManager.dispose();
verify(extension2, never()).dispose();
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class DefaultMuleCoreExtensionManagerTestCase method testAllCoreExtensionsAreStoppedAfterRuntimeException.
@Test
public void testAllCoreExtensionsAreStoppedAfterRuntimeException() throws Exception {
TestDeploymentServiceAwareExtension extensionFailsStops = mock(TestDeploymentServiceAwareExtension.class);
TestDeploymentServiceAwareExtension extensionStopsOk = mock(TestDeploymentServiceAwareExtension.class);
InOrder stopsInOrder = inOrder(extensionFailsStops, extensionStopsOk);
List<MuleCoreExtension> extensions = new LinkedList<>();
when(coreExtensionDiscoverer.discover()).thenReturn(extensions);
when(coreExtensionDependencyResolver.resolveDependencies(extensions)).thenReturn(extensions);
doThrow(RuntimeException.class).when(extensionFailsStops).stop();
extensions.add(extensionStopsOk);
extensions.add(extensionFailsStops);
coreExtensionManager.initialise();
coreExtensionManager.start();
try {
coreExtensionManager.stop();
} finally {
stopsInOrder.verify(extensionFailsStops).stop();
stopsInOrder.verify(extensionStopsOk).stop();
}
}
use of org.mule.runtime.container.api.MuleCoreExtension in project mule by mulesoft.
the class ReflectionMuleCoreExtensionDependencyResolverTestCase method resolvesOrderedCoreExtensionAwareExtensions.
@Test
public void resolvesOrderedCoreExtensionAwareExtensions() throws Exception {
MuleCoreExtension coreExtensionsAwareExtension1 = mockCoreExtension(EXTENSION1);
MuleCoreExtension coreExtensionsAwareExtension2 = mockCoreExtension(EXTENSION2);
List<MuleCoreExtension> coreExtensions = new LinkedList<>();
coreExtensions.add(coreExtensionsAwareExtension1);
coreExtensions.add(coreExtensionsAwareExtension2);
final List<MuleCoreExtension> resolvedCoreExtensions = dependencyResolver.resolveDependencies(coreExtensions);
assertThat(resolvedCoreExtensions.size(), equalTo(2));
assertThat(resolvedCoreExtensions.get(0), sameInstance(coreExtensionsAwareExtension1));
assertThat(resolvedCoreExtensions.get(1), sameInstance(coreExtensionsAwareExtension2));
}
Aggregations