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.LineString;
22: import com.vividsolutions.jts.geom.MultiLineString;
23: import org.geotools.xml.ElementInstance;
24: import org.geotools.xml.Node;
25:
26: public class GMLMultiLineStringPropertyTypeBindingTest 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: "myMultiLineStringProperty",
36: GML.MULTILINESTRINGPROPERTYTYPE, null);
37: geometry = createElement(GML.NAMESPACE, "myMultiLineString",
38: GML.MULTILINESTRINGTYPE, null);
39:
40: container = new DefaultPicoContainer();
41: container
42: .registerComponentImplementation(GeometryFactory.class);
43: container
44: .registerComponentImplementation(GMLGeometryAssociationTypeBinding.class);
45: container
46: .registerComponentImplementation(GMLMultiLineStringPropertyTypeBinding.class);
47: }
48:
49: public void testWithGeometry() throws Exception {
50: LineString p1 = new GeometryFactory()
51: .createLineString(new Coordinate[] {
52: new Coordinate(0, 0), new Coordinate(1, 1) });
53: LineString p2 = new GeometryFactory()
54: .createLineString(new Coordinate[] {
55: new Coordinate(2, 2), new Coordinate(3, 3) });
56:
57: Node node = createNode(association,
58: new ElementInstance[] { geometry },
59: new Object[] { new GeometryFactory()
60: .createMultiLineString(new LineString[] { p1,
61: p2 }) }, null, null);
62:
63: GMLGeometryAssociationTypeBinding s = (GMLGeometryAssociationTypeBinding) container
64: .getComponentInstanceOfType(GMLGeometryAssociationTypeBinding.class);
65:
66: GMLMultiLineStringPropertyTypeBinding s1 = (GMLMultiLineStringPropertyTypeBinding) container
67: .getComponentInstanceOfType(GMLMultiLineStringPropertyTypeBinding.class);
68:
69: MultiLineString p = (MultiLineString) s1.parse(association,
70: node, s.parse(association, node, null));
71: assertNotNull(p);
72: }
73: }
|