Search in sources :

Example 1 with ProvisionedState

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

Example 2 with ProvisionedState

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"));
    }
}
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)

Example 3 with ProvisionedState

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();
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProvisionedState(org.jboss.galleon.state.ProvisionedState) ProvisionedConfig(org.jboss.galleon.state.ProvisionedConfig)

Example 4 with ProvisionedState

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)));
    }
}
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 5 with ProvisionedState

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"));
    }
}
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

ProvisionedState (org.jboss.galleon.state.ProvisionedState)11 Test (org.junit.Test)9 Path (java.nio.file.Path)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)4 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)3 Collection (java.util.Collection)2 Set (java.util.Set)2 ConfigId (org.jboss.galleon.config.ConfigId)2 ProvisionedFeature (org.jboss.galleon.state.ProvisionedFeature)2 CommandException (org.aesh.command.CommandException)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ProvisionedConfig (org.jboss.galleon.state.ProvisionedConfig)1 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)1