use of org.apache.karaf.features.Repository in project karaf by apache.
the class RepositoryCacheTest method refCountForIncludedRepositories.
@Test
@Ignore("Ignoring to check if it's real problem")
public void refCountForIncludedRepositories() throws Exception {
RepositoryCacheImpl cache = new RepositoryCacheImpl(null);
Repository repo1 = cache.create(getClass().getResource("/org/apache/karaf/features/repo1.xml").toURI(), false);
Repository repo2 = cache.create(getClass().getResource("/org/apache/karaf/features/repo2.xml").toURI(), false);
cache.addRepository(repo1);
cache.addRepository(repo2);
cache.addRepository(new RepositoryImpl(URI.create("urn:r1"), false));
assertNotNull(cache.getRepository("urn:r1"));
cache.removeRepository(repo2.getURI());
assertNotNull("Repository referenced from two different repositories should not be cascade-removed", cache.getRepository("urn:r1"));
}
use of org.apache.karaf.features.Repository in project fabric8 by jboss-fuse.
the class FeatureUtils method search.
public static Feature search(String name, String version, Collection<Repository> repositories) {
VersionRange range = new VersionRange(version, false, true);
Feature bestFeature = null;
Version bestVersion = null;
for (Repository repo : repositories) {
Feature[] features;
try {
features = repo.getFeatures();
} catch (Exception e) {
// This should not happen as the repository has been loaded already
throw new IllegalStateException(e);
}
for (Feature feature : features) {
if (name.equals(feature.getName())) {
Version v = new Version(VersionCleaner.clean(feature.getVersion()));
if (range.contains(v)) {
if (bestVersion == null || bestVersion.compareTo(v) < 0) {
bestFeature = feature;
bestVersion = v;
}
}
}
}
}
return bestFeature;
}
use of org.apache.karaf.features.Repository in project ddf by codice.
the class ApplicationServiceImplTest method testGetAllFeaturesFTRException.
/**
* Tests the {@link ApplicationServiceImpl#getAllFeatures()} method for the case where an
* exception is thrown in getFeatureToRepository(..)
*/
@Test
public void testGetAllFeaturesFTRException() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl(featuresService);
doThrow(new NullPointerException()).when(featuresService).listRepositories();
List<FeatureDetails> details = appService.getAllFeatures();
assertThat("List of feature details should have 7 entries", details, hasSize(4));
details.forEach(d -> assertThat(d.getName() + " should not have a mapped repository", d.getRepository(), is(nullValue())));
}
use of org.apache.karaf.features.Repository in project ddf by codice.
the class ApplicationServiceImplTest method testGetInstallProfilesException.
/**
* Tests the {@link ApplicationServiceImpl#getInstallationProfiles()} method for the case where
* featuresService.listFeatures() throws an exception
*/
@Test
public void testGetInstallProfilesException() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = new ApplicationServiceImpl(featuresService, new Security()) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
};
doThrow(new NullPointerException()).when(featuresService).listFeatures();
assertThat("No installation profiles should of been found, expected an empty collection", appService.getInstallationProfiles(), is(empty()));
}
use of org.apache.karaf.features.Repository in project karaf by apache.
the class RepositoryCache method tranGetRepositories.
public Set<Repository> tranGetRepositories(Repository repo) throws Exception {
HashSet<Repository> repos = new HashSet<>();
repos.add(repo);
Set<Repository> deps = getRepositories(repo);
for (Repository depRepo : deps) {
if (!repos.contains(depRepo)) {
repos.addAll(tranGetRepositories(depRepo));
}
}
return repos;
}
Aggregations