View Javadoc

1   /*
2    * $Id: BeanPropertyExtractorTestCase.java 22414 2011-07-14 13:24:46Z dirk.olmes $
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 java.util.Properties;
14  
15  public class BeanPropertyExtractorTestCase extends AbstractXmlPropertyExtractorTestCase
16  {
17  
18      public BeanPropertyExtractorTestCase(ConfigVariant variant, String configResources)
19      {
20          super(variant, configResources, true);
21      }
22  
23      @Override
24      protected Properties getStartUpProperties()
25      {
26          Properties p = new Properties();
27          p.setProperty("selector.expression", "childBean.value");
28          p.setProperty("selector.evaluator", "bean");
29  
30          return p;
31      }
32  
33      @Override
34      protected Object getMatchMessage()
35      {
36          // Model a simple bean graph. Path is: childBean.value
37          return new TestRootBean(new TestValueBean("matchingEndpoint1"));
38      }
39  
40      @Override
41      protected Object getErrorMessage()
42      {
43          return new TestRootBean(new TestValueBean("missingEndpoint"));
44      }
45  
46      public class TestRootBean
47      {
48          private TestValueBean childBean;
49  
50          public TestRootBean(TestValueBean childBean)
51          {
52              this.childBean = childBean;
53          }
54  
55          public TestValueBean getChildBean()
56          {
57              return childBean;
58          }
59  
60          public void setChildBean(TestValueBean childBean)
61          {
62              this.childBean = childBean;
63          }
64      }
65  
66      public class TestValueBean
67      {
68          private String value;
69  
70          public TestValueBean(String value)
71          {
72              this.value = value;
73          }
74  
75          public String getValue()
76          {
77              return value;
78          }
79  
80          public void setValue(String value)
81          {
82              this.value = value;
83          }
84      }
85  
86  }