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