@@ -0,0 +1,1990 @@
+package org.apache.jmeter.functions;%0A%0Aimport java.util.Collection;%0Aimport java.util.LinkedList;%0A%0Aimport org.apache.jmeter.engine.util.CompoundVariable;%0Aimport org.apache.jmeter.junit.JMeterTestCase;%0A%0Apublic class TestXPathFunction extends JMeterTestCase %7B%0A%0A    private XPath setupXPath(String file, String expr) throws Exception%7B%0A        Collection parms = new LinkedList();%0A        parms.add(new CompoundVariable(file));%0A        parms.add(new CompoundVariable(expr));%0A        XPath xp = new XPath();%0A        xp.setParameters(parms);%0A        return xp;        %0A    %7D%0A    %0A    public void testEmpty() throws Exception%7B%0A        XPath xp = setupXPath(%22%22,%22%22);%0A        String val=xp.execute();%0A        assertEquals(%22%22,val);%0A        val=xp.execute();%0A        assertEquals(%22%22,val);%0A        val=xp.execute();%0A        assertEquals(%22%22,val);%0A    %7D%0A    %0A    public void testNoFile() throws Exception%7B%0A        XPath xp = setupXPath(%22no-such-file%22,%22%22);%0A        String val=xp.execute();%0A        assertEquals(%22%22,val); // TODO - should check that error has been logged...%0A    %7D%0A    %0A    public void testFile1() throws Exception%7B%0A        XPath xp = setupXPath(%22testfiles/XPathTest.xml%22,%22//user/@username%22);%0A        assertEquals(%22u1%22,xp.execute());%0A        assertEquals(%22u2%22,xp.execute());%0A        assertEquals(%22u1%22,xp.execute());%0A    %7D%0A    %0A    public void testFile2() throws Exception%7B%0A        XPath xp1  = setupXPath(%22testfiles/XPathTest.xml%22,%22//user/@username%22);%0A        XPath xp1a = setupXPath(%22testfiles/XPathTest.xml%22,%22//user/@username%22);%0A        XPath xp2  = setupXPath(%22testfiles/XPathTest.xml%22,%22//user/@password%22);%0A        XPath xp2a = setupXPath(%22testfiles/XPathTest.xml%22,%22//user/@password%22);%0A        assertEquals(%22u1%22,xp1.execute());%0A        assertEquals(%22p1%22,xp2.execute());%0A        assertEquals(%22p2%22,xp2.execute());%0A        assertEquals(%22u2%22,xp1a.execute());%0A        assertEquals(%22u1%22,xp1.execute());%0A        assertEquals(%22u2%22,xp1.execute());%0A        assertEquals(%22p1%22,xp2a.execute());%0A%0A    %7D%0A%7D%0A

Add some tests for XPath function