List of usage examples for org.apache.commons.daemon Daemon start
public void start() throws Exception;
Daemon
instance. From source file:com.google.enterprise.adaptor.DaemonTest.java
@Test public void testApplicationStartFailure() throws Exception { String[] args = makeArguments(BrokenInitAdaptor.class.getName(), 0); Daemon daemon = new Daemon(); Controller controller = new Controller(daemon); DaemonContext context = new Context(args, controller); daemon.init(context);/*from w w w .j ava 2 s. c o m*/ assertNotNull(daemon.getApplication()); daemon.start(); assertNotNull(controller.thrownException); assertTrue(controller.thrownException instanceof StartupException); assertNull(daemon.getApplication()); }
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 w w.ja v a2s .co 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 ww w .j ava 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; } }