Source Code Cross Referenced for ApplicationResourcesTest.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » ui » 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 » Blogger System » apache roller 3.1 » org.apache.roller.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
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.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:        /*
019:         * Filename: ApplicationResourcesTest.java
020:         * 
021:         * Created on 24-May-04
022:         */
023:        package org.apache.roller.ui;
024:
025:        import java.io.FileInputStream;
026:        import java.util.Iterator;
027:        import java.util.Properties;
028:        import java.util.Set;
029:
030:        import junit.framework.Test;
031:        import junit.framework.TestCase;
032:        import junit.framework.TestSuite;
033:
034:        /**
035:         * The purpose of this class is to verify that all messages in
036:         * the base ApplicationResources.properties file also appear
037:         * in the localized properties files.
038:         * 
039:         * If messages do not appear, the test fails and the 'evil-doers' are
040:         * printed to System.out.  
041:         * 
042:         * Note: we need to make sure that new property files are added to this
043:         * test.
044:         * 
045:         * @author <a href="mailto:molen@mail.com">Jaap van der Molen</a>
046:         * @version $Revision: 1.7 $
047:         */
048:        public class ApplicationResourcesTest extends TestCase {
049:            private String userDir = null;
050:            private Properties baseProps = null;
051:
052:            /**
053:             * @param arg0
054:             */
055:            public ApplicationResourcesTest(String name) {
056:                super (name);
057:            }
058:
059:            public static Test suite() {
060:                TestSuite suite = new TestSuite();
061:                //suite.addTest(new ApplicationResourcesTest("testSystemProperties"));
062:                suite.addTest(new ApplicationResourcesTest(
063:                        "testApplicationResources_nl"));
064:                suite.addTest(new ApplicationResourcesTest(
065:                        "testApplicationResources_zh_cn"));
066:                suite.addTest(new ApplicationResourcesTest(
067:                        "testApplicationResources_zh_tw"));
068:                suite.addTest(new ApplicationResourcesTest(
069:                        "testApplicationResources_vi"));
070:                return suite;
071:            }
072:
073:            /**
074:             * @see junit.framework.TestCase#setUp()
075:             */
076:            protected void setUp() throws Exception {
077:                super .setUp();
078:                userDir = System.getProperty("user.dir");
079:
080:                // load base ApplicationResources.properties file
081:                baseProps = new Properties();
082:                baseProps.load(new FileInputStream(userDir
083:                        + "/WEB-INF/classes/ApplicationResources.properties"));
084:            }
085:
086:            /**
087:             * Test Dutch stuff.
088:             * 
089:             * @throws Exception
090:             */
091:            public void testApplicationResources_nl() throws Exception {
092:                verifyResourceBundle("ApplicationResources_nl");
093:            }
094:
095:            /**
096:             * Test Simple Chinese stuff.
097:             * 
098:             * @throws Exception
099:             */
100:            public void testApplicationResources_zh_cn() throws Exception {
101:                verifyResourceBundle("ApplicationResources_zh_cn");
102:            }
103:
104:            /**
105:             * Test Traditional Chinese stuff.
106:             * 
107:             * @throws Exception
108:             */
109:            public void testApplicationResources_zh_tw() throws Exception {
110:                verifyResourceBundle("ApplicationResources_zh_tw");
111:            }
112:
113:            /**
114:             * Test Vietnamese stuff.
115:             * 
116:             * @throws Exception
117:             */
118:            public void testApplicationResources_vi() throws Exception {
119:                verifyResourceBundle("ApplicationResources_vi");
120:            }
121:
122:            public void testSystemProperties() {
123:                Properties sysProps = System.getProperties();
124:                Set keys = sysProps.keySet();
125:                for (Iterator iter = keys.iterator(); iter.hasNext();) {
126:                    String key = (String) iter.next();
127:                    System.out.println(key + " = " + sysProps.getProperty(key));
128:                }
129:            }
130:
131:            /**
132:             * Helper method to do the actual testing.
133:             * 
134:             * @param bundle name of bundle to test
135:             * @throws Exception if file not found, or if io ecxeption occurs.
136:             */
137:            private void verifyResourceBundle(String bundle) throws Exception {
138:                // verify user-dir; should end with roller
139:                assertNotNull(userDir);
140:                assertTrue(userDir.endsWith("roller"));
141:
142:                // load Chinese resource file
143:                Properties props = new Properties();
144:                props.load(new FileInputStream(userDir
145:                        + "/web/WEB-INF/classes/" + bundle + ".properties"));
146:
147:                Set keys = baseProps.keySet();
148:                boolean missingMessage = false;
149:
150:                // check Chinese
151:                System.out.println("Veriyfing " + bundle + "...");
152:                for (Iterator iter = keys.iterator(); iter.hasNext();) {
153:                    String key = (String) iter.next();
154:                    if (props.getProperty(key) == null) {
155:                        System.err.println(key + " = "
156:                                + baseProps.getProperty(key));
157:                        missingMessage = true;
158:                    }
159:                }
160:
161:                assertFalse(missingMessage);
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.