1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.xml.functional;
12
13 import java.util.Arrays;
14 import java.util.Collection;
15
16 import javax.xml.parsers.DocumentBuilder;
17 import javax.xml.parsers.DocumentBuilderFactory;
18 import javax.xml.parsers.ParserConfigurationException;
19
20 import org.junit.runners.Parameterized.Parameters;
21 import org.w3c.dom.Document;
22 import org.w3c.dom.Element;
23
24 public class W3CDomPropertyExtractorStaticTestCase extends AbstractXmlPropertyExtractorTestCase
25 {
26 public W3CDomPropertyExtractorStaticTestCase(ConfigVariant variant, String configResources)
27 {
28 super(variant, configResources, true);
29 }
30
31 @Parameters
32 public static Collection<Object[]> parameters()
33 {
34 return Arrays.asList(new Object[][]{
35 {ConfigVariant.SERVICE, "org/mule/module/xml/property-extractor-static-test-service.xml"},
36 {ConfigVariant.FLOW, "org/mule/module/xml/property-extractor-static-test-flow.xml"}});
37 }
38
39 @Override
40 protected Object getMatchMessage() throws ParserConfigurationException
41 {
42 return documentFor("matchingEndpoint1");
43 }
44
45 @Override
46 protected Object getErrorMessage() throws ParserConfigurationException
47 {
48 return documentFor("missingEndpoint");
49 }
50
51 protected Document documentFor(String nodeName) throws ParserConfigurationException
52 {
53 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
54 Document doc = builder.newDocument();
55 Element endpoint = doc.createElement("endpoint");
56 endpoint.appendChild(doc.createTextNode(nodeName));
57 doc.appendChild(endpoint);
58 return doc;
59 }
60 }