use of org.apache.karaf.features.Feature in project ddf by codice.
the class ApplicationServiceImplTest method testStopApplicationNoMainFeatureStringParam.
/**
* Tests the {@link ApplicationServiceImpl#stopApplication(String)} method
* for the case where there is no main feature, but other features exist
*
* @throws Exception
*/
@Test
public void testStopApplicationNoMainFeatureStringParam() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1, noMainFeatureRepo2));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
Feature[] featureList = noMainFeatureRepo1.getFeatures();
appService.stopApplication(TEST_APP);
verify(featuresService).uninstallFeature(featureList[0].getName(), featureList[0].getVersion(), EnumSet.of(Option.NoAutoRefreshBundles));
verify(featuresService).uninstallFeature(featureList[1].getName(), featureList[1].getVersion(), EnumSet.of(Option.NoAutoRefreshBundles));
}
use of org.apache.karaf.features.Feature in project ddf by codice.
the class ApplicationServiceImplTest method testFindFeatureExceptions.
/**
* Tests the {@link ApplicationServiceImpl#findFeature(Feature)} method
* for the case where exceptions are thrown inside findFeature(Feature, Set<Application>)
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix and un-ignore
@Test
@Ignore
public void testFindFeatureExceptions() throws Exception {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
final Appender mockAppender = mock(Appender.class);
when(mockAppender.getName()).thenReturn("MOCK");
root.addAppender(mockAppender);
Application testApp = mock(ApplicationImpl.class);
final Set<Application> applicationSet = new HashSet<>();
applicationSet.add(testApp);
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = new ApplicationServiceImpl(bundleStateServices) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
@Override
public Set<Application> getApplications() {
return applicationSet;
}
@Override
public boolean isPermittedToViewFeature(String featureName) {
return true;
}
};
Feature testFeature = mock(Feature.class);
doThrow(new NullPointerException()).when(testApp).getFeatures();
appService.findFeature(testFeature);
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(FIND_FEAT_EX);
}
}));
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(FIND_FEAT_EX2);
}
}));
}
use of org.apache.karaf.features.Feature 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());
}
use of org.apache.karaf.features.Feature in project fabric8 by jboss-fuse.
the class FabricFeaturesServiceImpl method getFeature.
@Override
public Feature getFeature(String name) throws Exception {
assertValid();
Feature[] features = listFeatures();
for (Feature feature : features) {
if (name.equals(feature.getName())) {
return feature;
}
}
return null;
}
use of org.apache.karaf.features.Feature in project fabric8 by jboss-fuse.
the class FabricFeaturesServiceImpl method installFeatures.
@Override
public void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception {
StringBuffer sb = new StringBuffer();
for (Feature feature : features) {
sb.append("--feature ").append(feature.getName());
}
unsupportedInstallFeature(sb.toString());
}
Aggregations