Source Code Cross Referenced for ComplexityCalculatorTest.java in  » Test-Coverage » cobertura » net » sourceforge » cobertura » reporting » 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 » cobertura » net.sourceforge.cobertura.reporting 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Cobertura - http://cobertura.sourceforge.net/
003:         *
004:         * Copyright (C) 2005 Grzegorz Lukasik
005:         * 
006:         * Cobertura is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published
008:         * by the Free Software Foundation; either version 2 of the License,
009:         * or (at your option) any later version.
010:         *
011:         * Cobertura is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with Cobertura; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019:         * USA
020:         */
021:        package net.sourceforge.cobertura.reporting;
022:
023:        import net.sourceforge.cobertura.coveragedata.ClassData;
024:        import net.sourceforge.cobertura.coveragedata.PackageData;
025:        import net.sourceforge.cobertura.coveragedata.ProjectData;
026:        import net.sourceforge.cobertura.coveragedata.SourceFileData;
027:        import net.sourceforge.cobertura.util.FileFinder;
028:        import net.sourceforge.cobertura.util.FileFixture;
029:        import junit.framework.TestCase;
030:
031:        public class ComplexityCalculatorTest extends TestCase {
032:            private FileFixture fileFixture;
033:            private FileFinder fileFinder;
034:            private ComplexityCalculator complexity;
035:
036:            public void testGetCCNForSourceFile() {
037:                double ccn1 = complexity
038:                        .getCCNForSourceFile(new SourceFileData(
039:                                "com/example/Sample1.java"));
040:                assertTrue(ccn1 != 0.0);
041:                double ccn2 = complexity
042:                        .getCCNForSourceFile(new SourceFileData(
043:                                "com/example/Sample2.java"));
044:                assertTrue(ccn2 != 0.0);
045:                assertTrue(ccn1 != ccn2);
046:
047:                ccn1 = complexity.getCCNForSourceFile(new SourceFileData(
048:                        "com/example/Sample5.java"));
049:                assertTrue(ccn1 != 0.0);
050:                ccn2 = complexity.getCCNForSourceFile(new SourceFileData(
051:                        "com/example/Sample6.java"));
052:                assertTrue(ccn2 != 0.0);
053:                assertTrue(ccn1 != ccn2);
054:
055:                double ccn0 = complexity
056:                        .getCCNForSourceFile(new SourceFileData(
057:                                "com/example/Sample8.java"));
058:                assertTrue(ccn0 == 0.0);
059:
060:                ccn0 = complexity.getCCNForSourceFile(new SourceFileData(
061:                        "Foo.java"));
062:                assertTrue(ccn0 == 0.0);
063:            }
064:
065:            public void testGetCCNForClass() {
066:                double ccn1 = complexity.getCCNForClass(new ClassData(
067:                        "com.example.Sample3"));
068:                assertTrue(ccn1 != 0.0);
069:                double ccn2 = complexity.getCCNForClass(new ClassData(
070:                        "com.example.Sample4"));
071:                assertTrue(ccn2 != 0.0);
072:                assertTrue(ccn1 != ccn2);
073:
074:                ccn1 = complexity.getCCNForClass(new ClassData(
075:                        "com.example.Sample5"));
076:                assertTrue(ccn1 != 0.0);
077:                ccn2 = complexity.getCCNForClass(new ClassData(
078:                        "com.example.Sample6"));
079:                assertTrue(ccn2 != 0.0);
080:                assertTrue(ccn1 != ccn2);
081:
082:                double ccn0 = complexity.getCCNForClass(new ClassData(
083:                        "com.example.Sample8"));
084:                assertEquals(0.0, ccn0, 0.0);
085:
086:                ccn0 = complexity.getCCNForClass(new ClassData("Foo"));
087:                assertEquals(0.0, ccn0, 0.0);
088:            }
089:
090:            public void testGetCCNForPackage() {
091:                PackageData pd = new PackageData("com.example");
092:                pd.addClassData(new ClassData("com.example.Sample3"));
093:                double ccn1 = complexity.getCCNForPackage(pd);
094:                assertTrue(ccn1 != 0.0);
095:
096:                ComplexityCalculator complexity2 = new ComplexityCalculator(
097:                        fileFinder);
098:                pd.addClassData(new ClassData("com.example.Sample4"));
099:                double ccn2 = complexity2.getCCNForPackage(pd);
100:                double ccn3 = complexity2.getCCNForPackage(pd);
101:                assertTrue(ccn2 != 0.0);
102:                assertTrue(ccn1 != ccn2);
103:                assertEquals(ccn2, ccn3, 0e-9);
104:
105:                PackageData empty = new PackageData("com.example2");
106:                ComplexityCalculator complexity3 = new ComplexityCalculator(
107:                        fileFinder);
108:                assertEquals(0.0, complexity3.getCCNForPackage(empty), 0.0);
109:            }
110:
111:            public void testGetCCNForProject() {
112:                ProjectData project = new ProjectData();
113:                project.addClassData(new ClassData("com.example.Sample5"));
114:                double ccn1 = complexity.getCCNForProject(project);
115:                assertTrue(ccn1 != 0.0);
116:
117:                ComplexityCalculator complexity2 = new ComplexityCalculator(
118:                        fileFinder);
119:                project.addClassData(new ClassData("com.example.Sample4"));
120:                double ccn2 = complexity2.getCCNForProject(project);
121:                assertTrue(ccn2 != 0.0);
122:                assertTrue(ccn1 != ccn2);
123:
124:                ComplexityCalculator complexity3 = new ComplexityCalculator(
125:                        fileFinder);
126:                project.addClassData(new ClassData("com.example.Sample8"));
127:                double ccn3 = complexity3.getCCNForProject(project);
128:                assertEquals(ccn2, ccn3, 0e-9);
129:
130:                ComplexityCalculator complexity4 = new ComplexityCalculator(
131:                        fileFinder);
132:                double ccn0 = complexity4.getCCNForProject(new ProjectData());
133:                assertEquals(0.0, ccn0, 0.0);
134:            }
135:
136:            public void testGetCCNForSourceFile_null() {
137:                try {
138:                    complexity.getCCNForSourceFile(null);
139:                    fail("NullPointerException expected");
140:                } catch (NullPointerException ex) {
141:                }
142:            }
143:
144:            public void testGetCCNForPackage_null() {
145:                try {
146:                    complexity.getCCNForPackage(null);
147:                    fail("NullPointerException expected");
148:                } catch (NullPointerException ex) {
149:                }
150:            }
151:
152:            public void testGetCCNForProject_null() {
153:                try {
154:                    complexity.getCCNForProject(null);
155:                    fail("NullPointerException expected");
156:                } catch (NullPointerException ex) {
157:                }
158:            }
159:
160:            public void testConstructor_null() {
161:                try {
162:                    new ComplexityCalculator(null);
163:                    fail("NullPointerException expected");
164:                } catch (NullPointerException ex) {
165:                }
166:            }
167:
168:            protected void setUp() throws Exception {
169:                super .setUp();
170:                fileFixture = new FileFixture();
171:                fileFixture.setUp();
172:
173:                fileFinder = new FileFinder();
174:                fileFinder.addSourceDirectory(fileFixture.sourceDirectory(
175:                        FileFixture.SOURCE_DIRECTORY_IDENTIFIER[0]).toString());
176:                fileFinder.addSourceDirectory(fileFixture.sourceDirectory(
177:                        FileFixture.SOURCE_DIRECTORY_IDENTIFIER[1]).toString());
178:                fileFinder.addSourceFile(fileFixture.sourceDirectory(
179:                        FileFixture.SOURCE_DIRECTORY_IDENTIFIER[2]).toString(),
180:                        "com/example\\Sample5.java");
181:                fileFinder.addSourceFile(fileFixture.sourceDirectory(
182:                        FileFixture.SOURCE_DIRECTORY_IDENTIFIER[2]).toString(),
183:                        "com/example/Sample6.java");
184:                fileFinder.addSourceFile(fileFixture.sourceDirectory(
185:                        FileFixture.SOURCE_DIRECTORY_IDENTIFIER[3]).toString(),
186:                        "com/example/Sample7.java");
187:
188:                // Do not add com/example/Sample8.java
189:                // fileFinder.addSourceFile( fileFixture.sourceDirectory(FileFixture.SOURCE_DIRECTORY_IDENTIFIER[3]).toString(), "com/example/Sample8.java");
190:
191:                complexity = new ComplexityCalculator(fileFinder);
192:            }
193:
194:            protected void tearDown() throws Exception {
195:                super.tearDown();
196:                fileFixture.tearDown();
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.