View Javadoc

1   /*
2    * $Id: GroovyScriptFunctionalTestCase.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;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  public class GroovyScriptFunctionalTestCase extends FunctionalTestCase
18  {
19      public GroovyScriptFunctionalTestCase()
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-component-config.xml";
29      }
30  
31      public void testInlineScript() throws Exception
32      {
33          MuleClient client = new MuleClient(muleContext);
34          client.dispatch("vm://in1", "Important Message", null);
35          MuleMessage response = client.request("vm://out1", RECEIVE_TIMEOUT);
36          assertNotNull(response);
37          assertEquals("Important Message Received", response.getPayloadAsString());
38      }
39      
40      public void testFileBasedScript() throws Exception
41      {
42          MuleClient client = new MuleClient(muleContext);
43          client.dispatch("vm://in2", "Important Message", null);
44          MuleMessage response = client.request("vm://out2", RECEIVE_TIMEOUT);
45          assertNotNull(response);
46          assertEquals("Important Message Received", response.getPayloadAsString());
47      }
48      
49      public void testReferencedScript() throws Exception
50      {
51          MuleClient client = new MuleClient(muleContext);
52          client.dispatch("vm://in3", "Important Message", null);
53          MuleMessage response = client.request("vm://out3", RECEIVE_TIMEOUT);
54          assertNotNull(response);
55          assertEquals("Important Message Received", response.getPayloadAsString());
56      }    
57  
58      public void testScriptVariables() throws Exception
59      {
60          MuleClient client = new MuleClient(muleContext);
61          client.dispatch("vm://in4", "Important Message", null);
62          MuleMessage response = client.request("vm://out4", RECEIVE_TIMEOUT);
63          assertNotNull(response);
64          assertEquals("Important Message Received A-OK", response.getPayloadAsString());
65      }    
66  }
67  
68