View Javadoc

1   /*
2    * $Id: GroovyScriptTransformerFunctionalTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  public class GroovyScriptTransformerFunctionalTestCase extends FunctionalTestCase
18  {
19      public GroovyScriptTransformerFunctionalTestCase()
20      {
21          //Groovy really hammers the startup time since it needs to create the interpreter on every start
22          setDisposeManagerPerSuite(true);
23      }
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "groovy-transformer-config.xml";
29      }
30  
31      public void testInlineScript() throws Exception
32      {
33          MuleClient client = new MuleClient(muleContext);
34          client.dispatch("vm://in1", "hello", null);
35          MuleMessage response = client.request("vm://out1", RECEIVE_TIMEOUT);
36          assertNotNull(response);
37          assertEquals("hexxo", response.getPayload());
38      }
39  
40      public void testFileBasedScript() throws Exception
41      {
42          MuleClient client = new MuleClient(muleContext);
43          client.dispatch("vm://in2", "hello", null);
44          MuleMessage response = client.request("vm://out2", RECEIVE_TIMEOUT);
45          assertNotNull(response);
46          assertEquals("hexxo", response.getPayload());
47      }
48  
49      public void testReferencedTransformer() throws Exception
50      {
51          MuleClient client = new MuleClient(muleContext);
52          client.dispatch("vm://in3", "hello", null);
53          MuleMessage response = client.request("vm://out3", RECEIVE_TIMEOUT);
54          assertNotNull(response);
55          assertEquals("hexxo", response.getPayload());
56      }
57  
58      public void testReferencedTransformerWithParameters() throws Exception
59      {
60          MuleClient client = new MuleClient(muleContext);
61          client.dispatch("vm://in4", "hello", null);
62          MuleMessage response = client.request("vm://out4", RECEIVE_TIMEOUT);
63          assertNotNull(response);
64          assertEquals("hexxo", response.getPayload());
65      }
66  }