Source Code Cross Referenced for KNSTestBase.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » test » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.test;
017:
018:        import java.util.HashMap;
019:        import java.util.Iterator;
020:        import java.util.Map;
021:
022:        import org.apache.log4j.Level;
023:        import org.apache.log4j.Logger;
024:        import org.junit.After;
025:        import org.junit.Before;
026:        import org.kuali.core.util.ErrorMap;
027:        import org.kuali.core.util.GlobalVariables;
028:        import org.kuali.rice.testharness.KNSTestCase;
029:        import org.kuali.rice.testharness.TransactionalLifecycle;
030:
031:        /**
032:         * This class is the superclass for all test cases which may require the use of
033:         * services, or datasources, or any of the other expensive/time-consuming
034:         * infrastructure.
035:         * <p>
036:         * For test methods or classes with the {@link RelatesTo} annotation, this class
037:         * also wraps any test errors or failures with a notice that the listed JIRA
038:         * issues are related. This is to help developers see on test reports what work
039:         * may be in progress or recently done for this problem. It will help
040:         * distinguish tests which have already been investigated from ones which still
041:         * need to be. Test errors before the setUp method, e.g., in connecting to the
042:         * database to start a test transaction or to Workflow for a user session, are
043:         * not wrapped with these notices. Tests not extending KualiTestBase also do not
044:         * get these notices. For the sake of speed, the current JIRA status of the
045:         * related issues are not checked. The original Throwable is the cause of the
046:         * wrapper, so it appears next in the stacktrace on the test report.
047:         * <p>
048:         * If the {@value #SKIP_OPEN_OR_IN_PROGRESS_OR_REOPENED_JIRA_ISSUES} system
049:         * property is set, then this class passes (without running its contents) any
050:         * test that {@link RelatesTo} a JIRA issue that is currently open or
051:         * in-progress or reopened. This is an alternative to
052:         * {@link org.kuali.test.suite.OpenOrInProgressOrReopenedSuite} for Anthill to
053:         * retain the same format of its test report while not revealing any failures of
054:         * such tests. When using this system property, keep in mind that it takes well
055:         * over a minute to get the list of open issues from JIRA. The list is cached
056:         * statically, so it's insignificant to add a minute or two to the time it takes
057:         * for the whole Anthill build. But, developers will probably not want to add
058:         * this system property to their own environments, because of this delay and so
059:         * that they can still work on those tests.
060:         * 
061:         * @see KNSWithTestSpringContext
062:         * 
063:         * 
064:         */
065:
066:        public abstract class KNSTestBase extends KNSTestCase implements 
067:                KNSTestConstants {
068:
069:            public static final String SKIP_OPEN_OR_IN_PROGRESS_OR_REOPENED_JIRA_ISSUES = "org.kuali.test.KualiTestBase.skipOpenOrInProgressOrReopenedJiraIssues";
070:
071:            private static final Map<String, Level> changedLogLevels = new HashMap<String, Level>();
072:
073:            private TransactionalLifecycle transactionalLifecycle;
074:
075:            /**
076:             * Changes the logging-level associated with the given loggerName to the
077:             * given level. The original logging-level is saved, and will be
078:             * automatically restored at the end of each test.
079:             * 
080:             * @param loggerName
081:             *            name of the logger whose level to change
082:             * @param newLevel
083:             *            the level to change to
084:             */
085:            protected void setLogLevel(String loggerName, Level newLevel) {
086:                Logger logger = Logger.getLogger(loggerName);
087:
088:                if (!changedLogLevels.containsKey(loggerName)) {
089:                    Level originalLevel = logger.getLevel();
090:                    changedLogLevels.put(loggerName, originalLevel);
091:                }
092:
093:                logger.setLevel(newLevel);
094:            }
095:
096:            /**
097:             * Restores the logging-levels changed through calls to setLogLevel to their
098:             * original values.
099:             */
100:            protected void resetLogLevels() {
101:                for (Iterator i = changedLogLevels.entrySet().iterator(); i
102:                        .hasNext();) {
103:                    Map.Entry e = (Map.Entry) i.next();
104:
105:                    String loggerName = (String) e.getKey();
106:                    Level originalLevel = (Level) e.getValue();
107:
108:                    Logger.getLogger(loggerName).setLevel(originalLevel);
109:                }
110:                changedLogLevels.clear();
111:            }
112:
113:            @Before
114:            public void setUp() throws Exception {
115:                super .setUp();
116:                final boolean needsSpring = getClass().isAnnotationPresent(
117:                        KNSWithTestSpringContext.class);
118:                GlobalVariables.setErrorMap(new ErrorMap());
119:                if (needsSpring) {
120:                    transactionalLifecycle = new TransactionalLifecycle();
121:                    transactionalLifecycle.start();
122:                }
123:            }
124:
125:            @After
126:            public void tearDown() throws Exception {
127:                final boolean needsSpring = getClass().isAnnotationPresent(
128:                        KNSWithTestSpringContext.class);
129:                resetLogLevels();
130:                if (needsSpring) {
131:                    transactionalLifecycle.stop();
132:                }
133:                GlobalVariables.setErrorMap(new ErrorMap());
134:                super.tearDown();
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.