Search in sources :

Example 21 with Application

use of org.codice.ddf.admin.application.service.Application in project ddf by codice.

the class ApplicationNodeImplTest method testEqualsObjParam.

/**
     * Tests the {@link ApplicationNodeImpl#equals(Object)} method for the case where the
     * parameter is null, the parameter is the same object, the parameter is not an
     * ApplicationNodeImpl object, and where the parameter is a different ApplicationNodeImpl
     * which has the same application
     */
@Test
public void testEqualsObjParam() {
    Application testApp = mock(Application.class);
    ApplicationNode testNode = new ApplicationNodeImpl(testApp);
    ApplicationNode testNode2 = new ApplicationNodeImpl(testApp);
    //        Case 1:
    assertFalse(testNode.equals(null));
    //        Case 2:
    assertTrue(testNode.equals(testNode));
    //        Case 3:
    assertFalse(testNode.equals(testApp));
    //        Case 4:
    assertTrue(testNode.equals(testNode2));
}
Also used : ApplicationNode(org.codice.ddf.admin.application.service.ApplicationNode) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 22 with Application

use of org.codice.ddf.admin.application.service.Application 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 23 with Application

use of org.codice.ddf.admin.application.service.Application 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 24 with Application

use of org.codice.ddf.admin.application.service.Application 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 25 with Application

use of org.codice.ddf.admin.application.service.Application 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)

Aggregations

Application (org.codice.ddf.admin.application.service.Application)55 Test (org.junit.Test)43 HashSet (java.util.HashSet)28 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)26 Repository (org.apache.karaf.features.Repository)21 FeaturesService (org.apache.karaf.features.FeaturesService)19 Feature (org.apache.karaf.features.Feature)14 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)13 ApplicationStatus (org.codice.ddf.admin.application.service.ApplicationStatus)13 ApplicationNode (org.codice.ddf.admin.application.service.ApplicationNode)11 ArrayList (java.util.ArrayList)9 RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)7 HashMap (java.util.HashMap)5 Logger (org.slf4j.Logger)5 Appender (ch.qos.logback.core.Appender)4 URI (java.net.URI)4 TreeSet (java.util.TreeSet)4 ArgumentMatcher (org.mockito.ArgumentMatcher)4 Mockito.anyString (org.mockito.Mockito.anyString)4 SecurityServiceException (ddf.security.service.SecurityServiceException)3