Search in sources :

Example 6 with RepositoryAdmin

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

the class OBRResolverAdvancedTest method testMutlipleServices.

@Test
public void testMutlipleServices() throws Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(false, HELLO_WORLD_SERVICE_BUNDLE1 + ".jar", HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
    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());
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("hello.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    // Wait 5 seconds just to give the blueprint-managed beans a chance to come up
    try {
        Thread.sleep(5000);
    } catch (InterruptedException ix) {
    }
    HelloWorld hw = context().getService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals(result, "hello world");
    // Uncomment the block below after https://issues.apache.org/jira/browse/FELIX-2546,
    // "Only one service is provisioned even when specifying for mulitple services"
    // is fixed. This tracks the problem of provisioning only one service even when we
    // specify multiple services.
    /**
     * HelloWorldManager hwm = context().getService(HelloWorldManager.class);
     * int numberOfServices = hwm.getNumOfHelloServices();
     * assertEquals(2, numberOfServices);
     */
    ctx.stop();
    manager.uninstall(ctx);
}
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) HelloWorld(org.apache.aries.sample.HelloWorld) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with RepositoryAdmin

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

the class OBRResolverTest method testProvisionExcludeLocalRepo.

/**
 * Test the resolution should fail because the required package org.apache.aries.util is provided by the local runtime,
 * which is not included when provisioning.
 *
 * @throws Exception
 */
@Test(expected = ResolverException.class)
public void testProvisionExcludeLocalRepo() throws Exception {
    // do not provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
    generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar");
    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());
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    // installing requires a valid url for the bundle in repository.xml.
    app = manager.resolve(app);
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 8 with RepositoryAdmin

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

the class OBRResolverTest method testBlogApp.

@Test
public void testBlogApp() throws Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar");
    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());
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    // installing requires a valid url for the bundle in repository.xml.
    app = manager.resolve(app);
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
    assertEquals(provision.toString(), 3, provision.size());
    List<String> bundleSymbolicNames = new ArrayList<String>();
    for (DeploymentContent dep : provision) {
        bundleSymbolicNames.add(dep.getContentName());
    }
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_REFERENCE));
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_VALUE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_VALUE));
    assertTrue("Bundle " + BUNDLE_IN_FRAMEWORK + " not found.", bundleSymbolicNames.contains(BUNDLE_IN_FRAMEWORK));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    Set<Bundle> bundles = ctx.getApplicationContent();
    assertEquals("Number of bundles provisioned in the app", 4, bundles.size());
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) Bundle(org.osgi.framework.Bundle) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) ArrayList(java.util.ArrayList) DeploymentContent(org.apache.aries.application.DeploymentContent) Repository(org.apache.felix.bundlerepository.Repository) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 9 with RepositoryAdmin

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

the class OBRResolverTest method testBlogAppResolveFail.

@Test(expected = ResolverException.class)
public void testBlogAppResolveFail() throws ResolverException, Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
    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());
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    // installing requires a valid url for the bundle in repository.xml.
    app = manager.resolve(app);
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 10 with RepositoryAdmin

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

the class OBRResolverTest method clearRepository.

@After
public void clearRepository() {
    RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
    Repository[] repos = repositoryAdmin.listRepositories();
    if ((repos != null) && (repos.length > 0)) {
        for (Repository repo : repos) {
            repositoryAdmin.removeRepository(repo.getURI());
        }
    }
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) After(org.junit.After)

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