List of usage examples for org.apache.commons.daemon Daemon init
public void init(DaemonContext context) throws DaemonInitException, Exception;
Daemon
instance. 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); try {/* w w w. j av a 2s . c om*/ 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); try {// www. j a v a 2 s . c o m thrown.expect(IllegalStateException.class); daemon.init(context); } finally { daemon.destroy(); } }
From source file:com.google.enterprise.adaptor.DaemonTest.java
@Test public void testNoArguments() throws Exception { DaemonContext context = new Context(new String[0], null); Daemon daemon = new Daemon(); thrown.expect(IllegalArgumentException.class); daemon.init(context); }
From source file:com.google.enterprise.adaptor.DaemonTest.java
@Test public void testApplicationInitFailure() throws Exception { // Invalid server.port should force Application.daemonInit() to fail. String[] args = makeArguments(MockAdaptor.class.getName(), Integer.MAX_VALUE); DaemonContext context = new Context(args, null); Daemon daemon = new Daemon(); thrown.expect(IllegalArgumentException.class); daemon.init(context); }
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); assertNotNull(daemon.getApplication()); daemon.start();/* w ww. j a v a 2 s . c om*/ 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); assertNotNull(daemon.getApplication()); try {//from www .jav a 2 s. c o m 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 . ja v a 2 s . co 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; } }