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


001:        /*
002:
003:           Derby - Class org.apache.derbyTesting.unitTests.services.T_Diagnosticable
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.services;
023:
024:        import org.apache.derby.iapi.services.context.ContextService;
025:        import org.apache.derby.iapi.services.diag.Diagnosticable;
026:        import org.apache.derby.iapi.services.diag.DiagnosticUtil;
027:        import org.apache.derby.iapi.services.monitor.Monitor;
028:        import org.apache.derby.iapi.services.sanity.SanityManager;
029:        import org.apache.derby.iapi.error.StandardException;
030:        import org.apache.derby.iapi.store.access.AccessFactory;
031:        import org.apache.derby.iapi.store.access.ConglomerateController;
032:        import org.apache.derby.iapi.store.access.TransactionController;
033:        import org.apache.derby.iapi.store.raw.ContainerHandle;
034:        import org.apache.derby.iapi.store.raw.ContainerKey;
035:        import org.apache.derby.iapi.store.raw.Page;
036:        import org.apache.derby.iapi.store.raw.Transaction;
037:        import org.apache.derby.iapi.store.raw.RawStoreFactory;
038:
039:        import org.apache.derbyTesting.unitTests.harness.T_MultiIterations;
040:        import org.apache.derbyTesting.unitTests.harness.T_Fail;
041:        import org.apache.derby.iapi.reference.Property;
042:
043:        import java.util.Properties;
044:
045:        // DEBUGGING:
046:
047:        /**
048:
049:         This T_Diagnosticable class provides a sample of how to use the "Diagnostic"
050:         facility.  The classes methods are built to be called by a "values" or
051:         a "call" statement from "ij".  Eventually there will be some sort of 
052:         diagnostic monitor which will be used to call the various "D_*" routines.
053:
054:         **/
055:
056:        public class T_Diagnosticable extends T_MultiIterations {
057:            private static final String testService = "DiagnosticableTest";
058:
059:            /* Constructors for This class: */
060:
061:            /**
062:             * No arg Constructor.
063:             **/
064:            public T_Diagnosticable() {
065:            }
066:
067:            /* Private/Protected methods of This class: */
068:
069:            /**
070:             * Simple test of DiagnosticUtil interfaces.
071:             * <p>
072:             * Simple test of DiagnosticUtil.toDiagString() and 
073:             * DiagnosticUtil.findDiagnostic() interfaces.
074:             *
075:             * @exception  T_Fail  If test fails for some reason.
076:             **/
077:            private void t_001() throws T_Fail {
078:                // Create object with also has a diagnostic interface:
079:                Object diag_obj = new T_DiagTestClass1(
080:                        "object with diag interface");
081:
082:                // Create an object in a sub-class that doesn't have a D_ class, but
083:                // its super-class does.
084:                Object diagSubObj = new T_DiagTestClass1Sub("sub-class");
085:
086:                // Create object with neither Diagnosticable:
087:                Object obj = new Long(5);
088:
089:                // Test just getting a single string back, from each type of object.
090:                String str = null;
091:                String expected_str = null;
092:                Diagnosticable helper_class = null;
093:
094:                // Here the string should come from the Diagnostic object's diag().
095:                str = DiagnosticUtil.toDiagString(diag_obj);
096:                expected_str = "D_T_DiagTestClass1: object with diag interface";
097:
098:                if (str.compareTo(expected_str) != 0) {
099:                    throw T_Fail
100:                            .testFailMsg("DiagnosticUtil.toDiagString() failed, got: ("
101:                                    + str
102:                                    + "), expected: ("
103:                                    + expected_str
104:                                    + ").");
105:                }
106:
107:                // make sure right class was found.
108:
109:                helper_class = DiagnosticUtil.findDiagnostic(diag_obj);
110:
111:                if (!(helper_class instanceof  D_T_DiagTestClass1))
112:                    throw T_Fail.testFailMsg("Bad helper class lookup.");
113:
114:                // make sure helper class gives right string.
115:
116:                try {
117:                    str = helper_class.diag();
118:                } catch (Throwable t) {
119:                    throw T_Fail
120:                            .testFailMsg("Unexpected exception from helper_class.diag() call");
121:                }
122:
123:                if (!str.equals(expected_str)) {
124:                    throw T_Fail
125:                            .testFailMsg("DiagnosticUtil.toDiagString() failed, got: ("
126:                                    + str
127:                                    + "), expected: ("
128:                                    + expected_str
129:                                    + ").");
130:                }
131:
132:                // make sure the Diagnostic class picks up a super-version of the D_ class
133:                str = DiagnosticUtil.toDiagString(diagSubObj);
134:                expected_str = "D_T_DiagTestClass1: sub-class";
135:                if (!str.equals(expected_str)) {
136:                    throw T_Fail
137:                            .testFailMsg("DiagnosticUtil.toDiagString() failed, got: ("
138:                                    + str
139:                                    + "), expected: ("
140:                                    + expected_str
141:                                    + ").");
142:                }
143:
144:                // Here the string should just be the system's default toString.
145:                str = DiagnosticUtil.toDiagString(obj);
146:                expected_str = "5";
147:
148:                if (str.compareTo(expected_str) != 0) {
149:                    throw T_Fail
150:                            .testFailMsg("DiagnosticUtil.toDiagString() failed, got: ("
151:                                    + str
152:                                    + "), expected: ("
153:                                    + expected_str
154:                                    + ").");
155:                }
156:
157:                // check that lookup for this class return correctly returns null,
158:                // since help class does not exist.
159:                helper_class = DiagnosticUtil.findDiagnostic(obj);
160:
161:                if (helper_class != null)
162:                    throw T_Fail
163:                            .testFailMsg("Bad helper class - should be null.");
164:            }
165:
166:            /* Public Methods of T_MultiIterations class: */
167:
168:            /**
169:             * Routine one once per invocation of the test by the driver.
170:             * <p>
171:             * Do work that should only be done once, no matter how many times
172:             * runTests() may be executed.
173:             *
174:             * @exception  T_Fail  Thrown on any error.
175:             **/
176:            protected void setupTest() throws T_Fail {
177:                // don't automatic boot this service if it gets left around
178:                if (startParams == null) {
179:                    startParams = new Properties();
180:                }
181:                startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString());
182:                // remove the service directory to ensure a clean run
183:                startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE
184:                        .toString());
185:            }
186:
187:            /*
188:             ** Methods required by T_Generic
189:             */
190:
191:            public String getModuleToTestProtocolName() {
192:                return ("org.apache.derby.iapi.services.diag.DiagnosticUtil");
193:            }
194:
195:            /**
196:             * Driver routine for the btree secondary index tests.
197:             * <p>
198:             *
199:             * @exception  T_Fail  Throws T_Fail on any test failure.
200:             **/
201:            protected void runTestSet() throws T_Fail {
202:                out.println("Executing " + testService + " test.");
203:
204:                t_001();
205:
206:                out.println("Finished Executing " + testService + " test.");
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.