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