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.Properties;
10  
11  import javax.xml.parsers.DocumentBuilder;
12  import javax.xml.parsers.DocumentBuilderFactory;
13  import javax.xml.parsers.ParserConfigurationException;
14  
15  public class W3CDomPropertyExtractorMultipleEndpointsTestCase extends AbstractXmlPropertyExtractorTestCase
16  {
17  
18      public W3CDomPropertyExtractorMultipleEndpointsTestCase()
19      {
20          super(false);
21      }
22  
23      @Override
24      protected Properties getStartUpProperties()
25      {
26          Properties p = new Properties();
27          p.setProperty("selector.expression", "/endpoints/endpoint");
28          p.setProperty("selector.evaluator", "xpath");
29  
30          return p;
31      }
32  
33      @Override
34      protected Object getMatchMessage() throws ParserConfigurationException
35      {
36          DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
37          org.w3c.dom.Document doc = builder.newDocument();
38          org.w3c.dom.Element endpoints = doc.createElement("endpoints");
39          org.w3c.dom.Element endpoint = doc.createElement("endpoint");
40          endpoint.appendChild(doc.createTextNode("matchingEndpoint1"));
41          endpoints.appendChild(endpoint);
42          endpoint = doc.createElement("endpoint");
43          endpoint.appendChild(doc.createTextNode("matchingEndpoint2"));
44          endpoints.appendChild(endpoint);
45          doc.appendChild(endpoints);
46          return doc;
47      }
48  
49      @Override
50      protected Object getErrorMessage() throws ParserConfigurationException
51      {
52          DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
53          org.w3c.dom.Document doc = builder.newDocument();
54          org.w3c.dom.Element endpoint = doc.createElement("endpoint");
55          endpoint.appendChild(doc.createTextNode("missingEndpoint"));
56          doc.appendChild(endpoint);
57          return doc;
58      }
59  }