Commit 595d1c4686d032623132fefdb324e1500dd91668

Authored by Ednara Oliveira
1 parent 166ab7e8
Exists in master

Ajustes

impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java
... ... @@ -50,13 +50,7 @@ public class ConfigurationStringValueExtractor implements ConfigurationValueExtr
50 50  
51 51 @Override
52 52 public Object getValue(String prefix, String key, Field field, Configuration configuration) {
53   - Object value = configuration.getString(prefix + key);
54   -
55   - if (value.equals("")) {
56   - value = null;
57   - }
58   -
59   - return value;
  53 + return configuration.getString(prefix + key);
60 54 }
61 55  
62 56 @Override
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,76 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper;
  38 +
  39 +public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig {
  40 +
  41 + private int primitiveInteger;
  42 +
  43 + private int nullPrimitiveInteger;
  44 +
  45 + private int errorPrimitiveInteger;
  46 +
  47 + private Integer wrappedInteger;
  48 +
  49 + private Integer nullWrappedInteger;
  50 +
  51 + private Integer errorWrappedInteger;
  52 +
  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;
  63 + }
  64 +
  65 + public Integer getNullWrappedInteger() {
  66 + return nullWrappedInteger;
  67 + }
  68 +
  69 + public int getErrorPrimitiveInteger() {
  70 + return errorPrimitiveInteger;
  71 + }
  72 +
  73 + public Integer getErrorWrappedInteger() {
  74 + return errorWrappedInteger;
  75 + }
  76 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java
... ... @@ -42,14 +42,10 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
42 42  
43 43 private int nullPrimitiveInteger;
44 44  
45   - private int errorPrimitiveInteger;
46   -
47 45 private Integer wrappedInteger;
48 46  
49 47 private Integer nullWrappedInteger;
50 48  
51   - private Integer errorWrappedInteger;
52   -
53 49 public Integer getWrappedInteger() {
54 50 return wrappedInteger;
55 51 }
... ... @@ -65,12 +61,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
65 61 public Integer getNullWrappedInteger() {
66 62 return nullWrappedInteger;
67 63 }
68   -
69   - public int getErrorPrimitiveInteger() {
70   - return errorPrimitiveInteger;
71   - }
72   -
73   - public Integer getErrorWrappedInteger() {
74   - return errorWrappedInteger;
75   - }
76 64 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java
... ... @@ -69,6 +69,15 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
69 69  
70 70 @Inject
71 71 private SystemPrimitiveOrWrapperFieldConfig systemConfig;
  72 +
  73 + @Inject
  74 + private PropertiesPrimitiveOrWrapperErrorFieldConfig propertiesErrorConfig;
  75 +
  76 + @Inject
  77 + private XMLPrimitiveOrWrapperErrorFieldConfig xmlErrorConfig;
  78 +
  79 + @Inject
  80 + private SystemPrimitiveOrWrapperErrorFieldConfig systemErrorConfig;
72 81  
73 82 @Deployment
74 83 public static JavaArchive createDeployment() {
... ... @@ -136,21 +145,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
136 145 int expected = 0;
137 146  
138 147 try {
139   - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger());
  148 + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger());
140 149 fail();
141 150 } catch (ConversionException cause) {
142 151 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
143 152 }
144 153  
145 154 try {
146   - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger());
  155 + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger());
147 156 fail();
148 157 } catch (ConversionException cause) {
149 158 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
150 159 }
151 160  
152 161 try {
153   - assertEquals(expected, xmlConfig.getErrorPrimitiveInteger());
  162 + assertEquals(expected, xmlErrorConfig.getErrorPrimitiveInteger());
154 163 fail();
155 164 } catch (ConversionException cause) {
156 165 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
... ... @@ -163,21 +172,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
163 172 Integer expected = 2;
164 173  
165 174 try {
166   - assertEquals(expected, propertiesConfig.getErrorWrappedInteger());
  175 + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger());
167 176 fail();
168 177 } catch (ConversionException cause) {
169 178 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
170 179 }
171 180  
172 181 try {
173   - assertEquals(expected, propertiesConfig.getErrorWrappedInteger());
  182 + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger());
174 183 fail();
175 184 } catch (ConversionException cause) {
176 185 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
177 186 }
178 187  
179 188 try {
180   - assertEquals(expected, xmlConfig.getErrorWrappedInteger());
  189 + assertEquals(expected, xmlErrorConfig.getErrorWrappedInteger());
181 190 fail();
182 191 } catch (ConversionException cause) {
183 192 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper;
  38 +
  39 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES;
  40 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  41 +
  42 +@Configuration(type = PROPERTIES)
  43 +public class PropertiesPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig {
  44 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper;
  38 +
  39 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM;
  40 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  41 +
  42 +@Configuration(type = SYSTEM)
  43 +public class SystemPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig {
  44 +
  45 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package br.gov.frameworkdemoiselle.configuration.field.primitiveorwrapper;
  38 +
  39 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML;
  40 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  41 +
  42 +@Configuration(type = XML)
  43 +public class XMLPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig {
  44 +
  45 +}
... ...
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());
... ...