use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class PluginOptionsTestCase method test.
@Test
public void test() throws Exception {
CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1", PluginTest.class);
CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Alpha1", PluginTest.class);
Path p = cli.newDir("install", false);
// Invalid option
try {
cli.execute("install " + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p + " --foo");
throw new Exception("Should have failed, --foo beeing unknown");
} catch (CommandException ex) {
// XXX OK.
}
// missing required option
try {
cli.execute("install " + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p);
throw new Exception("Should have failed, --opt1-req is required.");
} catch (CommandException ex) {
// XXX OK.
}
// successfull installation
cli.execute("install " + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p + " --" + PluginTest.OPT1_REQUIRED + "=XXX");
cli.execute("install " + CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p + " --" + PluginTest.OPT1_REQUIRED + "=XXX");
final Path provisioningXml = cli.newDir("workdir", true).resolve("provisioning.xml");
try (BufferedWriter writer = Files.newBufferedWriter(provisioningXml)) {
final ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1")).addFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "alpha", "1.0.0.Alpha1")).build();
ProvisioningXmlWriter.getInstance().write(config, writer);
}
// PROVISION command
Path target = cli.newDir("target", false);
// Invalid option
try {
cli.execute("provision " + provisioningXml + " --dir=" + target + " --foo");
throw new Exception("Should have failed, --foo beeing unknown");
} catch (CommandException ex) {
// XXX OK.
}
// missing required option
try {
cli.execute("provision " + provisioningXml + " --dir=" + target);
throw new Exception("Should have failed, --opt1-req is required.");
} catch (CommandException ex) {
// XXX OK.
}
// successfull provisioning
cli.execute("provision " + provisioningXml + " --dir=" + target + " --" + PluginTest.OPT1_REQUIRED + "=XXX");
// UNINSTALL command, remaining PRODUCER2 expects some options.
try {
cli.execute("uninstall " + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p + " --foo");
throw new Exception("Should have failed, --foo beeing unknown");
} catch (CommandException ex) {
// XXX OK.
}
// the required option has been persisted and does not have to be explicitly provided by the user
cli.execute("uninstall " + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1") + " --dir=" + p);
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class StateTestCase method testTransitiveWithVersion.
@Test
public void testTransitiveWithVersion() throws Exception {
ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(locWithTransitive).addTransitiveDep(transitive).build();
Path p = cli.newDir("version_transitive", false);
// Provision a config with a transitive with version set.
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.assertTrue(cli.getOutput(), cli.getOutput().contains("p1"));
Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
cli.execute("exclude-package " + transitive.getProducer() + "/p1");
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("undo");
// Check that we still have the transitive dep.
ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p).build();
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().size() == 1);
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().isEmpty());
} finally {
cli.execute("leave-state");
}
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class LayoutTestBase method main.
@Test
public void main() throws Exception {
try (ProvisioningLayout<FeaturePackLayout> layout = buildLayout()) {
if (pmErrors() != null) {
Assert.fail("Errors expected");
}
assertLayout(layout);
final ProvisioningConfig expectedConfig = expectedLayoutConfig();
if (expectedConfig == null) {
assertLayoutConfig(layout.getConfig());
} else {
assertEquals(expectedConfig, layout.getConfig());
}
} catch (ProvisioningException e) {
final String[] errors = pmErrors();
if (errors == null) {
throw e;
}
Throwable t = e;
int i = 0;
while (t != null) {
if (i == errors.length) {
Assert.fail("There are more error messages than expected");
}
assertEquals(errors[i++], t.getMessage());
t = e.getCause();
}
}
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class AbstractFPProvisionedCommand method getProvisionedFP.
public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException {
ProducerSpec producer = getProducer(session);
if (producer == null) {
return null;
}
ProvisioningConfig config = session.getState().getConfig();
for (FeaturePackConfig dep : config.getFeaturePackDeps()) {
if (dep.getLocation().getProducer().equals(producer)) {
return dep;
}
}
for (FeaturePackConfig dep : config.getTransitiveDeps()) {
if (dep.getLocation().getProducer().equals(producer)) {
return dep;
}
}
return null;
}
use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.
the class UpdateCommand method getDynamicOptions.
@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
String targetDirArg = (String) getValue(DIR_OPTION_NAME);
if (targetDirArg == null) {
// Check in argument or option, that is the option completion case.
targetDirArg = getOptionValue(DIR_OPTION_NAME);
}
Path installation = getAbsolutePath(targetDirArg, pmSession.getAeshContext());
ProvisioningConfig config = pmSession.newProvisioningManager(installation, false).getProvisioningConfig();
Set<ProvisioningOption> opts = pmSession.getResolver().get(null, PluginResolver.newResolver(pmSession, config)).getDiff();
List<DynamicOption> options = new ArrayList<>();
for (ProvisioningOption opt : opts) {
DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
options.add(dynOption);
}
return options;
}
Aggregations