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(ConfigVariant variant, String configResources)
26 {
27 super(variant, configResources, true);
28 }
29
30 @Override
31 protected Properties getStartUpProperties()
32 {
33 Properties p = new Properties();
34 p.setProperty("selector.expression", "/endpoint");
35 p.setProperty("selector.evaluator", "xpath");
36
37 return p;
38 }
39
40 @Override
41 protected Object getMatchMessage() throws ParserConfigurationException
42 {
43 return documentFor("matchingEndpoint1");
44 }
45
46 @Override
47 protected Object getErrorMessage() throws ParserConfigurationException
48 {
49 return documentFor("missingEndpoint");
50 }
51
52 protected Document documentFor(String name) throws ParserConfigurationException
53 {
54 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
55 Document doc = builder.newDocument();
56 Element endpoint = doc.createElement("endpoint");
57 endpoint.appendChild(doc.createTextNode(name));
58 doc.appendChild(endpoint);
59 return doc;
60 }
61
62 }