import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.*;
import java.util.*;

public class Tester extends TestCase implements myoPyx.Listener {
	public Tester( String n ) {
		super(n);
	}
	public void testValidate() {
		try {
			InputStreamReader reader = new InputStreamReader(new FileInputStream("cities.pyx"));
			myoPyx p = new myoPyx();
			p.parse( reader );
		} catch (Exception e) {
			fail("Error while parsing.\n"+e.getMessage());
		}
	}
	public void testParse() {
		try {
			InputStreamReader reader = new InputStreamReader(new FileInputStream("cities.pyx"));
			myoPyx p = new myoPyx();
			p.addListener( null, this );
			p.parse( reader );
		} catch (Exception e) {
			fail("Error while parsing.\n"+e.getMessage());
		}
	}
	public void testBadTagOrder() {
		try {
			InputStreamReader reader = new InputStreamReader(new FileInputStream("bad1.pyx"));
			myoPyx p = new myoPyx();
			p.parse( reader );
			fail("Should have gotten a bad tag error!");
		} catch (Exception e) {
			// This is the correct behavior
		}
	}
	public void testBadContent() {
		try {
			InputStreamReader reader = new InputStreamReader(new FileInputStream("bad2.pyx"));
			myoPyx p = new myoPyx();
			p.parse( reader );
			fail("Should have gotten a bad markup error!");
		} catch (Exception e) {
			// This is the correct behavior
		}
	}
	
	public static Test suite() {
		return new TestSuite( Tester.class );
	}

	private int _count = 0;
	public void startElement( String name, HashMap attributes ) {
		if (name.equals("Continent"))
			_count++;
	}
	public void endElement( String name ) {
	}
	public void text( String txt ) {
	}
}
