01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: * (C) 2002, Refractions Reserach Inc.
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;
10: * version 2.1 of the License.
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.graph.traverse.basic;
18:
19: import junit.framework.TestCase;
20:
21: import org.geotools.graph.structure.GraphVisitor;
22: import org.geotools.graph.structure.Graphable;
23: import org.geotools.graph.structure.Node;
24: import org.geotools.graph.structure.basic.BasicNode;
25: import org.geotools.graph.traverse.GraphTraversal;
26:
27: public class SimpleGraphWalkerTest extends TestCase {
28: private boolean m_visited;
29:
30: public SimpleGraphWalkerTest(String name) {
31: super (name);
32: }
33:
34: public void test_visit() {
35: m_visited = false;
36:
37: GraphVisitor visitor = new GraphVisitor() {
38: public int visit(Graphable component) {
39: m_visited = true;
40: return (GraphTraversal.CONTINUE);
41: }
42: };
43:
44: Node n = new BasicNode();
45: n.setVisited(false);
46:
47: SimpleGraphWalker walker = new SimpleGraphWalker(visitor);
48:
49: assertTrue(walker.visit(n, null) == GraphTraversal.CONTINUE);
50: assertTrue(m_visited);
51: }
52: }
|