Source Code Cross Referenced for BasicNodeTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » graph » structure » basic » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.graph.structure.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2002, Refractions Reserach Inc.
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.graph.structure.basic;
018:
019:        import java.util.Iterator;
020:
021:        import junit.framework.TestCase;
022:
023:        import org.geotools.graph.structure.Edge;
024:
025:        public class BasicNodeTest extends TestCase {
026:
027:            private BasicNode m_node;
028:            private BasicNode m_otherNode;
029:            private Edge m_edge;
030:            private Edge m_otherEdge;
031:            private Edge m_loop;
032:
033:            public BasicNodeTest(String name) {
034:                super (name);
035:            }
036:
037:            protected void setUp() throws Exception {
038:                super .setUp();
039:                m_node = new BasicNode();
040:                m_otherNode = new BasicNode();
041:
042:                m_edge = new BasicEdge(m_node, m_otherNode);
043:                m_otherEdge = new BasicEdge(m_node, m_otherNode);
044:                m_loop = new BasicEdge(m_node, m_node);
045:            }
046:
047:            public void test_add() {
048:                //test addition of single edge
049:                m_node.add(m_edge);
050:                assertTrue(m_node.getEdges().contains(m_edge));
051:
052:                //test addition of multiple edges, same edge 
053:                m_node.add(m_edge);
054:                assertTrue(m_node.getEdges().size() == 2);
055:
056:                //test addition of multiple edges, different
057:                Edge other = new BasicEdge(m_node, m_otherNode);
058:                m_node.add(other);
059:                assertTrue(m_node.getEdges().size() == 3);
060:                assertTrue(m_node.getEdges().contains(m_edge));
061:                assertTrue(m_node.getEdges().contains(other));
062:            }
063:
064:            public void test_remove() {
065:                m_node.add(m_edge);
066:                assertTrue(m_node.getEdges().contains(m_edge));
067:
068:                //test removal of a single edge 
069:                m_node.remove(m_edge);
070:                assertTrue(m_node.getEdges().size() == 0);
071:
072:                //test removal of multiple edges, same 
073:                m_node.add(m_edge);
074:                m_node.add(m_edge);
075:                assertTrue(m_node.getEdges().size() == 2);
076:
077:                m_node.remove(m_edge);
078:                assertTrue(m_node.getEdges().size() == 1);
079:
080:                m_node.remove(m_edge);
081:                assertTrue(m_node.getEdges().size() == 0);
082:
083:                //test removal of multiple edges, different
084:                m_node.add(m_edge);
085:                m_node.add(m_otherEdge);
086:
087:                m_node.remove(m_edge);
088:                assertTrue(m_node.getEdges().size() == 1);
089:
090:                m_node.remove(m_otherEdge);
091:                assertTrue(m_node.getEdges().size() == 0);
092:            }
093:
094:            public void test_getDegree() {
095:                //intially degree should be zero
096:                assertTrue(m_node.getDegree() == 0);
097:
098:                //add single edge making degree 1
099:                m_node.add(m_edge);
100:                assertTrue(m_node.getDegree() == 1);
101:
102:                //add the same edge, should be degree 2
103:                m_node.add(m_edge);
104:                assertTrue(m_node.getDegree() == 2);
105:
106:                //add different edge, should be degree 3
107:                m_node.add(m_otherEdge);
108:                assertTrue(m_node.getDegree() == 3);
109:
110:                m_node.getEdges().clear();
111:
112:                //add a loop edge, degree should be two, but size will be one
113:                m_node.add(m_loop);
114:                assertTrue(m_node.getEdges().size() == 1);
115:                assertTrue(m_node.getDegree() == 2);
116:            }
117:
118:            public void test_getEdge() {
119:                m_node.add(m_edge);
120:                assertSame(m_edge, m_node.getEdge(m_otherNode));
121:
122:                //add another edge that has the same other node, since the underlying
123:                // structure is a list, first one should be returned
124:                m_node.add(m_otherEdge);
125:                assertSame(m_edge, m_node.getEdge(m_otherNode));
126:
127:                //remove first edge
128:                m_node.remove(m_edge);
129:
130:                //the call should now return other edge
131:                assertSame(m_otherEdge, m_node.getEdge(m_otherNode));
132:            }
133:
134:            public void test_getEdges() {
135:                m_node.add(m_edge);
136:                assertTrue(m_node.getEdges(m_otherNode).contains(m_edge));
137:
138:                //add the same edge
139:                m_node.add(m_edge);
140:                assertTrue(m_node.getEdges(m_otherNode).size() == 2);
141:
142:                //add a different edge
143:                m_node.add(m_otherEdge);
144:                assertTrue(m_node.getEdges(m_otherNode).contains(m_edge));
145:                assertTrue(m_node.getEdges(m_otherNode).contains(m_otherEdge));
146:            }
147:
148:            public void test_getRelated() {
149:                // no edges should be empty
150:                assertTrue(!m_node.getRelated().hasNext());
151:
152:                //single edge
153:                m_node.add(m_edge);
154:                Iterator itr = m_node.getRelated();
155:                assertSame(itr.next(), m_otherNode);
156:                assertTrue(!itr.hasNext());
157:
158:                //multiple edges, same, same node should be returned twice
159:                m_node.add(m_edge);
160:                itr = m_node.getRelated();
161:                assertSame(itr.next(), m_otherNode);
162:                assertSame(itr.next(), m_otherNode);
163:                assertTrue(!itr.hasNext());
164:
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.