use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testRemoveTransformationsRecursively.
@Test
public void testRemoveTransformationsRecursively() throws Exception {
List<String> list = new LinkedList<String>();
list.add("imports-cleaner");
File aux = new File("src/test/resources/xmlmultimodule");
aux.mkdirs();
File module0 = new File(aux, "module0");
File module1 = new File(aux, "module1");
File cfg0 = new File(module0, "walkmod.xml");
File cfg1 = new File(module1, "walkmod.xml");
module0.mkdir();
module1.mkdir();
File xml = new File(aux, "walkmod.xml");
XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
try {
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.createConfig();
prov.addModules(Arrays.asList("module0", "module1"));
AddTransformationCommand command0 = new AddTransformationCommand("license-applier", "mychain", false, null, null, null, null, true);
prov.addTransformationConfig("mychain", null, command0.buildTransformationCfg(), true, null, null);
String output = FileUtils.readFileToString(cfg0);
System.out.println(output);
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, true);
prov.addTransformationConfig("mychain", null, command.buildTransformationCfg(), true, null, null);
output = FileUtils.readFileToString(cfg0);
System.out.println(output);
prov.removeTransformations("mychain", list, true);
output = FileUtils.readFileToString(cfg0);
Assert.assertTrue(!output.contains("imports-cleaner"));
Assert.assertTrue(output.contains("license-applier"));
output = FileUtils.readFileToString(cfg1);
Assert.assertTrue(!output.contains("imports-cleaner"));
Assert.assertTrue(output.contains("license-applier"));
} finally {
if (aux.exists()) {
FileUtils.deleteDirectory(aux);
}
}
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testRemoveTranformation.
@Test
public void testRemoveTranformation() throws Exception {
List<String> list = new LinkedList<String>();
list.add("imports-cleaner");
File aux = new File("src/test/resources/xml");
aux.mkdirs();
File xml = new File(aux, "walkmod.xml");
XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
try {
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.createConfig();
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
prov.removeTransformations(null, list, false);
String output = FileUtils.readFileToString(xml);
Assert.assertTrue(!output.contains("imports-cleaner"));
} finally {
if (xml.exists()) {
xml.delete();
}
}
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testRemoveModule.
@Test
public void testRemoveModule() throws Exception {
File aux = new File("src/test/resources/xml");
aux.mkdirs();
File xml = new File(aux, "walkmod.xml");
XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
try {
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.createConfig();
List<String> modules = new LinkedList<String>();
modules.add("module1");
prov.addModules(modules);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("module1"));
prov.removeModules(modules);
output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(!output.contains("module1"));
} finally {
if (xml.exists()) {
xml.delete();
}
}
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testVersion1_1.
@Test
public void testVersion1_1() throws Exception {
XMLConfigurationProvider prov = new XMLConfigurationProvider("src/test/resources/multimodule/walkmod.xml", false);
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.load();
Assert.assertEquals(0, conf.getChainConfigs().size());
Assert.assertEquals(2, conf.getModules().size());
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testVersion1_0.
@Test
public void testVersion1_0() throws Exception {
XMLConfigurationProvider prov = new XMLConfigurationProvider("src/test/resources/testFiles/walkmod.xml", false);
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.load();
Assert.assertEquals(1, conf.getChainConfigs().size());
Assert.assertEquals("default", conf.getChainConfigs().iterator().next().getName());
}
Aggregations