1   /*
2    * $Id: JXPathExpressionEvaluatorTestCase.java 11476 2008-03-21 22:47:59Z 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.xml.util.properties;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.module.xml.expression.JXPathExpressionEvaluator;
15  import org.mule.tck.AbstractMuleTestCase;
16  import org.mule.tck.testmodels.fruit.Apple;
17  import org.mule.tck.testmodels.fruit.Banana;
18  import org.mule.tck.testmodels.fruit.FruitBowl;
19  
20  public class JXPathExpressionEvaluatorTestCase extends AbstractMuleTestCase
21  {
22  
23      public void testWithExpressions()
24      {
25          Apple apple = new Apple();
26          apple.wash();
27          FruitBowl payload = new FruitBowl(apple, new Banana());
28          DefaultMuleMessage msg = new DefaultMuleMessage(payload);
29  
30          JXPathExpressionEvaluator e = new JXPathExpressionEvaluator();
31          Object value = e.evaluate("apple/washed", msg);
32          assertNotNull(value);
33          assertTrue(value instanceof Boolean);
34          assertTrue(((Boolean)value).booleanValue());
35  
36          value = e.evaluate("apple/washed", payload);
37          assertNotNull(value);
38          assertTrue(value instanceof Boolean);
39          assertTrue(((Boolean)value).booleanValue());
40  
41          value = e.evaluate("bar", msg);
42          assertNull(value);
43      }
44  }