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.picocontainer.defaults.DefaultPicoContainer;
19: import com.vividsolutions.jts.geom.Coordinate;
20: import com.vividsolutions.jts.geom.GeometryFactory;
21: import com.vividsolutions.jts.geom.MultiPoint;
22: import com.vividsolutions.jts.geom.Point;
23: import org.geotools.xml.ElementInstance;
24: import org.geotools.xml.Node;
25:
26: public class GMLMultiPointPropertyTypeBindingTest extends
27: AbstractGMLBindingTest {
28: ElementInstance association;
29: ElementInstance geometry;
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33:
34: association = createElement(GML.NAMESPACE,
35: "myMultiPointProperty", GML.MULTIPOINTPROPERTYTYPE,
36: null);
37: geometry = createElement(GML.NAMESPACE, "myMultiPoint",
38: GML.MULTIPOINTTYPE, null);
39:
40: container = new DefaultPicoContainer();
41: container
42: .registerComponentImplementation(GeometryFactory.class);
43: container
44: .registerComponentImplementation(GMLGeometryAssociationTypeBinding.class);
45: container
46: .registerComponentImplementation(GMLMultiPointPropertyTypeBinding.class);
47: }
48:
49: public void testWithGeometry() throws Exception {
50: Point p1 = new GeometryFactory().createPoint(new Coordinate(0,
51: 0));
52: Point p2 = new GeometryFactory().createPoint(new Coordinate(1,
53: 1));
54:
55: Node node = createNode(association,
56: new ElementInstance[] { geometry },
57: new Object[] { new GeometryFactory()
58: .createMultiPoint(new Point[] { p1, p2 }) },
59: null, null);
60:
61: GMLGeometryAssociationTypeBinding s = (GMLGeometryAssociationTypeBinding) container
62: .getComponentInstanceOfType(GMLGeometryAssociationTypeBinding.class);
63:
64: GMLMultiPointPropertyTypeBinding s1 = (GMLMultiPointPropertyTypeBinding) container
65: .getComponentInstanceOfType(GMLMultiPointPropertyTypeBinding.class);
66:
67: MultiPoint p = (MultiPoint) s1.parse(association, node, s
68: .parse(association, node, null));
69: assertNotNull(p);
70: }
71: }
|