001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.xml;
017:
018: import java.io.File;
019: import java.io.IOException;
020: import java.net.URI;
021: import java.util.logging.Level;
022:
023: import javax.xml.parsers.SAXParser;
024: import javax.xml.parsers.SAXParserFactory;
025:
026: import org.geotools.test.TestData;
027: import org.xml.sax.SAXException;
028:
029: import junit.framework.TestCase;
030:
031: /**
032: * <p>
033: * Big dataset tests ... more than you want for regular testing
034: * </p>
035: * @
036: *
037: * @author dzwiers www.refractions.net
038: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/test/java/org/geotools/xml/GMLParser2Test.java $
039: */
040: public class GMLParser2Test extends TestCase {
041: public void testBlank() {
042: // blank test ... lets it sit in the repository
043: }
044:
045: public void testFMEPostalFeatures() throws SAXException,
046: IOException {
047: try {
048: SAXParserFactory spf = SAXParserFactory.newInstance();
049: spf.setNamespaceAware(true);
050: spf.setValidating(false);
051:
052: SAXParser parser = spf.newSAXParser();
053:
054: String path = "city/dj.xml";
055: File f = TestData.file(this , path);
056: URI u = f.toURI();
057:
058: XMLSAXHandler xmlContentHandler = new XMLSAXHandler(u, null);
059: XMLSAXHandler.setLogLevel(Level.WARNING);
060: XSISAXHandler.setLogLevel(Level.WARNING);
061: XMLElementHandler.setLogLevel(Level.WARNING);
062: XSIElementHandler.setLogLevel(Level.WARNING);
063:
064: parser.parse(f, xmlContentHandler);
065:
066: Object doc = xmlContentHandler.getDocument();
067: assertNotNull("Document missing", doc);
068: //System.out.println(doc);
069: } catch (Throwable e) {
070: e.printStackTrace();
071: fail(e.toString());
072: }
073: }
074:
075: // public void testFMEPostalFeatures() throws SAXException, IOException {
076: // try {
077: // SAXParserFactory spf = SAXParserFactory.newInstance();
078: // spf.setNamespaceAware(true);
079: // spf.setValidating(false);
080: //
081: // SAXParser parser = spf.newSAXParser();
082: //
083: // String path = "fme/postal/postal.gml";
084: // File f = TestData.file(this,path);
085: // URI u = f.toURI();
086: //
087: // XMLSAXHandler xmlContentHandler = new XMLSAXHandler(u,null);
088: // XMLSAXHandler.setLogLevel(Level.WARNING);
089: // XSISAXHandler.setLogLevel(Level.WARNING);
090: // XMLElementHandler.setLogLevel(Level.WARNING);
091: // XSIElementHandler.setLogLevel(Level.WARNING);
092: //
093: // parser.parse(f, xmlContentHandler);
094: //
095: // Object doc = xmlContentHandler.getDocument();
096: // assertNotNull("Document missing", doc);
097: // System.out.println(doc);
098: //
099: // Object[] objs = (Object[])doc;
100: //
101: // assertTrue("Should have 95054 features + 1 bbox : "+objs.length,objs.length == 95055);
102: //
103: // } catch (Throwable e) {
104: // e.printStackTrace();
105: // fail(e.toString());
106: // }
107: // }
108: //
109: // public void testFMEFedCenFeatures() throws SAXException, IOException {
110: // try {
111: // SAXParserFactory spf = SAXParserFactory.newInstance();
112: // spf.setNamespaceAware(true);
113: // spf.setValidating(false);
114: //
115: // SAXParser parser = spf.newSAXParser();
116: //
117: // String path = "fme/fed-cen/fed308_a.gml";
118: // File f = TestData.file(this,path);
119: // URI u = f.toURI();
120: //
121: // XMLSAXHandler xmlContentHandler = new XMLSAXHandler(u,null);
122: // XMLSAXHandler.setLogLevel(Level.WARNING);
123: // XSISAXHandler.setLogLevel(Level.WARNING);
124: // XMLElementHandler.setLogLevel(Level.WARNING);
125: // XSIElementHandler.setLogLevel(Level.WARNING);
126: //
127: // parser.parse(f, xmlContentHandler);
128: //
129: // Object doc = xmlContentHandler.getDocument();
130: // assertNotNull("Document missing", doc);
131: // System.out.println(doc);
132: //
133: // Object[] objs = (Object[])doc;
134: //
135: // assertTrue("Should have N features + 1 bbox : "+objs.length,objs.length > 2);
136: //
137: // } catch (Throwable e) {
138: // e.printStackTrace();
139: // fail(e.toString());
140: // }
141: // }
142: //
143: // public void testFMEForestFeatures() throws SAXException, IOException {
144: // try {
145: // SAXParserFactory spf = SAXParserFactory.newInstance();
146: // spf.setNamespaceAware(true);
147: // spf.setValidating(false);
148: //
149: // SAXParser parser = spf.newSAXParser();
150: //
151: // String path = "fme/forest_districts/forest-districts-2003-04.gml";
152: // File f = TestData.file(this,path);
153: // URI u = f.toURI();
154: //
155: // XMLSAXHandler xmlContentHandler = new XMLSAXHandler(u,null);
156: // XMLSAXHandler.setLogLevel(Level.WARNING);
157: // XSISAXHandler.setLogLevel(Level.WARNING);
158: // XMLElementHandler.setLogLevel(Level.WARNING);
159: // XSIElementHandler.setLogLevel(Level.WARNING);
160: //
161: // parser.parse(f, xmlContentHandler);
162: //
163: // Object doc = xmlContentHandler.getDocument();
164: // assertNotNull("Document missing", doc);
165: // System.out.println(doc);
166: //
167: // Object[] objs = (Object[])doc;
168: //
169: // assertTrue("Should have N features + 1 bbox : "+objs.length,objs.length > 2);
170: //
171: // } catch (Throwable e) {
172: // e.printStackTrace();
173: // fail(e.toString());
174: // }
175: // }
176: //
177: // public void testFMEVictoriaFeatures() throws SAXException, IOException {
178: // try {
179: // SAXParserFactory spf = SAXParserFactory.newInstance();
180: // spf.setNamespaceAware(true);
181: // spf.setValidating(false);
182: //
183: // SAXParser parser = spf.newSAXParser();
184: //
185: // String path = "fme/victoria/victoria.gml";
186: // File f = TestData.file(this,path);
187: // URI u = f.toURI();
188: //
189: // XMLSAXHandler xmlContentHandler = new XMLSAXHandler(u,null);
190: // XMLSAXHandler.setLogLevel(Level.WARNING);
191: // XSISAXHandler.setLogLevel(Level.WARNING);
192: // XMLElementHandler.setLogLevel(Level.WARNING);
193: // XSIElementHandler.setLogLevel(Level.WARNING);
194: //
195: // parser.parse(f, xmlContentHandler);
196: //
197: // Object doc = xmlContentHandler.getDocument();
198: // assertNotNull("Document missing", doc);
199: // System.out.println(doc);
200: //
201: // Object[] objs = (Object[])doc;
202: //
203: // assertTrue("Should have N features + 1 bbox : "+objs.length,objs.length > 2);
204: //
205: // } catch (Throwable e) {
206: // e.printStackTrace();
207: // fail(e.toString());
208: // }
209: // }
210: }
|