Search in sources :

Example 1 with FrameworkDTO

use of org.osgi.framework.dto.FrameworkDTO in project bnd by bndtools.

the class MainTest method testRemoteMain.

public void testRemoteMain() throws Exception {
    //
    // Create a framework & start an agent
    //
    LauncherSupervisor supervisor = new LauncherSupervisor();
    supervisor.connect("localhost", Agent.DEFAULT_PORT + 1);
    assertEquals("not talking to an envoy", true, supervisor.getAgent().isEnvoy());
    HashMap<String, Object> configuration = new HashMap<String, Object>();
    configuration.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
    configuration.put(Constants.FRAMEWORK_STORAGE, "generated/storage");
    List<String> emptyList = Collections.emptyList();
    boolean created = supervisor.getAgent().createFramework("test", emptyList, configuration);
    assertTrue("there already was a framework, funny, since we created the main in setUp?", created);
    FrameworkDTO framework = supervisor.getAgent().getFramework();
    assertNotNull("just created it, so we should have a framework", framework);
    //
    // Create a second supervisor and ensure we do not
    // kill the primary
    //
    LauncherSupervisor sv2 = new LauncherSupervisor();
    sv2.connect("localhost", Agent.DEFAULT_PORT + 1);
    assertTrue("no second framework", supervisor.getAgent().ping());
    assertEquals("must be an envoy", true, sv2.getAgent().isEnvoy());
    assertFalse("the framework should already exist", sv2.getAgent().createFramework("test", emptyList, configuration));
    assertTrue("first framework is gone", supervisor.getAgent().ping());
    FrameworkDTO fw2 = sv2.getAgent().getFramework();
    assertEquals("we should not have created a new framework", framework.properties.get("org.osgi.framework.uuid"), fw2.properties.get("org.osgi.framework.uuid"));
    //
    // Kill the second framework
    //
    supervisor.getAgent().abort();
    Thread.sleep(500);
    assertFalse(supervisor.isOpen());
    assertTrue("should not have killed sv2", sv2.getAgent().ping());
    sv2.abort();
    Thread.sleep(500);
    assertFalse(sv2.isOpen());
}
Also used : FrameworkDTO(org.osgi.framework.dto.FrameworkDTO) HashMap(java.util.HashMap) LauncherSupervisor(aQute.remote.plugin.LauncherSupervisor)

Example 2 with FrameworkDTO

use of org.osgi.framework.dto.FrameworkDTO in project bnd by bndtools.

the class AgentServer method getFramework.

/**
	 * Get the framework's DTO
	 */
@Override
public FrameworkDTO getFramework() throws Exception {
    FrameworkDTO fw = new FrameworkDTO();
    fw.bundles = getBundles();
    fw.properties = getProperties();
    fw.services = getServiceReferences();
    return fw;
}
Also used : FrameworkDTO(org.osgi.framework.dto.FrameworkDTO)

Aggregations

FrameworkDTO (org.osgi.framework.dto.FrameworkDTO)2 LauncherSupervisor (aQute.remote.plugin.LauncherSupervisor)1 HashMap (java.util.HashMap)1