From 08d0c29827b3facbbf914bb9e6a5fb445075f454 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Mon, 18 Mar 2024 15:39:27 +0100 Subject: [PATCH] Fix for GAL-358, Introduce package and config stability --- .../java/org/jboss/galleon/Constants.java | 2 + .../org/jboss/galleon/ProvisioningOption.java | 16 +++- .../galleon/creator/FeaturePackBuilder.java | 9 ++- .../galleon/layout/ProvisioningLayout.java | 3 +- .../galleon/runtime/FeaturePackRuntime.java | 2 +- .../galleon/runtime/ProvisioningRuntime.java | 8 +- .../runtime/ProvisioningRuntimeBuilder.java | 80 ++++++++++++++----- .../jboss/galleon/spec/FeaturePackSpec.java | 47 ++++++++--- .../galleon/xml/FeaturePackXmlParser30.java | 23 ++++-- .../galleon/xml/FeaturePackXmlWriter.java | 7 +- .../AbstractFeatureStabilityTestCase.java | 4 +- ...nfigStabilityCommunityPackageTestCase.java | 67 ++++++++++++++++ ...efaultStabilityExcludePackageTestCase.java | 3 +- .../FeatureDefaultStabilityTestCase.java | 4 +- ...FeatureInvalidConfigStabilityTestCase.java | 54 +++++++++++++ ...eatureInvalidPackageStabilityTestCase.java | 54 +++++++++++++ .../FeaturePreviewStabilityTestCase.java | 3 +- .../AbstractFpStatibilityTestCase.java | 4 +- ...turePackSetCommunityStabilityTestCase.java | 2 +- ...eaturePackSetPreviewStabilityTestCase.java | 2 +- 20 files changed, 336 insertions(+), 58 deletions(-) create mode 100644 core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultConfigStabilityCommunityPackageTestCase.java create mode 100644 core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidConfigStabilityTestCase.java create mode 100644 core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidPackageStabilityTestCase.java diff --git a/common-api/src/main/java/org/jboss/galleon/Constants.java b/common-api/src/main/java/org/jboss/galleon/Constants.java index 82131d04..a4a5fa11 100644 --- a/common-api/src/main/java/org/jboss/galleon/Constants.java +++ b/common-api/src/main/java/org/jboss/galleon/Constants.java @@ -83,6 +83,8 @@ public interface Constants { String PASSIVE_PLUS = "passive+"; String STABILITY_LEVEL = "stability-level"; + String CONFIG_STABILITY_LEVEL = "config-stability-level"; + String PACKAGE_STABILITY_LEVEL = "package-stability-level"; String STABILITY_EXPERIMENTAL = "experimental"; String STABILITY_PREVIEW = "preview"; String STABILITY_COMMUNITY = "community"; diff --git a/core/src/main/java/org/jboss/galleon/ProvisioningOption.java b/core/src/main/java/org/jboss/galleon/ProvisioningOption.java index 37903911..cd647bfb 100644 --- a/core/src/main/java/org/jboss/galleon/ProvisioningOption.java +++ b/core/src/main/java/org/jboss/galleon/ProvisioningOption.java @@ -72,9 +72,23 @@ public class ProvisioningOption { .addToValueSet(Constants.STABILITY_DEFAULT) .build(); + public static final ProvisioningOption CONFIG_STABILITY_LEVEL = ProvisioningOption.builder(Constants.CONFIG_STABILITY_LEVEL) + .addToValueSet(Constants.STABILITY_EXPERIMENTAL) + .addToValueSet(Constants.STABILITY_PREVIEW) + .addToValueSet(Constants.STABILITY_COMMUNITY) + .addToValueSet(Constants.STABILITY_DEFAULT) + .build(); + + public static final ProvisioningOption PACKAGE_STABILITY_LEVEL = ProvisioningOption.builder(Constants.PACKAGE_STABILITY_LEVEL) + .addToValueSet(Constants.STABILITY_EXPERIMENTAL) + .addToValueSet(Constants.STABILITY_PREVIEW) + .addToValueSet(Constants.STABILITY_COMMUNITY) + .addToValueSet(Constants.STABILITY_DEFAULT) + .build(); + private static final List stdOptions = Arrays .asList(new ProvisioningOption[] { IGNORE_NOT_EXCLUDED_LAYERS, OPTIONAL_PACKAGES, VERSION_CONVERGENCE, PRINT_ONLY_CONFLICTS, - STORE_INPUT_PROVISIONING_CONFIG, EXPORT_SYSTEM_PATHS, STABILITY_LEVEL}); + STORE_INPUT_PROVISIONING_CONFIG, EXPORT_SYSTEM_PATHS, CONFIG_STABILITY_LEVEL, PACKAGE_STABILITY_LEVEL, STABILITY_LEVEL}); public static List getStandardList() { return stdOptions; diff --git a/core/src/main/java/org/jboss/galleon/creator/FeaturePackBuilder.java b/core/src/main/java/org/jboss/galleon/creator/FeaturePackBuilder.java index 1d5f08c5..8bacf953 100644 --- a/core/src/main/java/org/jboss/galleon/creator/FeaturePackBuilder.java +++ b/core/src/main/java/org/jboss/galleon/creator/FeaturePackBuilder.java @@ -419,8 +419,13 @@ private static void ensureDir(Path dir) throws IOException { } } - public FeaturePackBuilder setMinStability(String stability) { - fpBuilder.setMinStability(stability); + public FeaturePackBuilder setConfigStability(String stability) { + fpBuilder.setConfigStability(stability); + return this; + } + + public FeaturePackBuilder setPackageStability(String stability) { + fpBuilder.setPackageStability(stability); return this; } } diff --git a/core/src/main/java/org/jboss/galleon/layout/ProvisioningLayout.java b/core/src/main/java/org/jboss/galleon/layout/ProvisioningLayout.java index c6ddf985..7ec12b23 100644 --- a/core/src/main/java/org/jboss/galleon/layout/ProvisioningLayout.java +++ b/core/src/main/java/org/jboss/galleon/layout/ProvisioningLayout.java @@ -1284,7 +1284,8 @@ private F resolveFeaturePack(FeaturePackLocation fpl, int type, boolean translat } if(rebuilder != null) { rebuilder.setGalleonMinVersion(fpSpec.getGalleonMinVersion()); - rebuilder.setMinStability(fpSpec.getMinStability()); + rebuilder.setConfigStability(fpSpec.getConfigStability()); + rebuilder.setPackageStability(fpSpec.getPackageStability()); final FeaturePackSpec spec = rebuilder.build(); fp = fpFactory.newFeaturePack(spec.getFPID().getLocation(), spec, fp.getDir(), fp.getType()); } diff --git a/core/src/main/java/org/jboss/galleon/runtime/FeaturePackRuntime.java b/core/src/main/java/org/jboss/galleon/runtime/FeaturePackRuntime.java index 40ce1a0f..36bf3b76 100644 --- a/core/src/main/java/org/jboss/galleon/runtime/FeaturePackRuntime.java +++ b/core/src/main/java/org/jboss/galleon/runtime/FeaturePackRuntime.java @@ -105,7 +105,7 @@ public class FeaturePackRuntime extends FeaturePackLayout implements FeaturePack } // Filter out the packages that are not at the right stability level final Map filteredPackages = new LinkedHashMap<>(tmpPackages.size()); - Stability minStability= rt.getMinStability(getSpec().getMinStability()); + Stability minStability= rt.getMinPackageStability(getSpec().getPackageStability()); for(Map.Entry entry : tmpPackages.entrySet()) { Stability stability = entry.getValue().getSpec().getStability() == null ? Stability.DEFAULT : entry.getValue().getSpec().getStability(); if (minStability.enables(stability)) { diff --git a/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntime.java b/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntime.java index 4ebe2a41..fa250672 100644 --- a/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntime.java +++ b/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntime.java @@ -91,13 +91,13 @@ public List getDiscoveredFeatures() { private final MessageWriter messageWriter; private Boolean emptyStagedDir; private final boolean recordState; - private Stability lowestStability; + private Stability lowestConfigStability; private List configs = Collections.emptyList(); ProvisioningRuntime(final ProvisioningRuntimeBuilder builder, final MessageWriter messageWriter) throws ProvisioningException { this.startTime = builder.startTime; this.config = builder.config; - this.lowestStability = builder.lowestStability == null ? null : builder.lowestStability; + this.lowestConfigStability = builder.lowestConfigStability == null ? null : builder.lowestConfigStability; this.layout = builder.layout.transform(new FeaturePackLayoutTransformer() { @Override public FeaturePackRuntime transform(FeaturePackRuntimeBuilder other) throws ProvisioningException { @@ -131,8 +131,8 @@ public FeaturePackRuntime transform(FeaturePackRuntimeBuilder other) throws Prov this.messageWriter = messageWriter; } - public String getLowestStability() { - return lowestStability.toString(); + public String getLowestConfigStability() { + return lowestConfigStability.toString(); } @Override diff --git a/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntimeBuilder.java b/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntimeBuilder.java index 00bbb841..428ece85 100644 --- a/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntimeBuilder.java +++ b/core/src/main/java/org/jboss/galleon/runtime/ProvisioningRuntimeBuilder.java @@ -92,9 +92,10 @@ public static ProvisioningRuntimeBuilder newInstance(final MessageWriter message Path stagedDir; boolean recordState; FsDiff fsDiff; - Stability userStability; + Stability userConfigStability; + Stability userPackageStability; // Can be needed by Galleon plugins. - Stability lowestStability; + Stability lowestConfigStability; private final MessageWriter messageWriter; Map nameOnlyConfigs = Collections.emptyMap(); @@ -186,25 +187,46 @@ private ProvisioningRuntime doBuild() throws ProvisioningException { config = layout.getConfig(); fpConfigStack = new FpStack(config); String stabilityOption = layout.getOptionValue(ProvisioningOption.STABILITY_LEVEL); - if (stabilityOption == null) { + String configStabilityOption = layout.getOptionValue(ProvisioningOption.CONFIG_STABILITY_LEVEL); + String packageStabilityOption = layout.getOptionValue(ProvisioningOption.PACKAGE_STABILITY_LEVEL); + if(stabilityOption != null) { + if(configStabilityOption != null) { + throw new ProvisioningException(ProvisioningOption.STABILITY_LEVEL.getName() + " option can't be set when " + + ProvisioningOption.CONFIG_STABILITY_LEVEL.getName() + " is set."); + } + if (packageStabilityOption != null) { + throw new ProvisioningException(ProvisioningOption.STABILITY_LEVEL.getName() + " option can't be set when " + + ProvisioningOption.PACKAGE_STABILITY_LEVEL.getName() + " is set."); + } + configStabilityOption = stabilityOption; + packageStabilityOption = stabilityOption; + } + if (configStabilityOption == null) { Stability stability = Stability.DEFAULT; for (FeaturePackRuntimeBuilder fp : layout.getOrderedFeaturePacks()) { - Stability fpStability = fp.getSpec().getMinStability(); + Stability fpStability = fp.getSpec().getConfigStability(); if (stability == null || (fpStability.ordinal() > stability.ordinal())) { stability = fpStability; } } - lowestStability = stability; + lowestConfigStability = stability; if (messageWriter.isVerboseEnabled()) { - messageWriter.verbose("No stability level provided, minimum stability of each feature-pack will be used. " - + "The lowest stability is " + lowestStability); + messageWriter.verbose("No config stability level provided, config stability of each feature-pack will be used. " + + "The lowest stability is " + lowestConfigStability); } } else { - userStability = Stability.fromString(stabilityOption); - lowestStability = userStability; + userConfigStability = Stability.fromString(configStabilityOption); + lowestConfigStability = userConfigStability; if (messageWriter.isVerboseEnabled()) { - messageWriter.verbose("Stability level " + userStability + " has been provided. " - + "It constrains all feature-packs. The lowest stability is " + lowestStability); + messageWriter.verbose("Stability level " + userConfigStability + " has been provided. " + + "It constrains all feature-packs. The lowest config stability is " + lowestConfigStability); + } + } + if (packageStabilityOption != null) { + userPackageStability = Stability.fromString(packageStabilityOption); + if (messageWriter.isVerboseEnabled()) { + messageWriter.verbose("Stability level " + userPackageStability + " has been provided. " + + "It constrains all feature-packs. The lowest package stability is " + lowestConfigStability); } } @@ -260,21 +282,39 @@ private ProvisioningRuntime doBuild() throws ProvisioningException { } /** - * The min stability is constrained by the feature-pack stability that is the minimal for a + * The min config stability is constrained by the feature-pack stability that is the minimal for a * given feature-pack. The stability set by the user can only reduce the scope. */ - public Stability getMinStability(Stability featurePackStability) { + public Stability getMinConfigStability(Stability featurePackStability) { Stability minStability= featurePackStability; - if (getUserStability() != null) { - if (minStability.enables(getUserStability())) { - minStability = getUserStability(); + if (getUserConfigStability() != null) { + if (minStability.enables(getUserConfigStability())) { + minStability = getUserConfigStability(); } } return minStability; } - public Stability getUserStability() { - return userStability; + /** + * The min package stability is constrained by the feature-pack stability that is the minimal for a + * given feature-pack. The stability set by the user can only reduce the scope. + */ + public Stability getMinPackageStability(Stability featurePackStability) { + Stability minStability= featurePackStability; + if (getUserPackageStability() != null) { + if (minStability.enables(getUserPackageStability())) { + minStability = getUserPackageStability(); + } + } + return minStability; + } + + public Stability getUserConfigStability() { + return userConfigStability; + } + + public Stability getUserPackageStability() { + return userPackageStability; } private void mergeModelOnlyConfigs() throws ProvisioningException { @@ -925,10 +965,10 @@ private void processConfigItemContainer(ConfigItemContainer ciContainer) throws Stability fpStability = null; for (FeaturePackRuntimeBuilder fp : layout.getOrderedFeaturePacks()) { if (fp.producer.equals(spec.getId().getProducer())) { - fpStability = fp.getSpec().getMinStability(); + fpStability = fp.getSpec().getConfigStability(); } } - Stability minStability = getMinStability(fpStability); + Stability minStability = getMinConfigStability(fpStability); if (!minStability.enables(featureStability)) { if (messageWriter.isVerboseEnabled()) { messageWriter.verbose(configStack.id + ". Excluding feature '" + fconfig.getSpecId().getName() + "'. Its stability '" + featureStability + "' is lower than the expected '" + minStability +"' stability"); diff --git a/core/src/main/java/org/jboss/galleon/spec/FeaturePackSpec.java b/core/src/main/java/org/jboss/galleon/spec/FeaturePackSpec.java index 7033854a..ccf0fadc 100644 --- a/core/src/main/java/org/jboss/galleon/spec/FeaturePackSpec.java +++ b/core/src/main/java/org/jboss/galleon/spec/FeaturePackSpec.java @@ -44,7 +44,8 @@ public static class Builder extends FeaturePackDepsConfigBuilder { private Map plugins = Collections.emptyMap(); private Set systemPaths = Collections.emptySet(); private String galleonMinVersion; - private Stability minStability; + private Stability configStability; + private Stability packageStability; protected Builder() { } @@ -63,20 +64,36 @@ public String getGalleonMinVersion() { return galleonMinVersion; } - public Builder setMinStability(String minLevel) { - if (minLevel != null) { - this.minStability = Stability.fromString(minLevel); + public Builder setConfigStability(String configLevel) { + if (configLevel != null) { + this.configStability = Stability.fromString(configLevel); } return this; } - public Builder setMinStability(Stability minLevel) { - this.minStability = minLevel; + public Builder setConfigStability(Stability configLevel) { + this.configStability = configLevel; return this; } - public Stability getMinStability() { - return minStability; + public Stability getConfigStability() { + return configStability; + } + + public Builder setPackageStability(String packageLevel) { + if (packageLevel != null) { + this.packageStability = Stability.fromString(packageLevel); + } + return this; + } + + public Builder setPackageStability(Stability packageLevel) { + this.packageStability = packageLevel; + return this; + } + + public Stability getPackageStability() { + return packageStability; } public FPID getFPID() { @@ -152,7 +169,8 @@ public static Builder builder(FPID fpid) { private final FPID patchFor; private final Set systemPaths; private final String galleonMinVersion; - private final Stability minStability; + private final Stability configStability; + private final Stability packageStability; protected FeaturePackSpec(Builder builder) throws ProvisioningDescriptionException { super(builder); @@ -162,15 +180,20 @@ protected FeaturePackSpec(Builder builder) throws ProvisioningDescriptionExcepti this.patchFor = builder.patchFor; this.systemPaths = CollectionUtils.unmodifiable(builder.systemPaths); this.galleonMinVersion = builder.galleonMinVersion; - this.minStability = builder.minStability == null ? Stability.DEFAULT : builder.minStability; + this.configStability = builder.configStability == null ? Stability.DEFAULT : builder.configStability; + this.packageStability = builder.packageStability == null ? Stability.DEFAULT : builder.packageStability; } public String getGalleonMinVersion() { return galleonMinVersion; } - public Stability getMinStability() { - return minStability; + public Stability getConfigStability() { + return configStability; + } + + public Stability getPackageStability() { + return packageStability; } public FPID getFPID() { diff --git a/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlParser30.java b/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlParser30.java index 1c362bb3..5f389753 100644 --- a/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlParser30.java +++ b/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlParser30.java @@ -132,7 +132,8 @@ enum Attribute implements XmlNameProvider { INHERIT("inherit"), LOCATION("location"), GALLEON_MIN_VERSION("galleon-min-version"), - MIN_STABILITY_LEVEL("min-stability-level"), + CONFIG_STABILITY_LEVEL("config-stability-level"), + PACKAGE_STABILITY_LEVEL("package-stability-level"), MODEL("model"), NAMED_CONFIGS_ONLY("named-configs-only"), NAME("name"), @@ -152,7 +153,8 @@ enum Attribute implements XmlNameProvider { attributes.put(INHERIT.getLocalName(), INHERIT); attributes.put(LOCATION.getLocalName(), LOCATION); attributes.put(GALLEON_MIN_VERSION.getLocalName(), GALLEON_MIN_VERSION); - attributes.put(MIN_STABILITY_LEVEL.getLocalName(), MIN_STABILITY_LEVEL); + attributes.put(CONFIG_STABILITY_LEVEL.getLocalName(), CONFIG_STABILITY_LEVEL); + attributes.put(PACKAGE_STABILITY_LEVEL.getLocalName(), PACKAGE_STABILITY_LEVEL); attributes.put(MODEL.getLocalName(), MODEL); attributes.put(NAME.getLocalName(), NAME); attributes.put(PATH.getLocalName(), PATH); @@ -307,7 +309,8 @@ private String readSystemPathValue(XMLExtendedStreamReader reader) throws XMLStr private void readRootElement(XMLExtendedStreamReader reader, Builder builder) throws XMLStreamException { FeaturePackLocation location = null; String version = null; - String stability = null; + String configStability = null; + String packageStability = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart()); @@ -326,9 +329,16 @@ private void readRootElement(XMLExtendedStreamReader reader, Builder builder) th throw new XMLStreamException(ParsingUtils.error("Failed to parse feature-pack location", reader.getLocation()), e); } break; - case MIN_STABILITY_LEVEL: + case CONFIG_STABILITY_LEVEL: try { - stability = reader.getAttributeValue(i); + configStability = reader.getAttributeValue(i); + } catch (IllegalArgumentException e) { + throw new XMLStreamException(ParsingUtils.error("Failed to parse feature-pack location", reader.getLocation()), e); + } + break; + case PACKAGE_STABILITY_LEVEL: + try { + packageStability = reader.getAttributeValue(i); } catch (IllegalArgumentException e) { throw new XMLStreamException(ParsingUtils.error("Failed to parse feature-pack location", reader.getLocation()), e); } @@ -341,7 +351,8 @@ private void readRootElement(XMLExtendedStreamReader reader, Builder builder) th throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION)); } builder.setGalleonMinVersion(version); - builder.setMinStability(stability); + builder.setConfigStability(configStability); + builder.setPackageStability(packageStability); builder.setFPID(location.getFPID()); } diff --git a/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlWriter.java b/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlWriter.java index e3e5263d..cf23d307 100644 --- a/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlWriter.java +++ b/core/src/main/java/org/jboss/galleon/xml/FeaturePackXmlWriter.java @@ -45,8 +45,11 @@ protected ElementNode toElement(FeaturePackSpec fpSpec) { final ElementNode fp = addElement(null, Element.FEATURE_PACK); addAttribute(fp, Attribute.LOCATION, fpSpec.getFPID().toString()); addAttribute(fp, Attribute.GALLEON_MIN_VERSION, CoreVersion.getVersion()); - if (fpSpec.getMinStability() != null) { - addAttribute(fp, Attribute.MIN_STABILITY_LEVEL, fpSpec.getMinStability().toString()); + if (fpSpec.getConfigStability() != null) { + addAttribute(fp, Attribute.CONFIG_STABILITY_LEVEL, fpSpec.getConfigStability().toString()); + } + if (fpSpec.getPackageStability() != null) { + addAttribute(fp, Attribute.PACKAGE_STABILITY_LEVEL, fpSpec.getPackageStability().toString()); } ProvisioningXmlWriter.writeUniverseSpecs(fpSpec, fp); diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/AbstractFeatureStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/AbstractFeatureStabilityTestCase.java index fed04400..215e7b73 100644 --- a/core/src/test/java/org/jboss/galleon/config/feature/stability/AbstractFeatureStabilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/AbstractFeatureStabilityTestCase.java @@ -38,7 +38,7 @@ public abstract class AbstractFeatureStabilityTestCase extends PmProvisionConfig @Override protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException { creator - .newFeaturePack(FP1_GAV).setMinStability("experimental") + .newFeaturePack(FP1_GAV).setConfigStability("experimental").setPackageStability("experimental") .addFeatureSpec(FeatureSpec.builder("specNoStability") .addParam(FeatureParameterSpec.createId("id")) .build()) @@ -88,7 +88,7 @@ protected void createFeaturePacks(FeaturePackCreator creator) throws Provisionin .getFeaturePack() .newPackage("pExperimental", true).setStability("experimental") .getFeaturePack().getCreator() - .newFeaturePack(FP2_GAV).setMinStability("default") + .newFeaturePack(FP2_GAV).setConfigStability("default").setPackageStability("default") .addDependency(FP1_GAV.getLocation()) .addFeatureSpec(FeatureSpec.builder("specNoStability") .addParam(FeatureParameterSpec.createId("id")) diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultConfigStabilityCommunityPackageTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultConfigStabilityCommunityPackageTestCase.java new file mode 100644 index 00000000..08600281 --- /dev/null +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultConfigStabilityCommunityPackageTestCase.java @@ -0,0 +1,67 @@ +/* + * Copyright 2016-2024 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jboss.galleon.config.feature.stability; + +import org.jboss.galleon.Constants; +import org.jboss.galleon.ProvisioningDescriptionException; +import org.jboss.galleon.config.FeaturePackConfig; +import org.jboss.galleon.config.ProvisioningConfig; +import org.jboss.galleon.runtime.ResolvedFeatureId; +import org.jboss.galleon.runtime.ResolvedSpecId; +import org.jboss.galleon.state.ProvisionedFeaturePack; +import org.jboss.galleon.state.ProvisionedState; +import org.jboss.galleon.xml.ProvisionedConfigBuilder; +import org.jboss.galleon.xml.ProvisionedFeatureBuilder; + +/** + * + * @author jfdenise + */ +public class FeatureDefaultConfigStabilityCommunityPackageTestCase extends AbstractFeatureStabilityTestCase { + + @Override + protected ProvisioningConfig provisioningConfig() throws ProvisioningDescriptionException { + return ProvisioningConfig.builder(). + addFeaturePackDep(FeaturePackConfig.builder(FP1_GAV.getLocation()).setInheritPackages(true).build()). + addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()). + addOption(Constants.CONFIG_STABILITY_LEVEL, "default"). + addOption(Constants.PACKAGE_STABILITY_LEVEL, "community"). + build(); + } + + @Override + protected ProvisionedState provisionedState() throws ProvisioningDescriptionException { + return ProvisionedState.builder() + .addFeaturePack(ProvisionedFeaturePack.builder(FP1_GAV).addPackage("p").addPackage("pDefault").addPackage("pCommunity").build()) + .addConfig(ProvisionedConfigBuilder.builder() + .setName("configA") + .addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP1_GAV.getProducer(), "specNoStability"), "id", "1"))) + .addFeature(ProvisionedFeatureBuilder. + builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP1_GAV.getProducer(), "specDefault")). + setParam("id", "1").build()).setConfigParam("idDefault", "1").build()) + .build()) + .addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").build()) + .addConfig(ProvisionedConfigBuilder.builder() + .setName("configB") + .addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP2_GAV.getProducer(), "specNoStability"), "id", "1"))) + .addFeature(ProvisionedFeatureBuilder. + builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specDefault")). + setParam("id", "1").build()).setConfigParam("idDefault", "1").build()) + .build()) + .build(); + } +} diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityExcludePackageTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityExcludePackageTestCase.java index 71ca4d93..dfaaacc0 100644 --- a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityExcludePackageTestCase.java +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityExcludePackageTestCase.java @@ -41,7 +41,8 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription .excludePackage("pPreview") .excludePackage("pExperimental").build()) .addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()) - .addOption(Constants.STABILITY_LEVEL, "default").build(); + .addOption(Constants.CONFIG_STABILITY_LEVEL, "default") + .addOption(Constants.PACKAGE_STABILITY_LEVEL, "default").build(); } @Override diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityTestCase.java index 27cb05dd..4c1fc15e 100644 --- a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureDefaultStabilityTestCase.java @@ -38,7 +38,9 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription return ProvisioningConfig.builder(). addFeaturePackDep(FeaturePackConfig.builder(FP1_GAV.getLocation()).setInheritPackages(true).build()). addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()). - addOption(Constants.STABILITY_LEVEL, "default").build(); + addOption(Constants.CONFIG_STABILITY_LEVEL, "default"). + addOption(Constants.PACKAGE_STABILITY_LEVEL, "default"). + build(); } @Override diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidConfigStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidConfigStabilityTestCase.java new file mode 100644 index 00000000..e93a5cb6 --- /dev/null +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidConfigStabilityTestCase.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016-2024 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jboss.galleon.config.feature.stability; + +import org.jboss.galleon.Constants; +import org.jboss.galleon.ProvisioningDescriptionException; +import org.jboss.galleon.ProvisioningException; +import org.jboss.galleon.ProvisioningOption; +import org.jboss.galleon.config.FeaturePackConfig; +import org.jboss.galleon.config.ProvisioningConfig; +import org.jboss.galleon.state.ProvisionedState; + +/** + * + * @author jfdenise + */ +public class FeatureInvalidConfigStabilityTestCase extends AbstractFeatureStabilityTestCase { + + @Override + protected ProvisioningConfig provisioningConfig() throws ProvisioningDescriptionException { + return ProvisioningConfig.builder(). + addFeaturePackDep(FeaturePackConfig.builder(FP1_GAV.getLocation()).setInheritPackages(true).build()). + addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()). + addOption(Constants.CONFIG_STABILITY_LEVEL, "default"). + addOption(Constants.STABILITY_LEVEL, "community"). + build(); + } + + @Override + protected String[] pmErrors() throws ProvisioningException { + String[] array = {ProvisioningOption.STABILITY_LEVEL.getName() + " option can't be set when " + + ProvisioningOption.CONFIG_STABILITY_LEVEL.getName() + " is set."}; + return array; + } + + @Override + protected ProvisionedState provisionedState() throws ProvisioningDescriptionException { + throw new ProvisioningDescriptionException("Shouldn't be called."); + } +} diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidPackageStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidPackageStabilityTestCase.java new file mode 100644 index 00000000..1e683d89 --- /dev/null +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeatureInvalidPackageStabilityTestCase.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016-2024 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jboss.galleon.config.feature.stability; + +import org.jboss.galleon.Constants; +import org.jboss.galleon.ProvisioningDescriptionException; +import org.jboss.galleon.ProvisioningException; +import org.jboss.galleon.ProvisioningOption; +import org.jboss.galleon.config.FeaturePackConfig; +import org.jboss.galleon.config.ProvisioningConfig; +import org.jboss.galleon.state.ProvisionedState; + +/** + * + * @author jfdenise + */ +public class FeatureInvalidPackageStabilityTestCase extends AbstractFeatureStabilityTestCase { + + @Override + protected ProvisioningConfig provisioningConfig() throws ProvisioningDescriptionException { + return ProvisioningConfig.builder(). + addFeaturePackDep(FeaturePackConfig.builder(FP1_GAV.getLocation()).setInheritPackages(true).build()). + addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()). + addOption(Constants.PACKAGE_STABILITY_LEVEL, "default"). + addOption(Constants.STABILITY_LEVEL, "community"). + build(); + } + + @Override + protected String[] pmErrors() throws ProvisioningException { + String[] array = {ProvisioningOption.STABILITY_LEVEL.getName() + " option can't be set when " + + ProvisioningOption.PACKAGE_STABILITY_LEVEL.getName() + " is set."}; + return array; + } + + @Override + protected ProvisionedState provisionedState() throws ProvisioningDescriptionException { + throw new ProvisioningDescriptionException("Shouldn't be called."); + } +} diff --git a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeaturePreviewStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeaturePreviewStabilityTestCase.java index 2aeb1f91..3b5b677e 100644 --- a/core/src/test/java/org/jboss/galleon/config/feature/stability/FeaturePreviewStabilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/config/feature/stability/FeaturePreviewStabilityTestCase.java @@ -38,7 +38,8 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription return ProvisioningConfig.builder(). addFeaturePackDep(FeaturePackConfig.forLocation(FP1_GAV.getLocation())). addFeaturePackDep(FeaturePackConfig.builder(FP2_GAV.getLocation()).setInheritPackages(true).build()). - addOption(Constants.STABILITY_LEVEL, "preview").build(); + addOption(Constants.CONFIG_STABILITY_LEVEL, "preview"). + addOption(Constants.PACKAGE_STABILITY_LEVEL, "preview").build(); } @Override diff --git a/core/src/test/java/org/jboss/galleon/featurepack/stability/AbstractFpStatibilityTestCase.java b/core/src/test/java/org/jboss/galleon/featurepack/stability/AbstractFpStatibilityTestCase.java index 56e79403..a8690892 100644 --- a/core/src/test/java/org/jboss/galleon/featurepack/stability/AbstractFpStatibilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/featurepack/stability/AbstractFpStatibilityTestCase.java @@ -34,14 +34,14 @@ public abstract class AbstractFpStatibilityTestCase extends PmProvisionConfigTes @Override protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException { creator - .newFeaturePack(FP1_100_GAV).setMinStability("default") + .newFeaturePack(FP1_100_GAV).setConfigStability("default").setPackageStability("default") .newPackage("fp1_1default", true).setStability("default") .getFeaturePack() .newPackage("fp1_2noStability", true) .getFeaturePack() .newPackage("fp1_3experimental", true).setStability("experimental") .getFeaturePack().getCreator() - .newFeaturePack(FP2_100_GAV).setMinStability("experimental") + .newFeaturePack(FP2_100_GAV).setConfigStability("experimental").setPackageStability("experimental") .addDependency(FP1_100_GAV.getLocation()) .newPackage("fp2_1default", true).setStability("default") .getFeaturePack() diff --git a/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetCommunityStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetCommunityStabilityTestCase.java index eaf3a553..fe737c5e 100644 --- a/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetCommunityStabilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetCommunityStabilityTestCase.java @@ -34,7 +34,7 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription return ProvisioningConfig.builder(). addFeaturePackDep(FeaturePackConfig.forLocation(FP1_100_GAV.getLocation())). addFeaturePackDep(FeaturePackConfig.forLocation(FP2_100_GAV.getLocation())). - addOption(Constants.STABILITY_LEVEL, "community").build(); + addOption(Constants.PACKAGE_STABILITY_LEVEL, "community").build(); } @Override diff --git a/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetPreviewStabilityTestCase.java b/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetPreviewStabilityTestCase.java index a85f5e91..a922e7be 100644 --- a/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetPreviewStabilityTestCase.java +++ b/core/src/test/java/org/jboss/galleon/featurepack/stability/FeaturePackSetPreviewStabilityTestCase.java @@ -34,7 +34,7 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription return ProvisioningConfig.builder(). addFeaturePackDep(FeaturePackConfig.forLocation(FP1_100_GAV.getLocation())). addFeaturePackDep(FeaturePackConfig.forLocation(FP2_100_GAV.getLocation())). - addOption(Constants.STABILITY_LEVEL, "preview").build(); + addOption(Constants.PACKAGE_STABILITY_LEVEL, "preview").build(); } @Override