Search in sources :

Example 36 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class InstallUpdateTestCase method test.

@Test
public void test() throws Exception {
    Assert.assertEquals(cli.getMvnRepo().toString(), cli.getMvnRepo(), cli.getSession().getPmConfiguration().getMavenConfig().getLocalRepository());
    // Check resolved feature-packs
    cli.execute("find * --resolved-only --universe=" + universeSpec);
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    // Add an alpha1 snapshot release.
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1-SNAPSHOT");
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Alpha1-SNAPSHOT");
    cli.execute("find * --resolved-only --universe=" + universeSpec);
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    FeaturePackLocation finalLoc = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "final", null);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null), finalLoc);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null));
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null));
    // snapshot implies latest snapshot
    Path install1 = CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // no update available
    cli.execute("check-updates --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // Add an alpha1 release.
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null), finalLoc);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null));
    Path install2 = CliTestUtils.installAndCheck(cli, "install2", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1"));
    // no update available
    cli.execute("check-updates --dir=" + install2);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // Install an alpha-SNAPSHOT for producer2 in same directory
    CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // update available for the first installation, only producer1 has update.
    cli.execute("check-updates --dir=" + install1);
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(universeSpec.toString()));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    cli.execute("check-updates --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, null, null, null));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    cli.execute("check-updates --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER2, null, null, null));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // upgrade to Alpha1, only producer1 upgraded.
    cli.execute("update --yes --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    ProvisioningConfig config = CliTestUtils.getConfig(install1);
    FeaturePackConfig cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    FeaturePackConfig cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // Add an alpha1 release.
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Alpha1");
    // Then upgrade producer2
    cli.execute("update --yes --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER2, null, null, null));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1"));
    try {
        cli.execute("update --yes --dir=" + install1 + " --include-all-dependencies " + "--feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null) + "," + CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // ok expected.
    }
    // Downgrade P2 to 1.0.0.Alpha1-SNAPSHOT, P1 shouldn't be impacted.
    cli.execute("update --yes --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null) + "," + CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1-SNAPSHOT"));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT"));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 37 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class PatchTestCase method test.

@Test
public void test() throws Exception {
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
    Path install1 = CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    // No patches information
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
    Path patchDir = cli.newDir("patches", true);
    FPID patchID = CliTestUtils.installPatch(cli, universeSpec, PRODUCER1, "1.0.0", "Alpha1", patchDir);
    Path patchFile = patchDir.toFile().listFiles()[0].toPath();
    // try to install from the FPID, should fail.
    try {
        cli.execute("install " + patchID + " --dir=" + install1);
        throw new Exception("Install should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    // import the patch into universe
    cli.execute("feature-pack import " + patchFile + " --install-in-universe=true");
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.toString()));
    // Now we can use it.
    cli.execute("install " + patchID + " --dir=" + install1);
    ProvisioningConfig config = CliTestUtils.getConfig(install1);
    FeaturePackConfig cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertTrue(cf1.hasPatches());
    Assert.assertTrue(cf1.getPatches().contains(patchID));
    // Get info from the patch
    cli.execute("feature-pack get-info --file=" + patchFile);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(GetInfoCommand.PATCH_FOR + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1")));
    // Check that output contains the patch.
    cli.execute("get-info --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
    // Check that output contains the patch.
    cli.execute("get-info --dir=" + install1 + " --type=patches");
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH_FOR));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    // uninstall the patch
    cli.execute("uninstall --dir=" + install1 + " " + patchID);
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertFalse(cf1.hasPatches());
    // install the patch using the file
    cli.execute("install --dir=" + install1 + " --file=" + patchFile);
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertTrue(cf1.hasPatches());
    Assert.assertTrue(cf1.getPatches().contains(patchID));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 38 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class StateTestCase method testTransitiveWithExistingPackages.

@Test
public void testTransitiveWithExistingPackages() throws Exception {
    FeaturePackConfig transitiveConfig = FeaturePackConfig.transitiveBuilder(transitive).excludePackage("p1").includePackage("p2").build();
    FeaturePackConfig topLevelConfig = FeaturePackConfig.builder(locWithTransitive).setInheritPackages(false).build();
    ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(topLevelConfig).addFeaturePackDep(transitiveConfig).build();
    Path p = cli.newDir("transitive_packages", false);
    // Provision a config with a transitive with already excluded package
    ProvisioningManager mgr1 = cli.getSession().newProvisioningManager(p, true);
    mgr1.provision(config);
    cli.execute("state edit " + p.toFile().getAbsolutePath());
    try {
        cli.execute("get-info --type=optional-packages");
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("remove-excluded-package p1");
        cli.execute("get-info --type=optional-packages");
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("undo");
        cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
        cli.execute("remove-included-package p2");
        boolean failed = false;
        try {
            cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
        } catch (Exception ex) {
            // expected.
            failed = true;
        }
        if (!failed) {
            throw new Exception("Package p2 shouldn't be present");
        }
        cli.execute("undo");
        Path p2 = cli.newDir("transitive_packages_reprovisioned", false);
        cli.execute("provision --dir=" + p2.toFile().getAbsolutePath());
        // Check that we still have the transitive dep and its original content.
        ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p2).build();
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().size() == 1);
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().contains("p1"));
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getIncludedPackages().contains("p2"));
    } finally {
        cli.execute("leave-state");
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) CommandException(org.aesh.command.CommandException) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 39 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class FeaturePackProvisioningTestCase method testIncludeExcludeConfig.

@Test
public void testIncludeExcludeConfig() throws Exception {
    FeaturePackConfig builtConfig;
    // step 0 - no inclusions/exclusions initially
    Assert.assertTrue(getFeaturePackConfig().getIncludedConfigs().isEmpty());
    Assert.assertTrue(getFeaturePackConfig().getExcludedConfigs().isEmpty());
    // step 1 - include config
    builtConfig = performAction(provisioning.includeConfiguration(Collections.singletonMap(getFeaturePackConfig(), CONFIG_ID)));
    Assert.assertTrue(builtConfig.getIncludedConfigs().contains(CONFIG_ID));
    Assert.assertTrue(builtConfig.getExcludedConfigs().isEmpty());
    // step 2 - exclude the same config -> previous include should be removed
    builtConfig = performAction(provisioning.excludeConfiguration(Collections.singletonMap(getFeaturePackConfig(), CONFIG_ID)));
    Assert.assertTrue(builtConfig.getIncludedConfigs().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedConfigs().contains(CONFIG_ID));
    // step 3 - include the same config again -> previous exclude should be removed
    builtConfig = performAction(provisioning.includeConfiguration(Collections.singletonMap(getFeaturePackConfig(), CONFIG_ID)));
    Assert.assertTrue(builtConfig.getIncludedConfigs().contains(CONFIG_ID));
    Assert.assertTrue(builtConfig.getExcludedConfigs().isEmpty());
    // undo step 3
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedConfigs().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedConfigs().contains(CONFIG_ID));
    // undo step 2
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedConfigs().contains(CONFIG_ID));
    Assert.assertTrue(builtConfig.getExcludedConfigs().isEmpty());
    // undo step 1
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedConfigs().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedConfigs().isEmpty());
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 40 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig in project galleon by wildfly.

the class FeaturePackProvisioningTestCase method testIncludeExcludePackage.

@Test
public void testIncludeExcludePackage() throws Exception {
    FeaturePackConfig builtConfig;
    // no inclusions/exclusions initially
    Assert.assertTrue(getFeaturePackConfig().getIncludedPackages().isEmpty());
    Assert.assertTrue(getFeaturePackConfig().getExcludedPackages().isEmpty());
    // include a package
    builtConfig = performAction(provisioning.includePackage("package", getFeaturePackConfig()));
    Assert.assertTrue(builtConfig.getIncludedPackages().contains("package"));
    Assert.assertTrue(builtConfig.getExcludedPackages().isEmpty());
    // exclude the same package
    builtConfig = performAction(provisioning.excludePackage("package", getFeaturePackConfig()));
    Assert.assertTrue(builtConfig.getIncludedPackages().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedPackages().contains("package"));
    // include the same package again
    builtConfig = performAction(provisioning.includePackage("package", getFeaturePackConfig()));
    Assert.assertTrue(builtConfig.getIncludedPackages().contains("package"));
    Assert.assertTrue(builtConfig.getExcludedPackages().isEmpty());
    // undo
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedPackages().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedPackages().contains("package"));
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedPackages().contains("package"));
    Assert.assertTrue(builtConfig.getExcludedPackages().isEmpty());
    builtConfig = undo();
    Assert.assertTrue(builtConfig.getIncludedPackages().isEmpty());
    Assert.assertTrue(builtConfig.getExcludedPackages().isEmpty());
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Aggregations

FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)40 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)12 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)12 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)11 ProvisioningException (org.jboss.galleon.ProvisioningException)9 ArrayList (java.util.ArrayList)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 Path (java.nio.file.Path)6 HashMap (java.util.HashMap)6 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)6 Test (org.junit.Test)5 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CommandException (org.aesh.command.CommandException)3 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 ConfigModel (org.jboss.galleon.config.ConfigModel)3 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)3