Search in sources :

Example 11 with RepositoryImpl

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

the class ApplicationImplTest method testAppEquality.

/**
     * Tests that applications can be compared to each other for equality.
     *
     * @throws Exception
     */
@Test
public void testAppEquality() throws Exception {
    RepositoryImpl repo1 = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_MAIN_FEATURE).toURI());
    repo1.load();
    Application testApp1 = new ApplicationImpl(repo1);
    Application testApp1Duplicate = new ApplicationImpl(repo1);
    Application testAppNull = null;
    RepositoryImpl repo2 = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_NO_MAIN_FEATURES).toURI());
    repo2.load();
    Application testApp2 = new ApplicationImpl(repo2);
    assertTrue(testApp1.equals(testApp1));
    assertTrue(testApp2.equals(testApp2));
    assertTrue(testApp1.equals(testApp1Duplicate));
    assertFalse(testApp1.equals(testApp2));
    assertFalse(testApp2.equals(testApp1));
    assertFalse(testApp1.equals(testAppNull));
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 12 with RepositoryImpl

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

the class ApplicationImplTest method testAppGetters.

/**
     * Verify that the application is properly exposing the underlying
     * repository.
     *
     * @throws Exception
     */
@Test
public void testAppGetters() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_NO_MAIN_FEATURES).toURI());
    repo.load();
    Application testApp = new ApplicationImpl(repo);
    assertEquals(TEST_APP, testApp.getName());
    Set<Feature> appFeatures = testApp.getFeatures();
    assertNotNull(appFeatures);
    assertEquals(repo.getFeatures().length, appFeatures.size());
    assertTrue(appFeatures.containsAll(Arrays.asList(repo.getFeatures())));
    assertNull(testApp.getMainFeature());
    assertEquals(NUM_BUNDLES, testApp.getBundles().size());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Application(org.codice.ddf.admin.application.service.Application) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 13 with RepositoryImpl

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

the class ApplicationImplTest method testGetDescription.

/**
     * Tests the {@link ApplicationImpl#getDescription()} method
     *
     * @throws Exception
     */
@Test
public void testGetDescription() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_MAIN_FEATURE).toURI());
    repo.load();
    Application testApp = new ApplicationImpl(repo);
    assertEquals(MAIN_FEATURE_NAME, testApp.getDescription());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 14 with RepositoryImpl

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

the class ApplicationImplTest method testMainFeature.

/**
     * Tests that if an application HAS a main feature that the properties in it
     * are properly parsed and set.
     *
     * @throws Exception
     */
@Test
public void testMainFeature() throws Exception {
    String mainFeatureName = "main-feature";
    String mainFeatureVersion = "1.0.1";
    String mainFeatureDescription = "Main Feature Test";
    String appToString = mainFeatureName + " - " + mainFeatureVersion;
    RepositoryImpl repo = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_MAIN_FEATURE).toURI());
    repo.load();
    Application testApp = new ApplicationImpl(repo);
    assertEquals(mainFeatureName, testApp.getName());
    assertEquals(mainFeatureVersion, testApp.getVersion());
    assertEquals(mainFeatureDescription, testApp.getDescription());
    assertNotNull(testApp.toString());
    assertEquals(appToString, testApp.toString());
    assertNotNull(testApp.getMainFeature());
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 15 with RepositoryImpl

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

the class SubsystemTest method test1.

@Test
public void test1() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data1/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root", "f1");
    addToMapSet(features, "root/apps1", "f2");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root", "a/1.0.0");
    addToMapSet(expected, "root", "c/1.0.0");
    addToMapSet(expected, "root/apps1", "b/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data1"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
    resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
    verify(resolver, expected);
}
Also used : Set(java.util.Set) MapUtils.addToMapSet(org.apache.karaf.features.internal.util.MapUtils.addToMapSet) HashMap(java.util.HashMap) TestDownloadManager(org.apache.karaf.features.internal.support.TestDownloadManager) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Test(org.junit.Test)

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