View Javadoc

1   /*
2    * $Id: W3CDomPropertyExtractorStaticTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.xml.functional;
12  
13  import javax.xml.parsers.DocumentBuilder;
14  import javax.xml.parsers.DocumentBuilderFactory;
15  import javax.xml.parsers.ParserConfigurationException;
16  
17  import org.w3c.dom.Document;
18  import org.w3c.dom.Element;
19  
20  public class W3CDomPropertyExtractorStaticTestCase extends AbstractXmlPropertyExtractorTestCase
21  {
22  
23      public W3CDomPropertyExtractorStaticTestCase()
24      {
25          super(true);
26      }
27  
28      protected String getConfigResources()
29      {
30          return "org/mule/module/xml/property-extractor-static-test.xml";
31      }
32  
33      protected Object getMatchMessage() throws ParserConfigurationException
34      {
35          return documentFor("matchingEndpoint1");
36      }
37  
38      protected Object getErrorMessage() throws ParserConfigurationException
39      {
40          return documentFor("missingEndpoint");
41      }
42  
43      protected Document documentFor(String name) throws ParserConfigurationException
44      {
45          DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
46          Document doc = builder.newDocument();
47          Element endpoint = doc.createElement("endpoint");
48          endpoint.appendChild(doc.createTextNode(name));
49          doc.appendChild(endpoint);
50          return doc;
51      }
52  
53  }