use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.
the class AdvancedLayersTestCase method testWithExcludeLayers.
@Test
public void testWithExcludeLayers() throws Exception {
FeaturePackLocation prod = newFpl(PRODUCER4, "1", "1.0.0.Final");
buildFPWithOptionalLayers(cli, universeSpec, PRODUCER4, "1.0.0.Final");
{
Path path = cli.newDir("prod-exclude1", false);
cli.execute("install " + prod + " --dir=" + path + " --layers=layerC-" + PRODUCER4);
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
assertEquals(1, state.getConfigs().size());
Collection<ConfigId> layers = state.getConfigs().get(0).getLayers();
// contains base, A, B and C.
assertEquals(layers.toString(), 4, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "base-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerA-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerB-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerC-" + PRODUCER4)));
}
{
Path path = cli.newDir("prod-exclude2", false);
cli.execute("install " + prod + " --dir=" + path + " --layers=layerC-" + PRODUCER4 + ",-layerB-" + PRODUCER4);
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
assertEquals(1, state.getConfigs().size());
Collection<ConfigId> layers = state.getConfigs().get(0).getLayers();
// contains C, A and B are excluded, base, a dependency of A, is transitively excluded.
assertEquals(layers.toString(), 1, layers.size());
assertFalse(layers.toString(), layers.contains(new ConfigId("testmodel", "base-" + PRODUCER4)));
assertFalse(layers.toString(), layers.contains(new ConfigId("testmodel", "layerA-" + PRODUCER4)));
assertFalse(layers.toString(), layers.contains(new ConfigId("testmodel", "layerB-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerC-" + PRODUCER4)));
// Include layerA
cli.execute("install " + prod + " --dir=" + path + " --layers=layerA-" + PRODUCER4);
state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
assertEquals(1, state.getConfigs().size());
layers = state.getConfigs().get(0).getLayers();
// contains C, A and base, a dependency of A.
assertEquals(layers.toString(), 3, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "base-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerA-" + PRODUCER4)));
assertFalse(layers.toString(), layers.contains(new ConfigId("testmodel", "layerB-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerC-" + PRODUCER4)));
// Un-exclude layerB.
cli.execute("install " + prod + " --dir=" + path + " --layers=+layerB-" + PRODUCER4);
state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
assertEquals(1, state.getConfigs().size());
layers = state.getConfigs().get(0).getLayers();
assertEquals(layers.toString(), 4, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "base-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerA-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerB-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerC-" + PRODUCER4)));
// Attempt to un-exclude a layer that is not excluded
try {
cli.execute("install " + prod + " --dir=" + path + " --layers=+layerA-" + PRODUCER4);
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
// Attempt to exclude layerC that is not a dependency
try {
cli.execute("install " + prod + " --dir=" + path + " --layers=-layerC-" + PRODUCER4);
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
// Exclude layerB
cli.execute("install " + prod + " --dir=" + path + " --layers=-layerB-" + PRODUCER4);
state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
assertEquals(1, state.getConfigs().size());
layers = state.getConfigs().get(0).getLayers();
assertEquals(layers.toString(), 3, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "base-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerA-" + PRODUCER4)));
assertFalse(layers.toString(), layers.contains(new ConfigId("testmodel", "layerB-" + PRODUCER4)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerC-" + PRODUCER4)));
}
{
// Attempt to exclude a required layer.
Path path = cli.newDir("prod-exclude3", false);
try {
cli.execute("install " + prod + " --dir=" + path + " --layers=layerC-" + PRODUCER4 + ",-base-" + PRODUCER4);
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
}
{
// Attempt to exclude a layer that is not a dependency.
Path path = cli.newDir("prod-exclude4", false);
try {
cli.execute("install " + prod + " --dir=" + path + " --layers=layerB-" + PRODUCER4 + ",-layerC-" + PRODUCER4);
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
}
{
// Install layerA and layerB, layerA is dependency of layerB
Path path = cli.newDir("prod-exclude5", false);
cli.execute("install " + prod + " --dir=" + path + " --layers=layerA-" + PRODUCER4 + ",layerB-" + PRODUCER4);
try {
// Attempt to exclude layerA, it is not allowed, the layer has been explictly included.
cli.execute("install " + prod + " --dir=" + path + " --layers=-layerA-" + PRODUCER4);
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
}
}
use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.
the class AdvancedLayersTestCase method testWithFPDependency.
@Test
public void testWithFPDependency() throws Exception {
FeaturePackLocation prod2 = newFpl(PRODUCER2, "1", "1.0.0.Final");
buildFPWithDependency(cli, universeSpec, PRODUCER2, "1.0.0.Final");
{
Path path = cli.newDir("prod3", false);
cli.execute("install " + prod2 + " --dir=" + path + " --layers=layerA-" + PRODUCER2 + " --optional-packages=passive+");
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Set<String> pkgs = state.getFeaturePack(prod2.getProducer()).getPackageNames();
assertTrue(pkgs.toString(), pkgs.contains("p1-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-optional"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional"));
assertFalse(pkgs.toString(), pkgs.contains("p1-passive"));
FeaturePackLocation dep = newFpl(PRODUCER3, "1", "1.0.0.Final");
Set<String> pkgs2 = state.getFeaturePack(dep.getProducer()).getPackageNames();
assertTrue(pkgs2.toString(), pkgs2.contains("p0-required1"));
assertTrue(pkgs2.toString(), pkgs2.contains("p0-required2"));
assertFalse(pkgs2.toString(), pkgs2.contains("p0-required3"));
}
{
Path path = cli.newDir("prod3", false);
cli.execute("install " + prod2 + " --dir=" + path + " --layers=layerA-" + PRODUCER2 + ",layer0-" + PRODUCER3 + " --optional-packages=passive+");
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Set<String> pkgs = state.getFeaturePack(prod2.getProducer()).getPackageNames();
assertTrue(pkgs.toString(), pkgs.contains("p1-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-optional"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional"));
assertTrue(pkgs.toString(), pkgs.contains("p1-passive"));
FeaturePackLocation dep = newFpl(PRODUCER3, "1", "1.0.0.Final");
Set<String> pkgs2 = state.getFeaturePack(dep.getProducer()).getPackageNames();
assertTrue(pkgs2.toString(), pkgs2.contains("p0-required1"));
assertTrue(pkgs2.toString(), pkgs2.contains("p0-required2"));
assertTrue(pkgs2.toString(), pkgs2.contains("p0-required3"));
}
}
use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.
the class PersistChangesTestBase method provisionedState.
@Override
protected ProvisionedState provisionedState() throws ProvisioningException {
final ProvisionedState.Builder builder = ProvisionedState.builder();
final FPID[] fpids = provisionedFpids();
if (fpids != null && fpids.length > 0) {
for (FPID fpid : fpids) {
builder.addFeaturePack(ProvisionedFeaturePack.forFPID(fpid));
}
final ProvisionedConfig[] configs = provisionedConfigModels();
if (configs != null && configs.length > 0) {
for (ProvisionedConfig config : configs) {
builder.addConfig(config);
}
}
}
return builder.build();
}
use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.
the class AdvancedLayersTestCase method testCircularDepExcludeLayers.
@Test
public void testCircularDepExcludeLayers() throws Exception {
FeaturePackLocation prod = newFpl(PRODUCER5, "1", "1.0.0.Final");
buildFP(cli, universeSpec, PRODUCER5, "1.0.0.Final");
{
// Install layerD circular dependency with layerE
Path path = cli.newDir("prod6", false);
cli.execute("install " + prod + " --dir=" + path + " --layers=layerD-" + PRODUCER5);
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Collection<ConfigId> layers = state.getConfigs().get(0).getLayers();
assertEquals(layers.toString(), 2, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerE-" + PRODUCER5)));
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerD-" + PRODUCER5)));
}
{
// Install layerE, exclude layerD
Path path = cli.newDir("prod-exclude6", false);
cli.execute("install " + prod + " --dir=" + path + " --layers=layerE-" + PRODUCER5 + ",-layerD-" + PRODUCER5);
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Collection<ConfigId> layers = state.getConfigs().get(0).getLayers();
assertEquals(layers.toString(), 1, layers.size());
assertTrue(layers.toString(), layers.contains(new ConfigId("testmodel", "layerE-" + PRODUCER5)));
}
}
use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.
the class AdvancedLayersTestCase method test.
@Test
public void test() throws Exception {
FeaturePackLocation prod1 = newFpl(PRODUCER1, "1", "1.0.0.Final");
buildFP(cli, universeSpec, PRODUCER1, "1.0.0.Final");
{
Path path = cli.newDir("prod1", false);
cli.execute("install " + prod1 + " --dir=" + path + " --layers=layerA-" + PRODUCER1 + " --optional-packages=passive+");
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Set<String> pkgs = state.getFeaturePack(prod1.getProducer()).getPackageNames();
assertTrue(pkgs.toString(), pkgs.contains("p1-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-optional"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional1"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional2"));
assertFalse(pkgs.toString(), pkgs.contains("p1-passive"));
assertTrue(pkgs.toString(), pkgs.contains("p2-passive"));
cli.execute("get-info --dir=" + path + " --type=optional-packages");
assertTrue(cli.getOutput(), cli.getOutput().contains("p1-optional"));
assertFalse(cli.getOutput().contains("p1-passive"));
assertTrue(cli.getOutput().contains("p2-passive"));
assertFalse(cli.getOutput().contains("p1-required"));
}
{
Path path = cli.newDir("prod2", false);
cli.execute("install " + prod1 + " --dir=" + path + " --layers=layerA-" + PRODUCER1 + ",layerB-" + PRODUCER1 + " --optional-packages=passive+");
ProvisionedState state = ProvisioningManager.builder().setInstallationHome(path).build().getProvisionedState();
Set<String> pkgs = state.getFeaturePack(prod1.getProducer()).getPackageNames();
assertTrue(pkgs.toString(), pkgs.contains("p1-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-required"));
assertTrue(pkgs.toString(), pkgs.contains("p1-optional"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional1"));
assertTrue(pkgs.toString(), pkgs.contains("p1-ref-from-optional2"));
assertTrue(pkgs.toString(), pkgs.contains("p1-passive"));
assertTrue(pkgs.toString(), pkgs.contains("p2-passive"));
assertTrue(pkgs.toString(), pkgs.contains("p2-required"));
assertTrue(pkgs.toString(), pkgs.contains("p2-optional"));
}
{
Path path = cli.newDir("prod3", false);
cli.execute("install " + prod1 + " --dir=" + path + " --layers=layerA-" + PRODUCER1 + " --optional-packages=none");
cli.execute("get-info --dir=" + path + " --type=optional-packages");
assertTrue(cli.getOutput().contains("No optional packages."));
assertFalse(cli.getOutput().contains("p1-passive"));
assertFalse(cli.getOutput().contains("p2-passive"));
assertFalse(cli.getOutput().contains("p1-optional"));
}
{
Path path = cli.newDir("prod4", false);
cli.execute("install " + prod1 + " --dir=" + path + " --layers=layerA-" + PRODUCER1 + " --optional-packages=passive");
cli.execute("get-info --dir=" + path + " --type=optional-packages");
assertFalse(cli.getOutput().contains("p1-passive"));
assertTrue(cli.getOutput().contains("p2-passive"));
assertFalse(cli.getOutput().contains("p1-optional"));
}
{
Path path = cli.newDir("prod4", false);
cli.execute("install " + prod1 + " --dir=" + path + " --layers=layerA-" + PRODUCER1 + " --optional-packages=all");
cli.execute("get-info --dir=" + path + " --type=optional-packages");
assertTrue(cli.getOutput().contains("p1-passive"));
assertTrue(cli.getOutput().contains("p2-passive"));
assertTrue(cli.getOutput().contains("p1-optional"));
assertFalse(cli.getOutput().contains("p2-optional"));
cli.execute("feature-pack get-info " + prod1 + " --type=optional-packages");
assertTrue(cli.getOutput().contains("p1-passive"));
assertTrue(cli.getOutput().contains("p2-passive"));
assertTrue(cli.getOutput().contains("p1-optional"));
assertTrue(cli.getOutput().contains("p2-optional"));
}
}
Aggregations