001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
006: * This code is licensed under the GPL 2.0 license, availible at the root
007: * application directory.
008: */
009: package org.vfny.geoserver.global.dto;
010:
011: import junit.framework.TestCase;
012:
013: import org.vfny.geoserver.global.xml.GMLSchemaTranslator;
014: import org.vfny.geoserver.global.xml.NameSpaceTranslatorFactory;
015: import org.vfny.geoserver.global.xml.XMLSchemaTranslator;
016:
017: /**
018: * @author Jody Garnett
019: *
020: * To change the template for this generated type comment go to
021: * Window - Preferences - Java - Code Generation - Code and Comments
022: */
023: public class DataTransferObjectFactoryTest extends TestCase {
024: XMLSchemaTranslator xs = (XMLSchemaTranslator) NameSpaceTranslatorFactory
025: .getInstance().getNameSpaceTranslator("xs");
026: GMLSchemaTranslator gml = (GMLSchemaTranslator) NameSpaceTranslatorFactory
027: .getInstance().getNameSpaceTranslator("gml");
028:
029: public DataTransferObjectFactoryTest(String name) {
030: super (name);
031: }
032:
033: protected void assertString(String expected, Object value) {
034: assertEquals(expected, String.valueOf(value));
035: }
036:
037: // public void testPointPropertyTypeMappings() {
038: // Set expected = new HashSet();
039: // NameSpaceElement nse = null;
040: // nse = gml.getElement("PointPropertyType");
041: //System.out.println("Expected PointPropertyType : "+nse.getTypeDefName());
042: // expected.add( nse );
043: // nse = gml.getElement("PointType");
044: //System.out.println("Expected PointType : "+nse.getTypeDefName());
045: // expected.add( nse );
046: // nse = gml.getElement("GeometryPropertyType");
047: //System.out.println("Expected GeometryPropertyType : "+nse.getTypeDefName());
048: // expected.add( nse );
049: // nse = gml.getElement("AbstractGeometryType");
050: // System.out.println("Expected AbstractGeometryType : "+nse.getTypeDefName());
051: // expected.add( nse );
052: // nse = xs.getElement("string");
053: //System.out.println("Expected string : "+nse.getTypeDefName());
054: // expected.add( nse );
055: //
056: // List mappings = DataTransferObjectFactory.getElements("pointProperty", Point.class);
057: //Iterator i = mappings.iterator();
058: //while(i.hasNext()){
059: // System.out.println("Result : "+((NameSpaceElement)i.next()).getTypeDefName());
060: //}
061: //System.out.println("Result End");
062: // assertEquals(expected, new HashSet(mappings));
063: // }
064:
065: public void testSimpleTypes() {
066: /* assertString("xs:string", GMLUtils.schema("x", String.class));
067: assertString("xs:integer", GMLUtils.schema("x", BigInteger.class));
068: assertString("xs:decimal", GMLUtils.schema("x", BigDecimal.class));
069: assertString("xs:int", GMLUtils.schema("x", Integer.class));
070: assertString("xs:long", GMLUtils.schema("x", Long.class));
071: assertString("xs:short", GMLUtils.schema("x", Short.class));
072: assertString("xs:byte", GMLUtils.schema("x", Byte.class));
073: assertString("xs:double", GMLUtils.schema("x", Double.class));
074: assertString("xs:float", GMLUtils.schema("x", Float.class));
075: assertString("xs:boolean", GMLUtils.schema("x", Boolean.class));
076: }
077:
078: public void testPrimativeTypes() {
079: assertString("xs:int", GMLUtils.schema("x", Integer.TYPE));
080: assertString("xs:long", GMLUtils.schema("x", Long.TYPE));
081: assertString("xs:short", GMLUtils.schema("x", Short.TYPE));
082: assertString("xs:byte", GMLUtils.schema("x", Byte.TYPE));
083: assertString("xs:double", GMLUtils.schema("x", Double.TYPE));
084: assertString("xs:float", GMLUtils.schema("x", Float.TYPE));
085: assertString("xs:boolean", GMLUtils.schema("x", Boolean.TYPE));
086: }
087:
088: public void testJTSGeometryTypes() {
089: assertString("gml:AbstractGeometryType",
090: GMLUtils.schema("x", Geometry.class));
091: assertString("gml:PointType", GMLUtils.schema("x", Point.class));
092: assertString("gml:LineStringType",
093: GMLUtils.schema("x", LineString.class));
094: assertString("gml:LinearRingType",
095: GMLUtils.schema("x", LinearRing.class));
096: assertString("gml:PolygonType", GMLUtils.schema("x", Polygon.class));
097: assertString("gml:GeometryCollectionType",
098: GMLUtils.schema("x", GeometryCollection.class));
099: assertString("gml:MultiPointType",
100: GMLUtils.schema("x", MultiPoint.class));
101: assertString("gml:MultiPolygonType",
102: GMLUtils.schema("x", MultiPolygon.class));
103: assertString("gml:MultiLineStringType",
104: GMLUtils.schema("x", MultiLineString.class));
105: assertString("gml:MultiLineStringType",
106: GMLUtils.schema("x", MultiLineString.class));
107: }
108:
109: public void testJTSTypes() {
110: assertString("gml:BoxType", GMLUtils.schema("x", Envelope.class));
111: assertString("gml:CoordType", GMLUtils.schema("x", Coordinate.class));
112: assertString("gml:CoordinatesType",
113: GMLUtils.schema("x", CoordinateList.class));
114: }
115:
116: public void testGMLPropertyTypes() {
117: //assertString( "gml:AbstractGeometryPropertyType", GMLUtils.schema( "AbstractGeometry", Geometry.class ) );
118: assertString("gml:PointPropertyType",
119: GMLUtils.schema("PointPropertyType", Point.class));
120: assertString("gml:LineStringPropertyType",
121: GMLUtils.schema("LineStringPropertyType", LineString.class));
122: assertString("gml:PolygonPropertyType",
123: GMLUtils.schema("PolygonPropertyType", Polygon.class));
124: assertString("gml:MultiGeometryPropertyType",
125: GMLUtils.schema("MultiGeometryPropertyType",
126: GeometryCollection.class));
127: assertString("gml:MultiPointPropertyType",
128: GMLUtils.schema("MultiPointPropertyType", MultiPoint.class));
129: assertString("gml:MultiPolygonPropertyType",
130: GMLUtils.schema("MultiPolygonPropertyType", MultiPolygon.class));
131: assertString("gml:MultiLineStringPropertyType",
132: GMLUtils.schema("MultiLineStringPropertyType", MultiLineString.class));*/
133: }
134: }
|