Commit 35c7352556030a32c36d5abb4fc46ee1499d5007

Authored by Emerson Oliveira
2 parents 9382e955 595d1c46
Exists in master

Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0

impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java 0 → 100644
@@ -0,0 +1,76 @@ @@ -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,14 +42,10 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
42 42
43 private int nullPrimitiveInteger; 43 private int nullPrimitiveInteger;
44 44
45 - private int errorPrimitiveInteger;  
46 -  
47 private Integer wrappedInteger; 45 private Integer wrappedInteger;
48 46
49 private Integer nullWrappedInteger; 47 private Integer nullWrappedInteger;
50 48
51 - private Integer errorWrappedInteger;  
52 -  
53 public Integer getWrappedInteger() { 49 public Integer getWrappedInteger() {
54 return wrappedInteger; 50 return wrappedInteger;
55 } 51 }
@@ -65,12 +61,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { @@ -65,12 +61,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig {
65 public Integer getNullWrappedInteger() { 61 public Integer getNullWrappedInteger() {
66 return nullWrappedInteger; 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,6 +69,15 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
69 69
70 @Inject 70 @Inject
71 private SystemPrimitiveOrWrapperFieldConfig systemConfig; 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 @Deployment 82 @Deployment
74 public static JavaArchive createDeployment() { 83 public static JavaArchive createDeployment() {
@@ -136,21 +145,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @@ -136,21 +145,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
136 int expected = 0; 145 int expected = 0;
137 146
138 try { 147 try {
139 - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger()); 148 + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger());
140 fail(); 149 fail();
141 } catch (ConversionException cause) { 150 } catch (ConversionException cause) {
142 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 151 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
143 } 152 }
144 153
145 try { 154 try {
146 - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger()); 155 + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger());
147 fail(); 156 fail();
148 } catch (ConversionException cause) { 157 } catch (ConversionException cause) {
149 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 158 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
150 } 159 }
151 160
152 try { 161 try {
153 - assertEquals(expected, xmlConfig.getErrorPrimitiveInteger()); 162 + assertEquals(expected, xmlErrorConfig.getErrorPrimitiveInteger());
154 fail(); 163 fail();
155 } catch (ConversionException cause) { 164 } catch (ConversionException cause) {
156 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 165 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
@@ -163,21 +172,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @@ -163,21 +172,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat
163 Integer expected = 2; 172 Integer expected = 2;
164 173
165 try { 174 try {
166 - assertEquals(expected, propertiesConfig.getErrorWrappedInteger()); 175 + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger());
167 fail(); 176 fail();
168 } catch (ConversionException cause) { 177 } catch (ConversionException cause) {
169 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 178 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
170 } 179 }
171 180
172 try { 181 try {
173 - assertEquals(expected, propertiesConfig.getErrorWrappedInteger()); 182 + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger());
174 fail(); 183 fail();
175 } catch (ConversionException cause) { 184 } catch (ConversionException cause) {
176 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 185 Assert.assertEquals(ConversionException.class, cause.getCause().getClass());
177 } 186 }
178 187
179 try { 188 try {
180 - assertEquals(expected, xmlConfig.getErrorWrappedInteger()); 189 + assertEquals(expected, xmlErrorConfig.getErrorWrappedInteger());
181 fail(); 190 fail();
182 } catch (ConversionException cause) { 191 } catch (ConversionException cause) {
183 Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); 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 @@ @@ -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 @@ @@ -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 @@ @@ -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/AbstractStringFieldConfig.java
@@ -42,6 +42,8 @@ public abstract class AbstractStringFieldConfig { @@ -42,6 +42,8 @@ public abstract class AbstractStringFieldConfig {
42 42
43 private String stringWithComma; 43 private String stringWithComma;
44 44
  45 + private String emptyString;
  46 +
45 public String getStringWithSpace() { 47 public String getStringWithSpace() {
46 return stringWithSpace; 48 return stringWithSpace;
47 } 49 }
@@ -49,4 +51,8 @@ public abstract class AbstractStringFieldConfig { @@ -49,4 +51,8 @@ public abstract class AbstractStringFieldConfig {
49 public String getStringWithComma() { 51 public String getStringWithComma() {
50 return stringWithComma; 52 return stringWithComma;
51 } 53 }
  54 +
  55 + public String getEmptyString() {
  56 + return emptyString;
  57 + }
52 } 58 }
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java
@@ -82,6 +82,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest { @@ -82,6 +82,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest {
82 public static void afterClass() { 82 public static void afterClass() {
83 System.setProperty("stringWithSpace", String.valueOf("demoiselle framework")); 83 System.setProperty("stringWithSpace", String.valueOf("demoiselle framework"));
84 System.setProperty("stringWithComma", String.valueOf("demoiselle, framework")); 84 System.setProperty("stringWithComma", String.valueOf("demoiselle, framework"));
  85 + System.setProperty("emptyString", String.valueOf(""));
85 } 86 }
86 87
87 @Test 88 @Test
@@ -101,4 +102,12 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest { @@ -101,4 +102,12 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest {
101 assertEquals(expected, propertiesConfig.getStringWithComma()); 102 assertEquals(expected, propertiesConfig.getStringWithComma());
102 assertEquals(expected, xmlConfig.getStringWithComma()); 103 assertEquals(expected, xmlConfig.getStringWithComma());
103 } 104 }
  105 +
  106 + @Test
  107 + public void loadEmptyString() {
  108 + String expected = "";
  109 + assertEquals(expected, systemConfig.getEmptyString());
  110 + assertEquals(expected, propertiesConfig.getEmptyString());
  111 + assertEquals(expected, xmlConfig.getEmptyString());
  112 + }
104 } 113 }
impl/core/src/test/resources/configuration/field/string/demoiselle.properties
@@ -35,3 +35,4 @@ @@ -35,3 +35,4 @@
35 35
36 stringWithSpace=demoiselle framework 36 stringWithSpace=demoiselle framework
37 stringWithComma=demoiselle, framework 37 stringWithComma=demoiselle, framework
  38 +emptyString=
impl/core/src/test/resources/configuration/field/string/demoiselle.xml
@@ -38,4 +38,5 @@ @@ -38,4 +38,5 @@
38 <configuration> 38 <configuration>
39 <stringWithSpace>demoiselle framework</stringWithSpace> 39 <stringWithSpace>demoiselle framework</stringWithSpace>
40 <stringWithComma>demoiselle, framework</stringWithComma> 40 <stringWithComma>demoiselle, framework</stringWithComma>
  41 + <emptyString></emptyString>
41 </configuration> 42 </configuration>