Commit c71b1f48f1953e49f203ae607cc1376390627d24

Authored by Emerson Oliveira
1 parent 3cd30a8f
Exists in master

Revisão da classe ResourceBundleTest. Foram removidos testes

desnecessários, e mantido apenas o teste da método getString().
impl/core/src/test/java/util/ResourceBundleTest.java
... ... @@ -49,49 +49,13 @@ import org.junit.Test;
49 49  
50 50 import br.gov.frameworkdemoiselle.util.ResourceBundle;
51 51  
52   -@Ignore
53 52 public class ResourceBundleTest {
54 53  
55   - /**
56   - * This is a workaround to mock java.util.ResourceBundle. Since getString(key) method is defined as final, there is
57   - * no way to extend and override it. For that reason, setting expectations (i.e. expect(...)) won't work.
58   - */
59 54 private ResourceBundle resourceBundle;
60 55  
61 56 @Before
62 57 public void setUp() throws Exception {
63   - resourceBundle = new ResourceBundle("resource-bundle", new Locale("pt"));
64   - }
65   -
66   - @Test
67   - public void containsKey() {
68   - assertTrue(resourceBundle.containsKey("msgWithoutParams"));
69   -
70   - assertFalse(resourceBundle.containsKey("inexistentKey"));
71   - }
72   -
73   - @Test
74   - public void getKeys() {
75   - int keyCount = 0;
76   -
77   - Enumeration<String> e = resourceBundle.getKeys();
78   -
79   - while (e.hasMoreElements()) {
80   - keyCount++;
81   - e.nextElement();
82   - }
83   -
84   - assertEquals(resourceBundle.keySet().size(), keyCount);
85   - }
86   -
87   - @Test
88   - public void testGetLocale() {
89   - assertEquals(resourceBundle.getLocale(), new Locale("pt"));
90   - }
91   -
92   - @Test
93   - public void testKeySet() {
94   - assertEquals(2, resourceBundle.keySet().size());
  58 + resourceBundle = new ResourceBundle("resourcebundle/resource-bundle", new Locale("pt"));
95 59 }
96 60  
97 61 @Test
... ... @@ -103,24 +67,4 @@ public class ResourceBundleTest {
103 67 assertEquals("params: {0}, {1}", resourceBundle.getString("msgWithParams"));
104 68 }
105 69  
106   - /**
107   - * For this test, java.util.ResourceBundle is mocked to force an exception. Since the getString method is called
108   - * from the actual ResourceBundle, not from the mock, it tries to find a handleGetObject method that doesn't exist.
109   - *
110   - * @throws Exception
111   - */
112   - // @Test(expected = RuntimeException.class)
113   - // public void getStringWhenHandleGetObjectThrowsException() {
114   - // mockResourceBundle = createMock(java.util.ResourceBundle.class);
115   - // resourceBundle = new ResourceBundle(mockResourceBundle);
116   - //
117   - // replay(mockResourceBundle);
118   - //
119   - // resourceBundle.getString("msgWithParams");
120   - //
121   - // verify(mockResourceBundle);
122   - //
123   - // Assert.fail();
124   - // }
125   -
126 70 }
... ...