StandAloneClusterController { public static void runApplication(StandAloneClusterController myApp) { LogSetup.initVespaLogging("fleetcontroller"); try{ myApp.start(); } catch (Exception e) { log.log(Level.SEVERE, "Failed to start application '" + myApp.getName() + "': " + e.getMessage()); e.printStackTrace(); return; } Runtime.getRuntime().addShutdownHook(new ShutdownHook(myApp)); try{ myApp.run(); } catch (Exception e) { log.log(Level.SEVERE, "Application '" + myApp.getName() + "' runtime failure: " + e.getMessage()); e.printStackTrace(); } } StandAloneClusterController(ClusterControllerConfigFetcher config); static void main(String args[]); static void runApplication(StandAloneClusterController myApp); String getName(); void start(); void run(); void stop();  }
@Test public void testFailStart() throws Exception { setupConfig(); ClusterControllerConfigFetcher configFetcher = new ClusterControllerConfigFetcher(); StandAloneClusterController controller = new StandAloneClusterController(configFetcher) { @Override public void start() { throw new RuntimeException("Foo"); } }; StandAloneClusterController.runApplication(controller); }
@Test public void testFailRun() throws Exception { setupConfig(); ClusterControllerConfigFetcher configFetcher = new ClusterControllerConfigFetcher(); StandAloneClusterController controller = new StandAloneClusterController(configFetcher) { @Override public void run() { throw new RuntimeException("Foo"); } }; StandAloneClusterController.runApplication(controller); }