View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.xml.functional;
8   
9   import java.text.MessageFormat;
10  import java.util.Properties;
11  
12  import org.dom4j.Document;
13  import org.dom4j.DocumentHelper;
14  
15  public class Dom4jXPathExpressionWithNamespaceTestCase extends AbstractXmlPropertyExtractorTestCase
16  {
17  
18      public static final String MESSAGE = "<foo:endpoint xmlns:foo=\"http://foo.com\">{0}</foo:endpoint>";
19  
20      public Dom4jXPathExpressionWithNamespaceTestCase()
21      {
22          super(true);
23      }
24  
25      @Override
26      protected Properties getStartUpProperties()
27      {
28          Properties p = new Properties();
29          p.setProperty("selector.expression", "/foo:endpoint");
30          p.setProperty("selector.evaluator", "xpath");
31  
32          return p;
33      }
34  
35      @Override
36      protected Object getMatchMessage() throws Exception
37      {
38          return documentFor("matchingEndpoint1");
39      }
40  
41      @Override
42      protected Object getErrorMessage() throws Exception
43      {
44          return documentFor("missingEndpoint");
45      }
46  
47      protected Document documentFor(String name) throws Exception
48      {
49          return DocumentHelper.parseText(MessageFormat.format(MESSAGE, name));
50  
51      }
52  
53  }