org.mule.module.xml.functional.Dom4jXPathExpressionWithNamespaceTestCase.java Source code

Java tutorial

Introduction

Here is the source code for org.mule.module.xml.functional.Dom4jXPathExpressionWithNamespaceTestCase.java

Source

/*
 * $Id$
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.module.xml.functional;

import java.text.MessageFormat;
import java.util.Properties;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;

public class Dom4jXPathExpressionWithNamespaceTestCase extends AbstractXmlPropertyExtractorTestCase {

    public static final String MESSAGE = "<foo:endpoint xmlns:foo=\"http://foo.com\">{0}</foo:endpoint>";

    public Dom4jXPathExpressionWithNamespaceTestCase(ConfigVariant variant, String configResources) {
        super(variant, configResources, true);
    }

    @Override
    protected Properties getStartUpProperties() {
        Properties p = new Properties();
        p.setProperty("selector.expression", "/foo:endpoint");
        p.setProperty("selector.evaluator", "xpath");

        return p;
    }

    @Override
    protected Object getMatchMessage() throws Exception {
        return documentFor("matchingEndpoint1");
    }

    @Override
    protected Object getErrorMessage() throws Exception {
        return documentFor("missingEndpoint");
    }

    protected Document documentFor(String name) throws Exception {
        return DocumentHelper.parseText(MessageFormat.format(MESSAGE, name));

    }

}