Search in sources :

Example 31 with ConfigurationImpl

use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.

the class PluginsConfigurationProviderTest method testNullOverwriting.

@Test
public void testNullOverwriting() {
    PluginsConfigurationProvider provider = new PluginsConfigurationProvider();
    Configuration conf = new ConfigurationImpl();
    provider.init(conf);
    provider.load();
    Collection<PluginConfig> plugins = conf.getPlugins();
    Assert.assertNotNull(plugins);
    Assert.assertEquals(1, plugins.size());
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 32 with ConfigurationImpl

use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.

the class PluginsConfigurationProviderTest method testInvalidPlugins.

@Test
public void testInvalidPlugins() {
    IvyConfigurationProvider provider = new IvyConfigurationProvider();
    Configuration conf = new ConfigurationImpl();
    provider.init(conf);
    PluginConfig pc = new PluginConfigImpl();
    pc.setGroupId("foo");
    pc.setArtifactId("bar");
    pc.setVersion("10");
    conf.setPlugins(new LinkedList());
    conf.getPlugins().add(pc);
    Exception exception = null;
    try {
        provider.load();
    } catch (ConfigurationException e) {
        exception = e;
    }
    Assert.assertNotNull(exception);
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) ConfigurationException(org.walkmod.conf.ConfigurationException) PluginConfigImpl(org.walkmod.conf.entities.impl.PluginConfigImpl) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) ConfigurationException(org.walkmod.conf.ConfigurationException) Test(org.junit.Test)

Example 33 with ConfigurationImpl

use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testAddPluginRecursively.

@Test
public void testAddPluginRecursively() throws Exception {
    File aux = new File("src/test/resources/multmodulexml");
    aux.mkdirs();
    File module0 = new File(aux, "module0");
    module0.mkdir();
    File xml = new File(aux, "walkmod.xml");
    File modulexml = new File(module0, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        Configuration conf = new ConfigurationImpl();
        prov.init(conf);
        prov.createConfig();
        prov.addModules(Arrays.asList("module0"));
        List<String> plugins = new LinkedList<String>();
        plugins.add("org.walkmod:imports-cleaner");
        AddPluginCommand command = new AddPluginCommand(plugins);
        List<PluginConfig> pluginCfgs = command.build();
        prov.addPluginConfig(pluginCfgs.get(0), true);
        String output = FileUtils.readFileToString(modulexml);
        System.out.println(output);
        Assert.assertTrue(output.contains("imports-cleaner"));
    } finally {
        if (aux.exists()) {
            FileUtils.deleteQuietly(aux);
        }
    }
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) AddPluginCommand(org.walkmod.commands.AddPluginCommand) Test(org.junit.Test)

Example 34 with ConfigurationImpl

use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testSetReader.

@Test
public void testSetReader() 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();
        AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
        prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
        prov.setReader(null, "walkmod:commons:file-reader", null, false, null);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("walkmod:commons:file-reader"));
    } finally {
        if (xml.exists()) {
            xml.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 35 with ConfigurationImpl

use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testSetWriter.

@Test
public void testSetWriter() 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();
        AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
        prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
        prov.setWriter(null, "javalang:string-writer", null, false, null);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("javalang:string-writer"));
    } finally {
        if (xml.exists()) {
            xml.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Aggregations

ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)50 Configuration (org.walkmod.conf.entities.Configuration)48 Test (org.junit.Test)43 File (java.io.File)36 AddTransformationCommand (org.walkmod.commands.AddTransformationCommand)21 LinkedList (java.util.LinkedList)20 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)20 PluginConfig (org.walkmod.conf.entities.PluginConfig)9 ChainConfig (org.walkmod.conf.entities.ChainConfig)8 HashMap (java.util.HashMap)6 Document (org.w3c.dom.Document)4 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)4 ChainConfigImpl (org.walkmod.conf.entities.impl.ChainConfigImpl)4 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)4 AddCfgProviderCommand (org.walkmod.commands.AddCfgProviderCommand)3 TransformerException (javax.xml.transform.TransformerException)2 AddPluginCommand (org.walkmod.commands.AddPluginCommand)2