Commit f11975b0073c38de061d2e0cc03b9c7a6f601a9f
1 parent
b5da3754
Exists in
master
Formatação do código e inclusão do teste de prefixos que finalizam com
"."
Showing
23 changed files
with
72 additions
and
64 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationLoader.java
... | ... | @@ -220,12 +220,12 @@ public class ConfigurationLoader implements Serializable { |
220 | 220 | } |
221 | 221 | |
222 | 222 | private String getKey(Field field) { |
223 | - String key = ""; | |
223 | + String key; | |
224 | 224 | |
225 | 225 | if (field.isAnnotationPresent(Name.class)) { |
226 | - key += field.getAnnotation(Name.class).value(); | |
226 | + key = field.getAnnotation(Name.class).value(); | |
227 | 227 | } else { |
228 | - key += field.getName(); | |
228 | + key = field.getName(); | |
229 | 229 | } |
230 | 230 | |
231 | 231 | return key; | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/AbstractDefaultValueConfig.java
... | ... | @@ -36,17 +36,16 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.configuration.defaultvalue; |
38 | 38 | |
39 | - | |
40 | 39 | public abstract class AbstractDefaultValueConfig { |
41 | 40 | |
42 | 41 | private String stringDefaultWithoutKey = "Initialized value and without key in the property file"; |
43 | - | |
42 | + | |
44 | 43 | private String stringDefaultWithKey = "Initialized value and key in the property file"; |
45 | - | |
44 | + | |
46 | 45 | public String getStringDefaultWithoutKey() { |
47 | 46 | return stringDefaultWithoutKey; |
48 | 47 | } |
49 | - | |
48 | + | |
50 | 49 | public String getStringDefaultWithKey() { |
51 | 50 | return stringDefaultWithKey; |
52 | 51 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
... | ... | @@ -58,13 +58,13 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { |
58 | 58 | |
59 | 59 | @Inject |
60 | 60 | private FilledDefaultValueConfig filledFieldConfig; |
61 | - | |
61 | + | |
62 | 62 | @Inject |
63 | 63 | private EmptyDefaultValueConfig emptyFieldsConfig; |
64 | - | |
64 | + | |
65 | 65 | @Inject |
66 | 66 | private PropertyWithInexistenceFileConfig noFileConfig; |
67 | - | |
67 | + | |
68 | 68 | @Deployment |
69 | 69 | public static JavaArchive createDeployment() { |
70 | 70 | JavaArchive deployment = createConfigurationDeployment(); |
... | ... | @@ -78,18 +78,18 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { |
78 | 78 | |
79 | 79 | return deployment; |
80 | 80 | } |
81 | - | |
81 | + | |
82 | 82 | @Test |
83 | - public void loadDefaultValueWithoutKey(){ | |
83 | + public void loadDefaultValueWithoutKey() { | |
84 | 84 | String expected = "Initialized value and without key in the property file"; |
85 | - | |
85 | + | |
86 | 86 | assertEquals(expected, filledFieldConfig.getStringDefaultWithoutKey()); |
87 | 87 | assertEquals(expected, emptyFieldsConfig.getStringDefaultWithoutKey()); |
88 | 88 | assertEquals(expected, noFileConfig.getStringDefaultWithoutKey()); |
89 | 89 | } |
90 | - | |
90 | + | |
91 | 91 | @Test |
92 | - public void loadDefaultValueWithKey(){ | |
92 | + public void loadDefaultValueWithKey() { | |
93 | 93 | assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); |
94 | 94 | assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey()); |
95 | 95 | assertEquals("", emptyFieldsConfig.getStringDefaultWithKey()); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/EmptyDefaultValueConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "demoiselle", type = XML) |
43 | -public class EmptyDefaultValueConfig extends AbstractDefaultValueConfig{ | |
43 | +public class EmptyDefaultValueConfig extends AbstractDefaultValueConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/FilledDefaultValueConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "demoiselle", type = PROPERTIES) |
43 | -public class FilledDefaultValueConfig extends AbstractDefaultValueConfig{ | |
43 | +public class FilledDefaultValueConfig extends AbstractDefaultValueConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/PropertyWithInexistenceFileConfig.java
... | ... | @@ -39,5 +39,5 @@ package br.gov.frameworkdemoiselle.configuration.defaultvalue; |
39 | 39 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
40 | 40 | |
41 | 41 | @Configuration(resource = "nofile") |
42 | -public class PropertyWithInexistenceFileConfig extends AbstractDefaultValueConfig{ | |
42 | +public class PropertyWithInexistenceFileConfig extends AbstractDefaultValueConfig { | |
43 | 43 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java
... | ... | @@ -56,7 +56,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
56 | 56 | |
57 | 57 | @Inject |
58 | 58 | private PropertiesArrayFieldConfig propertiesConfig; |
59 | - | |
59 | + | |
60 | 60 | @Inject |
61 | 61 | private XMLArrayFieldConfig xmlConfig; |
62 | 62 | |
... | ... | @@ -65,10 +65,11 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
65 | 65 | JavaArchive deployment = createConfigurationDeployment(); |
66 | 66 | |
67 | 67 | deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage()); |
68 | - deployment.addAsResource(new FileAsset(new File( | |
69 | - "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties") | |
70 | - .addAsResource(new FileAsset(new File("src/test/resources/configuration/field/array/demoiselle.xml")), | |
71 | - "demoiselle.xml"); | |
68 | + deployment.addAsResource( | |
69 | + new FileAsset(new File("src/test/resources/configuration/field/array/demoiselle.properties")), | |
70 | + "demoiselle.properties").addAsResource( | |
71 | + new FileAsset(new File("src/test/resources/configuration/field/array/demoiselle.xml")), | |
72 | + "demoiselle.xml"); | |
72 | 73 | |
73 | 74 | return deployment; |
74 | 75 | } |
... | ... | @@ -92,19 +93,19 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
92 | 93 | @Test |
93 | 94 | public void loadString() { |
94 | 95 | String[] expected = { "demoisele", "demoiselle framework", "demoiselle,framework", "demoiselle, framework" }; |
95 | - | |
96 | + | |
96 | 97 | assertArrayEquals(expected, propertiesConfig.getStrings()); |
97 | 98 | assertArrayEquals(expected, xmlConfig.getStrings()); |
98 | 99 | } |
99 | - | |
100 | + | |
100 | 101 | @Test |
101 | - public void loadPrimitiveDoubles(){ | |
102 | + public void loadPrimitiveDoubles() { | |
102 | 103 | double[] expected = { -10, 200000.99999, 0 }; |
103 | 104 | |
104 | 105 | assertArrayEquals(expected, propertiesConfig.getPrimitiveDoubles(), 0); |
105 | 106 | assertArrayEquals(expected, xmlConfig.getPrimitiveDoubles(), 0); |
106 | 107 | } |
107 | - | |
108 | + | |
108 | 109 | @Test |
109 | 110 | public void loadWrappedDoubles() { |
110 | 111 | Double[] expected = { -456.123456789, 0.0, 52.2 }; | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java
... | ... | @@ -56,13 +56,13 @@ public class ConfigurationIgnoredFieldTest extends AbstractConfigurationTest { |
56 | 56 | |
57 | 57 | @Inject |
58 | 58 | private FilledIgnoredFieldConfig filledFieldConfig; |
59 | - | |
59 | + | |
60 | 60 | @Inject |
61 | 61 | private EmptyIgnoredFieldConfig emptyFieldsConfig; |
62 | - | |
62 | + | |
63 | 63 | @Inject |
64 | 64 | private PropertyWithoutFileConfig noFileConfig; |
65 | - | |
65 | + | |
66 | 66 | @Deployment |
67 | 67 | public static JavaArchive createDeployment() { |
68 | 68 | JavaArchive deployment = createConfigurationDeployment(); |
... | ... | @@ -76,11 +76,11 @@ public class ConfigurationIgnoredFieldTest extends AbstractConfigurationTest { |
76 | 76 | |
77 | 77 | return deployment; |
78 | 78 | } |
79 | - | |
79 | + | |
80 | 80 | @Test |
81 | - public void loadIgnoredInt(){ | |
81 | + public void loadIgnoredInt() { | |
82 | 82 | int expected = 0; |
83 | - | |
83 | + | |
84 | 84 | assertEquals(expected, filledFieldConfig.getIgnoredInt()); |
85 | 85 | assertEquals(expected, noFileConfig.getIgnoredInt()); |
86 | 86 | assertEquals(expected, emptyFieldsConfig.getIgnoredInt()); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "demoiselle", type = XML) |
43 | -public class EmptyIgnoredFieldConfig extends AbstractIgnoredFieldConfig{ | |
43 | +public class EmptyIgnoredFieldConfig extends AbstractIgnoredFieldConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "demoiselle", type = PROPERTIES) |
43 | -public class FilledIgnoredFieldConfig extends AbstractIgnoredFieldConfig{ | |
43 | +public class FilledIgnoredFieldConfig extends AbstractIgnoredFieldConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java
... | ... | @@ -39,5 +39,5 @@ package br.gov.frameworkdemoiselle.configuration.field.ignored; |
39 | 39 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
40 | 40 | |
41 | 41 | @Configuration(resource = "nofile") |
42 | -public class PropertyWithoutFileConfig extends AbstractIgnoredFieldConfig{ | |
42 | +public class PropertyWithoutFileConfig extends AbstractIgnoredFieldConfig { | |
43 | 43 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/AbstractNamedFieldConfig.java
... | ... | @@ -38,18 +38,17 @@ package br.gov.frameworkdemoiselle.configuration.field.named; |
38 | 38 | |
39 | 39 | import br.gov.frameworkdemoiselle.annotation.Name; |
40 | 40 | |
41 | - | |
42 | 41 | public abstract class AbstractNamedFieldConfig { |
43 | 42 | |
44 | 43 | @Name("main.int") |
45 | 44 | private int intUniqueName; |
46 | - | |
45 | + | |
47 | 46 | @Name("nonexistent.property") |
48 | 47 | private int intNotPresent; |
49 | - | |
48 | + | |
50 | 49 | @Name("attribute.without.file") |
51 | 50 | private int intNamedWithoutFile; |
52 | - | |
51 | + | |
53 | 52 | public int getIntUniqueName() { |
54 | 53 | return intUniqueName; |
55 | 54 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/AbstractNotNullFieldConfig.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/PropertyWithEmptyFieldConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "empty-field", type = PROPERTIES) |
43 | -public class PropertyWithEmptyFieldConfig extends AbstractNotNullFieldConfig{ | |
43 | +public class PropertyWithEmptyFieldConfig extends AbstractNotNullFieldConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/PropertyWithFilledFieldConfig.java
... | ... | @@ -40,5 +40,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; |
40 | 40 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
41 | 41 | |
42 | 42 | @Configuration(resource = "demoiselle", type = PROPERTIES) |
43 | -public class PropertyWithFilledFieldConfig extends AbstractNotNullFieldConfig{ | |
43 | +public class PropertyWithFilledFieldConfig extends AbstractNotNullFieldConfig { | |
44 | 44 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/PropertyWithoutFileConfig.java
... | ... | @@ -39,5 +39,5 @@ package br.gov.frameworkdemoiselle.configuration.field.notnull; |
39 | 39 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
40 | 40 | |
41 | 41 | @Configuration(resource = "nofile") |
42 | -public class PropertyWithoutFileConfig extends AbstractNotNullFieldConfig{ | |
42 | +public class PropertyWithoutFileConfig extends AbstractNotNullFieldConfig { | |
43 | 43 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/PropertyWithoutNotNullField.java
... | ... | @@ -4,5 +4,5 @@ import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; |
4 | 4 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
5 | 5 | |
6 | 6 | @Configuration(resource = "without-field", type = PROPERTIES) |
7 | -public class PropertyWithoutNotNullField extends AbstractNotNullFieldConfig{ | |
7 | +public class PropertyWithoutNotNullField extends AbstractNotNullFieldConfig { | |
8 | 8 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java
... | ... | @@ -36,6 +36,7 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.configuration.prefix; |
38 | 38 | |
39 | +import static junit.framework.Assert.assertNull; | |
39 | 40 | import static org.junit.Assert.assertEquals; |
40 | 41 | |
41 | 42 | import java.io.File; |
... | ... | @@ -56,29 +57,36 @@ public class ConfigurationPrefixTest extends AbstractConfigurationTest { |
56 | 57 | |
57 | 58 | @Inject |
58 | 59 | private ExistentPrefix existentPrefix; |
59 | - | |
60 | + | |
60 | 61 | @Inject |
61 | 62 | private MissingPrefix missingPrefix; |
62 | - | |
63 | + | |
64 | + @Inject | |
65 | + private PrefixEndingWithDot endingWithDotPrefix; | |
66 | + | |
63 | 67 | @Deployment |
64 | 68 | public static JavaArchive createDeployment() { |
65 | 69 | JavaArchive deployment = createConfigurationDeployment(); |
66 | 70 | |
67 | 71 | deployment.addPackages(true, ConfigurationPrefixTest.class.getPackage()); |
68 | - deployment.addAsResource( | |
69 | - new FileAsset(new File("src/test/resources/configuration/prefix/demoiselle.properties")), | |
70 | - "demoiselle.properties"); | |
72 | + deployment.addAsResource(new FileAsset( | |
73 | + new File("src/test/resources/configuration/prefix/demoiselle.properties")), "demoiselle.properties"); | |
71 | 74 | |
72 | 75 | return deployment; |
73 | 76 | } |
74 | - | |
77 | + | |
75 | 78 | @Test |
76 | - public void loadFromPrefixedExistentProperty(){ | |
77 | - assertEquals("Atributo com prefixo", existentPrefix.getPrefixedAttribute()); | |
79 | + public void loadFromPrefixedExistentProperty() { | |
80 | + assertEquals("with prefix", existentPrefix.getPrefixedAttribute()); | |
78 | 81 | } |
79 | - | |
82 | + | |
83 | + @Test | |
84 | + public void loadFromPrefixedWithouPrefixOnProperty() { | |
85 | + assertNull(missingPrefix.getPrefixedAttribute()); | |
86 | + } | |
87 | + | |
80 | 88 | @Test |
81 | - public void loadFromPrefixedWithouPrefixOnProperty(){ | |
82 | - assertEquals(null, missingPrefix.getPrefixedAttribute()); | |
89 | + public void loadPrefixEndingWithDot() { | |
90 | + assertEquals("prefix ending with dot", endingWithDotPrefix.getPrefixedAttribute()); | |
83 | 91 | } |
84 | 92 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java
... | ... | @@ -2,6 +2,6 @@ package br.gov.frameworkdemoiselle.configuration.prefix; |
2 | 2 | |
3 | 3 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
4 | 4 | |
5 | -@Configuration(prefix="prefix.") | |
5 | +@Configuration(prefix = "prefix") | |
6 | 6 | public class ExistentPrefix extends AbstractPrefixConfig { |
7 | 7 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java
... | ... | @@ -2,6 +2,6 @@ package br.gov.frameworkdemoiselle.configuration.prefix; |
2 | 2 | |
3 | 3 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
4 | 4 | |
5 | -@Configuration(prefix="missing.prefix.") | |
6 | -public class MissingPrefix extends AbstractPrefixConfig{ | |
5 | +@Configuration(prefix = "missing.prefix") | |
6 | +public class MissingPrefix extends AbstractPrefixConfig { | |
7 | 7 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.java
... | ... | @@ -65,12 +65,12 @@ public class ConfigurationScopeTest extends AbstractConfigurationTest { |
65 | 65 | |
66 | 66 | assertSame(config1, config2); |
67 | 67 | } |
68 | - | |
68 | + | |
69 | 69 | @Test |
70 | 70 | public void twoInvocationsDifferentInstances() { |
71 | 71 | DependentScopeWithoutSuperClassConfig config1 = Beans.getReference(DependentScopeWithoutSuperClassConfig.class); |
72 | 72 | DependentScopeWithoutSuperClassConfig config2 = Beans.getReference(DependentScopeWithoutSuperClassConfig.class); |
73 | - | |
73 | + | |
74 | 74 | assertNotSame(config1, config2); |
75 | 75 | } |
76 | 76 | } | ... | ... |
impl/core/src/test/resources/configuration/prefix/demoiselle.properties
... | ... | @@ -33,5 +33,6 @@ |
33 | 33 | # ou escreva para a Fundação do Software Livre (FSF) Inc., |
34 | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
35 | 35 | |
36 | -prefix.prefixedAttribute=Atributo com prefixo | |
37 | -prefixedAttribute=Sem prefixo | |
36 | +prefix.prefixedAttribute=with prefix | |
37 | +prefixedAttribute=without prefix | |
38 | +endingWithDot.prefixedAttribute=prefix ending with dot | ... | ... |