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.gml3.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.gml3.GML3TestSupport;
23: import org.geotools.xml.Configuration;
24:
25: public class AbstractFeatureTypeBindingTest extends GML3TestSupport {
26: protected Configuration createConfiguration() {
27: return new TestConfiguration();
28: }
29:
30: protected void registerNamespaces(Element root) {
31: super .registerNamespaces(root);
32: root.setAttribute("xmlns:test", TEST.NAMESPACE);
33: }
34:
35: public void testWithoutGmlProperties() throws Exception {
36: Element feature = GML3MockData.feature(document, document);
37: feature.setAttributeNS(GML.NAMESPACE, "id", "fid.1");
38:
39: Feature f = (Feature) parse();
40: assertNotNull(feature);
41:
42: assertEquals("fid.1", f.getID());
43:
44: Point p = (Point) f.getDefaultGeometry();
45: assertNotNull(p);
46: assertEquals(1.0, p.getX(), 0d);
47: assertEquals(2.0, p.getY(), 0d);
48:
49: Integer i = (Integer) f.getAttribute("count");
50: assertNotNull(i);
51: assertEquals(1, i.intValue());
52: }
53:
54: public void testEncode() throws Exception {
55: Document dom = encode(GML3MockData.feature(), TEST.TestFeature);
56:
57: assertEquals(1, dom.getElementsByTagName("gml:boundedBy")
58: .getLength());
59: assertEquals(1, dom.getElementsByTagName("test:geom")
60: .getLength());
61: assertEquals(1, dom.getElementsByTagName("test:count")
62: .getLength());
63: assertEquals(1, dom.getElementsByTagName("test:date")
64: .getLength());
65: }
66: }
|