View Javadoc

1   /*
2    * $Id: BeanPropertyExtractorMultipleEndpointsTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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.ArrayList;
14  import java.util.List;
15  import java.util.Properties;
16  
17  public class BeanPropertyExtractorMultipleEndpointsTestCase extends AbstractXmlPropertyExtractorTestCase
18  {
19  
20      public BeanPropertyExtractorMultipleEndpointsTestCase()
21      {
22          super(false);
23      }
24  
25      protected Properties getStartUpProperties()
26      {
27          Properties p = new Properties();
28          p.setProperty("selector.expression", "endpointsHolder.endpoints");
29          p.setProperty("selector.evaluator", "bean");
30          return p;
31      }
32  
33      protected Object getMatchMessage()
34      {
35          //Model a simple bean graph. Path is: endpointsHolder.endpoints
36          List endpoints = new ArrayList(2);
37          endpoints.add("matchingEndpoint1");
38          endpoints.add("matchingEndpoint2");
39          return new TestRootBean(new EndpointsHolder(endpoints));
40      }
41  
42      protected Object getErrorMessage()
43      {
44          List endpoints = new ArrayList(1);
45          endpoints.add("missingEndpoint");
46          return new TestRootBean(new EndpointsHolder(endpoints));
47      }
48  
49      public class TestRootBean
50      {
51          private EndpointsHolder endpointsHolder;
52  
53          public TestRootBean(EndpointsHolder endpointsHolder)
54          {
55              this.endpointsHolder = endpointsHolder;
56          }
57  
58          public EndpointsHolder getEndpointsHolder()
59          {
60              return endpointsHolder;
61          }
62  
63          public void setEndpointsHolder(EndpointsHolder endpointsHolder)
64          {
65              this.endpointsHolder = endpointsHolder;
66          }
67      }
68  
69      public class EndpointsHolder
70      {
71          private List endpoints;
72  
73          public EndpointsHolder(List endpoints)
74          {
75              this.endpoints = endpoints;
76          }
77  
78          public List getEndpoints()
79          {
80              return endpoints;
81          }
82  
83          public void setEndpoints(List endpoints)
84          {
85              this.endpoints = endpoints;
86          }
87      }
88  
89  }