use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.
the class SubsystemTest method testConditionalUnsatisfiedWithOptional.
@Test
public void testConditionalUnsatisfiedWithOptional() throws Exception {
RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data4/features.xml").toURI());
Map<String, Set<String>> features = new HashMap<>();
addToMapSet(features, "root/apps1", "f1");
Map<String, Set<String>> expected = new HashMap<>();
addToMapSet(expected, "root/apps1", "a/1.0.0");
SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data4"));
resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
verify(resolver, expected);
}
use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.
the class SubsystemTest method testResourceRepositories.
@Test
public void testResourceRepositories() throws Exception {
RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data7/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(), "data7"));
resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
verify(resolver, expected);
}
use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.
the class AppendTest method testLoad.
public void testLoad() throws Exception {
System.setProperty("karaf.data", "data");
System.setProperty("karaf.etc", "etc");
RepositoryImpl r = new RepositoryImpl(getClass().getResource("internal/service/f08.xml").toURI());
// Check repo
Feature[] features = r.getFeatures();
assertNotNull(features);
assertEquals(1, features.length);
Feature feature = features[0];
ConfigInfo configInfo = feature.getConfigurations().get(0);
assertNotNull(configInfo);
assertTrue(configInfo.isAppend());
Properties properties = configInfo.getProperties();
assertNotNull(properties);
String property = properties.getProperty("javax.servlet.context.tempdir");
assertNotNull(property);
assertFalse(property.contains("${"));
assertEquals(property, "data/pax-web-jsp");
ConfigurationAdmin admin = EasyMock.createMock(ConfigurationAdmin.class);
Configuration config = EasyMock.createMock(Configuration.class);
EasyMock.expect(admin.listConfigurations(EasyMock.eq("(service.pid=org.ops4j.pax.web)"))).andReturn(new Configuration[] { config });
Hashtable<String, Object> original = new Hashtable<>();
original.put("javax.servlet.context.tempdir", "data/pax-web-jsp");
EasyMock.expect(config.getProperties()).andReturn(original);
Hashtable<String, Object> expected = new Hashtable<>();
expected.put("org.ops4j.pax.web", "data/pax-web-jsp");
expected.put("org.apache.karaf.features.configKey", "org.ops4j.pax.web");
expected.put("foo", "bar");
EasyMock.expectLastCall();
EasyMock.replay(admin, config);
FeatureConfigInstaller installer = new FeatureConfigInstaller(admin);
installer.installFeatureConfigs(feature);
EasyMock.verify(admin, config);
EasyMock.reset(admin, config);
EasyMock.expect(admin.listConfigurations(EasyMock.eq("(service.pid=org.ops4j.pax.web)"))).andReturn(new Configuration[] { config });
original = new Hashtable<>();
original.put("org.apache.karaf.features.configKey", "org.ops4j.pax.web");
original.put("javax.servlet.context.tempdir", "value");
original.put("foo", "bar");
EasyMock.expect(config.getProperties()).andReturn(original);
EasyMock.replay(admin, config);
installer.installFeatureConfigs(feature);
EasyMock.verify(admin, config);
}
use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.
the class RepositoryTest method testLoadConfigAppend.
public void testLoadConfigAppend() throws Exception {
RepositoryImpl r = new RepositoryImpl(getClass().getResource("repo4.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"));
assertTrue(features[0].getConfigurations().get(0).isAppend());
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());
}
use of org.apache.karaf.features.internal.service.RepositoryImpl in project ddf by codice.
the class ApplicationImplTest method testNoMainFeature.
/**
* Verifies if an app does NOT have a main feature that operations can still
* be performed.
*
* @throws Exception
*/
@Test
public void testNoMainFeature() throws Exception {
String mainFeatureVersion = "1.0.0";
String mainFeatureDescription = null;
String appToString = TEST_APP + " - " + mainFeatureVersion;
RepositoryImpl repo = new RepositoryImpl(getClass().getClassLoader().getResource(FILE_NO_MAIN_FEATURES).toURI());
repo.load();
Application testApp = new ApplicationImpl(repo);
assertEquals(TEST_APP, testApp.getName());
assertEquals(mainFeatureVersion, testApp.getVersion());
assertEquals(mainFeatureDescription, testApp.getDescription());
assertNotNull(testApp.toString());
assertEquals(appToString, testApp.toString());
assertNull(testApp.getMainFeature());
}
Aggregations