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