Search in sources :

Example 1 with RemoteProjectLauncherPlugin

use of aQute.remote.plugin.RemoteProjectLauncherPlugin in project bnd by bndtools.

the class LauncherTest method testMain.

/**
	 * Launches against main
	 */
/*
	 * 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();
}
Also used : Project(aQute.bnd.build.Project) RunSessionImpl(aQute.remote.plugin.RunSessionImpl) RemoteProjectLauncherPlugin(aQute.remote.plugin.RemoteProjectLauncherPlugin) Run(aQute.bnd.build.Run) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 2 with RemoteProjectLauncherPlugin

use of aQute.remote.plugin.RemoteProjectLauncherPlugin in project bnd by bndtools.

the class LauncherTest method testSimpleLauncher.

/*
	 * Launches against the agent
	 */
public void testSimpleLauncher() 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", "test");
    final RemoteProjectLauncherPlugin pl = (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicInteger exitCode = new AtomicInteger(-1);
    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(1, sessions.size());
    final RunSession session = sessions.get(0);
    Thread t = new Thread("test-launch") {

        public void run() {
            try {
                exitCode.set(session.launch());
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                latch.countDown();
            }
        }
    };
    t.start();
    Thread.sleep(500);
    for (Bundle b : context.getBundles()) {
        System.out.println(b.getLocation());
    }
    assertEquals(4, context.getBundles().length);
    String p1 = t1.getAbsolutePath();
    System.out.println(p1);
    assertNotNull(context.getBundle(p1));
    assertNotNull(context.getBundle(t2.getAbsolutePath()));
    pl.cancel();
    latch.await();
    assertEquals(-3, exitCode.get());
    bndrun.close();
}
Also used : Project(aQute.bnd.build.Project) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(org.osgi.framework.Bundle) RemoteProjectLauncherPlugin(aQute.remote.plugin.RemoteProjectLauncherPlugin) Run(aQute.bnd.build.Run) CountDownLatch(java.util.concurrent.CountDownLatch) RunSession(aQute.bnd.build.RunSession)

Example 3 with RemoteProjectLauncherPlugin

use of aQute.remote.plugin.RemoteProjectLauncherPlugin in project bnd by bndtools.

the class LauncherTest method testAgentAndMain.

/*
	 * Launches against the agent& main
	 */
public void testAgentAndMain() 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", "agent,main;agent=1090");
    final RemoteProjectLauncherPlugin pl = (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();
    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(2, sessions.size());
    RunSession agent = sessions.get(0);
    RunSession main = sessions.get(1);
    CountDownLatch agentLatch = launch(agent);
    CountDownLatch mainLatch = launch(main);
    agent.waitTillStarted(1000);
    main.waitTillStarted(1000);
    Thread.sleep(500);
    agent.cancel();
    main.cancel();
    agentLatch.await();
    mainLatch.await();
    assertEquals(-3, agent.getExitCode());
    assertEquals(-3, main.getExitCode());
    bndrun.close();
}
Also used : Project(aQute.bnd.build.Project) RemoteProjectLauncherPlugin(aQute.remote.plugin.RemoteProjectLauncherPlugin) Run(aQute.bnd.build.Run) RunSession(aQute.bnd.build.RunSession) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Project (aQute.bnd.build.Project)3 Run (aQute.bnd.build.Run)3 RemoteProjectLauncherPlugin (aQute.remote.plugin.RemoteProjectLauncherPlugin)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 RunSession (aQute.bnd.build.RunSession)2 RunSessionImpl (aQute.remote.plugin.RunSessionImpl)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Bundle (org.osgi.framework.Bundle)1