use of org.walkmod.commands.AddCfgProviderCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testConfigProvidersConfig.
@Test
public void testConfigProvidersConfig() throws Exception {
AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
File file = new File("src/test/resources/yaml/addcfgproviders.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
ProviderConfig provCfg = command.build();
provider.addProviderConfig(provCfg, false);
String output = FileUtils.readFileToString(file);
String desiredOutput = "conf-providers:\n";
desiredOutput += "- type: \"maven\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.commands.AddCfgProviderCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testConfigProvidersConfigRecursive.
@Test
public void testConfigProvidersConfigRecursive() throws Exception {
AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
File parentDir = new File("src/test/resources/multimoduleyaml");
parentDir.mkdirs();
File module0 = new File(parentDir, "module0");
module0.mkdir();
File file = new File(parentDir, "walkmod.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
File cfg0 = new File(module0, "walkmod.yml");
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
ProviderConfig provCfg = command.build();
provider.addModules(Arrays.asList("module0"));
provider.addProviderConfig(provCfg, true);
String output = FileUtils.readFileToString(cfg0);
String desiredOutput = "conf-providers:\n";
desiredOutput += "- type: \"maven\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (parentDir.exists()) {
FileUtils.deleteDirectory(parentDir);
}
}
}
Aggregations