XPath in a JUnit test

import org.xml.sax.InputSource;
import javax.xml.xpath.*;

import junit.framework.*;
import java.io.*;

public class PListXPathTest extends TestCase {

    private InputSource plist;
    private XPath query;
    
    protected void setUp() throws IOException {
        plist = new InputSource(new FileInputStream("thunderbirdplist.xml"));      
        query = XPathFactory.newInstance().newXPath();
    }
    
    public void testNoTwoKeyElementsAreAdjacent() 
      throws XPathExpressionException {
       // //key/following-sibling::*[1]/self::key is empty
       
       Boolean result = (Boolean) query.evaluate(
         "//key/following-sibling::*[1]/self::key", 
         plist, XPathConstants.BOOLEAN);
       assertFalse(result.booleanValue());
        
    }

}

Previous | Next | Top | Cafe con Leche

Copyright 2005, 2006 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified August 16, 2005