Commit e82afb17964491f6cbc1617d87dcce2a96749bee

Authored by Ednara Oliveira
1 parent 07919d44
Exists in master

Correção dos testes para chaves com valor vazio

impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
@@ -90,6 +90,6 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { @@ -90,6 +90,6 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest {
90 public void loadDefaultValueWithKey() { 90 public void loadDefaultValueWithKey() {
91 assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); 91 assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey());
92 assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey()); 92 assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey());
93 - assertEquals("Initialized value and key in the property file", emptyFieldsConfig.getStringDefaultWithKey()); 93 + assertEquals("", emptyFieldsConfig.getStringDefaultWithKey());
94 } 94 }
95 } 95 }
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java
@@ -38,32 +38,20 @@ package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper; @@ -38,32 +38,20 @@ package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper;
38 38
39 public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig { 39 public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig {
40 40
41 - private int primitiveInteger;  
42 -  
43 - private int nullPrimitiveInteger; 41 + private int emptyPrimitiveInteger;
44 42
45 private int errorPrimitiveInteger; 43 private int errorPrimitiveInteger;
46 44
47 - private Integer wrappedInteger;  
48 -  
49 - private Integer nullWrappedInteger; 45 + private Integer emptyWrappedInteger;
50 46
51 private Integer errorWrappedInteger; 47 private Integer errorWrappedInteger;
52 48
53 - public Integer getWrappedInteger() {  
54 - return wrappedInteger;  
55 - }  
56 -  
57 - public int getPrimitiveInteger() {  
58 - return primitiveInteger;  
59 - }  
60 -  
61 - public int getNullPrimitiveInteger() {  
62 - return nullPrimitiveInteger; 49 + public int getEmptyPrimitiveInteger() {
  50 + return emptyPrimitiveInteger;
63 } 51 }
64 52
65 - public Integer getNullWrappedInteger() {  
66 - return nullWrappedInteger; 53 + public Integer getEmptyWrappedInteger() {
  54 + return emptyWrappedInteger;
67 } 55 }
68 56
69 public int getErrorPrimitiveInteger() { 57 public int getErrorPrimitiveInteger() {
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java
@@ -40,12 +40,8 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { @@ -40,12 +40,8 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
40 40
41 private int primitiveInteger; 41 private int primitiveInteger;
42 42
43 - private int nullPrimitiveInteger;  
44 -  
45 private Integer wrappedInteger; 43 private Integer wrappedInteger;
46 44
47 - private Integer nullWrappedInteger;  
48 -  
49 public Integer getWrappedInteger() { 45 public Integer getWrappedInteger() {
50 return wrappedInteger; 46 return wrappedInteger;
51 } 47 }
@@ -53,12 +49,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { @@ -53,12 +49,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
53 public int getPrimitiveInteger() { 49 public int getPrimitiveInteger() {
54 return primitiveInteger; 50 return primitiveInteger;
55 } 51 }
56 -  
57 - public int getNullPrimitiveInteger() {  
58 - return nullPrimitiveInteger;  
59 - }  
60 -  
61 - public Integer getNullWrappedInteger() {  
62 - return nullWrappedInteger;  
63 - }  
64 } 52 }
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java
@@ -94,10 +94,10 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @@ -94,10 +94,10 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
94 @BeforeClass 94 @BeforeClass
95 public static void afterClass() { 95 public static void afterClass() {
96 System.setProperty("primitiveInteger", String.valueOf(1)); 96 System.setProperty("primitiveInteger", String.valueOf(1));
97 - System.setProperty("nullPrimitiveInteger", String.valueOf("")); 97 + System.setProperty("emptyPrimitiveInteger", String.valueOf(""));
98 System.setProperty("errorPrimitiveInteger", String.valueOf("a")); 98 System.setProperty("errorPrimitiveInteger", String.valueOf("a"));
99 System.setProperty("wrappedInteger", String.valueOf(2)); 99 System.setProperty("wrappedInteger", String.valueOf(2));
100 - System.setProperty("nullWrappedInteger", String.valueOf("")); 100 + System.setProperty("emptyWrappedInteger", String.valueOf(""));
101 System.setProperty("errorWrappedInteger", String.valueOf("a")); 101 System.setProperty("errorWrappedInteger", String.valueOf("a"));
102 } 102 }
103 103
@@ -120,43 +120,65 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @@ -120,43 +120,65 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
120 } 120 }
121 121
122 @Test 122 @Test
123 - public void loadNullPrimitiveInteger() {  
124 - int expected = 0;  
125 -  
126 - assertEquals(expected, systemConfig.getNullPrimitiveInteger());  
127 - assertEquals(expected, propertiesConfig.getNullPrimitiveInteger());  
128 - assertEquals(expected, xmlConfig.getNullPrimitiveInteger()); 123 + public void loadEmptyPrimitiveInteger() {
  124 + try {
  125 + systemErrorConfig.getEmptyPrimitiveInteger();
  126 + } catch (ConfigurationException cause) {
  127 + assertEquals(ConversionException.class, cause.getCause().getClass());
  128 + }
  129 +
  130 + try {
  131 + propertiesErrorConfig.getEmptyPrimitiveInteger();
  132 + } catch (ConfigurationException cause) {
  133 + assertEquals(ConversionException.class, cause.getCause().getClass());
  134 + }
  135 +
  136 + try {
  137 + propertiesErrorConfig.getEmptyPrimitiveInteger();
  138 + } catch (ConfigurationException cause) {
  139 + assertEquals(ConversionException.class, cause.getCause().getClass());
  140 + }
129 } 141 }
130 142
131 @Test 143 @Test
132 public void loadNullWrappedInteger() { 144 public void loadNullWrappedInteger() {
133 - Integer expected = null;  
134 -  
135 - assertEquals(expected, systemConfig.getNullWrappedInteger());  
136 - assertEquals(expected, propertiesConfig.getNullWrappedInteger());  
137 - assertEquals(expected, xmlConfig.getNullWrappedInteger()); 145 + try {
  146 + systemErrorConfig.getEmptyWrappedInteger();
  147 + } catch (ConfigurationException cause) {
  148 + assertEquals(ConversionException.class, cause.getCause().getClass());
  149 + }
  150 +
  151 + try {
  152 + propertiesErrorConfig.getEmptyWrappedInteger();
  153 + } catch (ConfigurationException cause) {
  154 + assertEquals(ConversionException.class, cause.getCause().getClass());
  155 + }
  156 +
  157 + try {
  158 + propertiesErrorConfig.getEmptyWrappedInteger();
  159 + } catch (ConfigurationException cause) {
  160 + assertEquals(ConversionException.class, cause.getCause().getClass());
  161 + }
138 } 162 }
139 163
140 @Test 164 @Test
141 public void loadErrorPrimitiveInteger() { 165 public void loadErrorPrimitiveInteger() {
142 - int expected = 0;  
143 -  
144 try { 166 try {
145 - assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); 167 + propertiesErrorConfig.getErrorPrimitiveInteger();
146 fail(); 168 fail();
147 } catch (ConfigurationException cause) { 169 } catch (ConfigurationException cause) {
148 assertEquals(ConversionException.class, cause.getCause().getClass()); 170 assertEquals(ConversionException.class, cause.getCause().getClass());
149 } 171 }
150 172
151 try { 173 try {
152 - assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); 174 + propertiesErrorConfig.getErrorPrimitiveInteger();
153 fail(); 175 fail();
154 } catch (ConfigurationException cause) { 176 } catch (ConfigurationException cause) {
155 assertEquals(ConversionException.class, cause.getCause().getClass()); 177 assertEquals(ConversionException.class, cause.getCause().getClass());
156 } 178 }
157 179
158 try { 180 try {
159 - assertEquals(expected, xmlErrorConfig.getErrorPrimitiveInteger()); 181 + xmlErrorConfig.getErrorPrimitiveInteger();
160 fail(); 182 fail();
161 } catch (ConfigurationException cause) { 183 } catch (ConfigurationException cause) {
162 assertEquals(ConversionException.class, cause.getCause().getClass()); 184 assertEquals(ConversionException.class, cause.getCause().getClass());
@@ -165,24 +187,22 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @@ -165,24 +187,22 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
165 187
166 @Test 188 @Test
167 public void loadErrorWrappedInteger() { 189 public void loadErrorWrappedInteger() {
168 - Integer expected = 2;  
169 -  
170 try { 190 try {
171 - assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); 191 + propertiesErrorConfig.getErrorWrappedInteger();
172 fail(); 192 fail();
173 } catch (ConfigurationException cause) { 193 } catch (ConfigurationException cause) {
174 assertEquals(ConversionException.class, cause.getCause().getClass()); 194 assertEquals(ConversionException.class, cause.getCause().getClass());
175 } 195 }
176 196
177 try { 197 try {
178 - assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); 198 + propertiesErrorConfig.getErrorWrappedInteger();
179 fail(); 199 fail();
180 } catch (ConfigurationException cause) { 200 } catch (ConfigurationException cause) {
181 assertEquals(ConversionException.class, cause.getCause().getClass()); 201 assertEquals(ConversionException.class, cause.getCause().getClass());
182 } 202 }
183 203
184 try { 204 try {
185 - assertEquals(expected, xmlErrorConfig.getErrorWrappedInteger()); 205 + xmlErrorConfig.getErrorWrappedInteger();
186 fail(); 206 fail();
187 } catch (ConfigurationException cause) { 207 } catch (ConfigurationException cause) {
188 assertEquals(ConversionException.class, cause.getCause().getClass()); 208 assertEquals(ConversionException.class, cause.getCause().getClass());
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java
@@ -105,7 +105,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest { @@ -105,7 +105,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest {
105 105
106 @Test 106 @Test
107 public void loadEmptyString() { 107 public void loadEmptyString() {
108 - String expected = null; 108 + String expected = "";
109 assertEquals(expected, systemConfig.getEmptyString()); 109 assertEquals(expected, systemConfig.getEmptyString());
110 assertEquals(expected, propertiesConfig.getEmptyString()); 110 assertEquals(expected, propertiesConfig.getEmptyString());
111 assertEquals(expected, xmlConfig.getEmptyString()); 111 assertEquals(expected, xmlConfig.getEmptyString());
impl/core/src/test/resources/configuration/field/primitiveorwrapper/demoiselle.properties
@@ -34,8 +34,8 @@ @@ -34,8 +34,8 @@
34 # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. 34 # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
35 35
36 primitiveInteger=1 36 primitiveInteger=1
37 -nullPrimitiveInteger= 37 +emptyPrimitiveInteger=
38 errorPrimitiveInteger=a 38 errorPrimitiveInteger=a
39 wrappedInteger=2 39 wrappedInteger=2
40 -nullWrappedInteger= 40 +aemptyWrappedInteger=
41 errorWrappedInteger=a 41 errorWrappedInteger=a
42 \ No newline at end of file 42 \ No newline at end of file