View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.xml.functional;
8   
9   import java.util.ArrayList;
10  import java.util.List;
11  import java.util.Properties;
12  
13  public class BeanPropertyExtractorMultipleEndpointsTestCase extends AbstractXmlPropertyExtractorTestCase
14  {
15  
16      public BeanPropertyExtractorMultipleEndpointsTestCase()
17      {
18          super(false);
19      }
20  
21      @Override
22      protected Properties getStartUpProperties()
23      {
24          Properties p = new Properties();
25          p.setProperty("selector.expression", "endpointsHolder.endpoints");
26          p.setProperty("selector.evaluator", "bean");
27          return p;
28      }
29  
30      @Override
31      protected Object getMatchMessage()
32      {
33          //Model a simple bean graph. Path is: endpointsHolder.endpoints
34          List<String> endpoints = new ArrayList<String>(2);
35          endpoints.add("matchingEndpoint1");
36          endpoints.add("matchingEndpoint2");
37          return new TestRootBean(new EndpointsHolder(endpoints));
38      }
39  
40      @Override
41      protected Object getErrorMessage()
42      {
43          List<String> endpoints = new ArrayList<String>(1);
44          endpoints.add("missingEndpoint");
45          return new TestRootBean(new EndpointsHolder(endpoints));
46      }
47  
48      public class TestRootBean
49      {
50          private EndpointsHolder endpointsHolder;
51  
52          public TestRootBean(EndpointsHolder endpointsHolder)
53          {
54              this.endpointsHolder = endpointsHolder;
55          }
56  
57          public EndpointsHolder getEndpointsHolder()
58          {
59              return endpointsHolder;
60          }
61  
62          public void setEndpointsHolder(EndpointsHolder endpointsHolder)
63          {
64              this.endpointsHolder = endpointsHolder;
65          }
66      }
67  
68      public class EndpointsHolder
69      {
70          private List<String> endpoints;
71  
72          public EndpointsHolder(List<String> endpoints)
73          {
74              this.endpoints = endpoints;
75          }
76  
77          public List<String> getEndpoints()
78          {
79              return endpoints;
80          }
81  
82          public void setEndpoints(List<String> endpoints)
83          {
84              this.endpoints = endpoints;
85          }
86      }
87  }