Source Code Cross Referenced for TestA2O.java in  » Test-Coverage » Quilt » org » quilt » graph » 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 » Test Coverage » Quilt » org.quilt.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* TestA2O.java */
002:
003:        package org.quilt.graph;
004:
005:        import junit.framework.*;
006:
007:        public class TestA2O extends TestCase {
008:
009:            Directed graph = null;
010:            Entry entry = null;
011:            Exit exit = null;
012:            Directed subgraph = null;
013:            Vertex A, C, D, E, F, G, H, I, J, K, L, M, N, O;
014:            Entry Try = null;
015:            Exit subExit = null;
016:
017:            public TestA2O(String name) {
018:                super (name);
019:            }
020:
021:            public class Hansel implements  Visitor {
022:                private StringBuffer crumbs = new StringBuffer();
023:
024:                public Hansel() {
025:                }
026:
027:                public void discoverGraph(Directed g) {
028:                }
029:
030:                public void finishGraph(Directed g) {
031:                }
032:
033:                public void discoverVertex(Vertex v) {
034:                    String d = v.getLabel();
035:                    if (d != null) {
036:                        crumbs.append(d);
037:                    }
038:                }
039:
040:                public void finishVertex(Vertex v) {
041:                }
042:
043:                public void discoverEdge(Edge e) {
044:                }
045:
046:                public void finishEdge(Edge e) {
047:                }
048:
049:                public String getCrumbs() {
050:                    return crumbs.toString();
051:                }
052:            }
053:
054:            public void setUp() {
055:                graph = new Directed();
056:                entry = graph.getEntry();
057:                entry.setLabel("W");
058:                exit = graph.getExit();
059:                exit.setLabel("Z");
060:
061:                Edge e = entry.getEdge();
062:
063:                A = graph.insertVertex(e);
064:                A.setLabel("A");
065:                e = A.getEdge();
066:
067:                // try with three catch clauses
068:                subgraph = graph.subgraph(e, 3);
069:                Try = subgraph.getEntry();
070:                Try.setLabel("X");
071:
072:                Exit Y = subgraph.getExit();
073:                Y.setLabel("Y");
074:
075:                e = Try.getEdge();
076:                // block ending with if
077:                F = subgraph.insertVertex(e);
078:                F.setLabel("F");
079:                e = F.makeBinary(); // returns 'other' or 'then' edge
080:
081:                // return block; its target should be exit
082:                G = subgraph.insertVertex(e);
083:                G.setLabel("G");
084:
085:                e = F.getEdge();
086:                // else leads to another if
087:                L = subgraph.insertVertex(e);
088:                L.setLabel("L");
089:                e = L.getEdge(); // else edge
090:                // else leads to a throw; M's edge should go to exit
091:                M = subgraph.insertVertex(e);
092:                M.setLabel("M");
093:
094:                e = L.makeBinary(); // then edge
095:                H = subgraph.insertVertex(e);
096:                H.setLabel("H");
097:                H.makeMulti(3);
098:                // all of H's children should have exit as target
099:                e = ((MultiConnector) H.getConnector()).getEdge(0);
100:                I = subgraph.insertVertex(e);
101:                I.setLabel("I");
102:                e = ((MultiConnector) H.getConnector()).getEdge(1);
103:                J = subgraph.insertVertex(e);
104:                J.setLabel("J");
105:                e = ((MultiConnector) H.getConnector()).getEdge(2);
106:                K = subgraph.insertVertex(e);
107:                K.setLabel("K");
108:
109:                // catch blocks; these should also all have exit as target
110:                e = ((ComplexConnector) Try.getConnector()).getEdge(0);
111:                C = subgraph.insertVertex(e);
112:                C.setLabel("C");
113:                e = ((ComplexConnector) Try.getConnector()).getEdge(1);
114:                D = subgraph.insertVertex(e);
115:                D.setLabel("D");
116:                e = ((ComplexConnector) Try.getConnector()).getEdge(2);
117:                E = subgraph.insertVertex(e);
118:                E.setLabel("E");
119:
120:                subExit = subgraph.getExit();
121:                e = subExit.getEdge();
122:
123:                // vertices in the main graph
124:                N = graph.insertVertex(e);
125:                N.setLabel("N");
126:                e = N.getEdge();
127:                O = graph.insertVertex(e);
128:                O.setLabel("O");
129:            }
130:
131:            public void testRecheck() {
132:                assertNotNull("graph is null", graph);
133:                assertNotNull("subgraph is null", subgraph);
134:
135:                // C D E F G H I J K L M entry exit, total of 13
136:                assertEquals("wrong number of vertices in subgraph", 13,
137:                        subgraph.size());
138:                // subgraph A N O entry exit = 13 + 5 = 18
139:                assertEquals("wrong number of vertices in graph", 18, graph
140:                        .size());
141:                assertEquals("Vertex O's target is not exit", exit, O
142:                        .getTarget());
143:                assertEquals("subgraph's exit doesn't point to Vertex N", N,
144:                        subExit.getTarget());
145:                // catch blocks
146:                assertEquals("Vertex C's target is not subgraph exit", subExit,
147:                        C.getTarget());
148:                assertEquals("Vertex D's target is not subgraph exit", subExit,
149:                        D.getTarget());
150:                assertEquals("Vertex E's target is not subgraph exit", subExit,
151:                        E.getTarget());
152:
153:                // return blocks; arguably these should point to top-level exit
154:                assertEquals("Vertex G's target is not subgraph exit", subExit,
155:                        G.getTarget());
156:
157:                // select targets 
158:                assertEquals("Vertex I's target is not subgraph exit", subExit,
159:                        I.getTarget());
160:                assertEquals("Vertex J's target is not subgraph exit", subExit,
161:                        J.getTarget());
162:                assertEquals("Vertex K's target is not subgraph exit", subExit,
163:                        K.getTarget());
164:                // throw block
165:                assertEquals("Vertex M's target is not subgraph exit", subExit,
166:                        M.getTarget());
167:
168:            }
169:
170:            public void testHanselAndGretel() {
171:                Walker gretel = new Walker();
172:                Hansel hansel = new Hansel();
173:                gretel.visit(subgraph, hansel);
174:                String crumbs = hansel.getCrumbs();
175:                assertEquals("unexpected path taken through subgraph",
176:                        "XFLMYHIJKGCDE", crumbs);
177:
178:                gretel = new Walker();
179:                hansel = new Hansel();
180:                gretel.visit(graph, hansel);
181:                crumbs = hansel.getCrumbs();
182:                assertEquals("unexpected path taken through graph",
183:                        "WAXFLMYHIJKGCDENOZ", crumbs);
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.