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.structure.basic;
18:
19: import java.util.Iterator;
20:
21: import junit.framework.TestCase;
22:
23: public class BasicGraphableTest extends TestCase {
24:
25: private BasicGraphable m_graphable;
26:
27: public BasicGraphableTest(String name) {
28: super (name);
29: }
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33:
34: m_graphable = new BasicGraphable() {
35: public Iterator getRelated() {
36: return null;
37: }
38: };
39: }
40:
41: /**
42: * Test BasicGraphable#setVisited(boolean) method. <BR>
43: * <BR>
44: * Test: Clear visited flag, then reset.<BR>
45: * Expected: Visited flag should be set.
46: *
47: */
48: public void test_setVisited() {
49: assertTrue(!m_graphable.isVisited());
50: m_graphable.setVisited(true);
51: assertTrue(m_graphable.isVisited());
52: }
53:
54: /**
55: * Test BasicGraphable#setObject(Object). <BR>
56: * <BR>
57: * Test: Create a new object and set underlying object.
58: * Expected: Underlying object should be equal to created object.
59: *
60: */
61: public void test_setObject() {
62: Object obj = new Integer(1);
63:
64: assertTrue(m_graphable.getObject() == null);
65: m_graphable.setObject(obj);
66:
67: assertTrue(m_graphable.getObject() == obj);
68: }
69:
70: /**
71: * Test BasicGraphable#setCount(int). <BR>
72: * <BR>
73: * Test: Change value of counter.<BR>
74: * Expected: Counter equal to new value.
75: *
76: */
77: public void test_setCount() {
78: assertEquals(m_graphable.getCount(), -1);
79: m_graphable.setCount(10);
80:
81: assertEquals(m_graphable.getCount(), 10);
82: }
83:
84: /**
85: * Test BasicGraphable#setID(int). <BR>
86: * <BR>
87: * Test: Change id.<BR>
88: * Expected: Id equal to new value.
89: *
90: */
91: public void test_setID() {
92: m_graphable.setID(10);
93: assertEquals(m_graphable.getID(), 10);
94: }
95: }
|