GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / cli / AbstractCliTests.groovy
blobedff8b0828d55b7fb2dc0d168f4f7c2f15ca2ee5
1 package org.codehaus.groovy.grails.cli;
3 import org.codehaus.groovy.tools.RootLoader
4 import org.codehaus.groovy.tools.LoaderConfiguration
5 import org.codehaus.groovy.grails.plugins.PluginManagerHolder
7 abstract class AbstractCliTests extends GroovyTestCase {
9 protected appBase = "test/cliTestApp"
10 protected ant = new AntBuilder()
12 void setUp() {
13 ant.delete(dir:appBase, failonerror:false)
14 System.setProperty("base.dir", appBase)
15 System.setProperty("grails.cli.args", "testapp")
16 System.setProperty("grails.cli.testing", "true")
17 System.setProperty("env.GRAILS_HOME", new File("").absolutePath)
20 void tearDown() {
21 PluginManagerHolder.pluginManager = null
22 ant.delete(dir:appBase, failonerror:false)
23 ant = null
26 protected String createTestApp() {
27 // Pass the name of the test project to the create-app script.
28 def appName = "testapp"
29 System.setProperty("grails.cli.args", appName)
31 // Create the application.
32 gantRun( ["-f", "scripts/CreateApp.groovy"] as String[])
34 // Update the base directory to the application dir.
35 def appDir = appBase + File.separator + appName
36 System.setProperty("base.dir", appDir)
38 // Finally, clear the CLI arguments.
39 System.setProperty("grails.cli.args", "")
41 // Return the path to the new app.
42 return appDir
45 protected void gantRun(final String[] args) {
47 LoaderConfiguration loaderConfig = new LoaderConfiguration()
48 loaderConfig.setRequireMain(false);
50 def libDir = new File('lib')
51 assert libDir.exists()
52 assert libDir.isDirectory()
54 libDir.eachFileMatch(~/gant.*\.jar/) {jarFile ->
55 loaderConfig.addFile(jarFile)
58 def rootLoader = new RootLoader(loaderConfig)
59 def gant = rootLoader.loadClass('gant.Gant', false).newInstance()
61 gant.processArgs(args)