1   /*
2    * $Id: GroovyRefreshableBeanTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
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.components.script.refreshable;
12  
13  
14  public class GroovyRefreshableBeanTestCase extends AbstractRefreshableBeanTestCase
15  {
16  
17      public static final String RECEIVED = "Received";
18      public static final String RECEIVED2 = "Received2";
19      public static final String PAYLOAD = "Test:";
20      public static final String NAME_CALLABLE = "groovy-dynamic-script-callable.groovy";
21      public static final String NAME_BEAN = "groovy-dynamic-script-bean.groovy";
22      public static final String NAME_CHANGE_INTERFACE = "groovy-dynamic-script.groovy";
23      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 + "\"; }}";
24      public static final String ON_CALL_RECEIVED2 = ON_CALL_RECEIVED.replaceAll(RECEIVED, RECEIVED2);
25      public static final String RECEIVE_RECEIVED = "public class GroovyDynamicScript { public String receive(String src) { return src + \"" + RECEIVED + "\"; }}";
26      public static final String RECEIVE_RECEIVED2 = RECEIVE_RECEIVED.replaceAll(RECEIVED, RECEIVED2);
27  
28      protected String getConfigResources()
29      {
30          return "groovy-refreshable-config.xml";
31      }
32  
33      public void testFirstOnCallRefresh() throws Exception
34      {
35          runScriptTest(ON_CALL_RECEIVED, NAME_CALLABLE, "vm://groovy_refresh_callable", PAYLOAD, RECEIVED);
36      }
37      
38      public void testCallFirstTest() throws Exception
39      {
40          testFirstOnCallRefresh();
41      }
42      
43      public void testSecondOnCallRefresh() throws Exception
44      {
45          runScriptTest(ON_CALL_RECEIVED2, NAME_CALLABLE, "vm://groovy_refresh_callable", PAYLOAD, RECEIVED2);
46      }
47  
48      public void testFirstPojoRefresh() throws Exception
49      {
50          runScriptTest(RECEIVE_RECEIVED, NAME_BEAN, "vm://groovy_refresh_bean", PAYLOAD, RECEIVED);
51      }
52      
53      public void testSecondPojoRefresh() throws Exception
54      {
55          runScriptTest(RECEIVE_RECEIVED2, NAME_BEAN, "vm://groovy_refresh_bean", PAYLOAD, RECEIVED2);
56      }
57      
58      public void testFirstChangeInterfaces() throws Exception
59      {
60          runScriptTest(ON_CALL_RECEIVED, NAME_CHANGE_INTERFACE, "vm://groovy_refresh_changeInterfaces", PAYLOAD, RECEIVED);
61      }
62      
63      public void testSecondChangeInterfaces() throws Exception
64      {
65          runScriptTest(RECEIVE_RECEIVED2, NAME_CHANGE_INTERFACE, "vm://groovy_refresh_changeInterfaces", PAYLOAD, RECEIVED2);
66      }
67  
68  }
69  
70  
71