Source Code Cross Referenced for T_Generic.java in  » Database-DBMS » db-derby-10.2 » org » apache » derbyTesting » unitTests » harness » 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 » Database DBMS » db derby 10.2 » org.apache.derbyTesting.unitTests.harness 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derbyTesting.unitTests.harness.T_Generic
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to You under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derbyTesting.unitTests.harness;
023:
024:        import org.apache.derby.iapi.services.monitor.ModuleControl;
025:        import org.apache.derby.iapi.services.monitor.Monitor;
026:
027:        import org.apache.derbyTesting.unitTests.harness.UnitTest;
028:        import org.apache.derbyTesting.unitTests.harness.UnitTestConstants;
029:        import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
030:        import org.apache.derby.iapi.services.sanity.SanityManager;
031:        import org.apache.derby.iapi.error.StandardException;
032:        import org.apache.derby.iapi.services.sanity.SanityManager;
033:
034:        import java.util.Properties;
035:
036:        /**
037:         Abstract class which executes a unit test.
038:
039:         <P>To write a test,	extend this class with a class which implements the two
040:         abstract methods:
041:         <UL>	
042:         <LI>runTests
043:         <LI>setUp
044:         </UL>
045:         @see UnitTest
046:         @see ModuleControl
047:         */
048:        public abstract class T_Generic implements  UnitTest, ModuleControl {
049:            /**
050:              The unqualified name for the module to test. This is set by the generic
051:              code.
052:             */
053:            protected String shortModuleToTestName;
054:
055:            /**
056:              The start parameters for your test. This is set by generic code.
057:             */
058:            protected Properties startParams;
059:
060:            /**
061:              The HeaderPrintWriter for test output. This is set by the
062:              generic code.
063:             */
064:            protected HeaderPrintWriter out;
065:
066:            protected T_Generic() {
067:            }
068:
069:            /*
070:             ** Public methods of ModuleControl
071:             */
072:
073:            /**
074:              ModuleControl.start
075:              
076:              @see ModuleControl#boot
077:              @exception StandardException Module cannot be started.
078:             */
079:            public void boot(boolean create, Properties startParams)
080:                    throws StandardException {
081:                shortModuleToTestName = getModuleToTestProtocolName()
082:                        .substring(
083:                                getModuleToTestProtocolName().lastIndexOf('.') + 1);
084:
085:                this .startParams = startParams;
086:            }
087:
088:            /**
089:              ModuleControl.stop
090:              
091:              @see ModuleControl#stop
092:             */
093:            public void stop() {
094:            }
095:
096:            /*
097:             ** Public methods of UnitTest
098:             */
099:            /**
100:              UnitTest.Execute
101:              
102:              @see UnitTest#Execute
103:             */
104:            public boolean Execute(HeaderPrintWriter out) {
105:                this .out = out;
106:
107:                String myClass = this .getClass().getName();
108:                String testName = myClass
109:                        .substring(myClass.lastIndexOf('.') + 1);
110:
111:                System.out.println("-- Unit Test " + testName + " starting");
112:
113:                try {
114:                    runTests();
115:                }
116:
117:                catch (Throwable t) {
118:
119:                    while (t != null) {
120:                        FAIL(t.toString());
121:                        t.printStackTrace(out.getPrintWriter());
122:                        if (t instanceof  StandardException) {
123:                            t = ((StandardException) t).getNestedException();
124:                            continue;
125:                        }
126:                        break;
127:                    }
128:                    return false;
129:                }
130:
131:                System.out.println("-- Unit Test " + testName + " finished");
132:
133:                return true;
134:            }
135:
136:            /**
137:              UnitTest.UnitTestDuration
138:              
139:              @return UnitTestConstants.DURATION_MICRO
140:              @see UnitTest#UnitTestDuration
141:              @see UnitTestConstants
142:             */
143:            public int UnitTestDuration() {
144:                return UnitTestConstants.DURATION_MICRO;
145:            }
146:
147:            /**
148:              UnitTest.UnitTestType
149:              
150:              @return UnitTestConstants.TYPE_COMMON
151:              @see UnitTest#UnitTestType
152:              @see UnitTestConstants
153:             */
154:            public int UnitTestType() {
155:                return UnitTestConstants.TYPE_COMMON;
156:            }
157:
158:            /**
159:              Emit a message indicating why the test failed.
160:
161:              RESOLVE: Should this be localized?
162:
163:              @param msg the message.
164:              @return false
165:             */
166:            protected boolean FAIL(String msg) {
167:                out.println("[" + Thread.currentThread().getName()
168:                        + "] FAIL - " + msg);
169:                return false;
170:            }
171:
172:            /**
173:              Emit a message saying the test passed.
174:              You may use this to emit messages indicating individual test cases
175:              within a unit test passed.
176:
177:              <P>RESOLVE:Localize this.
178:              @param test the test which passed.
179:              @return true
180:             */
181:            protected boolean PASS(String testName) {
182:                out.println("[" + Thread.currentThread().getName()
183:                        + "] Pass - " + shortModuleToTestName + " " + testName);
184:                return true;
185:            }
186:
187:            /**
188:            	Emit a message during a unit test run, indent the message
189:            	to allow the PASS/FAIL messages to stand out.
190:             */
191:            public void REPORT(String msg) {
192:                out.println("[" + Thread.currentThread().getName() + "]     "
193:                        + msg);
194:            }
195:
196:            /**
197:              Abstract methods to implement for your test.
198:             */
199:
200:            /**
201:              Run the test. The test should raise an exception if it
202:              fails. runTests should return if the tests pass.
203:
204:              @exception Exception Test code throws these
205:             */
206:            protected abstract void runTests() throws Exception;
207:
208:            /**
209:              Get the name of the protocol for the module to test.
210:              This is the 'factory.MODULE' variable.
211:              
212:              'moduleName' to the name of the module to test. 
213:
214:              @param testConfiguration the configuration for this test.
215:             */
216:            protected abstract String getModuleToTestProtocolName();
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.