1   /*
2    * $Id: AbstractXmlPropertyExtractorTestCase.java 11652 2008-04-28 17:41:29Z rossmason $
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.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      public static long WAIT_PERIOD = 5000L;
21  
22      private boolean matchSingle = true;
23  
24      protected AbstractXmlPropertyExtractorTestCase(boolean matchSingle)
25      {
26          this.matchSingle = matchSingle;
27      }
28  
29      protected abstract Object getMatchMessage() throws Exception;
30  
31      protected abstract Object getErrorMessage() throws Exception;
32  
33      protected String getConfigResources()
34      {
35          return "org/mule/module/xml/property-extractor-test.xml";
36      }
37  
38      public void testMatch() throws Exception
39      {
40          MuleClient client = new MuleClient();
41          client.dispatch("in", getMatchMessage(), null);
42          MuleMessage message = client.request("vm://match1?connector=queue", WAIT_PERIOD);
43          //TODO MULE-2620 Bean Evaluator tests return null here. but only on the build machine.
44          //Extending the WAIT_PERIOD didn't seem to affect it
45          assertNotNull(message);
46          assertFalse(message.getPayload() instanceof NullPayload);
47          if(!matchSingle)
48          {
49              message = client.request("vm://match2?connector=queue", WAIT_PERIOD);
50              assertNotNull(message);
51              assertFalse(message.getPayload() instanceof NullPayload);
52          }
53      }
54      
55  
56      public void testError() throws Exception
57      {
58          MuleClient client = new MuleClient();
59          client.dispatch("in", getErrorMessage(), null);
60          MuleMessage message = client.request("vm://error?connector=queue", WAIT_PERIOD);
61          assertNotNull(message);
62          assertFalse(message.getPayload() instanceof NullPayload);
63      }
64      
65  }