KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > groovy > security > RunOneGroovyScript


1 package groovy.security;
2
3 import java.io.File JavaDoc;
4
5 import junit.framework.Test;
6 import junit.framework.TestSuite;
7 import junit.textui.TestRunner;
8
9 /**
10  * Test case for running a single groovy script parsed from a .groovy file.
11  */

12 public class RunOneGroovyScript extends SecurityTestSupport {
13
14     protected static String JavaDoc file;
15     
16     public static void main(String JavaDoc[] args) {
17         if (args.length > 0) {
18             file = args[0];
19         }
20         TestRunner.run( suite() );
21     }
22     
23     public static Test suite() {
24         return new TestSuite(RunOneGroovyScript.class);
25     }
26
27     public void testScript() {
28         String JavaDoc fileName = System.getProperty("script", file);
29         if (fileName == null) {
30             throw new RuntimeException JavaDoc("No filename given in the 'script' system property so cannot run a Groovy script");
31         }
32         assertExecute(new File JavaDoc(fileName), null);
33     }
34 }
35
Popular Tags