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("nimistu.xml"); NodeList tabelid=d.getFirstChild().getChildNodes(); assertEquals(tabelid.getLength(), 2); } catch (Exception viga){viga.printStackTrace();} } public void testArv2(){ try{ BufferedReader sisse=new BufferedReader( new FileReader("nimistu.xml") ); int k=0; String rida=sisse.readLine(); while(rida!=null){ rida=sisse.readLine(); k++; } if(k==2){ assertEquals(k, 2); } 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 */