01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-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.gml2;
17:
18: import junit.framework.TestCase;
19: import javax.xml.parsers.SAXParserFactory;
20: import com.vividsolutions.jts.geom.GeometryCollection;
21: import com.vividsolutions.jts.geom.LineString;
22: import com.vividsolutions.jts.geom.Point;
23: import com.vividsolutions.jts.geom.Polygon;
24: import org.geotools.xml.Configuration;
25: import org.geotools.xml.Parser;
26:
27: public class GMLGeometryTest extends TestCase {
28: Parser parser;
29:
30: protected void setUp() throws Exception {
31: SAXParserFactory spf = SAXParserFactory.newInstance();
32:
33: spf.setNamespaceAware(true);
34:
35: Configuration configuration = new GMLConfiguration();
36:
37: parser = new Parser(configuration, getClass()
38: .getResourceAsStream("geometry.xml"));
39: }
40:
41: public void test() throws Exception {
42: GeometryCollection gc = (GeometryCollection) parser.parse();
43:
44: assertEquals(gc.getNumGeometries(), 3);
45:
46: Object o = gc.getGeometryN(0);
47: assertNotNull(o);
48: assertTrue(o instanceof Point);
49:
50: o = gc.getGeometryN(1);
51: assertNotNull(o);
52: assertTrue(o instanceof LineString);
53:
54: o = gc.getGeometryN(2);
55: assertNotNull(o);
56: assertTrue(o instanceof Polygon);
57: }
58: }
|