01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data.mif;
17:
18: import com.vividsolutions.jts.io.ParseException;
19: import junit.framework.TestCase;
20: import junit.framework.TestSuite;
21: import java.io.BufferedReader;
22: import java.io.File;
23: import java.io.FileReader;
24:
25: /**
26: * DOCUMENT ME!
27: *
28: * @author Luca S. Percich, AMA-MI
29: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/mif/src/test/java/org/geotools/data/mif/MIFFileTokenizerTest.java $
30: */
31: public class MIFFileTokenizerTest extends TestCase {
32: MIFFileTokenizer tok = null;
33:
34: /**
35: * DOCUMENT ME!
36: *
37: * @param args DOCUMENT ME!
38: *
39: * @throws Exception DOCUMENT ME!
40: */
41: public static void main(java.lang.String[] args) throws Exception {
42: junit.textui.TestRunner.run(new TestSuite(
43: MIFFileTokenizerTest.class));
44: }
45:
46: /*
47: * @see TestCase#setUp()
48: */
49: protected void setUp() throws Exception {
50: super .setUp();
51: tok = new MIFFileTokenizer(new BufferedReader(
52: new FileReader(new File(MIFTestUtils
53: .fileName("MIFFileTokenizer.txt")))));
54: }
55:
56: /*
57: * @see TestCase#tearDown()
58: */
59: protected void tearDown() throws Exception {
60: tok = null;
61: super .tearDown();
62: }
63:
64: /*
65: * Class under test for boolean readLine()
66: */
67: public void testReadLine() {
68: assertEquals(true, tok.readLine());
69:
70: try {
71: assertEquals("one", tok.getToken(' '));
72: assertEquals("two", tok.getToken(' '));
73: assertEquals("three", tok.getToken(' ', true, false));
74: assertEquals(2, tok.getLineNumber());
75: } catch (ParseException e) {
76: fail(e.getMessage());
77: }
78: }
79:
80: /**
81: * DOCUMENT ME!
82: */
83: public void testGetLineNumber() {
84: assertEquals(true, tok.readLine());
85: assertEquals(true, tok.readLine());
86: assertEquals(2, tok.getLineNumber());
87: }
88: }
|