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 com.vividsolutions.jts.geom.Coordinate;
19: import com.vividsolutions.jts.geom.Geometry;
20: import com.vividsolutions.jts.geom.GeometryFactory;
21: import com.vividsolutions.jts.geom.Point;
22: import org.geotools.xml.ElementInstance;
23: import org.geotools.xml.Node;
24:
25: public class GMLGeometryAssociationTypeBindingTest extends
26: AbstractGMLBindingTest {
27: ElementInstance association;
28: ElementInstance geometry;
29:
30: protected void setUp() throws Exception {
31: super .setUp();
32:
33: association = createElement(GML.NAMESPACE, "myAssociation",
34: GML.GEOMETRYASSOCIATIONTYPE, null);
35: geometry = createElement(GML.NAMESPACE, "myGeometry",
36: GML.ABSTRACTGEOMETRYTYPE, null);
37: }
38:
39: public void testWithGeometry() throws Exception {
40: Node node = createNode(association,
41: new ElementInstance[] { geometry },
42: new Object[] { new GeometryFactory()
43: .createPoint(new Coordinate(0, 0)) }, null,
44: null);
45: GMLGeometryAssociationTypeBinding s = (GMLGeometryAssociationTypeBinding) getBinding(GML.GEOMETRYASSOCIATIONTYPE);
46: Geometry g = (Geometry) s.parse(association, node, null);
47: assertNotNull(g);
48: assertTrue(g instanceof Point);
49: }
50:
51: public void testWithoutGeometry() throws Exception {
52: Node node = createNode(association, null, null, null, null);
53: GMLGeometryAssociationTypeBinding s = (GMLGeometryAssociationTypeBinding) getBinding(GML.GEOMETRYASSOCIATIONTYPE);
54:
55: try {
56: s.parse(association, node, null);
57: } catch (Exception e) {
58: //ok
59: }
60: }
61: }
|