Commit 49c2461469caac3d39aa5c8c2a37ae8f6cb33897
1 parent
801bb459
Exists in
master
CRiação do teste unitário do configuration com o tipo Class
Showing
2 changed files
with
40 additions
and
1 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java
... | ... | @@ -44,6 +44,7 @@ import static org.junit.Assert.fail; |
44 | 44 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
45 | 45 | |
46 | 46 | import java.util.Locale; |
47 | +import java.util.Properties; | |
47 | 48 | |
48 | 49 | import javax.validation.constraints.NotNull; |
49 | 50 | |
... | ... | @@ -72,6 +73,20 @@ public class ConfigurationLoaderTest { |
72 | 73 | private CoreBootstrap coreBootstrap; |
73 | 74 | |
74 | 75 | @Configuration |
76 | + public class ConfigurationSuccessfulPropertiesWithClassField { | |
77 | + | |
78 | + protected Class classe; | |
79 | + | |
80 | + } | |
81 | + | |
82 | + @Configuration | |
83 | + public class ConfigurationSuccessfulPropertiesWithPropertiesField { | |
84 | + | |
85 | + protected Properties properties; | |
86 | + | |
87 | + } | |
88 | + | |
89 | + @Configuration | |
75 | 90 | public class ConfigurationSuccessfulProperties { |
76 | 91 | |
77 | 92 | @Name("frameworkdemoiselle.configurationtest.nameConfiguration") |
... | ... | @@ -295,6 +310,27 @@ public class ConfigurationLoaderTest { |
295 | 310 | } |
296 | 311 | |
297 | 312 | @Test |
313 | + public void testConfigurationSuccessfulPropertiesWithClassField() { | |
314 | + ConfigurationSuccessfulPropertiesWithClassField config = new ConfigurationSuccessfulPropertiesWithClassField(); | |
315 | + expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
316 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); | |
317 | + configurationLoader.load(config); | |
318 | + assertEquals(ConfigurationLoaderTest.class,config.classe); | |
319 | + } | |
320 | + | |
321 | + @Test | |
322 | + public void testConfigurationSuccessfulPropertiesWithPropertiesField() { | |
323 | + ConfigurationSuccessfulPropertiesWithPropertiesField config = new ConfigurationSuccessfulPropertiesWithPropertiesField(); | |
324 | + expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
325 | + PowerMock.replayAll(CoreBootstrap.class,Beans.class); | |
326 | + configurationLoader.load(config); | |
327 | + assertEquals("teste1",config.properties.getProperty("1")); | |
328 | + assertEquals("teste2",config.properties.getProperty("2")); | |
329 | + assertTrue(config.properties.containsKey("1")); | |
330 | + assertTrue(config.properties.containsKey("2")); | |
331 | + } | |
332 | + | |
333 | + @Test | |
298 | 334 | public void testConfigurationSuccessfulPropertiesPossibleConventions() { |
299 | 335 | ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties(); |
300 | 336 | expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ... | ... |
impl/core/src/test/resources/demoiselle.properties
... | ... | @@ -75,4 +75,7 @@ convention_underline=Convention Underline |
75 | 75 | convention.dot=Convention Dot |
76 | 76 | conventionalllowercase=All LowerCase |
77 | 77 | CONVENTIONALLUPPERCASE=ALL UPPERCASE |
78 | -complexObject=null | |
79 | 78 | \ No newline at end of file |
79 | +complexObject=null | |
80 | +properties.1=teste1 | |
81 | +properties.2=teste2 | |
82 | +classe=br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderTest | |
80 | 83 | \ No newline at end of file | ... | ... |