1   /*
2    * $Id: JXPathPropertyExtractorTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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.test.config;
12  
13  import org.mule.impl.MuleMessage;
14  import org.mule.tck.AbstractMuleTestCase;
15  import org.mule.tck.testmodels.fruit.Apple;
16  import org.mule.tck.testmodels.fruit.Banana;
17  import org.mule.tck.testmodels.fruit.FruitBowl;
18  import org.mule.util.properties.JXPathPropertyExtractor;
19  
20  public class JXPathPropertyExtractorTestCase 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          MuleMessage msg = new MuleMessage(payload);
29  
30          JXPathPropertyExtractor e = new JXPathPropertyExtractor();
31          Object value = e.getProperty("apple/washed", msg);
32          assertNotNull(value);
33          assertTrue(value instanceof Boolean);
34          assertTrue(((Boolean)value).booleanValue());
35  
36          value = e.getProperty("apple/washed", payload);
37          assertNotNull(value);
38          assertTrue(value instanceof Boolean);
39          assertTrue(((Boolean)value).booleanValue());
40  
41          value = e.getProperty("bar", msg);
42          assertNull(value);
43      }
44  }