01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-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; either
09: * version 2.1 of the License, or (at your option) any later version.
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: * Created on May 11, 2005, 9:02 PM
17: */
18: package org.geotools.filter.function;
19:
20: import org.geotools.data.DataUtilities;
21: import org.geotools.data.memory.MemoryDataStore;
22: import org.geotools.factory.CommonFactoryFinder;
23: import org.geotools.factory.GeoTools;
24: import org.geotools.feature.Feature;
25: import junit.framework.TestCase;
26: import org.geotools.feature.FeatureCollection;
27: import org.geotools.feature.FeatureType;
28: import org.geotools.filter.ExpressionBuilder;
29: import org.geotools.filter.FilterFactory;
30: import org.geotools.filter.FilterFactoryFinder;
31: import org.opengis.filter.FilterFactory2;
32:
33: import com.vividsolutions.jts.geom.Coordinate;
34: import com.vividsolutions.jts.geom.GeometryFactory;
35:
36: /**
37: *
38: * @author James
39: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/test/java/org/geotools/filter/function/FunctionTestSupport.java $
40: */
41: public class FunctionTestSupport extends TestCase {
42:
43: protected FeatureCollection featureCollection;
44: protected FilterFactory fac = FilterFactoryFinder
45: .createFilterFactory();
46: protected FilterFactory2 ff = CommonFactoryFinder
47: .getFilterFactory2(GeoTools.getDefaultHints());
48: protected ExpressionBuilder builder = new ExpressionBuilder();
49: protected FeatureType dataType;
50: protected Feature[] testFeatures;
51:
52: /** Creates a new instance of FunctionTestSupport */
53: public FunctionTestSupport(String testName) {
54: super (testName);
55: }
56:
57: protected void setUp() throws java.lang.Exception {
58: dataType = DataUtilities.createType("classification.test1",
59: "id:0,foo:int,bar:double,geom:Point,group:String");
60:
61: int iVal[] = new int[] { 4, 90, 20, 43, 29, 61, 8, 12 };
62: double dVal[] = new double[] { 2.5, 80.433, 24.5, 9.75, 18, 53,
63: 43.2, 16 };
64:
65: testFeatures = new Feature[iVal.length];
66: GeometryFactory fac = new GeometryFactory();
67:
68: for (int i = 0; i < iVal.length; i++) {
69: testFeatures[i] = dataType.create(new Object[] {
70: new Integer(i + 1), new Integer(iVal[i]),
71: new Double(dVal[i]),
72: fac.createPoint(new Coordinate(iVal[i], iVal[i])),
73: "Group" + (i % 4) }, "classification.t" + (i + 1));
74: }
75:
76: MemoryDataStore store = new MemoryDataStore();
77: store.createSchema(dataType);
78: store.addFeatures(testFeatures);
79:
80: featureCollection = store.getFeatureSource("test1")
81: .getFeatures();
82: }
83:
84: public void testEmpty() {
85: //to make tests pass
86: }
87: }
|