1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package ch.qos.cal10n.util;
23
24 import static org.junit.Assert.assertEquals;
25
26 import java.io.IOException;
27 import java.util.Locale;
28 import java.util.ResourceBundle;
29
30 import org.junit.Test;
31
32 public class PropertyResourceBundleFinderTest {
33 ResourceBundle rb;
34
35 @Test
36 public void smoke() throws IOException {
37 rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
38 "colors", Locale.FRENCH);
39 assertEquals("les roses sont rouges", rb.getString("RED"));
40 }
41
42 @Test
43 public void withCountry() throws IOException {
44 rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
45 "colors", Locale.FRENCH);
46 assertEquals("les roses sont rouges", rb.getString("RED"));
47
48 rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
49 "colors", Locale.FRANCE);
50 assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
51 }
52
53 @Test
54 public void inDirectory() throws IOException {
55 rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
56 "foobar/sample", Locale.ENGLISH);
57 assertEquals("A is the first letter of the alphabet", rb.getString("A"));
58
59 rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
60 "foobar.sample", Locale.ENGLISH);
61 assertEquals("A is the first letter of the alphabet", rb.getString("A"));
62 }
63 }