1 package org.apache.maven.plugin.invoker;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.ByteArrayOutputStream;
23 import java.io.PrintStream;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import junit.framework.TestCase;
28
29
30
31
32
33
34
35 public class GroovyScriptInterpreterTest
36 extends TestCase
37 {
38
39 public void testEvaluateScript()
40 throws Exception
41 {
42 ByteArrayOutputStream out = new ByteArrayOutputStream();
43 ScriptInterpreter interpreter = new GroovyScriptInterpreter();
44 assertEquals( Boolean.TRUE, interpreter.evaluateScript( "print \"Test\"\nreturn true", null, null,
45 new PrintStream( out ) ) );
46 assertEquals( "Test", out.toString() );
47 }
48
49 public void testEvaluateScriptVars()
50 throws Exception
51 {
52 Map vars = new HashMap();
53 vars.put( "testVar", "data" );
54 ByteArrayOutputStream out = new ByteArrayOutputStream();
55 ScriptInterpreter interpreter = new GroovyScriptInterpreter();
56 assertEquals( Boolean.TRUE, interpreter.evaluateScript( "print testVar\nreturn true", null, vars,
57 new PrintStream( out ) ) );
58 assertEquals( "data", out.toString() );
59 }
60
61 }