1   /*
2    * $Id: GroovyScriptTransformerTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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.transformers.script;
12  
13  import org.mule.tck.AbstractTransformerTestCase;
14  import org.mule.umo.transformer.UMOTransformer;
15  
16  import java.util.ArrayList;
17  import java.util.List;
18  
19  public class GroovyScriptTransformerTestCase extends AbstractTransformerTestCase
20  {
21  
22      public UMOTransformer getTransformer() throws Exception
23      {
24          ScriptTransformer transformer = new ScriptTransformer();
25          transformer.setScriptEngineName("groovy");
26          transformer.setName("StringToList");
27          transformer.setScriptFile("StringToList2.groovy");
28          transformer.initialise();
29          return transformer;
30      }
31  
32      public UMOTransformer getRoundTripTransformer() throws Exception
33      {
34          ScriptTransformer transformer = new ScriptTransformer();
35          transformer.setName("ListToStringTransformer");
36          transformer.setScriptFile("ListToString2.groovy");
37          transformer.initialise();
38          return transformer;
39      }
40  
41      public Object getTestData()
42      {
43          return "this is groovy!";
44      }
45  
46      public Object getResultData()
47      {
48          List list = new ArrayList();
49          list.add("this");
50          list.add("is");
51          list.add("groovy!");
52          return list;
53      }
54  
55      // @Override
56      protected void doTestClone(UMOTransformer original, UMOTransformer clone) throws Exception
57      {
58          super.doTestClone(original, clone);
59  
60          ScriptTransformer t1 = (ScriptTransformer) original;
61          ScriptTransformer t2 = (ScriptTransformer) clone;
62  
63          // The Scriptable instance must be different 
64          assertNotSame(t1.scriptable, t2.scriptable);
65      }
66  
67  }