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.bindings;
17:
18: import org.w3c.dom.Document;
19: import org.w3c.dom.Element;
20: import com.vividsolutions.jts.geom.Point;
21: import org.geotools.feature.Feature;
22: import org.geotools.gml2.TEST;
23: import org.geotools.gml2.TestConfiguration;
24: import org.geotools.xml.Binding;
25: import org.geotools.xml.Configuration;
26:
27: public class GMLAbstractFeatureTypeBindingTest extends GMLTestSupport {
28: protected Configuration createConfiguration() {
29: return new TestConfiguration();
30: }
31:
32: protected void registerNamespaces(Element root) {
33: super .registerNamespaces(root);
34: root.setAttribute("xmlns:test", TEST.NAMESPACE);
35: }
36:
37: public void testType() {
38: assertEquals(Feature.class, binding(GML.AbstractFeatureType)
39: .getType());
40: }
41:
42: public void testExectionMode() {
43: assertEquals(Binding.OVERRIDE, binding(GML.AbstractFeatureType)
44: .getExecutionMode());
45: }
46:
47: public void testParse() throws Exception {
48: Element feature = GML2MockData.feature(document, document);
49: feature.setAttributeNS(GML.NAMESPACE, "fid", "fid.1");
50:
51: Feature f = (Feature) parse();
52: assertNotNull(feature);
53:
54: assertEquals("fid.1", f.getID());
55:
56: Point p = (Point) f.getDefaultGeometry();
57: assertNotNull(p);
58: assertEquals(1.0, p.getX(), 0d);
59: assertEquals(2.0, p.getY(), 0d);
60:
61: Integer i = (Integer) f.getAttribute("count");
62: assertNotNull(i);
63: assertEquals(1, i.intValue());
64: }
65:
66: public void testEncode() throws Exception {
67: Document dom = encode(GML2MockData.feature(), TEST.TestFeature);
68:
69: assertEquals(1, dom.getElementsByTagName("gml:boundedBy")
70: .getLength());
71: assertEquals(1, dom.getElementsByTagName("test:geom")
72: .getLength());
73: assertEquals(1, dom.getElementsByTagName("test:count")
74: .getLength());
75: assertEquals(1, dom.getElementsByTagName("test:date")
76: .getLength());
77: }
78: }
|