// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java
// public class XML {
// 
//     private static final String APACHE_INDENTATION = "{http://xml.apache.org/xslt}indent-amount";
// 
//     public static String toString(Node xml) {
//         try {
//             TransformerFactory f = TransformerFactory.newInstance();
//             Transformer t = f.newTransformer();
//             t.setOutputProperty(OutputKeys.INDENT, "yes");
//             t.setOutputProperty(APACHE_INDENTATION, "2");
//             OutputStream out = new ByteArrayOutputStream();
//             t.transform(new DOMSource(xml), new StreamResult(out));
//             return out.toString();
//         } catch (TransformerException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static String textContentOf(Element element) {
//         StringBuffer textContent = new StringBuffer(100);
//         NodeList children = element.getChildNodes();
//         for (int i = 0; i < children.getLength(); i++) {
//             appendTextContentOf(children.item(i), textContent);
//         }
//         return textContent.toString();
//     }
// 
//     private static void appendTextContentOf(Node from, StringBuffer to) {
//         if (from.getNodeType() == Node.ELEMENT_NODE) {
//             to.append(textContentOf((Element) from));
//         } else if (from.getNodeType() != Node.COMMENT_NODE) {
//             to.append(from.getNodeValue().trim());
//         }
//     }
// }


import java.util.List;
import junit.framework.Assert;
import net.sf.jsptest.utils.XML;
import org.jaxen.JaxenException;
import org.jaxen.dom.DOMXPath;
import org.w3c.dom.Element;
package net.sf.jsptest.assertion;


/**
 * Base class providing assertion methods related to the HTML DOM tree.
 * 
 * @author Lasse Koskela
 */
public abstract class DOMAssertion extends AbstractAssertion {

    protected Element context;

    /**
     * Returns the <tt>Element</tt> as the context of assertions.
     */
    public Element getElement() {
        return context;
    }

    /**
     * Assert that the selected DOM element contains the given text.
     * 
     * @param text
     *            The (partial) content that should be found.
     */
    public void shouldContain(String text) {
// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java
// public class XML {
// 
//     private static final String APACHE_INDENTATION = "{http://xml.apache.org/xslt}indent-amount";
// 
//     public static String toString(Node xml) {
//         try {
//             TransformerFactory f = TransformerFactory.newInstance();
//             Transformer t = f.newTransformer();
//             t.setOutputProperty(OutputKeys.INDENT, "yes");
//             t.setOutputProperty(APACHE_INDENTATION, "2");
//             OutputStream out = new ByteArrayOutputStream();
//             t.transform(new DOMSource(xml), new StreamResult(out));
//             return out.toString();
//         } catch (TransformerException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     public static String textContentOf(Element element) {
//         StringBuffer textContent = new StringBuffer(100);
//         NodeList children = element.getChildNodes();
//         for (int i = 0; i < children.getLength(); i++) {
//             appendTextContentOf(children.item(i), textContent);
//         }
//         return textContent.toString();
//     }
// 
//     private static void appendTextContentOf(Node from, StringBuffer to) {
//         if (from.getNodeType() == Node.ELEMENT_NODE) {
//             to.append(textContentOf((Element) from));
//         } else if (from.getNodeType() != Node.COMMENT_NODE) {
//             to.append(from.getNodeValue().trim());
//         }
//     }
// }


// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/DOMAssertion.java
import java.util.List;
import junit.framework.Assert;
import net.sf.jsptest.utils.XML;
import org.jaxen.JaxenException;
import org.jaxen.dom.DOMXPath;
import org.w3c.dom.Element;

package net.sf.jsptest.assertion;


/**
 * Base class providing assertion methods related to the HTML DOM tree.
 * 
 * @author Lasse Koskela
 */
public abstract class DOMAssertion extends AbstractAssertion {

    protected Element context;

    /**
     * Returns the <tt>Element</tt> as the context of assertions.
     */
    public Element getElement() {
        return context;
    }

    /**
     * Assert that the selected DOM element contains the given text.
     * 
     * @param text
     *            The (partial) content that should be found.
     */
    public void shouldContain(String text) {
        assertContains(XML.textContentOf(context), text);