001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: package com.izforge.izpack;
021:
022: import java.io.File;
023: import java.io.FileInputStream;
024: import java.util.Iterator;
025:
026: import junit.framework.TestCase;
027:
028: /**
029: * A JUnit TestCase to check completeness of the all the language packs
030: *
031: * @author Hans Aikema
032: *
033: */
034: public class Bin_Langpacks_InstallerTest extends TestCase {
035: private final static String referencePack = "eng.xml";
036: private final static String basePath = "." + File.separator + "bin"
037: + File.separator + "langpacks" + File.separator
038: + "installer" + File.separator;
039: private static LocaleDatabase reference;
040: private LocaleDatabase check;
041:
042: /**
043: * Creates a new 'test all' installer langpack testcase
044: *
045: * @throws Exception Forwarded Exception from LocaleDatabase constructor or FileNotFoundException on allocation of the reference languagepack
046: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
047: */
048: public Bin_Langpacks_InstallerTest() throws Exception {
049: this ("");
050: }
051:
052: /**
053: * Creates a new 'single testmethod' installer langpack testcase
054: *
055: * @throws Exception Forwarded Exception from LocaleDatabase constructor or FileNotFoundException on allocation of the reference languagepack
056: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
057: * @see junit.framework.TestCase#TestCase(java.lang.String)
058: */
059: public Bin_Langpacks_InstallerTest(String arg0) throws Exception {
060: super (arg0);
061: Bin_Langpacks_InstallerTest.reference = new LocaleDatabase(
062: new FileInputStream(basePath + referencePack));
063: }
064:
065: private void checkLangpack(String langpack) throws Exception {
066: this .check = new LocaleDatabase(new FileInputStream(basePath
067: + langpack));
068: // all keys in the English langpack should be present in the foreign langpack
069: for (Iterator i = reference.keySet().iterator(); i.hasNext();) {
070: // Locale Database uses the id strings as keys
071: String id = (String) i.next();
072: assertTrue("Missing translation for id:" + id, this .check
073: .containsKey(id));
074: }
075: // there should be no keys in the foreign langpack which don't exist in the
076: // english langpack
077: for (Iterator i = this .check.keySet().iterator(); i.hasNext();) {
078: // LocaleDatabase uses the id strings as keys
079: String id = (String) i.next();
080: assertTrue("Superfluous translation for id:" + id,
081: reference.containsKey(id));
082: }
083: }
084:
085: /**
086: * Checks the Catalan language pack for missing / superfluous translations
087: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
088: *
089: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
090: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
091: * @see java.util.TreeMap#containsKey(java.lang.Object)
092: */
093: public void testCat() throws Exception {
094: this .checkLangpack("cat.xml");
095: }
096:
097: /**
098: * Checks the Chinese language pack for missing / superfluous translations
099: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
100: *
101: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
102: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
103: * @see java.util.TreeMap#containsKey(java.lang.Object)
104: */
105: public void testChn() throws Exception {
106: this .checkLangpack("chn.xml");
107: }
108:
109: /**
110: * Checks the Czech language pack for missing / superfluous translations
111: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
112: *
113: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
114: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
115: * @see java.util.TreeMap#containsKey(java.lang.Object)
116: */
117: public void testCze() throws Exception {
118: this .checkLangpack("cze.xml");
119: }
120:
121: /**
122: * Checks the Danish language pack for missing / superfluous translations
123: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
124: *
125: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
126: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
127: * @see java.util.TreeMap#containsKey(java.lang.Object)
128: */
129: public void testDan() throws Exception {
130: this .checkLangpack("dan.xml");
131: }
132:
133: /**
134: * Checks the German language pack for missing / superfluous translations
135: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
136: *
137: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
138: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
139: * @see java.util.TreeMap#containsKey(java.lang.Object)
140: */
141: public void testDeu() throws Exception {
142: this .checkLangpack("deu.xml");
143: }
144:
145: /**
146: * Checks the Modern Greek language pack for missing / superfluous translations
147: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
148: *
149: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
150: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
151: * @see java.util.TreeMap#containsKey(java.lang.Object)
152: */
153: public void testEll() throws Exception {
154: this .checkLangpack("ell.xml");
155: }
156:
157: /**
158: * Checks the English language pack for missing / superfluous translations<br />
159: * <em>This test should always succeed, since the english langpack is the reference pack)</em>
160: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
161: *
162: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
163: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
164: * @see java.util.TreeMap#containsKey(java.lang.Object)
165: */
166: public void testEng() throws Exception {
167: this .checkLangpack("eng.xml");
168: }
169:
170: /**
171: * Checks the Farsi language pack for missing / superfluous translations
172: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
173: *
174: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
175: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
176: * @see java.util.TreeMap#containsKey(java.lang.Object)
177: */
178: public void testFa() throws Exception {
179: this .checkLangpack("fa.xml");
180: }
181:
182: /**
183: * Checks the Finnish language pack for missing / superfluous translations
184: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
185: *
186: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
187: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
188: * @see java.util.TreeMap#containsKey(java.lang.Object)
189: */
190: public void testFin() throws Exception {
191: this .checkLangpack("fin.xml");
192: }
193:
194: /**
195: * Checks the French language pack for missing / superfluous translations
196: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
197: *
198: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
199: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
200: * @see java.util.TreeMap#containsKey(java.lang.Object)
201: */
202: public void testFra() throws Exception {
203: this .checkLangpack("fra.xml");
204: }
205:
206: /**
207: * Checks the Hungarian language pack for missing / superfluous translations
208: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
209: *
210: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
211: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
212: * @see java.util.TreeMap#containsKey(java.lang.Object)
213: */
214: public void testHun() throws Exception {
215: this .checkLangpack("hun.xml");
216: }
217:
218: /**
219: * Checks the Indonesian language pack for missing / superfluous translations
220: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
221: *
222: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
223: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
224: * @see java.util.TreeMap#containsKey(java.lang.Object)
225: */
226: public void testInd() throws Exception {
227: this .checkLangpack("ind.xml");
228: }
229:
230: /**
231: * Checks the Italian language pack for missing / superfluous translations
232: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
233: *
234: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
235: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
236: * @see java.util.TreeMap#containsKey(java.lang.Object)
237: */
238: public void testIta() throws Exception {
239: this .checkLangpack("ita.xml");
240: }
241:
242: /**
243: * Checks the Japanese language pack for missing / superfluous translations
244: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
245: *
246: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
247: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
248: * @see java.util.TreeMap#containsKey(java.lang.Object)
249: */
250: public void testJpn() throws Exception {
251: this .checkLangpack("jpn.xml");
252: }
253:
254: /**
255: * Checks the Korean language pack for missing / superfluous translations
256: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
257: *
258: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
259: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
260: * @see java.util.TreeMap#containsKey(java.lang.Object)
261: */
262: public void testKor() throws Exception {
263: this .checkLangpack("kor.xml");
264: }
265:
266: /**
267: * Checks the Malaysian language pack for missing / superfluous translations
268: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
269: *
270: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
271: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
272: * @see java.util.TreeMap#containsKey(java.lang.Object)
273: */
274: public void testMys() throws Exception {
275: this .checkLangpack("mys.xml");
276: }
277:
278: /**
279: * Checks the Dutch language pack for missing / superfluous translations
280: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
281: *
282: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
283: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
284: * @see java.util.TreeMap#containsKey(java.lang.Object)
285: */
286: public void testNed() throws Exception {
287: this .checkLangpack("ned.xml");
288: }
289:
290: /**
291: * Checks the Norwegian language pack for missing / superfluous translations
292: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
293: *
294: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
295: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
296: * @see java.util.TreeMap#containsKey(java.lang.Object)
297: */
298: public void testNor() throws Exception {
299: this .checkLangpack("nor.xml");
300: }
301:
302: /**
303: * Checks the Polish language pack for missing / superfluous translations
304: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
305: *
306: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
307: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
308: * @see java.util.TreeMap#containsKey(java.lang.Object)
309: */
310: public void testPol() throws Exception {
311: this .checkLangpack("pol.xml");
312: }
313:
314: /**
315: * Checks the Portugese language pack for missing / superfluous translations
316: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
317: *
318: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
319: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
320: * @see java.util.TreeMap#containsKey(java.lang.Object)
321: */
322: public void testPor() throws Exception {
323: this .checkLangpack("por.xml");
324: }
325:
326: /**
327: * Checks the Romanian language pack for missing / superfluous translations
328: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
329: *
330: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
331: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
332: * @see java.util.TreeMap#containsKey(java.lang.Object)
333: */
334: public void testRom() throws Exception {
335: this .checkLangpack("rom.xml");
336: }
337:
338: /**
339: * Checks the Russian language pack for missing / superfluous translations
340: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
341: *
342: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
343: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
344: * @see java.util.TreeMap#containsKey(java.lang.Object)
345: */
346: public void testRus() throws Exception {
347: this .checkLangpack("rus.xml");
348: }
349:
350: /**
351: * Checks the Serbia/Montenegro language pack for missing / superfluous translations
352: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
353: *
354: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
355: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
356: * @see java.util.TreeMap#containsKey(java.lang.Object)
357: */
358: public void testScg() throws Exception {
359: this .checkLangpack("scg.xml");
360: }
361:
362: /**
363: * Checks the Spanish language pack for missing / superfluous translations
364: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
365: *
366: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
367: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
368: * @see java.util.TreeMap#containsKey(java.lang.Object)
369: */
370: public void testSpa() throws Exception {
371: this .checkLangpack("spa.xml");
372: }
373:
374: /**
375: * Checks the Slovak language pack for missing / superfluous translations
376: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
377: *
378: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
379: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
380: * @see java.util.TreeMap#containsKey(java.lang.Object)
381: */
382: public void testSvk() throws Exception {
383: this .checkLangpack("svk.xml");
384: }
385:
386: /**
387: * Checks the Swedish language pack for missing / superfluous translations
388: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
389: *
390: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
391: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
392: * @see java.util.TreeMap#containsKey(java.lang.Object)
393: */
394: public void testSwe() throws Exception {
395: this .checkLangpack("swe.xml");
396: }
397:
398: /**
399: * Checks the Turkish language pack for missing / superfluous translations
400: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
401: *
402: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
403: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
404: * @see java.util.TreeMap#containsKey(java.lang.Object)
405: */
406: public void testTur() throws Exception {
407: this .checkLangpack("tur.xml");
408: }
409:
410: /**
411: * Checks the Ukranian language pack for missing / superfluous translations
412: * @throws Exception Forwarded Exception for the LocaleDatabase contructor, FileInputStream constructor or TreeMap containsKey method
413: *
414: * @see com.izforge.izpack.LocaleDatabase#LocaleDatabase(java.io.InputStream)
415: * @see java.io.FileInputStream#FileInputStream(java.lang.String)
416: * @see java.util.TreeMap#containsKey(java.lang.Object)
417: */
418: public void testUkr() throws Exception {
419: this .checkLangpack("ukr.xml");
420: }
421: }
|