Search in sources :

Example 86 with FeaturePackLocation

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

the class ChangesTestCase method testPersist.

@Test
public void testPersist() throws Exception {
    CliTestUtils.installWithLayers(cli, universeSpec, PRODUCER1, "1.0.0.Alpha2");
    Path p = cli.newDir("install-persist", false);
    FeaturePackLocation fpl = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha2");
    cli.execute("install " + fpl + " --dir=" + p);
    cli.execute("persist-changes --dir=" + p);
    assertTrue(cli.getOutput(), cli.getOutput().contains("No changes to persist"));
    Path root = p.resolve(PRODUCER1);
    Path file = root.resolve("p1.txt");
    Files.write(file, "HelloWorld".getBytes());
    cli.execute("persist-changes --dir=" + p);
    assertTrue(cli.getOutput(), cli.getOutput().contains("No changes to persist"));
    overwrite(p, ProvisionedConfigBuilder.builder().setModel("testmodel").setName("config1").addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(fpl.getProducer(), PRODUCER1 + "-FeatureA", "id", "2")).build()).build());
    cli.execute("persist-changes --dir=" + p);
    assertFalse(cli.getOutput(), cli.getOutput().contains("No changes to persist"));
}
Also used : Path(java.nio.file.Path) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Test(org.junit.Test)

Example 87 with FeaturePackLocation

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

the class ChangesTestCase method test.

@Test
public void test() throws Exception {
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
    Path p = cli.newDir("install", false);
    FeaturePackLocation fpl = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1");
    cli.execute("install " + fpl + " --dir=" + p);
    Path root = p.resolve(PRODUCER1);
    Path file = root.resolve("p1.txt");
    Path newFile = p.resolve("newfile.xml");
    Files.createFile(newFile);
    Files.write(file, "HelloWorld".getBytes());
    cli.execute("cd " + p.resolve(".."));
    cli.execute("get-changes --dir=" + p.getFileName());
    Path nf = p.getParent().relativize(newFile);
    Path f = p.getParent().relativize(file);
    assertTrue(cli.getOutput(), cli.getOutput().contains(" + " + nf));
    assertTrue(cli.getOutput(), cli.getOutput().contains(" C " + f));
    cli.execute("cd " + p);
    cli.execute("get-changes");
    nf = p.relativize(newFile);
    f = p.relativize(file);
    assertTrue(cli.getOutput(), cli.getOutput().contains(" + " + nf));
    assertTrue(cli.getOutput(), cli.getOutput().contains(" C " + f));
    cli.execute("cd " + root);
    cli.execute("get-changes");
    nf = root.relativize(newFile);
    f = root.relativize(file);
    assertTrue(cli.getOutput(), cli.getOutput().contains(" + " + nf));
    assertTrue(cli.getOutput(), cli.getOutput().contains(" C " + f));
    Files.delete(file);
    cli.execute("get-changes");
    assertTrue(cli.getOutput(), cli.getOutput().contains(" + " + nf));
    assertTrue(cli.getOutput(), cli.getOutput().contains(" - " + f));
}
Also used : Path(java.nio.file.Path) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Test(org.junit.Test)

Example 88 with FeaturePackLocation

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

the class CliTestCase method testCommandFromChilDir.

@Test
public void testCommandFromChilDir() throws Exception {
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Final");
    Path p = cli.newDir("installCommandFromChilDir", false);
    FeaturePackLocation fpl = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "final", "1.0.0.Final");
    cli.execute("install " + fpl + " --dir=" + p);
    cli.execute("cd " + p.resolve(PRODUCER1));
    cli.execute("installation add-universe --name=" + UNIVERSE_CUSTOM_NAME + " --factory=maven --location=" + universeSpec.getLocation());
    cli.execute("list-feature-packs");
    assertTrue(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME + "@1"));
    cli.execute("find " + PRODUCER1);
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER1, "1", null, "1.0.0.Final").toString()));
    cli.execute("installation remove-universe --name=" + UNIVERSE_CUSTOM_NAME);
    cli.execute("list-feature-packs");
    assertFalse(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME + "@1"));
    cli.execute("installation export ./exported.xml");
    assertTrue(Files.exists(p.resolve(PRODUCER1).resolve("exported.xml")));
    cli.execute("installation set-history-limit 777");
    cli.execute("installation get-history-limit");
    assertTrue(cli.getOutput(), cli.getOutput().contains("777"));
    cli.execute("installation clear-history");
    cli.execute("get-info");
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    // Will not fail from a child directory.
    cli.execute("check-updates");
    // without a target directory
    try {
        cli.execute("install " + fpl);
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    try {
        cli.execute("undo");
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    try {
        cli.execute("uninstall " + fpl.getFPID());
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    try {
        cli.execute("update");
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    // uninstall from a child directory with a --dir option
    FeaturePackLocation toUnInstall = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Final");
    cli.execute("uninstall " + toUnInstall.getFPID() + " --dir=..");
}
Also used : Path(java.nio.file.Path) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) Test(org.junit.Test)

Example 89 with FeaturePackLocation

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

the class PatchTransitiveDepTestCase method install.

private static void install() throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    fp1 = new FeaturePackLocation(universeSpec, PRODUCER1, "1", null, "1.0.0.Final");
    creator.newFeaturePack(fp1.getFPID()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1");
    fp1Patch = new FeaturePackLocation(universeSpec, PRODUCER1, "1", null, "1.0.0.Patch.Final");
    creator.newFeaturePack(fp1Patch.getFPID()).setPatchFor(fp1.getFPID()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1 patch");
    fp2 = new FeaturePackLocation(universeSpec, PRODUCER2, "1", null, "1.0.0.Final");
    creator.newFeaturePack(fp2.getFPID()).addDependency(fp1);
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 90 with FeaturePackLocation

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

the class UniverseTestCase method test.

@Test
public void test() throws Exception {
    CliTestUtils.install(cli, universeSpec1, PRODUCER1, "1.0.0.Final");
    CliTestUtils.install(cli, universeSpec2, PRODUCER2, "1.0.0.Final");
    CliTestUtils.install(cli, universeSpec_builtin, PRODUCER3, "1.0.0.Final");
    Path dir = cli.newDir("install1", false);
    FeaturePackLocation toInstall = CliTestUtils.buildFPL(universeSpec1, PRODUCER1, "1", null, null);
    cli.execute("install " + toInstall + " --dir=" + dir);
    cli.execute("get-info --dir=" + dir);
    assertTrue(cli.getOutput(), cli.getOutput().contains(universeSpec1 + "@1"));
    cli.execute("installation add-universe --name=" + UNIVERSE_CUSTOM_NAME + " --factory=maven --location=" + universeSpec2.getLocation() + " --dir=" + dir);
    cli.execute("get-info --dir=" + dir + " --type=universes");
    assertTrue(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME));
    FeaturePackLocation toInstall2 = CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, null);
    cli.execute("install " + toInstall2 + " --dir=" + dir);
    cli.execute("get-info --dir=" + dir);
    assertTrue(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME + "@1"));
    FeaturePackLocation toUnInstall = CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, "1.0.0.Final");
    cli.execute("uninstall " + toUnInstall + " --dir=" + dir);
    cli.execute("undo --dir=" + dir);
    cli.execute("cd " + dir);
    cli.execute("list-feature-packs");
    assertTrue(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME + "@1"));
    cli.execute("find " + PRODUCER2 + "@");
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, "1.0.0.Final").toString()));
    cli.execute("find " + PRODUCER2);
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, "1.0.0.Final").toString()));
    cli.execute("installation remove-universe --name=" + UNIVERSE_CUSTOM_NAME);
    cli.execute("list-feature-packs");
    assertFalse(cli.getOutput(), cli.getOutput().contains(UNIVERSE_CUSTOM_NAME + "@1"));
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, "1.0.0.Final").toString()));
    cli.execute("find " + PRODUCER2);
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(UniverseSpec.fromString(UNIVERSE_CUSTOM_NAME), PRODUCER2, "1", null, "1.0.0.Final").toString()));
    // Only spec is now usable to reference universe.
    FeaturePackLocation toUnInstall2 = CliTestUtils.buildFPL(universeSpec2, PRODUCER2, "1", null, "1.0.0.Final");
    cli.execute("uninstall " + toUnInstall2 + " --dir=" + dir);
    // Default universe in installation
    Path dir2 = cli.newDir("install2", false);
    cli.execute("install " + toInstall + " --dir=" + dir2);
    cli.execute("installation add-universe --factory=maven --location=" + universeSpec1.getLocation() + " --dir=" + dir2);
    cli.execute("get-info --dir=" + dir2 + " --type=universes");
    assertTrue(cli.getOutput(), cli.getOutput().contains(universeSpec1.getFactory()));
    assertTrue(cli.getOutput(), cli.getOutput().contains(universeSpec1.getLocation()));
    assertTrue(cli.getOutput(), cli.getOutput().contains("<default>"));
    FeaturePackLocation toUnInstall3 = CliTestUtils.buildFPL(null, PRODUCER1, "1", null, "1.0.0.Final");
    cli.execute("uninstall " + toUnInstall3.getFPID() + " --dir=" + dir2);
    cli.execute("installation add-universe --factory=maven --location=" + universeSpec2.getLocation() + " --dir=" + dir2);
    FeaturePackLocation toInstall3 = CliTestUtils.buildFPL(null, PRODUCER2, "1", null, null);
    cli.execute("install " + toInstall3 + " --dir=" + dir2);
    cli.execute("get-info --dir=" + dir2);
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    assertFalse(cli.getOutput(), cli.getOutput().contains(UNIVERSE_NAME));
    // Builtin universe
    cli.execute("cd -");
    try {
        cli.execute("get-info");
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // OK not an installation
    }
    Path dir3 = cli.newDir("install3", false);
    FeaturePackLocation toInstall4 = CliTestUtils.buildFPL(null, PRODUCER3, "1", null, null);
    cli.execute("install " + toInstall4 + " --dir=" + dir3);
    cli.execute("get-info --dir=" + dir3);
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
    assertFalse(cli.getOutput(), cli.getOutput().contains(UNIVERSE_NAME));
}
Also used : Path(java.nio.file.Path) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) 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