Example usage for org.apache.commons.daemon Daemon stop

List of usage examples for org.apache.commons.daemon Daemon stop

Introduction

In this page you can find the example usage for org.apache.commons.daemon Daemon stop.

Prototype

public void stop() throws Exception;

Source Link

Document

Stops the operation of this Daemon instance.

Usage

From source file:com.google.enterprise.adaptor.DaemonTest.java

@Test
public void testStopAfterInit() throws Exception {
    DaemonContext context = new Context(arguments, null);
    Daemon daemon = new Daemon();
    daemon.init(context);//from  w ww  . j a v a 2  s.c  om
    try {
        daemon.stop();
    } finally {
        daemon.destroy();
    }
}

From source file:com.google.enterprise.adaptor.DaemonTest.java

@Test
public void testApplicationRetryStartFailure() throws Exception {
    String[] args = makeArguments(RetryInitAdaptor.class.getName(), 0);
    Daemon daemon = new Daemon();
    Controller controller = new Controller(daemon);
    DaemonContext context = new Context(args, controller);
    daemon.init(context);/*from   ww w.  j av  a2 s  .  c om*/
    assertNotNull(daemon.getApplication());
    try {
        daemon.start();
        assertNull(controller.thrownException);
        assertNotNull(daemon.getApplication());
    } finally {
        daemon.stop();
        daemon.destroy();
    }
}

From source file:com.google.enterprise.adaptor.DaemonTest.java

@Test
public void testBasicListen() throws Exception {
    Daemon daemon = new Daemon();
    Controller controller = new Controller(daemon);
    DaemonContext context = new Context(arguments, controller);
    SingleDocAdaptor adaptor = null;//  w  w  w  .  j  av a  2 s . c o m
    URL contentUrl;
    daemon.init(context);
    try {
        daemon.start();
        assertNull(controller.thrownException);
        try {
            Adaptor tmpAdaptor = daemon.getApplication().getGsaCommunicationHandler().getAdaptor();
            adaptor = (SingleDocAdaptor) tmpAdaptor;
            assertTrue(adaptor.inited);
            contentUrl = getContentUrl(daemon);
            assertEquals("success", getDocContent(contentUrl));
        } finally {
            daemon.stop();
        }
    } finally {
        daemon.destroy();
    }
    assertFalse(adaptor.inited);
    assertNull(controller.thrownException);
    // Service should be shut down.
    try {
        getDocContent(contentUrl);
        fail("Expected a ConnectException, but got none.");
    } catch (ConnectException expected) {
        // expected;
    }
}