class ModClusterService implements ModClusterServiceMBean, ContainerEventHandler, LoadBalanceFactorProvider,
        MCMPConnectionListener, ContextFilter {

    @Override
    public void stop(Server server) {
        ModClusterLogger.LOGGER.stopServer();

        if (this.established) {
            for (Engine engine : server.getEngines()) {
                for (Host host : engine.getHosts()) {
                    for (Context context : host.getContexts()) {
                        if (context.isStarted()) {
                            this.stop(context);
                        }

                        this.remove(context);
                    }
                }

                this.removeAll(engine);
            }
        }
    }

}

class ModClusterServiceTest {

    private static final String SOME_PATH;

    @Test
    public void stopSingleContext() {


        MCMPHandler mcmpHandler = mock(MCMPHandler.class);
        ModClusterService mod = createModClusterService(mcmpHandler);
        Context context = createContext(SOME_PATH);
        addInnerContexts(context, context);

        mod.stop(context);

        verify(mcmpHandler, times(2)).sendRequest(eq(null));
    }

}