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


001:        /*
002:         * @(#)FailOnReportStyleUTest.java
003:         *
004:         * Copyright (C) 2004 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.ant;
028:
029:        import java.io.File;
030:        import java.io.IOException;
031:        import java.util.Properties;
032:
033:        import junit.framework.Test;
034:        import junit.framework.TestSuite;
035:        import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
036:
037:        import org.apache.tools.ant.BuildException;
038:
039:        /**
040:         * Tests the FailOnReportStyle class.
041:         *
042:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
043:         * @version   $Date: 2004/07/07 09:39:12 $
044:         * @since     March 19, 2004
045:         */
046:        public class FailOnReportStyleUTest extends AntTestA {
047:            //-------------------------------------------------------------------------
048:            // Standard JUnit Class-specific declarations
049:
050:            private static final Class THIS_CLASS = FailOnReportStyleUTest.class;
051:            private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
052:
053:            public FailOnReportStyleUTest(String name) {
054:                super (name);
055:            }
056:
057:            //-------------------------------------------------------------------------
058:            // Tests
059:
060:            //...........................
061:            // Non-ant tests
062:
063:            public void testClassFilterConstructor1() {
064:                try {
065:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
066:                            null);
067:                    fail("Did not throw a BuildException.");
068:                } catch (BuildException be) {
069:                    assertTrue(
070:                            "Does not contain correct exception text.",
071:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
072:                }
073:            }
074:
075:            public void testClassFilterConstructor2() {
076:                try {
077:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
078:                            ".a");
079:                    fail("Did not throw a BuildException.");
080:                } catch (BuildException be) {
081:                    assertTrue(
082:                            "Does not contain correct exception text.",
083:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
084:                }
085:            }
086:
087:            public void testClassFilterConstructor3() {
088:                try {
089:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
090:                            "");
091:                    fail("Did not throw a BuildException.");
092:                } catch (BuildException be) {
093:                    assertTrue(
094:                            "Does not contain correct exception text.",
095:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
096:                }
097:            }
098:
099:            public void testClassFilterConstructor4() {
100:                try {
101:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
102:                            "a..b");
103:                    fail("Did not throw a BuildException.");
104:                } catch (BuildException be) {
105:                    assertTrue(
106:                            "Does not contain correct exception text.",
107:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
108:                }
109:            }
110:
111:            public void testClassFilterConstructor5() {
112:                try {
113:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
114:                            "a//b");
115:                    fail("Did not throw a BuildException.");
116:                } catch (BuildException be) {
117:                    assertTrue(
118:                            "Does not contain correct exception text.",
119:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
120:                }
121:            }
122:
123:            public void testClassFilterConstructor6() {
124:                try {
125:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
126:                            "a.");
127:                    fail("Did not throw a BuildException.");
128:                } catch (BuildException be) {
129:                    assertTrue(
130:                            "Does not contain correct exception text.",
131:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
132:                }
133:            }
134:
135:            public void testClassFilterConstructor7() {
136:                try {
137:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
138:                            "a.b*c");
139:                    fail("Did not throw a BuildException.");
140:                } catch (BuildException be) {
141:                    assertTrue(
142:                            "Does not contain correct exception text.",
143:                            be
144:                                    .getMessage()
145:                                    .indexOf(
146:                                            "Invalid class filter: a wildcard may "
147:                                                    + "only be present before and after a text part.") >= 0);
148:                }
149:            }
150:
151:            public void testClassFilterConstructor8() {
152:                try {
153:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
154:                            "a.b**.c");
155:                    fail("Did not throw a BuildException.");
156:                } catch (BuildException be) {
157:                    assertTrue(
158:                            "Does not contain correct exception text.",
159:                            be
160:                                    .getMessage()
161:                                    .indexOf(
162:                                            "Invalid class filter: "
163:                                                    + "only 1 wildcard may be present between delimiters.") >= 0);
164:                }
165:            }
166:
167:            public void testClassFilterConstructor9() {
168:                try {
169:                    FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
170:                            "a/");
171:                    fail("Did not throw a BuildException.");
172:                } catch (BuildException be) {
173:                    assertTrue(
174:                            "Does not contain correct exception text.",
175:                            be.getMessage().indexOf("Invalid class filter '") >= 0);
176:                }
177:            }
178:
179:            public void testClassFilterMatch1() {
180:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
181:                        "a.B");
182:                assertFalse("Incorrectly matched the filter.", cf
183:                        .match("a.B$C"));
184:            }
185:
186:            public void testClassFilterMatch2() {
187:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
188:                        "a.B");
189:                assertFalse("Incorrectly matched the filter.", cf
190:                        .match("a.B.c"));
191:            }
192:
193:            public void testClassFilterMatch3() {
194:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
195:                        "a.B");
196:                assertTrue("Should have matched the filter.", cf.match("a.B"));
197:            }
198:
199:            public void testClassFilterMatch4() {
200:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
201:                        "a.*");
202:                assertTrue("Should have matched the filter.", cf.match("a.B"));
203:            }
204:
205:            public void testClassFilterMatch5() {
206:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
207:                        "a.*");
208:                assertTrue("Should have matched the filter.", cf.match("a.B$C"));
209:            }
210:
211:            public void testClassFilterMatch6() {
212:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
213:                        "a.*");
214:                assertFalse("Incorrectly matched the filter.", cf
215:                        .match("a.B.C"));
216:            }
217:
218:            public void testClassFilterMatch7() {
219:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
220:                        "a.*.C");
221:                assertFalse("Incorrectly matched the filter.", cf
222:                        .match("a.b.c.C"));
223:            }
224:
225:            public void testClassFilterMatch8() {
226:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
227:                        "a.*.C");
228:                assertFalse("Incorrectly matched the filter.", cf
229:                        .match("a.b.C$"));
230:            }
231:
232:            public void testClassFilterMatch9() {
233:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
234:                        "a.*.C");
235:                assertTrue("Did not matched the filter.", cf.match("a.b.C"));
236:            }
237:
238:            public void testClassFilterMatch10() {
239:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
240:                        "a.b*.C");
241:                assertTrue("Did not matched the filter.", cf.match("a.b.C"));
242:            }
243:
244:            public void testClassFilterMatch11() {
245:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
246:                        "a.b*.C");
247:                assertTrue("Did not matched the filter.", cf.match("a.bc.C"));
248:            }
249:
250:            public void testClassFilterMatch12() {
251:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
252:                        "a.b*.C");
253:                assertFalse("Incorrectly matched the filter.", cf
254:                        .match("a.ab.C"));
255:            }
256:
257:            public void testClassFilterMatch13() {
258:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
259:                        "a.b*.C");
260:                assertFalse("Incorrectly matched the filter.", cf
261:                        .match("a.ba.D"));
262:            }
263:
264:            public void testClassFilterMatch14() {
265:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
266:                        "a.*bc.C");
267:                assertFalse("Incorrectly matched the filter.", cf
268:                        .match("a.bca.C"));
269:            }
270:
271:            public void testClassFilterMatch15() {
272:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
273:                        "a.*bc.C");
274:                assertFalse("Incorrectly matched the filter.", cf
275:                        .match("a.b.C"));
276:            }
277:
278:            public void testClassFilterMatch16() {
279:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
280:                        "a.*bc.C");
281:                assertFalse("Incorrectly matched the filter.", cf
282:                        .match("a.bc.D"));
283:            }
284:
285:            public void testClassFilterMatch17() {
286:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
287:                        "a.*bc.C");
288:                assertFalse("Incorrectly matched the filter.", cf
289:                        .match("a.bc.CD"));
290:            }
291:
292:            public void testClassFilterMatch18() {
293:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
294:                        "a.*bc.C");
295:                assertTrue("Did not matched the filter.", cf.match("a.bc.C"));
296:            }
297:
298:            public void testClassFilterMatch19() {
299:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
300:                        "a.*bc.C");
301:                assertTrue("Did not matched the filter.", cf.match("a.adbbc.C"));
302:            }
303:
304:            public void testClassFilterMatch20() {
305:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
306:                        "a.**.C");
307:                assertTrue("Did not matched the filter.", cf.match("a.adbbc.C"));
308:            }
309:
310:            /**
311:             * Special case!!!!
312:             */
313:            public void testClassFilterMatch21() {
314:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
315:                        "a.**.C");
316:                assertTrue("Did not matched the filter.", cf.match("a.C"));
317:            }
318:
319:            public void testClassFilterMatch22() {
320:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
321:                        "a.**.C");
322:                assertTrue("Did not matched the filter.", cf
323:                        .match("a.B.a.a.a.a.a.a.a.a.a.a.C"));
324:            }
325:
326:            public void testClassFilterMatch23() {
327:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
328:                        "a.**.C");
329:                assertFalse("Incorrectly matched the filter.", cf
330:                        .match("a.B.a.C.a.a.a.a.a.a.a.a.C"));
331:            }
332:
333:            public void testClassFilterMatch24() {
334:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
335:                        "a.**");
336:                assertTrue("Did not matched the filter.", cf
337:                        .match("a.B.a.a.a.a.a.a.a.a.a.a.C"));
338:            }
339:
340:            public void testClassFilterMatch25() {
341:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
342:                        "a.**");
343:                assertFalse("Incorrectly matched the filter.", cf.match("b.C"));
344:            }
345:
346:            public void testClassFilterMatch26() {
347:                FailOnReportStyle.ClassFilter cf = new FailOnReportStyle.ClassFilter(
348:                        "a.**");
349:                assertFalse("Incorrectly matched the filter.", cf.match("a"));
350:            }
351:
352:            //...........................
353:            // Tests that pass
354:
355:            public void testFailon1() {
356:                try {
357:                    executeTarget("failon-1");
358:                } finally {
359:                    System.out.println("--------------------------------");
360:                    System.out.println("failon-1:");
361:                    System.out.println(getFullLog());
362:                }
363:            }
364:
365:            public void testFailon2() {
366:                executeTarget("failon-2");
367:            }
368:
369:            public void testFailon3() {
370:                executeTarget("failon-3");
371:            }
372:
373:            public void testFailon4() {
374:                executeTarget("failon-4");
375:            }
376:
377:            public void testFailon5() {
378:                try {
379:                    executeTarget("failon-5");
380:                } finally {
381:                    System.out.println("--------------------------------");
382:                    System.out.println("failon-5:");
383:                    System.out.println(getFullLog());
384:                }
385:            }
386:
387:            //...........................
388:            // Tests that fail
389:
390:            public void testFFailon1() {
391:                expectBuildException("f-failon-1",
392:                        "Did not fail for below coverage numbers.");
393:            }
394:
395:            public void testFFailon2() {
396:                expectBuildExceptionContaining("f-failon-2",
397:                        "Did not fail for invalid filter.",
398:                        "Invalid class filter '");
399:            }
400:
401:            public void testFFailon3() {
402:                expectBuildExceptionContaining("f-failon-3",
403:                        "Did not fail for invalid filter.",
404:                        "Invalid class filter '");
405:            }
406:
407:            public void testFFailon4() {
408:                expectBuildExceptionContaining("f-failon-4",
409:                        "Did not fail for invalid filter.",
410:                        "Invalid class filter '");
411:            }
412:
413:            public void testFFailon5() {
414:                expectBuildExceptionContaining("f-failon-5",
415:                        "Did not fail for invalid filter.",
416:                        "Invalid class filter '");
417:            }
418:
419:            public void testFFailon6() {
420:                expectBuildExceptionContaining("f-failon-6",
421:                        "Did not fail for invalid filter.",
422:                        "Invalid class filter '");
423:            }
424:
425:            public void testFFailon7() {
426:                expectBuildExceptionContaining(
427:                        "f-failon-7",
428:                        "Did not fail for nothing specified.",
429:                        "One of 'module' or 'class' attributes must be specified in an include element.");
430:            }
431:
432:            public void testFFailon8() {
433:                expectBuildException("f-failon-8",
434:                        "Did not fail for below coverage numbers.");
435:            }
436:
437:            //-------------------------------------------------------------------------
438:            // Helpers
439:
440:            protected void assertEquals(String text, Properties expected,
441:                    Properties actual) {
442:                PropertyCheckUtil.assertEquals(text, expected, actual);
443:            }
444:
445:            protected Properties loadGroboProperties() throws IOException {
446:                return loadProperties((new File(getCoverageDir(), "classes"
447:                        + File.separator + "grobocoverage.properties"))
448:                        .getAbsolutePath());
449:            }
450:
451:            protected Properties loadProperties(String file) throws IOException {
452:                return PropertyCheckUtil.loadProperties(file);
453:            }
454:
455:            protected File getCoverageDir() {
456:                return new File(getProjectDir(), "instrument" + File.separator
457:                        + "coverage");
458:            }
459:
460:            //-------------------------------------------------------------------------
461:            // Standard JUnit declarations
462:
463:            public static Test suite() {
464:                TestSuite suite = new TestSuite(THIS_CLASS);
465:
466:                return suite;
467:            }
468:
469:            public static void main(String[] args) {
470:                String[] name = { THIS_CLASS.getName() };
471:
472:                // junit.textui.TestRunner.main( name );
473:                // junit.swingui.TestRunner.main( name );
474:
475:                junit.textui.TestRunner.main(name);
476:            }
477:
478:            /**
479:             * 
480:             * @exception Exception thrown under any exceptional condition.
481:             */
482:            protected void setUp() throws Exception {
483:                super .setUp();
484:
485:                // set ourself up
486:                configureProject("failon.xml");
487:            }
488:
489:            /**
490:             * 
491:             * @exception Exception thrown under any exceptional condition.
492:             */
493:            protected void tearDown() throws Exception {
494:                // tear ourself down
495:                executeTarget("test-teardown");
496:
497:                super.tearDown();
498:            }
499:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.