Search in sources :

Example 1 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class ConditionalTest method testLoad.

public void testLoad() throws Exception {
    RepositoryImpl r = new RepositoryImpl(getClass().getResource("internal/service/f06.xml").toURI());
    // Check repo
    Feature[] features = r.getFeatures();
    assertNotNull(features);
    assertEquals(1, features.length);
    Feature feature = features[0];
    assertNotNull(feature.getConditional());
    assertEquals(2, feature.getConditional().size());
    Conditional conditional = feature.getConditional().get(0);
    assertNotNull(conditional.getCondition());
    assertEquals(1, conditional.getCondition().size());
    String dependency = conditional.getCondition().get(0);
    assertNotNull(dependency);
    assertEquals("http", dependency);
    assertNotNull(conditional.getBundles());
    assertEquals(1, feature.getConditional().get(0).getBundles().size());
    conditional = feature.getConditional().get(1);
    assertNotNull(conditional.getCondition());
    assertEquals(1, conditional.getCondition().size());
    dependency = conditional.getCondition().get(0);
    assertNotNull(dependency);
    assertEquals("req:osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(!(version>=1.7)))\"", dependency);
    String wrapperName = "my6/1.5.3-beta-3".replaceAll("[^A-Za-z0-9 ]", "_");
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl)

Example 2 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class RepositoryTest method testLoadRepoWithCapabilitiesAndRequirement.

public void testLoadRepoWithCapabilitiesAndRequirement() throws Exception {
    RepositoryImpl r = new RepositoryImpl(getClass().getResource("repo3.xml").toURI());
    // Check features
    Feature[] features = r.getFeatures();
    assertNotNull(features);
    assertEquals(1, features.length);
    assertNotNull(features[0]);
    assertEquals("f1", features[0].getName());
    assertEquals(1, features[0].getCapabilities().size());
    assertEquals("cap", features[0].getCapabilities().get(0).getValue().trim());
    assertEquals(1, features[0].getRequirements().size());
    assertEquals("req", features[0].getRequirements().get(0).getValue().trim());
    Resource res = FeatureResource.build(features[0], null, null);
    assertEquals(1, res.getCapabilities("cap").size());
    assertEquals(1, res.getRequirements("req").size());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Resource(org.osgi.resource.Resource) FeatureResource(org.apache.karaf.features.internal.resolver.FeatureResource)

Example 3 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class RepositoryTest method testLoad.

public void testLoad() throws Exception {
    RepositoryImpl r = new RepositoryImpl(getClass().getResource("repo1.xml").toURI());
    // Check repo
    URI[] repos = r.getRepositories();
    assertNotNull(repos);
    assertEquals(1, repos.length);
    assertEquals(URI.create("urn:r1"), repos[0]);
    // Check features
    Feature[] features = r.getFeatures();
    assertNotNull(features);
    assertEquals(3, features.length);
    assertNotNull(features[0]);
    assertEquals("http://karaf.apache.org/xmlns/features/v1.1.0", features[0].getNamespace());
    assertEquals("f1", features[0].getName());
    assertNotNull(features[0].getConfigurations());
    assertEquals(1, features[0].getConfigurations().size());
    assertNotNull(features[0].getConfigurations().get(0).getName());
    assertEquals("c1", features[0].getConfigurations().get(0).getName());
    assertEquals(1, features[0].getConfigurations().get(0).getProperties().size());
    assertEquals("v", features[0].getConfigurations().get(0).getProperties().get("k"));
    assertNotNull(features[0].getDependencies());
    assertEquals(0, features[0].getDependencies().size());
    assertNotNull(features[0].getBundles());
    assertEquals(2, features[0].getBundles().size());
    assertEquals("b1", features[0].getBundles().get(0).getLocation());
    assertEquals("b2", features[0].getBundles().get(1).getLocation());
    assertNotNull(features[1]);
    assertEquals("f2", features[1].getName());
    assertNotNull(features[1].getConfigurations());
    assertEquals(0, features[1].getConfigurations().size());
    assertNotNull(features[1].getDependencies());
    assertEquals(1, features[1].getDependencies().size());
    assertEquals("f1" + org.apache.karaf.features.internal.model.Feature.VERSION_SEPARATOR + org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION, features[1].getDependencies().get(0).toString());
    assertNotNull(features[1].getBundles());
    assertEquals(1, features[1].getBundles().size());
    assertEquals("b3", features[1].getBundles().get(0).getLocation());
    assertEquals("f3", features[2].getName());
    assertNotNull(features[2].getConfigurationFiles());
    assertEquals(1, features[2].getConfigurationFiles().size());
    assertEquals("cf1", features[2].getConfigurationFiles().get(0).getFinalname());
    assertEquals(true, features[2].getConfigurationFiles().get(0).isOverride());
    assertEquals("cfloc", features[2].getConfigurationFiles().get(0).getLocation());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) URI(java.net.URI)

Example 4 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class RepositoryTest method testShowWrongUriInException.

public void testShowWrongUriInException() throws Exception {
    String uri = "src/test/resources/org/apache/karaf/shell/features/repo1.xml";
    RepositoryImpl r = new RepositoryImpl(new URI(uri));
    try {
        r.load();
    } catch (Exception e) {
        assertTrue(e.getMessage().contains(uri));
    }
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) URI(java.net.URI)

Example 5 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class RepositoryTest method testLoadFormattedRepo.

public void testLoadFormattedRepo() throws Exception {
    RepositoryImpl r = new RepositoryImpl(getClass().getResource("repo2.xml").toURI());
    // Check repo
    URI[] repos = r.getRepositories();
    assertNotNull(repos);
    assertEquals(1, repos.length);
    assertEquals(URI.create("urn:r1"), repos[0]);
    // Check features
    Feature[] features = r.getFeatures();
    assertNotNull(features);
    assertEquals(3, features.length);
    assertNotNull(features[0]);
    assertEquals("f1", features[0].getName());
    assertNotNull(features[0].getConfigurations());
    assertEquals(1, features[0].getConfigurations().size());
    assertNotNull(features[0].getConfigurations().get(0).getName());
    assertEquals("c1", features[0].getConfigurations().get(0).getName());
    assertEquals(1, features[0].getConfigurations().get(0).getProperties().size());
    assertEquals("v", features[0].getConfigurations().get(0).getProperties().get("k"));
    assertNotNull(features[0].getDependencies());
    assertEquals(0, features[0].getDependencies().size());
    assertNotNull(features[0].getBundles());
    assertEquals(2, features[0].getBundles().size());
    assertEquals("b1", features[0].getBundles().get(0).getLocation());
    assertEquals("b2", features[0].getBundles().get(1).getLocation());
    assertNotNull(features[1]);
    assertEquals("f2", features[1].getName());
    assertNotNull(features[1].getConfigurations());
    assertEquals(0, features[1].getConfigurations().size());
    assertNotNull(features[1].getDependencies());
    assertEquals(1, features[1].getDependencies().size());
    assertEquals("f1" + org.apache.karaf.features.internal.model.Feature.VERSION_SEPARATOR + org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION, features[1].getDependencies().get(0).toString());
    assertNotNull(features[1].getBundles());
    assertEquals(1, features[1].getBundles().size());
    assertEquals("b3", features[1].getBundles().get(0).getLocation());
    assertEquals("f3", features[2].getName());
    assertNotNull(features[2].getConfigurationFiles());
    assertEquals(1, features[2].getConfigurationFiles().size());
    assertEquals("cf1", features[2].getConfigurationFiles().get(0).getFinalname());
    assertEquals(true, features[2].getConfigurationFiles().get(0).isOverride());
    assertEquals("cfloc", features[2].getConfigurationFiles().get(0).getLocation());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) URI(java.net.URI)

Aggregations

RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)27 Test (org.junit.Test)18 HashMap (java.util.HashMap)12 Set (java.util.Set)12 TestDownloadManager (org.apache.karaf.features.internal.support.TestDownloadManager)12 MapUtils.addToMapSet (org.apache.karaf.features.internal.util.MapUtils.addToMapSet)12 Application (org.codice.ddf.admin.application.service.Application)7 URI (java.net.URI)5 Feature (org.apache.karaf.features.Feature)2 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Properties (java.util.Properties)1 Repository (org.apache.karaf.features.Repository)1 FeatureResource (org.apache.karaf.features.internal.resolver.FeatureResource)1 FeatureConfigInstaller (org.apache.karaf.features.internal.service.FeatureConfigInstaller)1 ApplicationNode (org.codice.ddf.admin.application.service.ApplicationNode)1 Resource (org.osgi.resource.Resource)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1