import junit.framework.*; import java.io.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.*; public class XmlTest extends TestCase{ public void testArv1(){ try{ Document d=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("puu.xml"); NodeList tabelid=d.getFirstChild().getChildNodes(); assertEquals(tabelid.getLength(), 3); } catch (Exception viga){viga.printStackTrace();} } public void testArv2(){ try{ BufferedReader sisse=new BufferedReader( new FileReader("puu.xml") ); int k=0; String rida=sisse.readLine(); while(rida!=null){ rida=sisse.readLine(); k++; } if(k==3){ assertEquals(k, 3); } sisse.close(); } catch (Exception viga){viga.printStackTrace();} } public static void main(String[] argumendid){ junit.textui.TestRunner.run(new TestSuite(XmlTest.class)); } } //javac -classpath junit.jar;. XmlTest.java //java -cp junit.jar;. XmlTest