View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.scripting.filter;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  import static org.junit.Assert.assertNull;
18  
19  public class GroovyScriptFilterFunctionalTestCase extends FunctionalTestCase
20  {
21  
22      public GroovyScriptFilterFunctionalTestCase()
23      {
24          // Groovy really hammers the startup time since it needs to create the
25          // interpreter on every start
26          setDisposeContextPerClass(true);
27      }
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "groovy-filter-config.xml";
33      }
34  
35      @Test
36      public void testFilterScript() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39          client.dispatch("vm://in1", "hello", null);
40          MuleMessage response = client.request("vm://out1", RECEIVE_TIMEOUT);
41          assertNotNull(response);
42          assertEquals("hello", response.getPayload());
43  
44          client.dispatch("vm://in1", "1", null);
45          response = client.request("vm://out1", RECEIVE_TIMEOUT);
46          assertNull(response);
47      }
48  }