Source Code Cross Referenced for SimpleAggregatorTst.java in  » Code-Analyzer » pmd-4.2rc1 » test » net » sourceforge » pmd » testframework » 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 » Code Analyzer » pmd 4.2rc1 » test.net.sourceforge.pmd.testframework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
003:         */package test.net.sourceforge.pmd.testframework;
004:
005:        import java.util.ArrayList;
006:        import java.util.List;
007:
008:        import net.sourceforge.pmd.Rule;
009:
010:        import org.junit.Test;
011:        import org.junit.internal.runners.InitializationError;
012:        import org.junit.internal.runners.JUnit4ClassRunner;
013:        import org.junit.runner.Description;
014:        import org.junit.runner.RunWith;
015:        import org.junit.runner.notification.Failure;
016:        import org.junit.runner.notification.RunNotifier;
017:
018:        /**
019:         * Standard methods for (simple) testcases.
020:         */
021:        @RunWith(SimpleAggregatorTst.CustomXmlTestClassMethodsRunner.class)
022:        public abstract class SimpleAggregatorTst extends RuleTst {
023:            /**
024:             * Run a set of tests defined in an XML test-data file for a rule. The file
025:             * should be ./xml/RuleName.xml relative to the test-class. The format is
026:             * defined in test-data.xsd.
027:             */
028:            public void runTests(Rule rule) {
029:                runTests(extractTestsFromXml(rule));
030:            }
031:
032:            /**
033:             * Run a set of tests defined in a XML test-data file. The file should be
034:             * ./xml/[testsFileName].xml relative to the test-class. The format is
035:             * defined in test-data.xsd.
036:             */
037:            public void runTests(Rule rule, String testsFileName) {
038:                runTests(extractTestsFromXml(rule, testsFileName));
039:            }
040:
041:            /**
042:             * Run a set of tests of a certain sourceType.
043:             */
044:            public void runTests(TestDescriptor[] tests) {
045:                for (int i = 0; i < tests.length; i++) {
046:                    runTest(tests[i]);
047:                }
048:            }
049:
050:            private List<Rule> rules = new ArrayList<Rule>();
051:
052:            /**
053:             * Add new XML tests associated with the rule to the test suite. This should
054:             * be called from the setup method.
055:             */
056:            protected void addRule(String ruleSet, String ruleName) {
057:                rules.add(findRule(ruleSet, ruleName));
058:            }
059:
060:            /**
061:             * Run a set of tests for all rules added in the setup method.
062:             */
063:            @Test
064:            public void testAll() {
065:                boolean regressionTest = TestDescriptor.inRegressionTestMode();
066:                ArrayList<Failure> l = new ArrayList<Failure>();
067:                for (Rule r : rules) {
068:                    TestDescriptor[] tests = extractTestsFromXml(r);
069:                    for (TestDescriptor test : tests) {
070:                        try {
071:                            if (!regressionTest || test.isRegressionTest()) {
072:                                runTest(test);
073:                            }
074:                        } catch (Throwable t) {
075:                            Failure f = CustomXmlTestClassMethodsRunner
076:                                    .createFailure(r, t);
077:                            l.add(f);
078:                        }
079:                    }
080:                }
081:                for (Failure f : l) {
082:                    CustomXmlTestClassMethodsRunner.addFailure(f);
083:                }
084:            }
085:
086:            public static class CustomXmlTestClassMethodsRunner extends
087:                    JUnit4ClassRunner {
088:                public CustomXmlTestClassMethodsRunner(Class<?> klass)
089:                        throws InitializationError {
090:                    super (klass);
091:                }
092:
093:                public static Failure createFailure(Rule rule,
094:                        Throwable targetException) {
095:                    return new Failure(Description.createTestDescription(
096:                            SimpleAggregatorTst.class, "xml."
097:                                    + rule.getRuleSetName() + '.'
098:                                    + rule.getName()), targetException);
099:                }
100:
101:                public static void addFailure(Failure failure) {
102:                    synchronized (CustomXmlTestClassMethodsRunner.class) {
103:                        NOTIFIER.fireTestFailure(failure);
104:                    }
105:                }
106:
107:                @Override
108:                public void run(RunNotifier n) {
109:                    synchronized (CustomXmlTestClassMethodsRunner.class) {
110:                        // synchronized so that access to NOTIFIER is safe: only
111:                        // one runner at a time is active
112:                        NOTIFIER = n;
113:                        super .run(n);
114:                    }
115:                }
116:
117:                private static RunNotifier NOTIFIER;
118:            }
119:
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.