use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class IncludeDefaultTestCase method testMain.
@Test
public void testMain() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/packages-inherit.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1")).setInheritPackages(true).build()).addFeaturePackDep(FeaturePackConfig.forLocation(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2"))).addFeaturePackDep(FeaturePackConfig.forLocation(FeaturePackLocation.fromString("fp3@maven(universe):0#0.0.3"))).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp4@maven(universe):0#0.0.3"), false).build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class ProvisioningWithConfigTestCase method testMainAdvanced.
@Test
public void testMainAdvanced() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning-config2.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep("foo", FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final")).setInheritConfigs(false).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0-patch.Final").getFPID()).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.1-patch.Final").getFPID()).includeConfigModel("model1").excludeConfigModel("model2").excludeDefaultConfig("model1", "name1").includeDefaultConfig("model2", "name2").addConfig(ConfigModel.builder().setName("main").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2")).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.builder("dep4").setOrigin("source4").build()).addFeature(new FeatureConfig("spec1").setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v3").setParam("p2", "v4")).setInheritLayers(false).includeLayer("layer1").excludeLayer("layer2").includeLayer("layer3").excludeLayer("layer4").setProperty("prop1", "value1").setProperty("prop2", "value2").setConfigDep("id1", new ConfigId("model1", "name1")).setConfigDep("id2", new ConfigId("model2", null)).setConfigDep("id3", new ConfigId(null, "name3")).build()).build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class ProvisioningWithConfigTestCase method testMain.
@Test
public void testMain() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning-config.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final")).setInheritConfigs(false).includeConfigModel("model1").excludeConfigModel("model2").excludeDefaultConfig("model1", "name1").includeDefaultConfig("model2", "name2").addConfig(ConfigModel.builder().setName("main").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2")).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.builder("dep4").setOrigin("source4").build()).addFeature(new FeatureConfig("spec1").setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v3").setParam("p2", "v4")).build()).build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class ProvisioningXmlExcludesIncludesTestCase method readIncludeExcludePackages.
@Test
public void readIncludeExcludePackages() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/include-exclude-packages.xml");
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1")).setInheritPackages(false).includePackage("p1").build()).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2")).excludePackage("p2").includePackage("p3").build()).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp3@maven(universe):0#0.0.3")).setInheritPackages(true).excludePackage("p2").includePackage("p3").build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class ProvisioningDiffProvider method getMergedConfig.
public ProvisioningConfig getMergedConfig() throws ProvisioningException {
if (mergedConfig != null) {
return mergedConfig;
}
if (!hasConfigChanges()) {
mergedConfig = provisionedConfig;
return provisionedConfig;
}
final ProvisioningConfig.Builder configBuilder = initProvisioningConfig();
final Collection<ConfigModel> definedConfigs = provisionedConfig.getDefinedConfigs();
if (!definedConfigs.isEmpty()) {
for (ConfigModel originalConfig : definedConfigs) {
final ConfigModel updatedConfig = updatedConfigs.remove(originalConfig.getId());
if (updatedConfig != null) {
configBuilder.addConfig(updatedConfig);
continue;
}
if (removedConfigs.contains(originalConfig.getId())) {
continue;
}
configBuilder.addConfig(originalConfig);
}
}
if (!updatedConfigs.isEmpty()) {
for (ConfigModel updatedConfig : updatedConfigs.values()) {
configBuilder.addConfig(updatedConfig);
}
}
if (!addedConfigs.isEmpty()) {
for (ConfigModel addedConfig : addedConfigs.values()) {
configBuilder.addConfig(addedConfig);
}
}
if (!removedConfigs.isEmpty()) {
List<ProvisionedConfig> baseConfigs = null;
for (ConfigId configId : removedConfigs) {
if (provisionedConfig.hasDefinedConfig(configId)) {
if (baseConfigs == null) {
final ProvisioningConfig.Builder baseBuilder = initProvisioningConfig();
for (ProvisionedConfig config : provisionedState.getConfigs()) {
final ConfigId provisionedId = new ConfigId(config.getModel(), config.getName());
if (!provisionedConfig.hasDefinedConfig(provisionedId)) {
baseBuilder.excludeDefaultConfig(provisionedId);
}
}
try (ProvisioningRuntime baseRt = ProvisioningRuntimeBuilder.newInstance(log).initLayout(layout.getFactory(), baseBuilder.build()).build()) {
baseConfigs = baseRt.getConfigs();
}
}
if (getProvisionedConfig(baseConfigs, configId.getModel(), configId.getName()) != null) {
if (provisionedConfig.isInheritConfigs(true)) {
if (!provisionedConfig.isConfigModelExcluded(configId)) {
configBuilder.excludeDefaultConfig(configId);
}
} else if (provisionedConfig.isConfigModelIncluded(configId)) {
configBuilder.excludeDefaultConfig(configId);
}
}
} else if (provisionedConfig.isInheritConfigs(true)) {
if (!provisionedConfig.isConfigModelExcluded(configId)) {
configBuilder.excludeDefaultConfig(configId);
}
} else if (provisionedConfig.isConfigModelIncluded(configId)) {
configBuilder.excludeDefaultConfig(configId);
}
}
}
mergedConfig = configBuilder.build();
return mergedConfig;
}
Aggregations