Search in sources :

Example 81 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class LayersTestCase method test.

@Test
public void test() throws Exception {
    FeaturePackLocation prod1 = newFpl(PRODUCER1, "1", "1.0.0.Final");
    FeaturePackLocation prod2 = newFpl(PRODUCER2, "1", "1.0.0.Final");
    CliTestUtils.installWithLayers(cli, universeSpec, PRODUCER1, "1.0.0.Final");
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Final");
    cli.execute("find * --layers=layerZ --universe=" + universeSpec);
    assertFalse(cli.getOutput(), cli.getOutput().contains(prod1.toString()));
    cli.execute("find * --layers=layerB --universe=" + universeSpec);
    assertTrue(cli.getOutput(), cli.getOutput().contains(prod1.toString()));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    cli.execute("feature-pack get-info " + prod1 + " --type=layers");
    assertTrue(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    cli.execute("feature-pack get-info " + prod1 + " --type=configs");
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    Path path = cli.newDir("prod1", false);
    try {
        cli.execute("install " + prod1 + " --dir=" + path + " --layers=foo");
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK, expected
    }
    cli.execute("install " + prod1 + " --dir=" + path + " --layers=" + "layerA-" + PRODUCER1 + ",layerC-" + PRODUCER1);
    ProvisioningConfig config = ProvisioningManager.builder().setInstallationHome(path).build().getProvisioningConfig();
    ConfigModel conf = config.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf);
    assertTrue(conf.getIncludedLayers().size() == 2);
    assertTrue(conf.getIncludedLayers().contains("layerA-" + PRODUCER1));
    assertTrue(conf.getIncludedLayers().contains("layerC-" + PRODUCER1));
    String opt = config.getOption(Constants.OPTIONAL_PACKAGES);
    assertNotNull(opt);
    assertEquals(Constants.PASSIVE_PLUS, opt);
    cli.execute("get-info --dir=" + path + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    // Multiple configurations are invalid with layers
    try {
        cli.execute("install " + prod1 + " --dir=" + path + " --config=testmodel/foobar.xml,testmodel/foobar2.xml, --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("should have failed");
    } catch (CommandException ex) {
    // XXX OK expected
    }
    Path path2 = cli.newDir("prod2", false);
    try {
        cli.execute("install " + prod1 + " --dir=" + path2 + " --config=moo/foobar.xml --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("should have failed");
    } catch (CommandException ex) {
    // XXX OK expected
    }
    cli.execute("install " + prod1 + " --dir=" + path2 + " --config=testmodel/foobar.xml --layers=" + "layerB-" + PRODUCER1);
    ProvisioningConfig config2 = ProvisioningManager.builder().setInstallationHome(path2).build().getProvisioningConfig();
    ConfigModel conf2 = config2.getDefinedConfig(new ConfigId("testmodel", "foobar.xml"));
    assertNotNull(conf2);
    assertTrue(conf2.getIncludedLayers().size() == 1);
    assertTrue(conf2.getIncludedLayers().contains("layerB-" + PRODUCER1));
    cli.execute("get-info --dir=" + path2 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("foobar.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    // Default model and config names
    Path path3 = cli.newDir("prod3", false);
    cli.execute("install " + prod1 + " --dir=" + path3 + " --config=foobar.xml --layers=" + "layerB-" + PRODUCER1);
    cli.execute("get-info --dir=" + path3 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("foobar.xml"));
    config = ProvisioningManager.builder().setInstallationHome(path3).build().getProvisioningConfig();
    assertTrue(config.getDefinedConfigs().size() == 1);
    conf = config.getDefinedConfig(new ConfigId("testmodel", "foobar.xml"));
    assertNotNull(conf);
    try {
        cli.execute("install " + prod1 + " --dir=" + path3 + " --config=foomodel/ --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK, expected
    }
    Path path4 = cli.newDir("prod4", false);
    cli.execute("install " + prod1 + " --dir=" + path4 + " --config=testmodel/ --layers=" + "layerB-" + PRODUCER1);
    cli.execute("get-info --dir=" + path4 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel.xml"));
    config = ProvisioningManager.builder().setInstallationHome(path4).build().getProvisioningConfig();
    assertTrue(config.getDefinedConfigs().size() == 1);
    conf = config.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf);
    // Install a specified config without layers
    Path path5 = cli.newDir("prod5", false);
    cli.execute("install " + prod1 + " --dir=" + path5);
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    cli.execute("install " + prod1 + " --dir=" + path5 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertFalse(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    cli.execute("install " + prod1 + " --dir=" + path5 + " --default-configs=testmodel/config1.xml,testmodel/config2.xml");
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    // Install multiple producers, installing default-config should not erase existing producer.
    Path path6 = cli.newDir("prod6", false);
    cli.execute("install " + prod2 + " --dir=" + path6);
    cli.execute("install " + prod1 + " --dir=" + path6 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path6);
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    // Install a default-config into empty directory
    Path path7 = cli.newDir("prod7", false);
    cli.execute("install " + prod1 + " --dir=" + path7 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path7 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    // Install layers in multiple steps
    Path path8 = cli.newDir("prod8", false);
    cli.execute("install " + prod1 + " --dir=" + path8 + " --layers=" + "layerA-" + PRODUCER1);
    cli.execute("install " + prod1 + " --dir=" + path8 + " --layers=" + "layerC-" + PRODUCER1);
    ProvisioningConfig config3 = ProvisioningManager.builder().setInstallationHome(path8).build().getProvisioningConfig();
    ConfigModel conf3 = config3.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf3);
    assertTrue(conf3.getIncludedLayers().size() == 2);
    assertTrue(conf3.getIncludedLayers().contains("layerA-" + PRODUCER1));
    assertTrue(conf3.getIncludedLayers().contains("layerC-" + PRODUCER1));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ConfigModel(org.jboss.galleon.config.ConfigModel) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) ConfigId(org.jboss.galleon.config.ConfigId) CommandException(org.aesh.command.CommandException) Test(org.junit.Test)

Example 82 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class AdvancedLayersTestCase method buildFPWithOptionalLayers.

public static void buildFPWithOptionalLayers(CliWrapper cli, UniverseSpec universeSpec, String producer, String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, producer, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addFeatureSpec(FeatureSpec.builder(producer + "-FeatureA").addParam(FeatureParameterSpec.createId("id")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("base-" + producer).addFeature(new FeatureConfig(producer + "-FeatureA").setParam("id", "base")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layerA-" + producer).addLayerDep("base-" + producer).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layerB-" + producer).addLayerDep("layerA-" + producer, true).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layerC-" + producer).addLayerDep("layerB-" + producer, true).build());
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 83 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation 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)));
    }
}
Also used : Path(java.nio.file.Path) Collection(java.util.Collection) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) ConfigId(org.jboss.galleon.config.ConfigId) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Example 84 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class AdvancedLayersTestCase method buildFPWithDependency.

private static void buildFPWithDependency(CliWrapper cli, UniverseSpec universeSpec, String producer, String version) throws ProvisioningException {
    FeaturePackLocation fpDep = new FeaturePackLocation(universeSpec, PRODUCER3, "1", null, version);
    FeaturePackCreator creatorDep = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    creatorDep.newFeaturePack(fpDep.getFPID()).addFeatureSpec(FeatureSpec.builder().addPackageDep("p0-required3").setName("feat0").build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layer0-" + PRODUCER3).addConfigItem(FeatureConfig.newConfig("feat0")).build()).newPackage("p0-required1", false).writeContent(PRODUCER3 + "/p0-required1.txt", "fp1 p1").getFeaturePack().newPackage("p0-required2", false).writeContent(PRODUCER3 + "/p0-required2.txt", "fp1 p1").getFeaturePack().newPackage("p0-required3", false).writeContent(PRODUCER3 + "/p0-required3.txt", "fp1 p1").getFeaturePack();
    creatorDep.install();
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, producer, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addDependency(PRODUCER3, fpDep).addFeatureSpec(FeatureSpec.builder().addPackageDep("p1-required").addPackageDep("p1-optional", true).addPackageDep(PackageDependencySpec.newInstance("p1-passive", PackageDependencySpec.PASSIVE)).setName("feat1").build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("base-" + producer).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layerA-" + producer).addLayerDep("base-" + producer).addConfigItem(FeatureConfig.newConfig("feat1")).build()).newPackage("p1-required", false).addDependency("p1-ref-from-required").addDependency(PRODUCER3, "p0-required1").writeContent("fp1/p1-required.txt", "fp1 p1").getFeaturePack().newPackage("p1-ref-from-required", false).writeContent("fp1/p1-ref-from-required.txt", "fp1 p1").getFeaturePack().newPackage("p1-passive", false).addDependency(PRODUCER3, "p0-required3").writeContent("fp1/p1-optional.txt", "fp1 p1").getFeaturePack().newPackage("p1-optional", false).addDependency("p1-ref-from-optional").addDependency(PRODUCER3, "p0-required2").writeContent("fp1/p1-optional.txt", "fp1 p1").getFeaturePack().newPackage("p1-ref-from-optional", false).writeContent("fp1/p1-ref-from-optional.txt", "fp1 p1").getFeaturePack();
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 85 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation 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"));
    }
}
Also used : Path(java.nio.file.Path) Set(java.util.Set) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Aggregations

FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)111 Test (org.junit.Test)46 Path (java.nio.file.Path)23 ProvisioningException (org.jboss.galleon.ProvisioningException)18 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)18 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)16 ArrayList (java.util.ArrayList)13 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)13 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)12 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)9 XMLStreamException (javax.xml.stream.XMLStreamException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)8 IOException (java.io.IOException)7 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)7 HashMap (java.util.HashMap)6 CommandException (org.aesh.command.CommandException)6 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)6 FeatureConfig (org.jboss.galleon.config.FeatureConfig)6 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)6 Set (java.util.Set)5