1   /*
2    * $Id: GroovyScriptTransformerTestCase.java 11701 2008-05-08 13:02:44Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.scripting.transformer;
12  
13  import org.mule.api.transformer.Transformer;
14  import org.mule.module.scripting.component.Scriptable;
15  import org.mule.module.scripting.transformer.ScriptTransformer;
16  import org.mule.transformer.AbstractTransformerTestCase;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  public class GroovyScriptTransformerTestCase extends AbstractTransformerTestCase
22  {
23      public Transformer getTransformer() throws Exception
24      {
25          Scriptable script = new Scriptable();
26          script.setScriptEngineName("groovy");
27          script.setScriptFile("StringToList.groovy");
28          script.initialise();
29          
30          ScriptTransformer transformer = new ScriptTransformer();
31          transformer.setName("StringToList");
32          transformer.setScript(script);
33          transformer.initialise();
34          return transformer;
35      }
36  
37      public Transformer getRoundTripTransformer() throws Exception
38      {
39          Scriptable script = new Scriptable();
40          script.setScriptFile("ListToString.groovy");
41          script.initialise();
42          
43          ScriptTransformer transformer = new ScriptTransformer();
44          transformer.setName("ListToString");
45          transformer.setScript(script);
46          transformer.initialise();
47          return transformer;
48      }
49  
50      public Object getTestData()
51      {
52          return "this is groovy!";
53      }
54  
55      public Object getResultData()
56      {
57          List list = new ArrayList();
58          list.add("this");
59          list.add("is");
60          list.add("groovy!");
61          return list;
62      }
63  }