Source Code Cross Referenced for SegResBundle.java in  » Workflow-Engines » wfmopen-2.1.1 » util » 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 » Workflow Engines » wfmopen 2.1.1 » util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Danet GmbH
003:         * Beratung und Software-Entwicklung
004:         * Geschäftstelle AN
005:         *
006:         * $Id: SegResBundle.java,v 1.2 2007/03/27 21:59:42 mlipp Exp $
007:         *
008:         * $Log: SegResBundle.java,v $
009:         * Revision 1.2  2007/03/27 21:59:42  mlipp
010:         * Fixed lots of checkstyle warnings.
011:         *
012:         * Revision 1.1.1.1  2003/06/30 20:07:00  drmlipp
013:         * Initial import
014:         *
015:         * Revision 1.11  2003/04/16 19:25:04  lipp
016:         * Adapted to jdk 1.4
017:         *
018:         * Revision 1.10  2002/06/18 14:07:50  lipp
019:         * Fixed bug in SegmentedMap that prevented the use of top level keys.
020:         *
021:         * Revision 1.9  2002/02/03 21:41:42  lipp
022:         * Cleaned up unittests.
023:         *
024:         * Revision 1.8  2002/01/28 12:34:48  huaiyang
025:         * Removed obsolete import for SegmentedResourceBundle.
026:         *
027:         * Revision 1.7  2001/12/05 16:32:26  feldgen
028:         * Patched for use with Hashmaps
029:         *
030:         * Revision 1.6  2001/12/04 11:53:06  schlue
031:         * Minor bug fixes
032:         *
033:         * Revision 1.5  2001/11/26 17:37:50  feldgen
034:         * changed tests to SegmentedMap
035:         *
036:         * Revision 1.4  2001/11/15 09:56:06  schlue
037:         * Import statement updated
038:         *
039:         * Revision 1.3  2001/10/10 09:51:56  schlue
040:         * Call of deprecated method "assert" replaced by "assertTrue"
041:         *
042:         * Revision 1.2  2001/10/05 08:46:57  schlue
043:         * Caching of keylists and values added
044:         *
045:         * Revision 1.1  2001/09/25 16:16:04  schlue
046:         * SegmentedResourceBundle added and used for mapping entries
047:         *
048:         *
049:         */
050:        package util;
051:
052:        import java.util.ArrayList;
053:        import java.util.Arrays;
054:        import java.util.List;
055:        import java.util.Locale;
056:        import java.util.ResourceBundle;
057:        import java.util.Set;
058:
059:        import junit.framework.Test;
060:        import junit.framework.TestCase;
061:        import junit.framework.TestSuite;
062:        import de.danet.an.util.ResourceBundleAsMap;
063:        import de.danet.an.util.SegmentedMap;
064:
065:        /**
066:         * Tests the SegmentedResourceBundle
067:         */
068:        public class SegResBundle extends TestCase {
069:            /**
070:             * Konstruktor zum Erzeugen eines TestCase
071:             */
072:            public SegResBundle(String name) {
073:                super (name);
074:            }
075:
076:            /**
077:             * Assembling the test suite
078:             */
079:            public static Test suite() {
080:                TestSuite suite = new TestSuite();
081:
082:                suite.addTest(new SegResBundle("getAllResources"));
083:                suite.addTest(new SegResBundle("getKeysOfPathDanetOSS"));
084:                suite.addTest(new SegResBundle("getKeysOfPathDanetOSSAN"));
085:                suite.addTest(new SegResBundle("getKeysOfPathTelekom"));
086:                suite.addTest(new SegResBundle("getKeysOfEmptyPath"));
087:                suite.addTest(new SegResBundle("getValues"));
088:                suite.addTest(new SegResBundle("testKeyListCache"));
089:                suite.addTest(new SegResBundle("testValueCache"));
090:                return suite;
091:            }
092:
093:            /**
094:             * Test locale and loading all resource entries
095:             */
096:            public void getAllResources() throws Exception {
097:                ResourceBundle bundle = ResourceBundle.getBundle(
098:                        "util.I18nTest", Locale.GERMANY);
099:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
100:                SegmentedMap segmap = new SegmentedMap(rbm);
101:
102:                // Make sure that german property file is used
103:                assertTrue(bundle.getLocale().toString().equals("de"));
104:                int i = segmap.size();
105:                // Verfiy that all entries have been found
106:                assertTrue(i == 21);
107:            }
108:
109:            /**
110:             * Test loading all resource entries in path "danet.oss"
111:             */
112:            public void getKeysOfPathDanetOSS() throws Exception {
113:                final String[] resultKeys = { "danet.oss.danet",
114:                        "danet.oss.poolPKW", "danet.oss.oss", "danet.oss.sm",
115:                        "danet.oss.bss", "danet.oss.an.poolPKW", "danet.oss.z",
116:                        "danet.oss.danet-is", "danet.oss.telekom",
117:                        "danet.oss.an", "danet.oss.tt" };
118:                List resultList = new ArrayList();
119:                resultList.addAll(Arrays.asList(resultKeys));
120:
121:                ResourceBundle bundle = ResourceBundle.getBundle(
122:                        "util.I18nTest", Locale.GERMANY);
123:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
124:                SegmentedMap segmap = new SegmentedMap(rbm);
125:                Set myKeySet = segmap.keySet("danet.oss");
126:                int i = 0;
127:                assertTrue(myKeySet.containsAll(resultList));
128:                i = myKeySet.size();
129:                // Verfiy that all entries have been found
130:                assertTrue(i == resultKeys.length);
131:            }
132:
133:            /**
134:             * Test loading all resource entries in path "danet.oss.an"
135:             */
136:            public void getKeysOfPathDanetOSSAN() throws Exception {
137:                final String[] resultKeys = { "danet.oss.an.danet",
138:                        "danet.oss.an.poolPKW", "danet.oss.an.oss",
139:                        "danet.oss.an.sm", "danet.oss.an.bss",
140:                        "danet.oss.an.z", "danet.oss.an.danet-is",
141:                        "danet.oss.an.telekom", "danet.oss.an.an",
142:                        "danet.oss.an.tt" };
143:                List resultList = new ArrayList();
144:                resultList.addAll(Arrays.asList(resultKeys));
145:
146:                ResourceBundle bundle = ResourceBundle.getBundle(
147:                        "util.I18nTest", Locale.GERMANY);
148:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
149:                SegmentedMap segmap = new SegmentedMap(rbm);
150:                int i = 0;
151:                Set myKeySet = segmap.keySet("danet.oss.an");
152:                assertTrue(myKeySet.containsAll(resultList));
153:                i = myKeySet.size();
154:                // Verfiy that all entries have been found
155:                assertTrue(i == resultKeys.length);
156:            }
157:
158:            /**
159:             * Test loading all resource entries in path "telekom"
160:             */
161:            public void getKeysOfPathTelekom() throws Exception {
162:                final String[] resultKeys = { "telekom.danet",
163:                        "telekom.danet-is", "telekom.telekom",
164:                        "telekom.t-systems", "telekom.t-data",
165:                        "telekom.t-mobil" };
166:                List resultList = new ArrayList();
167:                resultList.addAll(Arrays.asList(resultKeys));
168:
169:                ResourceBundle bundle = ResourceBundle.getBundle(
170:                        "util.I18nTest", Locale.GERMANY);
171:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
172:                SegmentedMap segmap = new SegmentedMap(rbm);
173:                int i = 0;
174:                Set myKeySet = segmap.keySet("telekom");
175:                assertTrue(myKeySet.containsAll(resultList));
176:                i = myKeySet.size();
177:                // Verfiy that all entries have been found
178:                assertTrue(i == resultKeys.length);
179:            }
180:
181:            /**
182:             * Test loading all resource entries in empty path
183:             */
184:            public void getKeysOfEmptyPath() throws Exception {
185:                ResourceBundle bundle = ResourceBundle.getBundle(
186:                        "util.I18nTest", Locale.GERMANY);
187:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
188:                SegmentedMap segmap = new SegmentedMap(rbm);
189:                int i = 0;
190:                Set myKeySet = segmap.keySet();
191:                i = myKeySet.size();
192:                // Verfiy that all entries have been found
193:                assertTrue(i == 21);
194:            }
195:
196:            /**
197:             * Test loading all resource entries in empty path
198:             */
199:            public void getValues() throws Exception {
200:                ResourceBundle bundle = ResourceBundle.getBundle(
201:                        "util.I18nTest", Locale.GERMANY);
202:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
203:                SegmentedMap segmap = new SegmentedMap(rbm);
204:
205:                // oss.an has its own PKW resource
206:                assertTrue(segmap.get("danet.oss.an.poolPKW").equals(
207:                        "DA-AN 964"));
208:                // oss.sm uses the PKW resource of oss
209:                assertTrue(segmap.get("danet.oss.sm.poolPKW").equals(
210:                        "DA-OS 137"));
211:                // bss.bs uses the PKW resource of danet
212:                assertTrue(segmap.get("danet.bss.bs.poolPKW").equals(
213:                        "DA-NET 123"));
214:                // everybody uses danet
215:                assertTrue(segmap.get("danet.oss.an.danet")
216:                        .equals("Danet GmbH"));
217:                boolean notFound = false;
218:                Object value = segmap.get("telekom.poolPKW");
219:                if ((value == null) && !segmap.containsKey("telekom.poolPKW")) {
220:                    notFound = true;
221:                }
222:                assertTrue(notFound);
223:            }
224:
225:            /**
226:             * Test caching of key list to given path
227:             */
228:            public void testKeyListCache() throws Exception {
229:                ResourceBundle bundle = ResourceBundle.getBundle(
230:                        "util.I18nTest", Locale.GERMANY);
231:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
232:                SegmentedMap segmap = new SegmentedMap(rbm);
233:                Set keyList1 = segmap.keySet("telekom");
234:                Set keyList2 = segmap.keySet("telekom");
235:                Set keyList3 = segmap.keySet("danet");
236:                Set keyList4 = segmap.keySet("telekom.t-data");
237:                // Verfiy that keylist1 matches keylist2
238:                assertTrue(keyList1.equals(keyList2));
239:                // Verfiy that keylist1 doesn't match keylist3
240:                assertTrue(!(keyList1.equals(keyList3)));
241:                // Verfiy that keylist1 doesn't match keylist4
242:                assertTrue(!(keyList1.equals(keyList4)));
243:            }
244:
245:            /**
246:             * Test caching of value to given key
247:             */
248:            public void testValueCache() throws Exception {
249:                ResourceBundle bundle = ResourceBundle.getBundle(
250:                        "util.I18nTest", Locale.GERMANY);
251:                ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
252:                SegmentedMap segmap = new SegmentedMap(rbm);
253:
254:                String pkw1 = (String) segmap.get("danet.oss.sm.poolPKW");
255:                String pkw2 = (String) segmap.get("danet.oss.poolPKW");
256:                String pkw3 = (String) segmap.get("danet.oss.sm.poolPKW");
257:                assertTrue(pkw1.equals(pkw2));
258:                assertTrue(pkw1 == pkw3);
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.