View Javadoc

1   /*
2    * $Id: Dom4jXPathExpressionWithNamespaceTestCase.java 22414 2011-07-14 13:24:46Z dirk.olmes $
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 java.text.MessageFormat;
14  import java.util.Properties;
15  
16  import org.dom4j.Document;
17  import org.dom4j.DocumentHelper;
18  
19  public class Dom4jXPathExpressionWithNamespaceTestCase extends AbstractXmlPropertyExtractorTestCase
20  {
21  
22      public static final String MESSAGE = "<foo:endpoint xmlns:foo=\"http://foo.com\">{0}</foo:endpoint>";
23  
24      public Dom4jXPathExpressionWithNamespaceTestCase(ConfigVariant variant, String configResources)
25      {
26          super(variant, configResources, true);
27      }
28  
29      @Override
30      protected Properties getStartUpProperties()
31      {
32          Properties p = new Properties();
33          p.setProperty("selector.expression", "/foo:endpoint");
34          p.setProperty("selector.evaluator", "xpath");
35  
36          return p;
37      }
38  
39      @Override
40      protected Object getMatchMessage() throws Exception
41      {
42          return documentFor("matchingEndpoint1");
43      }
44  
45      @Override
46      protected Object getErrorMessage() throws Exception
47      {
48          return documentFor("missingEndpoint");
49      }
50  
51      protected Document documentFor(String name) throws Exception
52      {
53          return DocumentHelper.parseText(MessageFormat.format(MESSAGE, name));
54  
55      }
56  
57  }