1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 package org.apache.harmony.tests.java.util;
18 
19 import junit.framework.TestCase;
20 import tests.support.resource.Support_Resources;
21 import java.io.File;
22 import java.io.FileNotFoundException;
23 import java.io.FileWriter;
24 import java.io.IOException;
25 import java.io.InputStreamReader;
26 import java.io.PrintWriter;
27 import java.io.Reader;
28 import java.io.Writer;
29 import java.net.URL;
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.List;
33 import java.util.ListResourceBundle;
34 import java.util.Locale;
35 import java.util.PropertyResourceBundle;
36 import java.util.ResourceBundle;
37 import java.util.ResourceBundle.Control;
38 import java.util.Scanner;
39 import static java.util.ResourceBundle.Control.*;
40 
41 /**
42  * Test cases for java.util.ResourceBundle.Control
43  *
44  * @since 1.6
45  */
46 public class ControlTest extends TestCase {
47 
48     /**
49      * Control with format:FORMAT_PROPERTIES
50      */
51     private Control controlP;
52 
53     /**
54      * Control with format:FORMAT_CLASS
55      */
56     private Control controlC;
57 
58     /**
59      * Control with format:FORMAT_DEFAULT
60      */
61     private Control control;
62 
63     /**
64      * {@link java.util.ResourceBundle.Control#Control()}.
65      */
66     @SuppressWarnings("nls")
test_Constructor()67     public void test_Constructor() {
68 
69         class SubControl extends Control {
70             SubControl() {
71                 super();
72             }
73         }
74         Control subControl = new SubControl();
75         assertEquals(FORMAT_DEFAULT, subControl.getFormats(""));
76         assertFalse(control.equals(subControl));
77     }
78 
79     /**
80      * Test for all the public constants.
81      *
82      * {@link java.util.ResourceBundle.Control#FORMAT_CLASS}
83      * {@link java.util.ResourceBundle.Control#FORMAT_DEFAULT}
84      * {@link java.util.ResourceBundle.Control#FORMAT_PROPERTIES}
85      * {@link java.util.ResourceBundle.Control#TTL_DONT_CACHE}
86      * {@link java.util.ResourceBundle.Control#TTL_NO_EXPIRATION_CONTROL}
87      */
88     @SuppressWarnings("nls")
test_Constants()89     public void test_Constants() {
90         List<String> list = FORMAT_CLASS;
91         assertEquals(1, list.size());
92         assertEquals("java.class", list.get(0));
93         list = FORMAT_PROPERTIES;
94         assertEquals(1, list.size());
95         assertEquals("java.properties", list.get(0));
96         list = FORMAT_DEFAULT;
97         assertEquals(2, list.size());
98         assertEquals("java.class", list.get(0));
99         assertEquals("java.properties", list.get(1));
100         try {
101             FORMAT_CLASS.add("");
102             fail("Should throw UnsupportedOperationException");
103         } catch (UnsupportedOperationException e) {
104             // expected
105         }
106         try {
107             FORMAT_DEFAULT.add("");
108             fail("Should throw UnsupportedOperationException");
109         } catch (UnsupportedOperationException e) {
110             // expected
111         }
112         try {
113             FORMAT_PROPERTIES.add("");
114             fail("Should throw UnsupportedOperationException");
115         } catch (UnsupportedOperationException e) {
116             // expected
117         }
118         Class<?> unmodifiableListClass = Collections.unmodifiableList(
119                 new ArrayList<String>()).getClass();
120         assertEquals(FORMAT_CLASS.getClass(), unmodifiableListClass);
121         assertEquals(FORMAT_DEFAULT.getClass(), unmodifiableListClass);
122         assertEquals(FORMAT_PROPERTIES.getClass(), unmodifiableListClass);
123         assertEquals(-1L, TTL_DONT_CACHE);
124         assertEquals(-2L, TTL_NO_EXPIRATION_CONTROL);
125     }
126 
127     /**
128      * {@link java.util.ResourceBundle.Control#getControl(java.util.List)}.
129      */
130     @SuppressWarnings("nls")
test_getControl_LList()131     public void test_getControl_LList() {
132         // singleton
133         assertSame(control, Control.getControl(FORMAT_DEFAULT));
134         assertSame(controlC, Control.getControl(FORMAT_CLASS));
135         assertSame(controlP, Control.getControl(FORMAT_PROPERTIES));
136 
137         // class
138         assertTrue(control.getClass() == Control.class);
139         assertTrue(controlC.getClass() != Control.class);
140         assertTrue(controlP.getClass() != Control.class);
141 
142         // formats: need not same, just need equal
143         List<String> list = new ArrayList<String>(FORMAT_CLASS);
144         assertSame(controlC, Control.getControl(list));
145         // can add
146         list.add(FORMAT_PROPERTIES.get(0));
147         assertSame(control, Control.getControl(list));
148 
149         // exceptions
150         try {
151             Control.getControl(null);
152             fail("Should throw NullPointerException");
153         } catch (NullPointerException e) {
154             // expected
155         }
156         list = new ArrayList<String>();
157         try {
158             Control.getControl(list);
159             fail("Should throw IllegalArgumentException");
160         } catch (IllegalArgumentException e) {
161             // expected
162         }
163         list = new ArrayList<String>(FORMAT_CLASS);
164         // java.class -> JAVA.CLASS
165         list.set(0, list.get(0).toUpperCase());
166         try {
167             Control.getControl(list);
168             fail("Should throw IllegalArgumentException");
169         } catch (IllegalArgumentException e) {
170             // expected
171         }
172         list = new ArrayList<String>(FORMAT_CLASS);
173         list.add("");
174         try {
175             Control.getControl(list);
176             fail("Should throw IllegalArgumentException");
177         } catch (IllegalArgumentException e) {
178             // expected
179         }
180     }
181 
182     /**
183      * {@link java.util.ResourceBundle.Control#getNoFallbackControl(java.util.List)}.
184      */
185     @SuppressWarnings("nls")
test_getNoFallbackControl_LList()186     public void test_getNoFallbackControl_LList() {
187         assertNotSame(control, Control.getNoFallbackControl(FORMAT_DEFAULT));
188         assertNotSame(controlC, Control.getNoFallbackControl(FORMAT_CLASS));
189         assertNotSame(controlP, Control.getNoFallbackControl(FORMAT_PROPERTIES));
190         controlP = Control.getNoFallbackControl(FORMAT_PROPERTIES);
191         controlC = Control.getNoFallbackControl(FORMAT_CLASS);
192         control = Control.getNoFallbackControl(FORMAT_DEFAULT);
193         // singleton
194         assertSame(control, Control.getNoFallbackControl(FORMAT_DEFAULT));
195         assertSame(controlC, Control.getNoFallbackControl(FORMAT_CLASS));
196         assertSame(controlP, Control.getNoFallbackControl(FORMAT_PROPERTIES));
197 
198         // class
199         assertTrue(control.getClass() != Control.class);
200         assertTrue(controlC.getClass() != Control.class);
201         assertTrue(controlP.getClass() != Control.class);
202 
203         // format
204         assertEquals(FORMAT_CLASS, controlC.getFormats(""));
205         assertEquals(FORMAT_DEFAULT, control.getFormats(""));
206         assertEquals(FORMAT_PROPERTIES, controlP.getFormats(""));
207 
208         // no fall back locale
209         Locale defaultLocale = Locale.getDefault();
210         Locale.setDefault(new Locale("TestLanguage", "TestCountry", "Var"));
211         assertNull(control.getFallbackLocale("message", Locale.US));
212         try {
213             control.getFallbackLocale("message", null);
214             fail("Should throw NullPointerException");
215         } catch (NullPointerException e) {
216             // expected
217         }
218         try {
219             control.getFallbackLocale(null, Locale.US);
220             fail("Should throw NullPointerException");
221         } catch (NullPointerException e) {
222             // expected
223         }
224         Locale.setDefault(defaultLocale);
225 
226         // formats: need not same, just need equal
227         List<String> list = new ArrayList<String>(FORMAT_CLASS);
228         assertSame(controlC, Control.getNoFallbackControl(list));
229         // can add
230         list.add(FORMAT_PROPERTIES.get(0));
231         assertSame(control, Control.getNoFallbackControl(list));
232 
233         // exceptions
234         try {
235             Control.getNoFallbackControl(null);
236             fail("Should throw NullPointerException");
237         } catch (NullPointerException e) {
238             // expected
239         }
240         list = new ArrayList<String>();
241         try {
242             Control.getNoFallbackControl(list);
243             fail("Should throw IllegalArgumentException");
244         } catch (IllegalArgumentException e) {
245             // expected
246         }
247         list = new ArrayList<String>(FORMAT_CLASS);
248         // java.class -> JAVA.CLASS
249         list.set(0, list.get(0).toUpperCase());
250         try {
251             Control.getNoFallbackControl(list);
252             fail("Should throw IllegalArgumentException");
253         } catch (IllegalArgumentException e) {
254             // expected
255         }
256         list = new ArrayList<String>(FORMAT_CLASS);
257         list.add("");
258         try {
259             Control.getNoFallbackControl(list);
260             fail("Should throw IllegalArgumentException");
261         } catch (IllegalArgumentException e) {
262             // expected
263         }
264     }
265 
266     /**
267      * {@link java.util.ResourceBundle.Control#getFormats(java.lang.String)}.
268      */
269     @SuppressWarnings("nls")
test_getFormats_LString()270     public void test_getFormats_LString() {
271         assertEquals(FORMAT_DEFAULT, control.getFormats(""));
272         assertEquals(FORMAT_PROPERTIES, controlP.getFormats(""));
273         assertEquals(FORMAT_CLASS, controlC.getFormats(""));
274         try {
275             controlC.getFormats(null);
276             fail("Should throw NullPointerException");
277         } catch (NullPointerException e) {
278             // expected
279         }
280     }
281 
282     /**
283      * {@link java.util.ResourceBundle.Control#getCandidateLocales(java.lang.String, java.util.Locale)}.
284      */
285     @SuppressWarnings("nls")
test_getCandidateLocales_LStringLLocale()286     public void test_getCandidateLocales_LStringLLocale() {
287         // the ResourceBundle for this baseName and Locale does not exists
288         List<Locale> result = control.getCandidateLocales("baseName",
289                 new Locale("one", "two", "three"));
290         assertEquals(4, result.size());
291         Locale locale = result.get(0);
292         assertEquals("one", locale.getLanguage());
293         assertEquals("TWO", locale.getCountry());
294         assertEquals("three", locale.getVariant());
295         assertEquals(new Locale("one", "TWO"), result.get(1));
296         assertEquals(new Locale("one"), result.get(2));
297         assertSame(Locale.ROOT, result.get(3));
298         // ArrayList is not immutable
299         assertTrue(ArrayList.class == result.getClass());
300 
301         result = control.getCandidateLocales("baseName", new Locale("one",
302                 "two", ""));
303         assertEquals(new Locale("one", "TWO"), result.get(0));
304         assertEquals(new Locale("one"), result.get(1));
305         assertSame(Locale.ROOT, result.get(2));
306 
307         result = control.getCandidateLocales("baseName", new Locale("one", "",
308                 "three"));
309         assertEquals(new Locale("one", "", "three"), result.get(0));
310         assertEquals(new Locale("one"), result.get(1));
311         assertSame(Locale.ROOT, result.get(2));
312 
313         result = control.getCandidateLocales("baseName", new Locale("", "two",
314                 "three"));
315         assertEquals(new Locale("", "TWO", "three"), result.get(0));
316         assertEquals(new Locale("", "TWO"), result.get(1));
317         assertSame(Locale.ROOT, result.get(2));
318 
319         result = control.getCandidateLocales("baseName", new Locale("", "",
320                 "three"));
321         assertEquals(new Locale("", "", "three"), result.get(0));
322         assertSame(Locale.ROOT, result.get(1));
323 
324         result = control.getCandidateLocales("baseName", new Locale("", "two",
325                 ""));
326         assertEquals(new Locale("", "TWO"), result.get(0));
327         assertSame(Locale.ROOT, result.get(1));
328 
329         result = control.getCandidateLocales("baseName", Locale.ROOT);
330         assertSame(Locale.ROOT, result.get(0));
331 
332         try {
333             control.getCandidateLocales(null, Locale.US);
334             fail("Should throw NullPointerException");
335         } catch (NullPointerException e) {
336             // expected
337         }
338 
339         try {
340             control.getCandidateLocales("baseName", null);
341             fail("Should throw NullPointerException");
342         } catch (NullPointerException e) {
343             // expected
344         }
345     }
346 
347     /**
348      * {@link java.util.ResourceBundle.Control#getFallbackLocale(java.lang.String, java.util.Locale)}.
349      */
350     @SuppressWarnings("nls")
test_getFallbackLocale_LStringLLocale()351     public void test_getFallbackLocale_LStringLLocale() {
352         Locale defaultLocale = Locale.getDefault();
353         Locale testLocale = new Locale("TestLanguage", "TestCountry", "Var");
354         Locale.setDefault(testLocale);
355         assertSame(testLocale, control.getFallbackLocale("baseName",
356                 Locale.ROOT));
357         assertSame(testLocale, control.getFallbackLocale("baseName", Locale.US));
358         assertSame(null, control.getFallbackLocale("baseName", testLocale));
359         try {
360             control.getFallbackLocale(null, Locale.US);
361             fail("Should throw NullPointerException");
362         } catch (NullPointerException e) {
363             // expected
364         }
365 
366         try {
367             control.getFallbackLocale("baseName", null);
368             fail("Should throw NullPointerException");
369         } catch (NullPointerException e) {
370             // expected
371         }
372         // restore
373         Locale.setDefault(defaultLocale);
374     }
375 
376     @SuppressWarnings("nls")
copyFile(final URL src)377     static File copyFile(final URL src) throws IOException {
378         String tail = src.getFile().split("hyts_resource")[1];
379         String tmpdir = System.getProperty("java.io.tmpdir");
380         if (null == tmpdir) {
381             return null;
382         }
383         String copyName = tmpdir + File.separator + "hyts_resource_copy" + tail;
384         File copy = new File(copyName);
385         if (copy.exists()) {
386             copy.delete();
387         }
388         copy.createNewFile();
389         copy.deleteOnExit();
390 
391         Reader in = new InputStreamReader(src.openStream());
392         Writer out = new FileWriter(copy);
393         int c;
394         while ((c = in.read()) != -1) {
395             out.write(c);
396         }
397         in.close();
398         out.close();
399         return copy;
400     }
401 
402     static class SubRBStaticPrivate extends ListResourceBundle {
SubRBStaticPrivate()403         private SubRBStaticPrivate() {
404             super();
405         }
406 
407         @Override
getContents()408         protected Object[][] getContents() {
409             return null;
410         }
411     }
412 
413     /*
414      * change the value in the .properties file
415      */
416     @SuppressWarnings("nls")
changeProperties(File file)417     static void changeProperties(File file) throws FileNotFoundException {
418         String newValue = "property=changedValue";
419         PrintWriter writer = new PrintWriter(file);
420         writer.write(newValue);
421         writer.flush();
422         writer.close();
423         Scanner scanner = new Scanner(file);
424         assertEquals(newValue, scanner.nextLine());
425         scanner.close();
426     }
427 
428     /**
429      * {@link java.util.ResourceBundle.Control#getTimeToLive(java.lang.String, java.util.Locale)}.
430      */
431     @SuppressWarnings("nls")
test_getTimeToLive_LStringLLocale()432     public void test_getTimeToLive_LStringLLocale() {
433         assertEquals(TTL_NO_EXPIRATION_CONTROL, control.getTimeToLive(
434                 "baseName", Locale.US));
435         try {
436             control.getTimeToLive(null, Locale.US);
437             fail("Should throw NullPointerException");
438         } catch (NullPointerException e) {
439             // expected
440         }
441         try {
442             control.getTimeToLive("baseName", null);
443             fail("Should throw NullPointerException");
444         } catch (NullPointerException e) {
445             // expected
446         }
447     }
448 
449     /**
450      * @throws Exception
451      * {@link java.util.ResourceBundle.Control#needsReload(java.lang.String, java.util.Locale, java.lang.String, java.lang.ClassLoader, java.util.ResourceBundle, long)}.
452      */
453     @SuppressWarnings("nls")
test_needsReload_LStringLLocaleLStringLClassLoaderResourceBundleJ()454     public void test_needsReload_LStringLLocaleLStringLClassLoaderResourceBundleJ()
455             throws Exception {
456         String className = "tests.support.Support_TestResource";
457         String propertiesName = Support_Resources.RESOURCE_PACKAGE_NAME
458                 + ".hyts_resource";
459         String propertiesNameCopy = "hyts_resource_copy";
460         String CLASS = "java.class";
461         String PROPERTIES = "java.properties";
462         Locale frFR = new Locale("fr", "FR");
463         ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
464         ClassLoader URLLoader = systemLoader;
465         ResourceBundle bundle = null;
466         long time = 0L;
467         final URL srcFile = URLLoader.getResource(control.toResourceName(
468                 control.toBundleName(propertiesName, frFR), "properties"));
469         assertNotNull(srcFile);
470         final File copyFile = copyFile(srcFile);
471 
472         // 1. format = "java.properties"
473         if (null != URLLoader.getResourceAsStream(copyFile.toURL().toString())) {
474             Thread.sleep(1000);
475             bundle = control.newBundle(propertiesNameCopy, frFR, PROPERTIES,
476                     URLLoader, false);
477             time = System.currentTimeMillis();
478             assertTrue(bundle.getClass() == PropertyResourceBundle.class);
479             assertEquals("fr_FR_resource", bundle.getString("property"));
480             assertFalse(control.needsReload(propertiesNameCopy, frFR,
481                     PROPERTIES, URLLoader, bundle, time));
482             // change the file
483             Thread.sleep(2000);
484             changeProperties(copyFile);
485             assertTrue(control.needsReload(propertiesNameCopy, frFR,
486                     PROPERTIES, URLLoader, bundle, time));
487             // detect again
488             assertTrue(control.needsReload(propertiesNameCopy, frFR,
489                     PROPERTIES, URLLoader, bundle, time));
490             // long long ago
491             assertTrue(control.needsReload(propertiesNameCopy, frFR,
492                     PROPERTIES, URLLoader, bundle, 2006L));
493             // other loader
494             assertFalse(control.needsReload(propertiesNameCopy, frFR,
495                     PROPERTIES, systemLoader, bundle, time));
496             // other bundle
497             ResourceBundle otherBundle = control.newBundle(propertiesName,
498                     Locale.ROOT, PROPERTIES, systemLoader, false);
499             assertEquals("parent", otherBundle.getString("property"));
500             assertTrue(control.needsReload(propertiesNameCopy, frFR,
501                     PROPERTIES, URLLoader, otherBundle, time));
502             otherBundle = control.newBundle(propertiesName, Locale.ROOT,
503                     PROPERTIES, URLLoader, false);
504             assertEquals("resource", otherBundle.getString("property"));
505             assertTrue(control.needsReload(propertiesNameCopy, frFR,
506                     PROPERTIES, URLLoader, otherBundle, time));
507             // other time
508             assertFalse(control.needsReload(propertiesNameCopy, frFR,
509                     PROPERTIES, URLLoader, bundle, System.currentTimeMillis()));
510         } else {
511             System.err
512                     .println("Can not find the test file, some code of this test 'test_needsReload_LStringLLocaleLStringLClassLoaderResourceBundleJ' did not run.");
513 
514         }
515 
516         // 2. format = "java.class"
517         bundle = control.newBundle(className, frFR, CLASS, systemLoader, false);
518         time = System.currentTimeMillis();
519         assertEquals("frFRValue3", bundle.getString("parent3"));
520         assertFalse(control.needsReload(className, frFR, CLASS, systemLoader,
521                 bundle, time));
522         // exceptions
523         control.needsReload(propertiesName, frFR, PROPERTIES, URLLoader,
524                 bundle, time);
525         try {
526             control
527                     .needsReload(null, frFR, PROPERTIES, URLLoader, bundle,
528                             time);
529             fail("Should throw NullPointerException");
530         } catch (NullPointerException e) {
531             // expected
532         }
533         try {
534             control.needsReload(propertiesName, null, PROPERTIES, URLLoader,
535                     bundle, time);
536             fail("Should throw NullPointerException");
537         } catch (NullPointerException e) {
538             // expected
539         }
540         try {
541             control.needsReload(propertiesName, frFR, null, URLLoader, bundle,
542                     time);
543             fail("Should throw NullPointerException");
544         } catch (NullPointerException e) {
545             // expected
546         }
547         try {
548             control.needsReload(propertiesName, frFR, PROPERTIES, null, bundle,
549                     time);
550             fail("Should throw NullPointerException");
551         } catch (NullPointerException e) {
552             // expected
553         }
554         try {
555             control.needsReload(propertiesName, frFR, PROPERTIES, URLLoader,
556                     null, time);
557             fail("Should throw NullPointerException");
558         } catch (NullPointerException e) {
559             // expected
560         }
561     }
562 
563     /**
564      * {@link java.util.ResourceBundle.Control#toBundleName(java.lang.String, java.util.Locale)}.
565      */
566     @SuppressWarnings("nls")
test_toBundleName_LStringLLocale()567     public void test_toBundleName_LStringLLocale() {
568         assertEquals("baseName_one_TWO_three", control.toBundleName("baseName",
569                 new Locale("one", "two", "three")));
570         assertEquals("baseName_one_TWO", control.toBundleName("baseName",
571                 new Locale("one", "two")));
572         assertEquals("baseName_one__three", control.toBundleName("baseName",
573                 new Locale("one", "", "three")));
574         assertEquals("baseName__TWO_three", control.toBundleName("baseName",
575                 new Locale("", "two", "three")));
576         assertEquals("baseName_one", control.toBundleName("baseName",
577                 new Locale("one", "", "")));
578         assertEquals("baseName___three", control.toBundleName("baseName",
579                 new Locale("", "", "three")));
580         assertEquals("baseName__TWO", control.toBundleName("baseName",
581                 new Locale("", "two", "")));
582         assertEquals("baseName", control.toBundleName("baseName", new Locale(
583                 "", "", "")));
584         assertEquals("baseName", control.toBundleName("baseName", Locale.ROOT));
585         assertEquals("_one_TWO_three", control.toBundleName("", new Locale(
586                 "one", "two", "three")));
587         assertEquals("", control.toBundleName("", Locale.ROOT));
588 
589         assertEquals("does.not.exists_one_TWO_three", control.toBundleName(
590                 "does.not.exists", new Locale("one", "two", "three")));
591         assertEquals("does/not/exists_one_TWO_three", control.toBundleName(
592                 "does/not/exists", new Locale("one", "two", "three")));
593         assertEquals("does_not_exists__one_TWO_three", control.toBundleName(
594                 "does_not_exists_", new Locale("one", "two", "three")));
595 
596         assertEquals("...", control.toBundleName("...", Locale.ROOT));
597         assertEquals("s/./\\//g", control
598                 .toBundleName("s/./\\//g", Locale.ROOT));
599         assertEquals("123_one", control.toBundleName("123", new Locale("one")));
600 
601         try {
602             control.toBundleName(null, Locale.US);
603             fail("Should throw NullPointerException");
604         } catch (NullPointerException e) {
605             // expected
606         }
607 
608         try {
609             control.toBundleName("baseName", null);
610             fail("Should throw NullPointerException");
611         } catch (NullPointerException e) {
612             // expected
613         }
614     }
615 
616     /**
617      * {@link java.util.ResourceBundle.Control#toResourceName(java.lang.String, java.lang.String)}.
618      */
619     @SuppressWarnings("nls")
test_toResourceNameLStringLString()620     public void test_toResourceNameLStringLString() {
621         assertEquals("does/not/exists_language_country.someSuffix", control
622                 .toResourceName("does.not.exists_language_country",
623                         "someSuffix"));
624         assertEquals("does/not/exists_language_country.someSuffix", control
625                 .toResourceName("does/not/exists_language_country",
626                         "someSuffix"));
627         assertEquals("does///not//exists_language/country.someSuffix", control
628                 .toResourceName("does...not..exists_language.country",
629                         "someSuffix"));
630         assertEquals("does\\not\\exists_language_country.someSuffix", control
631                 .toResourceName("does\\not\\exists_language_country",
632                         "someSuffix"));
633         assertEquals("does/not/exists_language_country/.someSuffix", control
634                 .toResourceName("does.not.exists_language_country.",
635                         "someSuffix"));
636         assertEquals("does/not/exists_language_country../someSuffix", control
637                 .toResourceName("does.not.exists_language_country",
638                         "./someSuffix"));
639 
640         assertEquals("///.//", control.toResourceName("...", "//"));
641         assertEquals("///...", control.toResourceName("///", ".."));
642         assertEquals("123...", control.toResourceName("123", ".."));
643         assertEquals("base.", control.toResourceName("base", ""));
644         assertEquals(".suffix", control.toResourceName("", "suffix"));
645         assertEquals(".", control.toResourceName("", ""));
646 
647         try {
648             control.toResourceName(null, "suffix");
649             fail("Should throw NullPointerException");
650         } catch (NullPointerException e) {
651             // expected
652         }
653 
654         try {
655             control.toResourceName("bundleName", null);
656             fail("Should throw NullPointerException");
657         } catch (NullPointerException e) {
658             // expected
659         }
660 
661     }
662 
663     /**
664      * @throws java.lang.Exception
665      */
666     @Override
tearDown()667     protected void tearDown() throws Exception {
668         super.tearDown();
669     }
670 
671     /**
672      * @throws java.lang.Exception
673      */
674     @Override
setUp()675     protected void setUp() throws Exception {
676         super.setUp();
677         controlP = Control.getControl(FORMAT_PROPERTIES);
678         controlC = Control.getControl(FORMAT_CLASS);
679         control = Control.getControl(FORMAT_DEFAULT);
680     }
681 
682 }
683