Search in sources :

Example 6 with ServiceDiscoverer

use of org.mule.runtime.module.service.api.discoverer.ServiceDiscoverer in project mule by mulesoft.

the class MuleServiceManagerTestCase method stopsOnlyStoppableServices.

@Test
public void stopsOnlyStoppableServices() throws Exception {
    final ServiceDiscoverer serviceDiscoverer = mock(ServiceDiscoverer.class);
    final List<Pair<ArtifactClassLoader, Service>> services = new ArrayList<>();
    Pair<ArtifactClassLoader, Service> service1Pairs = new Pair(mock(ArtifactClassLoader.class), mock(StoppableService.class));
    Pair<ArtifactClassLoader, Service> service2Pairs = new Pair(mock(ArtifactClassLoader.class), mock(StoppableService.class));
    services.add(service1Pairs);
    services.add(service2Pairs);
    when(serviceDiscoverer.discoverServices()).thenReturn(services);
    final MuleServiceManager muleServiceManager = new MuleServiceManager(serviceDiscoverer);
    muleServiceManager.start();
    muleServiceManager.stop();
    InOrder inOrder = inOrder(service1Pairs.getSecond(), service2Pairs.getSecond());
    inOrder.verify((StoppableService) service2Pairs.getSecond()).stop();
    inOrder.verify((StoppableService) service1Pairs.getSecond()).stop();
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) Service(org.mule.runtime.api.service.Service) ServiceDiscoverer(org.mule.runtime.module.service.api.discoverer.ServiceDiscoverer) Pair(org.mule.runtime.api.util.Pair) Test(org.junit.Test)

Example 7 with ServiceDiscoverer

use of org.mule.runtime.module.service.api.discoverer.ServiceDiscoverer in project mule by mulesoft.

the class MuleServiceManagerTestCase method stopsStartableStoppableServices.

@Test
public void stopsStartableStoppableServices() throws Exception {
    final ServiceDiscoverer serviceDiscoverer = mock(ServiceDiscoverer.class);
    final List<Pair<ArtifactClassLoader, Service>> services = new ArrayList<>();
    Pair<ArtifactClassLoader, Service> service1Pairs = new Pair(mock(ArtifactClassLoader.class), mock(StartableStoppableService.class));
    Pair<ArtifactClassLoader, Service> service2Pairs = new Pair(mock(ArtifactClassLoader.class), mock(StartableStoppableService.class));
    services.add(service1Pairs);
    services.add(service2Pairs);
    when(serviceDiscoverer.discoverServices()).thenReturn(services);
    final MuleServiceManager muleServiceManager = new MuleServiceManager(serviceDiscoverer);
    muleServiceManager.start();
    muleServiceManager.stop();
    InOrder inOrder = inOrder(service1Pairs.getSecond(), service2Pairs.getSecond());
    inOrder.verify((StartableStoppableService) service2Pairs.getSecond()).stop();
    inOrder.verify((StartableStoppableService) service1Pairs.getSecond()).stop();
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) Service(org.mule.runtime.api.service.Service) ServiceDiscoverer(org.mule.runtime.module.service.api.discoverer.ServiceDiscoverer) Pair(org.mule.runtime.api.util.Pair) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Pair (org.mule.runtime.api.util.Pair)7 ServiceDiscoverer (org.mule.runtime.module.service.api.discoverer.ServiceDiscoverer)7 Service (org.mule.runtime.api.service.Service)5 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)5 InOrder (org.mockito.InOrder)4