Commit e82afb17964491f6cbc1617d87dcce2a96749bee
1 parent
07919d44
Exists in
master
Correção dos testes para chaves com valor vazio
Showing
6 changed files
with
53 additions
and
57 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
| ... | ... | @@ -90,6 +90,6 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { |
| 90 | 90 | public void loadDefaultValueWithKey() { |
| 91 | 91 | assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); |
| 92 | 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 | 38 | |
| 39 | 39 | public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig { |
| 40 | 40 | |
| 41 | - private int primitiveInteger; | |
| 42 | - | |
| 43 | - private int nullPrimitiveInteger; | |
| 41 | + private int emptyPrimitiveInteger; | |
| 44 | 42 | |
| 45 | 43 | private int errorPrimitiveInteger; |
| 46 | 44 | |
| 47 | - private Integer wrappedInteger; | |
| 48 | - | |
| 49 | - private Integer nullWrappedInteger; | |
| 45 | + private Integer emptyWrappedInteger; | |
| 50 | 46 | |
| 51 | 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 | 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 | 40 | |
| 41 | 41 | private int primitiveInteger; |
| 42 | 42 | |
| 43 | - private int nullPrimitiveInteger; | |
| 44 | - | |
| 45 | 43 | private Integer wrappedInteger; |
| 46 | 44 | |
| 47 | - private Integer nullWrappedInteger; | |
| 48 | - | |
| 49 | 45 | public Integer getWrappedInteger() { |
| 50 | 46 | return wrappedInteger; |
| 51 | 47 | } |
| ... | ... | @@ -53,12 +49,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { |
| 53 | 49 | public int getPrimitiveInteger() { |
| 54 | 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 | 94 | @BeforeClass |
| 95 | 95 | public static void afterClass() { |
| 96 | 96 | System.setProperty("primitiveInteger", String.valueOf(1)); |
| 97 | - System.setProperty("nullPrimitiveInteger", String.valueOf("")); | |
| 97 | + System.setProperty("emptyPrimitiveInteger", String.valueOf("")); | |
| 98 | 98 | System.setProperty("errorPrimitiveInteger", String.valueOf("a")); |
| 99 | 99 | System.setProperty("wrappedInteger", String.valueOf(2)); |
| 100 | - System.setProperty("nullWrappedInteger", String.valueOf("")); | |
| 100 | + System.setProperty("emptyWrappedInteger", String.valueOf("")); | |
| 101 | 101 | System.setProperty("errorWrappedInteger", String.valueOf("a")); |
| 102 | 102 | } |
| 103 | 103 | |
| ... | ... | @@ -120,43 +120,65 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 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 | 143 | @Test |
| 132 | 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 | 164 | @Test |
| 141 | 165 | public void loadErrorPrimitiveInteger() { |
| 142 | - int expected = 0; | |
| 143 | - | |
| 144 | 166 | try { |
| 145 | - assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); | |
| 167 | + propertiesErrorConfig.getErrorPrimitiveInteger(); | |
| 146 | 168 | fail(); |
| 147 | 169 | } catch (ConfigurationException cause) { |
| 148 | 170 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| 149 | 171 | } |
| 150 | 172 | |
| 151 | 173 | try { |
| 152 | - assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); | |
| 174 | + propertiesErrorConfig.getErrorPrimitiveInteger(); | |
| 153 | 175 | fail(); |
| 154 | 176 | } catch (ConfigurationException cause) { |
| 155 | 177 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| 156 | 178 | } |
| 157 | 179 | |
| 158 | 180 | try { |
| 159 | - assertEquals(expected, xmlErrorConfig.getErrorPrimitiveInteger()); | |
| 181 | + xmlErrorConfig.getErrorPrimitiveInteger(); | |
| 160 | 182 | fail(); |
| 161 | 183 | } catch (ConfigurationException cause) { |
| 162 | 184 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| ... | ... | @@ -165,24 +187,22 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat |
| 165 | 187 | |
| 166 | 188 | @Test |
| 167 | 189 | public void loadErrorWrappedInteger() { |
| 168 | - Integer expected = 2; | |
| 169 | - | |
| 170 | 190 | try { |
| 171 | - assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); | |
| 191 | + propertiesErrorConfig.getErrorWrappedInteger(); | |
| 172 | 192 | fail(); |
| 173 | 193 | } catch (ConfigurationException cause) { |
| 174 | 194 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| 175 | 195 | } |
| 176 | 196 | |
| 177 | 197 | try { |
| 178 | - assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); | |
| 198 | + propertiesErrorConfig.getErrorWrappedInteger(); | |
| 179 | 199 | fail(); |
| 180 | 200 | } catch (ConfigurationException cause) { |
| 181 | 201 | assertEquals(ConversionException.class, cause.getCause().getClass()); |
| 182 | 202 | } |
| 183 | 203 | |
| 184 | 204 | try { |
| 185 | - assertEquals(expected, xmlErrorConfig.getErrorWrappedInteger()); | |
| 205 | + xmlErrorConfig.getErrorWrappedInteger(); | |
| 186 | 206 | fail(); |
| 187 | 207 | } catch (ConfigurationException cause) { |
| 188 | 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 | 105 | |
| 106 | 106 | @Test |
| 107 | 107 | public void loadEmptyString() { |
| 108 | - String expected = null; | |
| 108 | + String expected = ""; | |
| 109 | 109 | assertEquals(expected, systemConfig.getEmptyString()); |
| 110 | 110 | assertEquals(expected, propertiesConfig.getEmptyString()); |
| 111 | 111 | assertEquals(expected, xmlConfig.getEmptyString()); | ... | ... |
impl/core/src/test/resources/configuration/field/primitiveorwrapper/demoiselle.properties
| ... | ... | @@ -34,8 +34,8 @@ |
| 34 | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 35 | 35 | |
| 36 | 36 | primitiveInteger=1 |
| 37 | -nullPrimitiveInteger= | |
| 37 | +emptyPrimitiveInteger= | |
| 38 | 38 | errorPrimitiveInteger=a |
| 39 | 39 | wrappedInteger=2 |
| 40 | -nullWrappedInteger= | |
| 40 | +aemptyWrappedInteger= | |
| 41 | 41 | errorWrappedInteger=a |
| 42 | 42 | \ No newline at end of file | ... | ... |