01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
05: * (C) 2004 TOPP - www.openplans.org
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.validation;
18:
19: import java.util.HashMap;
20:
21: import org.geotools.data.DataTestCase;
22: import org.geotools.data.memory.MemoryDataStore;
23: import org.geotools.validation.attributes.UniqueFIDValidation;
24:
25: /**
26: * IntegrityValidationTest purpose.
27: *
28: * <p>
29: * Description of IntegrityValidationTest ...
30: * </p>
31: *
32: * <p></p>
33: *
34: * @author jgarnett, Refractions Research, Inc.
35: * @author $Author: sploreg $ (last modification)
36: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/test/java/org/geotools/validation/IntegrityValidationTest.java $
37: * @version $Id: IntegrityValidationTest.java 20884 2006-08-07 14:10:46Z jgarnett $
38: */
39: public class IntegrityValidationTest extends DataTestCase {
40: MemoryDataStore store;
41:
42: /**
43: * FeatureValidationTest constructor.
44: *
45: * <p>
46: * Run test <code>testName</code>.
47: * </p>
48: *
49: * @param testName
50: */
51: public IntegrityValidationTest(String testName) {
52: super (testName);
53: }
54:
55: /**
56: * Construct data store for use.
57: *
58: * @throws Exception
59: *
60: * @see junit.framework.TestCase#setUp()
61: */
62: protected void setUp() throws Exception {
63: super .setUp();
64: store = new MemoryDataStore();
65: store.addFeatures(roadFeatures);
66: store.addFeatures(riverFeatures);
67: }
68:
69: /**
70: * Override tearDown.
71: *
72: * @throws Exception
73: *
74: * @see junit.framework.TestCase#tearDown()
75: */
76: protected void tearDown() throws Exception {
77: store = null;
78: super .tearDown();
79: }
80:
81: public void testUniqueFIDIntegrityValidation() throws Exception {
82: // the visitor
83: RoadValidationResults validationResults = new RoadValidationResults();
84:
85: UniqueFIDValidation validator = new UniqueFIDValidation();
86: validator.setName("isValidRoad");
87: validator.setDescription("Tests to see if a road is valid");
88: validator.setTypeRef("*");
89: validationResults.setValidation(validator);
90:
91: HashMap layers = new HashMap();
92: layers.put("road", store.getFeatureSource("road"));
93: layers.put("river", store.getFeatureSource("river"));
94:
95: assertTrue(validator.validate(layers, null, validationResults)); // validate will return true
96: }
97: }
|