Source Code Cross Referenced for AnalysisModuleSetUTest.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » codecoverage » v2 » datastore » 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 » GroboUtils » net.sourceforge.groboutils.codecoverage.v2.datastore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)AnalysisModuleSetUTest.java
003:         *
004:         * Copyright (C) 2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Permission is hereby granted, free of charge, to any person obtaining a
009:         *  copy of this software and associated documentation files (the "Software"),
010:         *  to deal in the Software without restriction, including without limitation
011:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
012:         *  and/or sell copies of the Software, and to permit persons to whom the 
013:         *  Software is furnished to do so, subject to the following conditions:
014:         *
015:         *  The above copyright notice and this permission notice shall be included in 
016:         *  all copies or substantial portions of the Software. 
017:         *
018:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
019:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
020:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
021:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
022:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
023:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
024:         *  DEALINGS IN THE SOFTWARE.
025:         */
026:
027:        package net.sourceforge.groboutils.codecoverage.v2.datastore;
028:
029:        import junit.framework.Test;
030:        import junit.framework.TestCase;
031:        import junit.framework.TestSuite;
032:        import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
033:        import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil;
034:        import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
035:
036:        /**
037:         * Tests the AnalysisModuleSet class.
038:         *
039:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
040:         * @version   $Date: 2004/04/15 05:48:28 $
041:         * @since     January 22, 2003
042:         */
043:        public class AnalysisModuleSetUTest extends TestCase {
044:            //-------------------------------------------------------------------------
045:            // Standard JUnit Class-specific declarations
046:
047:            private static final Class THIS_CLASS = AnalysisModuleSetUTest.class;
048:            private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
049:
050:            public AnalysisModuleSetUTest(String name) {
051:                super (name);
052:            }
053:
054:            //-------------------------------------------------------------------------
055:            // Tests
056:
057:            public void testConstructor1() {
058:                try {
059:                    new AnalysisModuleSet((IAnalysisModule[]) null);
060:                    fail("Did not throw IllegalArgumentException.");
061:                } catch (IllegalArgumentException ex) {
062:                    // check exception
063:                }
064:            }
065:
066:            public void testConstructor2() {
067:                try {
068:                    new AnalysisModuleSet((AnalysisModuleSet) null);
069:                    fail("Did not throw IllegalArgumentException.");
070:                } catch (IllegalArgumentException ex) {
071:                    // check exception
072:                }
073:            }
074:
075:            public void testConstructor3() {
076:                try {
077:                    new AnalysisModuleSet(new IAnalysisModule[1]);
078:                    fail("Did not throw IllegalArgumentException.");
079:                } catch (IllegalArgumentException ex) {
080:                    // check exception
081:                }
082:            }
083:
084:            public void testConstructor4() {
085:                try {
086:                    new AnalysisModuleSet(new IAnalysisModule[] {
087:                            createIAnalysisModule("0"), null });
088:                    fail("Did not throw IllegalArgumentException.");
089:                } catch (IllegalArgumentException ex) {
090:                    // check exception
091:                }
092:            }
093:
094:            public void testConstructor5() {
095:                new AnalysisModuleSet(new AnalysisModuleSet());
096:            }
097:
098:            public void testAddAnalysisModule1() {
099:                AnalysisModuleSet ams = new AnalysisModuleSet();
100:                IAnalysisModule a1 = createIAnalysisModule("a");
101:                IAnalysisModule a2 = createIAnalysisModule("a");
102:                assertEquals(a1.getMeasureName(), a2.getMeasureName());
103:                ams.addAnalysisModule(a1);
104:                try {
105:                    ams.addAnalysisModule(a2);
106:                    fail("Did not throw IllegalStateException.");
107:                } catch (IllegalStateException ex) {
108:                    // test exception
109:                }
110:            }
111:
112:            public void testAddAnalysisModule2() {
113:                AnalysisModuleSet ams = new AnalysisModuleSet();
114:                try {
115:                    ams.addAnalysisModule(null);
116:                    fail("Did not throw IllegalStateException.");
117:                } catch (IllegalArgumentException iae) {
118:                    // check exception
119:                }
120:            }
121:
122:            public void testJoinAnalysisModuleSet1() {
123:                AnalysisModuleSet ams = new AnalysisModuleSet();
124:                try {
125:                    ams.joinAnalysisModuleSet(null);
126:                    fail("Did not throw IllegalStateException.");
127:                } catch (IllegalArgumentException iae) {
128:                    // check exception
129:                }
130:            }
131:
132:            public void testJoinAnalysisModuleSet2() {
133:                IAnalysisModule a1 = createIAnalysisModule("a");
134:                AnalysisModuleSet ams = new AnalysisModuleSet(
135:                        new IAnalysisModule[] { a1 });
136:                ams.joinAnalysisModuleSet(ams);
137:            }
138:
139:            public void testJoinAnalysisModuleSet3() {
140:                IAnalysisModule a1 = createIAnalysisModule("a");
141:                IAnalysisModule a2 = createIAnalysisModule("b");
142:                AnalysisModuleSet ams = new AnalysisModuleSet(
143:                        new IAnalysisModule[] { a1 });
144:                ams.joinAnalysisModuleSet(new AnalysisModuleSet(
145:                        new IAnalysisModule[] { a2 }));
146:                assertEquals("Did not store correct number of modules.", 2, ams
147:                        .getAnalysisModuleCount());
148:            }
149:
150:            /* this test takes a VERY long time, and as such is not suitable for
151:            unit tests.  If you want to increase unit test coverage, though,
152:            include this test to get 1 more branch and 1 more line.  Not only that,
153:            but this is a rarely encountered situation, and encountering this situation
154:            may be a sign of a bug elsewhere.
155:            public void testAddAnalysisModule2()
156:            {
157:                // test the limits of the short index vs. int internal structure
158:                // counting system.
159:                AnalysisModuleSet ams = new AnalysisModuleSet();
160:                IAnalysisModule amL[] = CCCreatorUtil.createAnalysisModules(
161:                    (int)Short.MAX_VALUE );
162:                ams.addAnalysisModules( amL );
163:                IAnalysisModule a1 = createIAnalysisModule( "a" );
164:                try
165:                {
166:                    ams.addAnalysisModule( a1 );
167:                    fail( "Did not throw IllegalStateException." );
168:                }
169:                catch (IllegalStateException ex)
170:                {
171:                    // test exception
172:                }
173:            }
174:             */
175:
176:            public void testGetAnalysisModules1() {
177:                AnalysisModuleSet ams = new AnalysisModuleSet();
178:                IAnalysisModule[] amL = ams.getAnalysisModules();
179:                assertNotNull("Returned null module list.", amL);
180:                assertEquals("Returned invalid module array length.", 0,
181:                        amL.length);
182:            }
183:
184:            public void testGetAnalysisModules2() {
185:                IAnalysisModule orig = createIAnalysisModule("a");
186:                AnalysisModuleSet ams = new AnalysisModuleSet(
187:                        new IAnalysisModule[] { orig });
188:                IAnalysisModule[] amL = ams.getAnalysisModules();
189:                assertNotNull("Returned null module list.", amL);
190:                assertEquals("Returned invalid module array length.", 1,
191:                        amL.length);
192:                assertSame("Returned invalid module.", orig, amL[0]);
193:            }
194:
195:            public void testGetMeasureIndex1() {
196:                AnalysisModuleSet ams = new AnalysisModuleSet();
197:                short i = ams.getMeasureIndex("b");
198:                assertEquals("Returned invalid index.", -1, i);
199:            }
200:
201:            public void testGetMeasureIndex2() {
202:                IAnalysisModule orig = createIAnalysisModule("b");
203:                AnalysisModuleSet ams = new AnalysisModuleSet(
204:                        new IAnalysisModule[] { orig });
205:                short i = ams.getMeasureIndex("b");
206:                assertEquals("Returned invalid index.", 0, i);
207:            }
208:
209:            public void testGetMeasureIndex3() {
210:                AnalysisModuleSet ams = new AnalysisModuleSet();
211:                try {
212:                    ams.getMeasureIndex(null);
213:                    fail("Did not throw IllegalArgumentException.");
214:                } catch (IllegalArgumentException ex) {
215:                    // test exception
216:                }
217:            }
218:
219:            public void testGetAnalysisModuleIndex1() {
220:                AnalysisModuleSet ams = new AnalysisModuleSet();
221:                try {
222:                    ams.getAnalysisModuleIndex(null);
223:                    fail("Did not throw IllegalArgumentException.");
224:                } catch (IllegalArgumentException ex) {
225:                    // test exception
226:                }
227:            }
228:
229:            public void testGetAnalysisModuleIndex2() {
230:                IAnalysisModule orig = createIAnalysisModule("b");
231:                AnalysisModuleSet ams = new AnalysisModuleSet();
232:                short i = ams.getAnalysisModuleIndex(orig);
233:                assertEquals("Did not return correct index.", -1, i);
234:            }
235:
236:            public void testGetAnalysisModuleIndex3() {
237:                IAnalysisModule orig = createIAnalysisModule("b");
238:                IAnalysisModule a = createIAnalysisModule("a");
239:                AnalysisModuleSet ams = new AnalysisModuleSet(
240:                        new IAnalysisModule[] { a });
241:                short i = ams.getAnalysisModuleIndex(orig);
242:                assertEquals("Did not return correct index.", -1, i);
243:            }
244:
245:            public void testGetAnalysisModuleIndex4() {
246:                IAnalysisModule orig1 = createIAnalysisModule("b");
247:                AnalysisModuleSet ams = new AnalysisModuleSet(
248:                        new IAnalysisModule[] { orig1 });
249:                short i = ams.getAnalysisModuleIndex(orig1);
250:                assertEquals("Did not return correct index.", 0, i);
251:            }
252:
253:            public void testGetAnalysisModuleCount1() {
254:                AnalysisModuleSet ams = new AnalysisModuleSet();
255:                assertEquals("Did not return correct count.", 0, ams
256:                        .getAnalysisModuleCount());
257:            }
258:
259:            public void testGetAnalysisModuleCount2() {
260:                AnalysisModuleSet ams = new AnalysisModuleSet(CCCreatorUtil
261:                        .createAnalysisModules(15));
262:                assertEquals("Did not return correct count.", 15, ams
263:                        .getAnalysisModuleCount());
264:            }
265:
266:            //-------------------------------------------------------------------------
267:            // Helpers
268:
269:            protected IAnalysisModule createIAnalysisModule(String name) {
270:                return CCCreatorUtil.createIAnalysisModule(name, "u", "m");
271:            }
272:
273:            //-------------------------------------------------------------------------
274:            // Standard JUnit declarations
275:
276:            public static Test suite() {
277:                TestSuite suite = new TestSuite(THIS_CLASS);
278:
279:                return suite;
280:            }
281:
282:            public static void main(String[] args) {
283:                String[] name = { THIS_CLASS.getName() };
284:
285:                // junit.textui.TestRunner.main( name );
286:                // junit.swingui.TestRunner.main( name );
287:
288:                junit.textui.TestRunner.main(name);
289:            }
290:
291:            /**
292:             * 
293:             * @exception Exception thrown under any exceptional condition.
294:             */
295:            protected void setUp() throws Exception {
296:                super .setUp();
297:
298:                // set ourself up
299:            }
300:
301:            /**
302:             * 
303:             * @exception Exception thrown under any exceptional condition.
304:             */
305:            protected void tearDown() throws Exception {
306:                // tear ourself down
307:
308:                super.tearDown();
309:            }
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.