1
2
3
4
5
6
7
8
9
10
11 package org.mule.components.script.refreshable;
12
13
14 import java.util.Arrays;
15 import java.util.Collection;
16
17 import org.junit.Test;
18 import org.junit.runners.Parameterized.Parameters;
19
20 public class GroovyRefreshableBeanTestCase extends AbstractRefreshableBeanTestCase
21 {
22 public static final String RECEIVED = "Received";
23 public static final String RECEIVED2 = "Received2";
24 public static final String PAYLOAD = "Test:";
25 public static final String NAME_CALLABLE = "groovy-dynamic-script-callable.groovy";
26 public static final String NAME_BEAN = "groovy-dynamic-script-bean.groovy";
27 public static final String NAME_CHANGE_INTERFACE = "groovy-dynamic-script.groovy";
28 public static final String ON_CALL_RECEIVED = "import org.mule.api.MuleEventContext; import org.mule.api.lifecycle.Callable; public class GroovyDynamicScript implements Callable { public Object onCall(MuleEventContext eventContext) throws Exception{ return eventContext.getMessage().getPayloadAsString() + \"" + RECEIVED + "\"; }}";
29 public static final String ON_CALL_RECEIVED2 = ON_CALL_RECEIVED.replaceAll(RECEIVED, RECEIVED2);
30 public static final String RECEIVE_RECEIVED = "public class GroovyDynamicScript { public String receive(String src) { return src + \"" + RECEIVED + "\"; }}";
31 public static final String RECEIVE_RECEIVED2 = RECEIVE_RECEIVED.replaceAll(RECEIVED, RECEIVED2);
32
33 public GroovyRefreshableBeanTestCase(ConfigVariant variant, String configResources)
34 {
35 super(variant, configResources);
36 }
37
38 @Parameters
39 public static Collection<Object[]> parameters()
40 {
41 return Arrays.asList(new Object[][]{
42 {ConfigVariant.SERVICE, "groovy-refreshable-config-service.xml"},
43 {ConfigVariant.FLOW, "groovy-refreshable-config-flow.xml"}
44 });
45 }
46
47 @Test
48 public void testFirstOnCallRefresh() throws Exception
49 {
50 runScriptTest(ON_CALL_RECEIVED, NAME_CALLABLE, "vm://groovy_refresh_callable", PAYLOAD, RECEIVED);
51 }
52
53 @Test
54 public void testCallFirstTest() throws Exception
55 {
56 testFirstOnCallRefresh();
57 }
58
59 @Test
60 public void testSecondOnCallRefresh() throws Exception
61 {
62 runScriptTest(ON_CALL_RECEIVED2, NAME_CALLABLE, "vm://groovy_refresh_callable", PAYLOAD, RECEIVED2);
63 }
64
65 @Test
66 public void testFirstPojoRefresh() throws Exception
67 {
68 runScriptTest(RECEIVE_RECEIVED, NAME_BEAN, "vm://groovy_refresh_bean", PAYLOAD, RECEIVED);
69 }
70
71 @Test
72 public void testSecondPojoRefresh() throws Exception
73 {
74 runScriptTest(RECEIVE_RECEIVED2, NAME_BEAN, "vm://groovy_refresh_bean", PAYLOAD, RECEIVED2);
75 }
76
77 @Test
78 public void testFirstChangeInterfaces() throws Exception
79 {
80 runScriptTest(ON_CALL_RECEIVED, NAME_CHANGE_INTERFACE, "vm://groovy_refresh_changeInterfaces", PAYLOAD, RECEIVED);
81 }
82
83 @Test
84 public void testSecondChangeInterfaces() throws Exception
85 {
86 runScriptTest(RECEIVE_RECEIVED2, NAME_CHANGE_INTERFACE, "vm://groovy_refresh_changeInterfaces", PAYLOAD, RECEIVED2);
87 }
88
89 }
90
91
92