Search in sources :

Example 16 with RepositoryAdmin

use of org.apache.felix.bundlerepository.RepositoryAdmin in project aries by apache.

the class MinimumImportsTest method testAppUsingAriesApplicationManager.

@Test
public void testAppUsingAriesApplicationManager() throws Exception {
    // Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
    AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
    ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
    RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
        repositoryAdmin.removeRepository(repo.getURI());
    }
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    int sleepfor = 3000;
    while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
        Thread.sleep(100);
        sleepfor -= 100;
    }
    assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
    assertTrue("Received Blueprint FAILURE event", acbl.success);
    ctx.stop();
    manager.uninstall(ctx);
    sr.unregister();
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 17 with RepositoryAdmin

use of org.apache.felix.bundlerepository.RepositoryAdmin in project aries by apache.

the class Aries1523Test method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    BundleContext context = context();
    ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
    assertNotNull("The RepositoryAdmin service does not exist", ref);
    try {
        repositoryAdmin = (RepositoryAdmin) context.getService(ref);
        DataModelHelper helper = repositoryAdmin.getHelper();
        url = createRepositoryXml(helper);
        Repository repository = repositoryAdmin.addRepository(url);
        Resource resource = repository.getResources()[0];
        System.out.println(resource.getURI());
    } finally {
        context.ungetService(ref);
    }
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) Resource(org.apache.felix.bundlerepository.Resource) DataModelHelper(org.apache.felix.bundlerepository.DataModelHelper) BundleContext(org.osgi.framework.BundleContext)

Example 18 with RepositoryAdmin

use of org.apache.felix.bundlerepository.RepositoryAdmin in project aries by apache.

the class Aries1608Test method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    BundleContext context = context();
    ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
    assertNotNull("The RepositoryAdmin service does not exist", ref);
    try {
        repositoryAdmin = (RepositoryAdmin) context.getService(ref);
        DataModelHelper helper = repositoryAdmin.getHelper();
        url = createRepositoryXml(helper);
        Repository repository = repositoryAdmin.addRepository(url);
        Resource resource = repository.getResources()[0];
        System.out.println(resource.getURI());
    } finally {
        context.ungetService(ref);
    }
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) Resource(org.apache.felix.bundlerepository.Resource) DataModelHelper(org.apache.felix.bundlerepository.DataModelHelper) BundleContext(org.osgi.framework.BundleContext)

Example 19 with RepositoryAdmin

use of org.apache.felix.bundlerepository.RepositoryAdmin in project aries by apache.

the class Aries1522Test method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    BundleContext context = context();
    ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
    assertNotNull("The RepositoryAdmin service does not exist", ref);
    try {
        repositoryAdmin = (RepositoryAdmin) context.getService(ref);
        DataModelHelper helper = repositoryAdmin.getHelper();
        url = createRepositoryXml(helper);
        Repository repository = repositoryAdmin.addRepository(url);
        Resource resource = repository.getResources()[0];
        System.out.println(resource.getURI());
    } finally {
        context.ungetService(ref);
    }
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) Resource(org.apache.felix.bundlerepository.Resource) DataModelHelper(org.apache.felix.bundlerepository.DataModelHelper) BundleContext(org.osgi.framework.BundleContext)

Aggregations

RepositoryAdmin (org.apache.felix.bundlerepository.RepositoryAdmin)19 Repository (org.apache.felix.bundlerepository.Repository)15 File (java.io.File)9 AriesApplication (org.apache.aries.application.management.AriesApplication)8 AriesApplicationManager (org.apache.aries.application.management.AriesApplicationManager)8 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)8 Test (org.junit.Test)8 Resource (org.apache.felix.bundlerepository.Resource)7 AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)5 DataModelHelper (org.apache.felix.bundlerepository.DataModelHelper)3 BundleContext (org.osgi.framework.BundleContext)3 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ServletException (javax.servlet.ServletException)2 DeploymentContent (org.apache.aries.application.DeploymentContent)2 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)2 HelloWorld (org.apache.aries.sample.HelloWorld)2 Capability (org.apache.felix.bundlerepository.Capability)2 Resolver (org.apache.felix.bundlerepository.Resolver)2