001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2002, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.referencing;
018:
019: // J2SE dependencies
020: import java.io.FileNotFoundException;
021: import java.io.IOException;
022: import java.io.InputStreamReader;
023: import java.io.LineNumberReader;
024: import java.net.URL;
025:
026: // JUnit dependencies
027: import junit.framework.Test;
028: import junit.framework.TestCase;
029: import junit.framework.TestSuite;
030:
031: // OpenGIS dependencies
032: import org.opengis.referencing.FactoryException;
033: import org.opengis.referencing.operation.TransformException;
034:
035: // Geotools dependencies
036: import org.geotools.test.TestData;
037:
038: /**
039: * Run a test scripts. Scripts include a test suite provided by OpenGIS.
040: * Each script contains a list of source and target coordinates reference systems (in WKT),
041: * source coordinate points and expected coordinate points after the transformation from
042: * source CRS to target CRS.
043: * <p>
044: * This is probably the most important test case for the whole CRS module.
045: *
046: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/test/java/org/geotools/referencing/ScriptTest.java $
047: * @version $Id: ScriptTest.java 27848 2007-11-12 13:10:32Z desruisseaux $
048: * @author Yann Cézard
049: * @author Remi Eve
050: * @author Martin Desruisseaux
051: */
052: public final class ScriptTest extends TestCase {
053: /**
054: * Run all tests from the command line.
055: */
056: public static void main(final String[] args) throws Exception {
057: org.geotools.util.logging.Logging.GEOTOOLS
058: .forceMonolineConsoleOutput();
059: junit.textui.TestRunner.run(suite());
060: }
061:
062: /**
063: * Returns the test suite.
064: */
065: public static Test suite() {
066: return new TestSuite(ScriptTest.class);
067: }
068:
069: /**
070: * Constructs a test case with the given name.
071: */
072: public ScriptTest(final String name) {
073: super (name);
074: }
075:
076: /**
077: * Run the specified test script.
078: *
079: * @throws Exception If a test failed.
080: */
081: private void runScript(final String filename) throws Exception {
082: final LineNumberReader in = TestData.openReader(this , filename);
083: final TestScript test = new TestScript(in);
084: test.executeAll();
085: in.close();
086: }
087:
088: /**
089: * Run "AbridgedMolodensky.txt".
090: *
091: * @throws Exception If a test failed.
092: */
093: public void testAbridgedMolodesky() throws Exception {
094: runScript("scripts/AbridgedMolodensky.txt");
095: }
096:
097: /**
098: * Run "Molodensky.txt".
099: *
100: * @throws IOException If {@link #MT_MOLODENSKY_SCRIPT} can't be read.
101: * @throws FactoryException if a line can't be parsed.
102: * @throws TransformException if the transformation can't be run.
103: */
104: public void testMolodesky() throws Exception {
105: runScript("scripts/Molodensky.txt");
106: }
107:
108: /**
109: * Run "Simple.txt".
110: *
111: * @throws Exception If a test failed.
112: */
113: public void testSimple() throws Exception {
114: runScript("scripts/Simple.txt");
115: }
116:
117: /**
118: * Run "Projections.txt".
119: *
120: * @throws Exception If a test failed.
121: */
122: public void testProjections() throws Exception {
123: runScript("scripts/Projections.txt");
124: }
125:
126: /**
127: * Run "Mercator.txt".
128: *
129: * @throws Exception If a test failed.
130: */
131: public void testMercator() throws Exception {
132: runScript("scripts/Mercator.txt");
133: }
134:
135: /**
136: * Run the "ObliqueMercator.txt".
137: *
138: * @throws Exception If a test failed.
139: */
140: public void testObliqueMercator() throws Exception {
141: runScript("scripts/ObliqueMercator.txt");
142: }
143:
144: /**
145: * Run "TransverseMercator.txt".
146: *
147: * @throws Exception If a test failed.
148: */
149: public void testTransverseMercator() throws Exception {
150: runScript("scripts/TransverseMercator.txt");
151: }
152:
153: /**
154: * Run "AlbersEqualArea.txt"
155: *
156: * @throws Exception If a test failed.
157: */
158: public void testAlbersEqualArea() throws Exception {
159: runScript("scripts/AlbersEqualArea.txt");
160: }
161:
162: /**
163: * Run "LambertAzimuthalEqualArea.txt".
164: *
165: * @throws Exception If a test failed.
166: */
167: public void testLambertAzimuthalEqualArea() throws Exception {
168: runScript("scripts/LambertAzimuthalEqualArea.txt");
169: }
170:
171: /**
172: * Run "LambertConic.txt".
173: *
174: * @throws Exception If a test failed.
175: */
176: public void testLambertConic() throws Exception {
177: runScript("scripts/LambertConic.txt");
178: }
179:
180: /**
181: * Run "Stereographic.txt".
182: *
183: * @throws Exception If a test failed.
184: */
185: public void testStereographic() throws Exception {
186: runScript("scripts/Stereographic.txt");
187: }
188:
189: /**
190: * Run "Orthographic.txt".
191: *
192: * @throws Exception If a test failed.
193: */
194: public void testOrthographic() throws Exception {
195: runScript("scripts/Orthographic.txt");
196: }
197:
198: /**
199: * Run "NZMG.txt"
200: *
201: * @throws Exception If a test failed.
202: */
203: public void testNZMG() throws Exception {
204: runScript("scripts/NZMG.txt");
205: }
206:
207: /**
208: * Run "Krovak.txt"
209: *
210: * @throws Exception If a test failed.
211: */
212: public void testKrovak() throws Exception {
213: runScript("scripts/Krovak.txt");
214: }
215:
216: /**
217: * Run "OpenGIS.txt".
218: *
219: * @throws Exception If a test failed.
220: */
221: // public void testOpenGIS() throws Exception {
222: // runScript("scripts/OpenGIS.txt");
223: // }
224: /**
225: * Run "NADCON.txt"
226: *
227: * @throws Exception If a test failed.
228: */
229: // public void testNADCON() throws Exception {
230: // runScript("scripts/NADCON.txt");
231: // }
232: }
|