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

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

Introduction

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

Prototype

public void destroy();

Source Link

Document

Frees any resources allocated by this daemon such as file descriptors or sockets.

Usage

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

@Test
public void testAnyTimeDestroy() {
    Daemon daemon = new Daemon();
    // Destroy without init should still work.
    daemon.destroy();
}

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 w w . ja  v a 2  s .c o m*/
    try {
        daemon.stop();
    } finally {
        daemon.destroy();
    }
}

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

@Test
public void testDoubleInit() throws Exception {
    DaemonContext context = new Context(arguments, null);
    Daemon daemon = new Daemon();
    daemon.init(context);//  w w  w.j a va 2  s  . c o  m
    try {
        thrown.expect(IllegalStateException.class);
        daemon.init(context);
    } 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  w  ww . j  a  va2 s  .  c o  m*/
    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;/*from   w w w  .  j  av a 2s. 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;
    }
}