Search in sources :

Example 6 with ProvisionedState

use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.

the class ProvisionedStateXmlWriterTestCase method testFeatureOrder.

@Test
public void testFeatureOrder() throws Exception {
    ProvisionedState originalState = ProvisionedState.builder().addConfig(ProvisionedConfigBuilder.builder().addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec1", "create-param", "a")).build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec2", "create-param", "b")).build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec1", "create-param", "c")).build()).addFeature(ProvisionedFeatureBuilder.builder(new ResolvedSpecId(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp2", "1.0").getProducer(), "spec3")).setIdParam("id-param", "b").build()).addFeature(ProvisionedFeatureBuilder.builder(new ResolvedSpecId(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp2", "1.0").getProducer(), "spec3")).setIdParam("id-param", "a").build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec1", "create-param", "c")).build()).build()).build();
    // marshall and unmarshall
    Path path = marshallToTempFile(originalState);
    ProvisionedState newState = validator.validateAndParse(path);
    // read features and check the order
    ReadFeaturesHandler handler = new ReadFeaturesHandler();
    newState.getConfigs().iterator().next().handle(handler);
    Iterator<ProvisionedFeature> iterator = handler.features.iterator();
    Assert.assertEquals("{org.jboss.group@galleon1}spec1:create-param=a", iterator.next().getId().toString());
    Assert.assertEquals("{org.jboss.group@galleon1}spec2:create-param=b", iterator.next().getId().toString());
    Assert.assertEquals("{org.jboss.group@galleon1}spec1:create-param=c", iterator.next().getId().toString());
    Assert.assertEquals("{org.jboss.group@galleon1}spec3:id-param=b", iterator.next().getId().toString());
    Assert.assertEquals("{org.jboss.group@galleon1}spec3:id-param=a", iterator.next().getId().toString());
    Assert.assertEquals("{org.jboss.group@galleon1}spec1:create-param=c", iterator.next().getId().toString());
}
Also used : Path(java.nio.file.Path) ProvisionedFeature(org.jboss.galleon.state.ProvisionedFeature) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Example 7 with ProvisionedState

use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.

the class ProvisionedStateXmlWriterTestCase method testMarshallUnmarshall.

@Test
public void testMarshallUnmarshall() throws Exception {
    ProvisionedState originalState = ProvisionedState.builder().addFeaturePack(ProvisionedFeaturePack.builder(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0")).addPackage("package1").addPackage(ProvisionedPackage.newInstance("package2")).build()).addFeaturePack(ProvisionedFeaturePack.builder(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp2", "1.0")).addPackage("package3").build()).addConfig(ProvisionedConfigBuilder.builder().addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec1", "create-param", "a")).setConfigParam("param", "config").build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec1", "create-param", "b")).build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp1", "1.0").getProducer(), "spec2", "create-param", "c")).build()).addFeature(ProvisionedFeatureBuilder.builder(new ResolvedSpecId(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp2", "1.0").getProducer(), "spec3")).setIdParam("id-param", "config").build()).setModel("model").setName("name").setProperty("prop", "value").setProperty("prop2", "value2").build()).addConfig(ProvisionedConfigBuilder.builder().build()).build();
    // marshall to XML and then parse again
    Path path = marshallToTempFile(originalState);
    ProvisionedState newState = validator.validateAndParse(path);
    // compare parsed state with the original
    Assert.assertEquals(originalState, newState);
}
Also used : Path(java.nio.file.Path) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Example 8 with ProvisionedState

use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.

the class ProvisionedStateXmlWriterTestCase method testFeatureParams.

@Test
public void testFeatureParams() throws Exception {
    ProvisionedState originalState = ProvisionedState.builder().addConfig(ProvisionedConfigBuilder.builder().addFeature(ProvisionedFeatureBuilder.builder(new ResolvedSpecId(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp", "1.0").getProducer(), "spec")).setIdParam("id-param", "config").setIdParam("id-param2", "config").setConfigParam("param", "config").build()).addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.builder(LegacyGalleon1Universe.newFPID("org.jboss.group", "fp", "1.0").getProducer(), "spec2").setParam("id-param", // TODO: this resolved value will not have config representation
    "resolved").build()).setConfigParam("param", "config").build())).build();
    // marshall and unmarshall
    Path path = marshallToTempFile(originalState);
    ProvisionedState newState = validator.validateAndParse(path);
    // retrieve the parsedFeature
    ReadFeaturesHandler readFeaturesHandler = new ReadFeaturesHandler();
    newState.getConfigs().get(0).handle(readFeaturesHandler);
    ProvisionedFeature parsedFeature = readFeaturesHandler.features.get(0);
    Assert.assertEquals("config", parsedFeature.getConfigParam("id-param"));
    Assert.assertEquals("config", parsedFeature.getConfigParam("id-param2"));
    Assert.assertEquals("config", parsedFeature.getConfigParam("param"));
    parsedFeature = readFeaturesHandler.features.get(1);
    Assert.assertEquals("resolved", parsedFeature.getConfigParam("id-param"));
    Assert.assertEquals("config", parsedFeature.getConfigParam("param"));
}
Also used : Path(java.nio.file.Path) ProvisionedFeature(org.jboss.galleon.state.ProvisionedFeature) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Example 9 with ProvisionedState

use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.

the class ProvisionedStateXmlWriterTestCase method testEmpty.

@Test
public void testEmpty() throws Exception {
    ProvisionedState originalState = ProvisionedState.builder().build();
    Path path = marshallToTempFile(originalState);
    ProvisionedState newState = validator.parse(path);
    Assert.assertEquals(originalState, newState);
}
Also used : Path(java.nio.file.Path) ProvisionedState(org.jboss.galleon.state.ProvisionedState) Test(org.junit.Test)

Example 10 with ProvisionedState

use of org.jboss.galleon.state.ProvisionedState in project galleon by wildfly.

the class ProvisionedXmlParserTestCase method readValid.

@Test
public void readValid() throws Exception {
    final ProvisionedState found = validator.validateAndParse("xml/provisioned/provisioned-state.xml", null, null);
    ProvisionedState expected = ProvisionedState.builder().addFeaturePack(ProvisionedFeaturePack.forFPID(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1.Final").getFPID())).addFeaturePack(ProvisionedFeaturePack.builder(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2.Final").getFPID()).addPackage("p1").addPackage("p2").build()).build();
    Assert.assertEquals(expected, found);
}
Also used : 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