Source Code Cross Referenced for ModuleTest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *******************************************************************************
003:         * Copyright (C) 2001-2006, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */package com.ibm.icu.dev.test;
007:
008:        import java.lang.reflect.Method;
009:        import java.util.Iterator;
010:        import java.util.MissingResourceException;
011:
012:        import com.ibm.icu.dev.test.TestDataModule.DataMap;
013:        import com.ibm.icu.dev.test.TestDataModule.DataModuleFormatError;
014:        import com.ibm.icu.dev.test.TestDataModule.Factory;
015:        import com.ibm.icu.dev.test.TestDataModule.TestData;
016:
017:        /**
018:         * Ray: An adapter class for TestDataMoule to make it like TestFmwk
019:         * 
020:         * A convenience extension of TestFmwk for use by data module-driven tests.
021:         * 
022:         * Tests can implement this if they make extensive use of information in a
023:         * TestDataModule.
024:         * 
025:         * Subclasses can allow for test methods that don't use data from the modeul by
026:         * overriding validateMethod to return true for these methods. Tests are also
027:         * free to instantiate their own modules and run from them, though care should
028:         * be taken not to interfere with the methods in this class.
029:         * 
030:         * See CollationTest for an example.
031:         */
032:        public abstract class ModuleTest extends TestFmwk {
033:            private TestDataModule m;
034:
035:            protected TestData t = null;
036:
037:            private String localeName = null;
038:
039:            private String baseName = null;
040:
041:            abstract protected void processModules();
042:
043:            protected ModuleTest(String baseName, String locName) {
044:                localeName = locName;
045:                this .baseName = baseName;
046:            }
047:
048:            protected Target getTargets(String targetName) {
049:                if (params.doMethods()) {
050:                    Target target = null;
051:                    if (!validate()) {
052:                        return null;
053:                    }
054:                    Iterator testData = m.getTestDataIterator();
055:                    if (testData != null) {
056:                        try {
057:                            Method method = getClass().getMethod(
058:                                    "processModules", null);
059:                            while (testData.hasNext()) {
060:                                target = new MethodTarget(((TestData) testData
061:                                        .next()).getName(), method)
062:                                        .setNext(target);
063:                            }
064:                        } catch (Exception e) {
065:                            e.printStackTrace();
066:                            throw new IllegalStateException(e.getMessage());
067:                        }
068:                    }
069:                    return target;
070:                } else {
071:                    return null;
072:                }
073:            }
074:
075:            /**
076:             * 
077:             * TestFmwk calls this before trying to run a suite of tests. The test suite
078:             * if valid if a module whose name is the name of this class + "Data" can be
079:             * opened. Subclasses can override this if there are different or additional
080:             * data required.
081:             */
082:            protected boolean validate() {
083:                try {
084:                    m = Factory.get(baseName, localeName);
085:                } catch (DataModuleFormatError e) {
086:                    e.printStackTrace();
087:                    m = null;
088:                } catch (MissingResourceException e) {
089:                    warnln("Could not load data: " + e.getMessage());
090:                }
091:                return m != null;
092:            }
093:
094:            /**
095:             * TestFmwk calls this before trying to invoke a test method. The method is
096:             * valid if there is test data with the name of this method in the module.
097:             * Subclasses can override this to allow for tests that do not require test
098:             * data from the module, or if there are different or additional data
099:             * required.
100:             */
101:            protected boolean validateMethod(String methodName) {
102:                return openTestData(methodName);
103:            }
104:
105:            /**
106:             * Override of TestFmwk method to get the test suite description from the
107:             * DESCRIPTION field of the module info.
108:             */
109:            protected String getDescription() {
110:                DataMap info = moduleInfo();
111:                if (info != null) {
112:                    // return info.getString(TestDataModule.DESCRIPTION);
113:                }
114:                return null;
115:            }
116:
117:            /**
118:             * Override of TestFmwk method to get the test method description from the
119:             * DESCRIPTION field of the test info.
120:             */
121:            protected String getMethodDescription(String methodName) {
122:                if (openTestData(methodName)) {
123:                    DataMap info = testInfo();
124:                    if (info != null) {
125:                        // return info.getString(TestDataModule.DESCRIPTION);
126:                    }
127:                }
128:                return null;
129:            }
130:
131:            /**
132:             * Open the test data in the module with the given name, and return true if
133:             * success. The current test is reset.
134:             * 
135:             * @throws DataModuleFormatError
136:             */
137:            protected boolean openTestData(String name) {
138:                try {
139:                    t = m == null ? null : m.getTestData(name);
140:                } catch (DataModuleFormatError e) {
141:                    return false;
142:                }
143:                return t != null;
144:            }
145:
146:            /**
147:             * Get information on this module. Returns null if no module open or no info
148:             * for the module.
149:             */
150:            private DataMap moduleInfo() {
151:                return m == null ? null : m.getInfo();
152:            }
153:
154:            /**
155:             * Get information on this test. Returns null if no module open or no test
156:             * open or not info for this test.
157:             */
158:            private DataMap testInfo() {
159:                return t == null ? null : t.getInfo();
160:            }
161:
162:            public void msg(String message, int level, boolean incCount,
163:                    boolean newln) {
164:                if (level == ERR && t != null) {
165:                    //t.stopIteration();
166:                }
167:                super.msg(message, level, incCount, newln);
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.