View Javadoc

1   /*
2    * $Id: AbstractXmlPropertyExtractorTestCase.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.xml.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.NullPayload;
17  
18  public abstract class AbstractXmlPropertyExtractorTestCase extends FunctionalTestCase
19  {
20      private boolean matchSingle = true;
21  
22      protected AbstractXmlPropertyExtractorTestCase(boolean matchSingle)
23      {
24          this.matchSingle = matchSingle;
25      }
26  
27      protected abstract Object getMatchMessage() throws Exception;
28  
29      protected abstract Object getErrorMessage() throws Exception;
30  
31      protected String getConfigResources()
32      {
33          return "org/mule/module/xml/property-extractor-test.xml";
34      }
35  
36      public void testMatch() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39          client.dispatch("vm://in", getMatchMessage(), null);
40          MuleMessage message = client.request("vm://match1", RECEIVE_TIMEOUT);
41  
42          assertNotNull(message);
43          assertFalse(message.getPayload() instanceof NullPayload);
44          if(!matchSingle)
45          {
46              message = client.request("vm://match2", RECEIVE_TIMEOUT);
47              assertNotNull(message);
48              assertFalse(message.getPayload() instanceof NullPayload);
49          }
50      }
51      
52  
53      public void testError() throws Exception
54      {
55          MuleClient client = new MuleClient(muleContext);
56          client.dispatch("vm://in", getErrorMessage(), null);
57          MuleMessage message = client.request("vm://error", RECEIVE_TIMEOUT);
58          assertNotNull(message);
59          assertFalse(message.getPayload() instanceof NullPayload);
60      }
61      
62  }