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,11 +36,9 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.configuration; | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
| 38 | 38 | ||
| 39 | -import static org.easymock.EasyMock.createMock; | ||
| 40 | import static org.easymock.EasyMock.expect; | 39 | import static org.easymock.EasyMock.expect; |
| 41 | import static org.junit.Assert.assertEquals; | 40 | import static org.junit.Assert.assertEquals; |
| 42 | import static org.powermock.api.easymock.PowerMock.mockStatic; | 41 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
| 43 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 44 | 42 | ||
| 45 | import java.awt.Color; | 43 | import java.awt.Color; |
| 46 | import java.math.BigDecimal; | 44 | import java.math.BigDecimal; |
| @@ -58,14 +56,11 @@ import org.junit.runner.RunWith; | @@ -58,14 +56,11 @@ import org.junit.runner.RunWith; | ||
| 58 | import org.powermock.api.easymock.PowerMock; | 56 | import org.powermock.api.easymock.PowerMock; |
| 59 | import org.powermock.core.classloader.annotations.PrepareForTest; | 57 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 60 | import org.powermock.modules.junit4.PowerMockRunner; | 58 | import org.powermock.modules.junit4.PowerMockRunner; |
| 61 | -import org.powermock.reflect.Whitebox; | ||
| 62 | -import org.slf4j.Logger; | ||
| 63 | 59 | ||
| 64 | import br.gov.frameworkdemoiselle.configuration.ConfigType; | 60 | import br.gov.frameworkdemoiselle.configuration.ConfigType; |
| 65 | import br.gov.frameworkdemoiselle.configuration.Configuration; | 61 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
| 66 | import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | 62 | import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; |
| 67 | import br.gov.frameworkdemoiselle.util.Beans; | 63 | import br.gov.frameworkdemoiselle.util.Beans; |
| 68 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 69 | 64 | ||
| 70 | @RunWith(PowerMockRunner.class) | 65 | @RunWith(PowerMockRunner.class) |
| 71 | @PrepareForTest(Beans.class) | 66 | @PrepareForTest(Beans.class) |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java
| @@ -36,10 +36,9 @@ | @@ -36,10 +36,9 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package br.gov.frameworkdemoiselle.internal.configuration; | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
| 38 | 38 | ||
| 39 | -import static org.easymock.EasyMock.createMock; | ||
| 40 | import static org.easymock.EasyMock.expect; | 39 | import static org.easymock.EasyMock.expect; |
| 41 | import static org.junit.Assert.assertEquals; | 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 | import java.awt.Color; | 43 | import java.awt.Color; |
| 45 | import java.math.BigDecimal; | 44 | import java.math.BigDecimal; |
| @@ -53,21 +52,19 @@ import java.util.Locale; | @@ -53,21 +52,19 @@ import java.util.Locale; | ||
| 53 | 52 | ||
| 54 | import org.junit.After; | 53 | import org.junit.After; |
| 55 | import org.junit.Before; | 54 | import org.junit.Before; |
| 56 | -import org.junit.Ignore; | ||
| 57 | import org.junit.Test; | 55 | import org.junit.Test; |
| 58 | import org.junit.runner.RunWith; | 56 | import org.junit.runner.RunWith; |
| 59 | import org.powermock.api.easymock.PowerMock; | 57 | import org.powermock.api.easymock.PowerMock; |
| 58 | +import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 60 | import org.powermock.modules.junit4.PowerMockRunner; | 59 | import org.powermock.modules.junit4.PowerMockRunner; |
| 61 | -import org.powermock.reflect.Whitebox; | ||
| 62 | -import org.slf4j.Logger; | ||
| 63 | 60 | ||
| 64 | import br.gov.frameworkdemoiselle.configuration.ConfigType; | 61 | import br.gov.frameworkdemoiselle.configuration.ConfigType; |
| 65 | import br.gov.frameworkdemoiselle.configuration.Configuration; | 62 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
| 66 | import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | 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 | @RunWith(PowerMockRunner.class) | 66 | @RunWith(PowerMockRunner.class) |
| 67 | +@PrepareForTest(Beans.class) | ||
| 71 | public class ConfigurationLoaderWithListTest { | 68 | public class ConfigurationLoaderWithListTest { |
| 72 | 69 | ||
| 73 | private ConfigurationLoader configurationLoader; | 70 | private ConfigurationLoader configurationLoader; |
| @@ -150,13 +147,7 @@ public class ConfigurationLoaderWithListTest { | @@ -150,13 +147,7 @@ public class ConfigurationLoaderWithListTest { | ||
| 150 | 147 | ||
| 151 | @Before | 148 | @Before |
| 152 | public void setUp() throws Exception { | 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 | configurationLoader = new ConfigurationLoader(); | 150 | configurationLoader = new ConfigurationLoader(); |
| 158 | - Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); | ||
| 159 | - Whitebox.setInternalState(this.configurationLoader, "logger", logger); | ||
| 160 | } | 151 | } |
| 161 | 152 | ||
| 162 | @After | 153 | @After |
| @@ -342,12 +333,17 @@ public class ConfigurationLoaderWithListTest { | @@ -342,12 +333,17 @@ public class ConfigurationLoaderWithListTest { | ||
| 342 | } | 333 | } |
| 343 | 334 | ||
| 344 | private ConfigurationPropertiesWithList prepareConfigurationPropertiesWithList() { | 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 | ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); | 342 | ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); |
| 346 | 343 | ||
| 347 | - CoreBootstrap coreBootstrap = createMock(CoreBootstrap.class); | ||
| 348 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | 344 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); |
| 349 | 345 | ||
| 350 | - replay(coreBootstrap); | 346 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); |
| 351 | 347 | ||
| 352 | configurationLoader.load(config); | 348 | configurationLoader.load(config); |
| 353 | return config; | 349 | return config; |
| @@ -532,12 +528,17 @@ public class ConfigurationLoaderWithListTest { | @@ -532,12 +528,17 @@ public class ConfigurationLoaderWithListTest { | ||
| 532 | } | 528 | } |
| 533 | 529 | ||
| 534 | private ConfigurationXMLWithList prepareConfigurationXMLWithList() { | 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 | ConfigurationXMLWithList config = new ConfigurationXMLWithList(); | 537 | ConfigurationXMLWithList config = new ConfigurationXMLWithList(); |
| 536 | 538 | ||
| 537 | - CoreBootstrap coreBootstrap = createMock(CoreBootstrap.class); | ||
| 538 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | 539 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); |
| 539 | 540 | ||
| 540 | - replay(coreBootstrap); | 541 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); |
| 541 | 542 | ||
| 542 | configurationLoader.load(config); | 543 | configurationLoader.load(config); |
| 543 | return config; | 544 | return config; |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | package br.gov.frameworkdemoiselle.internal.configuration; | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
| 38 | 38 | ||
| 39 | import static org.junit.Assert.assertEquals; | 39 | import static org.junit.Assert.assertEquals; |
| 40 | -import org.junit.Ignore; | 40 | + |
| 41 | import org.junit.Before; | 41 | import org.junit.Before; |
| 42 | import org.junit.Test; | 42 | import org.junit.Test; |
| 43 | 43 |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
| 1 | package br.gov.frameworkdemoiselle.internal.configuration; | 1 | package br.gov.frameworkdemoiselle.internal.configuration; |
| 2 | 2 | ||
| 3 | -import org.junit.Ignore; | ||
| 4 | import static org.junit.Assert.assertEquals; | 3 | import static org.junit.Assert.assertEquals; |
| 5 | 4 | ||
| 6 | import org.junit.Before; | 5 | import org.junit.Before; |