    1   package groovy.security;
    2
    3   import java.io.File;
    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 file;
    15
    16      public static void main(String[] 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 fileName = System.getProperty("script", file);
    29          if (fileName == null) {
    30              throw new RuntimeException("No filename given in the 'script' system property so cannot run a Groovy script");
    31          }
    32  		assertExecute(new File(fileName), null);
    33  	}
    34  }