01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-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: package org.geotools.styling.visitor;
17:
18: import junit.framework.TestCase;
19:
20: import org.geotools.factory.CommonFactoryFinder;
21: import org.geotools.filter.IllegalFilterException;
22: import org.geotools.styling.Style;
23: import org.geotools.styling.StyleBuilder;
24: import org.geotools.styling.StyleFactory;
25: import org.geotools.styling.StyleFactoryFinder;
26: import org.opengis.filter.FilterFactory;
27: import org.opengis.filter.FilterFactory2;
28:
29: /**
30: * Unit test for DuplicatorStyleVisitor.
31: *
32: * @author Cory Horner, Refractions Research Inc.
33: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/test/java/org/geotools/styling/visitor/DuplicatorStyleVisitorTest.java $
34: */
35: public class DuplicatorStyleVisitorTest extends TestCase {
36: StyleBuilder sb;
37: StyleFactory sf;
38: FilterFactory ff;
39:
40: public DuplicatorStyleVisitorTest(String testName) {
41: super (testName);
42: }
43:
44: protected void setUp() throws Exception {
45: sf = StyleFactoryFinder.createStyleFactory();
46: ff = CommonFactoryFinder.getFilterFactory(null);
47: sb = new StyleBuilder(sf, ff);
48: }
49:
50: public void testStyleDuplication() throws IllegalFilterException {
51: //create a style
52: Style oldStyle = sb.createStyle("FTSName", sf
53: .createPolygonSymbolizer());
54: oldStyle.getFeatureTypeStyles()[0]
55: .setSemanticTypeIdentifiers(new String[] { "simple",
56: "generic:geometry" });
57: //duplicate it
58: DuplicatingStyleVisitor visitor = new DuplicatingStyleVisitor(
59: sf, (FilterFactory2) ff);
60: oldStyle.accept(visitor);
61: Style newStyle = (Style) visitor.getCopy();
62:
63: //compare it
64: assertNotNull(newStyle);
65: assertEquals(2, newStyle.getFeatureTypeStyles()[0]
66: .getSemanticTypeIdentifiers().length);
67: //TODO: actually compare it
68: }
69:
70: }
|