/* * Launches against the agent& main */ public void testMain() throws Exception { Project project = workspace.getProject("p1"); Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun")); bndrun.setProperty("-runpath", "biz.aQute.remote.launcher"); bndrun.setProperty("-runbundles", "bsn-1,bsn-2"); bndrun.setProperty("-runremote", "main;agent=1090"); final RemoteProjectLauncherPlugin pl = (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher(); pl.prepare(); List<? extends RunSession> sessions = pl.getRunSessions(); assertEquals(1, sessions.size()); RunSessionImpl main = (RunSessionImpl) sessions.get(0); CountDownLatch mainLatch = launch(main); main.waitTillStarted(1000); assertEquals(0, main.started.getCount()); Thread.sleep(500); main.cancel(); mainLatch.await(); assertEquals(-3, main.getExitCode()); bndrun.close(); }
/** Kill! */ public void cancel() throws Exception { for (RunSessionImpl session : sessions) try { session.cancel(); } catch (Exception e) { // ignore } }
/** Make sure all sessions are closed */ public void close() { for (RunSessionImpl session : sessions) try { session.close(); } catch (Exception e) { // ignore } }
/** * Called when a change in the IDE is detected. We will then upate from the project and then * update the remote framework. */ @Override public void update() throws Exception { updateFromProject(); Parameters runremote = new Parameters(getProject().getProperty(Constants.RUNREMOTE)); for (RunSessionImpl session : sessions) try { Attrs attrs = runremote.get(session.getName()); RunRemoteDTO dto = Converter.cnv(RunRemoteDTO.class, attrs); session.update(dto); } catch (Exception e) { getProject().exception(e, "Failed to update session %s", session.getName()); } }