Commit 6af81f592daff4268fe1d770ee004b7247e1a940
1 parent
8e8fc827
Exists in
master
Refatoração dos testes unitários do Configuration
Showing
4 changed files
with
19 additions
and
24 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java
... | ... | @@ -36,11 +36,9 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
38 | 38 | |
39 | -import static org.easymock.EasyMock.createMock; | |
40 | 39 | import static org.easymock.EasyMock.expect; |
41 | 40 | import static org.junit.Assert.assertEquals; |
42 | 41 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
43 | -import static org.powermock.api.easymock.PowerMock.replay; | |
44 | 42 | |
45 | 43 | import java.awt.Color; |
46 | 44 | import java.math.BigDecimal; |
... | ... | @@ -58,14 +56,11 @@ import org.junit.runner.RunWith; |
58 | 56 | import org.powermock.api.easymock.PowerMock; |
59 | 57 | import org.powermock.core.classloader.annotations.PrepareForTest; |
60 | 58 | import org.powermock.modules.junit4.PowerMockRunner; |
61 | -import org.powermock.reflect.Whitebox; | |
62 | -import org.slf4j.Logger; | |
63 | 59 | |
64 | 60 | import br.gov.frameworkdemoiselle.configuration.ConfigType; |
65 | 61 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
66 | 62 | import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; |
67 | 63 | import br.gov.frameworkdemoiselle.util.Beans; |
68 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
69 | 64 | |
70 | 65 | @RunWith(PowerMockRunner.class) |
71 | 66 | @PrepareForTest(Beans.class) | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java
... | ... | @@ -36,10 +36,9 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
38 | 38 | |
39 | -import static org.easymock.EasyMock.createMock; | |
40 | 39 | import static org.easymock.EasyMock.expect; |
41 | 40 | import static org.junit.Assert.assertEquals; |
42 | -import static org.powermock.api.easymock.PowerMock.replay; | |
41 | +import static org.powermock.api.easymock.PowerMock.mockStatic; | |
43 | 42 | |
44 | 43 | import java.awt.Color; |
45 | 44 | import java.math.BigDecimal; |
... | ... | @@ -53,21 +52,19 @@ import java.util.Locale; |
53 | 52 | |
54 | 53 | import org.junit.After; |
55 | 54 | import org.junit.Before; |
56 | -import org.junit.Ignore; | |
57 | 55 | import org.junit.Test; |
58 | 56 | import org.junit.runner.RunWith; |
59 | 57 | import org.powermock.api.easymock.PowerMock; |
58 | +import org.powermock.core.classloader.annotations.PrepareForTest; | |
60 | 59 | import org.powermock.modules.junit4.PowerMockRunner; |
61 | -import org.powermock.reflect.Whitebox; | |
62 | -import org.slf4j.Logger; | |
63 | 60 | |
64 | 61 | import br.gov.frameworkdemoiselle.configuration.ConfigType; |
65 | 62 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
66 | 63 | import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; |
67 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
64 | +import br.gov.frameworkdemoiselle.util.Beans; | |
68 | 65 | |
69 | -@Ignore | |
70 | 66 | @RunWith(PowerMockRunner.class) |
67 | +@PrepareForTest(Beans.class) | |
71 | 68 | public class ConfigurationLoaderWithListTest { |
72 | 69 | |
73 | 70 | private ConfigurationLoader configurationLoader; |
... | ... | @@ -150,13 +147,7 @@ public class ConfigurationLoaderWithListTest { |
150 | 147 | |
151 | 148 | @Before |
152 | 149 | public void setUp() throws Exception { |
153 | - Logger logger; | |
154 | - ResourceBundle bundle; | |
155 | - logger = PowerMock.createMock(Logger.class); | |
156 | - bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
157 | 150 | configurationLoader = new ConfigurationLoader(); |
158 | - Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); | |
159 | - Whitebox.setInternalState(this.configurationLoader, "logger", logger); | |
160 | 151 | } |
161 | 152 | |
162 | 153 | @After |
... | ... | @@ -342,12 +333,17 @@ public class ConfigurationLoaderWithListTest { |
342 | 333 | } |
343 | 334 | |
344 | 335 | private ConfigurationPropertiesWithList prepareConfigurationPropertiesWithList() { |
336 | + mockStatic(Beans.class); | |
337 | + CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | |
338 | + | |
339 | + expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | |
340 | + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | |
341 | + | |
345 | 342 | ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); |
346 | 343 | |
347 | - CoreBootstrap coreBootstrap = createMock(CoreBootstrap.class); | |
348 | 344 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); |
349 | 345 | |
350 | - replay(coreBootstrap); | |
346 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); | |
351 | 347 | |
352 | 348 | configurationLoader.load(config); |
353 | 349 | return config; |
... | ... | @@ -532,12 +528,17 @@ public class ConfigurationLoaderWithListTest { |
532 | 528 | } |
533 | 529 | |
534 | 530 | private ConfigurationXMLWithList prepareConfigurationXMLWithList() { |
531 | + mockStatic(Beans.class); | |
532 | + CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | |
533 | + | |
534 | + expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | |
535 | + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | |
536 | + | |
535 | 537 | ConfigurationXMLWithList config = new ConfigurationXMLWithList(); |
536 | 538 | |
537 | - CoreBootstrap coreBootstrap = createMock(CoreBootstrap.class); | |
538 | 539 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); |
539 | 540 | |
540 | - replay(coreBootstrap); | |
541 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); | |
541 | 542 | |
542 | 543 | configurationLoader.load(config); |
543 | 544 | return config; | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java