1
2
3
4
5
6
7
8
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
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