1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.xml.functional;
12
13 import java.util.Properties;
14
15 import javax.xml.parsers.DocumentBuilder;
16 import javax.xml.parsers.DocumentBuilderFactory;
17 import javax.xml.parsers.ParserConfigurationException;
18
19 public class W3CDomPropertyExtractorMultipleEndpointsTestCase extends AbstractXmlPropertyExtractorTestCase
20 {
21
22 public W3CDomPropertyExtractorMultipleEndpointsTestCase()
23 {
24 super(false);
25 }
26
27 protected Properties getStartUpProperties()
28 {
29 Properties p = new Properties();
30 p.setProperty("selector.expression", "/endpoints/endpoint");
31 p.setProperty("selector.evaluator", "xpath");
32
33 return p;
34 }
35
36 protected Object getMatchMessage() throws ParserConfigurationException
37 {
38 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
39 org.w3c.dom.Document doc = builder.newDocument();
40 org.w3c.dom.Element endpoints = doc.createElement("endpoints");
41 org.w3c.dom.Element endpoint = doc.createElement("endpoint");
42 endpoint.appendChild(doc.createTextNode("matchingEndpoint1"));
43 endpoints.appendChild(endpoint);
44 endpoint = doc.createElement("endpoint");
45 endpoint.appendChild(doc.createTextNode("matchingEndpoint2"));
46 endpoints.appendChild(endpoint);
47 doc.appendChild(endpoints);
48 return doc;
49 }
50
51 protected Object getErrorMessage() throws ParserConfigurationException
52 {
53 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
54 org.w3c.dom.Document doc = builder.newDocument();
55 org.w3c.dom.Element endpoint = doc.createElement("endpoint");
56 endpoint.appendChild(doc.createTextNode("missingEndpoint"));
57 doc.appendChild(endpoint);
58 return doc;
59 }
60
61 protected org.w3c.dom.Document documentFor(String name) throws ParserConfigurationException
62 {
63 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
64 org.w3c.dom.Document doc = builder.newDocument();
65 org.w3c.dom.Element endpoint = doc.createElement("endpoint");
66 endpoint.appendChild(doc.createTextNode(name));
67 doc.appendChild(endpoint);
68 return doc;
69 }
70
71 }