Commit e3e1da1712acc77d1e6320984f7bfdea9b6693eb

Authored by Dancovich
2 parents c470c29f 5fefbbf2
Exists in master

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

impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationClassValueExtractor.java
... ... @@ -52,14 +52,8 @@ public class ConfigurationClassValueExtractor implements ConfigurationValueExtra
52 52  
53 53 @Override
54 54 public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {
55   - Object value = null;
56 55 String canonicalName = configuration.getString(prefix + key);
57   -
58   - if (!Strings.isEmpty(canonicalName)) {
59   - value = Reflections.forName(canonicalName);
60   - }
61   -
62   - return value;
  56 + return Reflections.forName(canonicalName);
63 57 }
64 58  
65 59 @Override
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/AbstractArrayEmptyFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,58 @@
  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.array;
  38 +
  39 +public abstract class AbstractArrayEmptyFieldConfig {
  40 +
  41 + private int[] emptyPrimitiveIntegers;
  42 +
  43 + private Integer[] emptyWrapperIntegers;
  44 +
  45 + private Integer[] errorTypeWrapperIntegers;
  46 +
  47 + public Integer[] getEmptyWrapperIntegers() {
  48 + return emptyWrapperIntegers;
  49 + }
  50 +
  51 + public int[] getEmptyPrimitiveIntegers() {
  52 + return emptyPrimitiveIntegers;
  53 + }
  54 +
  55 + public Integer[] getErrorTypeWrapperIntegers() {
  56 + return errorTypeWrapperIntegers;
  57 + }
  58 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/AbstractArrayFieldConfig.java
... ... @@ -48,6 +48,8 @@ public abstract class AbstractArrayFieldConfig {
48 48  
49 49 private Double[] wrappedDoubles;
50 50  
  51 + private String[] emptyStrings;
  52 +
51 53 public int[] getPrimitiveIntegers() {
52 54 return primitiveIntegers;
53 55 }
... ... @@ -67,4 +69,8 @@ public abstract class AbstractArrayFieldConfig {
67 69 public Double[] getWrappedDoubles() {
68 70 return wrappedDoubles;
69 71 }
  72 +
  73 + public String[] getEmptyStrings() {
  74 + return emptyStrings;
  75 + }
70 76 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java
... ... @@ -36,12 +36,16 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.configuration.field.array;
38 38  
  39 +import static junit.framework.Assert.assertEquals;
39 40 import static org.junit.Assert.assertArrayEquals;
40 41  
41 42 import java.io.File;
42 43  
43 44 import javax.inject.Inject;
44 45  
  46 +import junit.framework.Assert;
  47 +
  48 +import org.apache.commons.configuration.ConversionException;
45 49 import org.jboss.arquillian.container.test.api.Deployment;
46 50 import org.jboss.arquillian.junit.Arquillian;
47 51 import org.jboss.shrinkwrap.api.asset.FileAsset;
... ... @@ -50,12 +54,16 @@ import org.junit.Test;
50 54 import org.junit.runner.RunWith;
51 55  
52 56 import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest;
  57 +import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
53 58  
54 59 @RunWith(Arquillian.class)
55 60 public class ConfigurationArrayFieldTest extends AbstractConfigurationTest {
56 61  
57 62 @Inject
58 63 private PropertiesArrayFieldConfig propertiesConfig;
  64 +
  65 + @Inject
  66 + private PropertiesArrayEmptyFieldConfig propertiesNullConfig;
59 67  
60 68 @Inject
61 69 private XMLArrayFieldConfig xmlConfig;
... ... @@ -113,4 +121,40 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest {
113 121 assertArrayEquals(expected, propertiesConfig.getWrappedDoubles());
114 122 assertArrayEquals(expected, xmlConfig.getWrappedDoubles());
115 123 }
  124 +
  125 + @Test
  126 + public void loadEmptyString() {
  127 + String[] expected = { "demoisele", "" };
  128 + assertArrayEquals(expected, propertiesConfig.getEmptyStrings());
  129 + }
  130 +
  131 + @Test
  132 + public void loadEmptyPrimitive() {
  133 + try {
  134 + propertiesNullConfig.getEmptyPrimitiveIntegers();
  135 + Assert.fail();
  136 + } catch (ConfigurationException cause) {
  137 + assertEquals(ConversionException.class, cause.getCause().getClass());
  138 + }
  139 + }
  140 +
  141 + @Test
  142 + public void loadEmptyWrapper() {
  143 + try {
  144 + propertiesNullConfig.getEmptyWrapperIntegers();
  145 + Assert.fail();
  146 + } catch (ConfigurationException cause) {
  147 + assertEquals(ConversionException.class, cause.getCause().getClass());
  148 + }
  149 + }
  150 +
  151 + @Test
  152 + public void loadErrorTypeWrapper() {
  153 + try {
  154 + propertiesNullConfig.getErrorTypeWrapperIntegers();
  155 + Assert.fail();
  156 + } catch (ConfigurationException cause) {
  157 + assertEquals(ConversionException.class, cause.getCause().getClass());
  158 + }
  159 + }
116 160 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/PropertiesArrayEmptyFieldConfig.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.array;
  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 PropertiesArrayEmptyFieldConfig extends AbstractArrayEmptyFieldConfig {
  44 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/ConfigurationClassFieldTest.java
... ... @@ -61,7 +61,7 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest {
61 61  
62 62 @Inject
63 63 private PropertiesClassNotFoundFieldConfig propertiesNotFoundConfig;
64   -
  64 +
65 65 @Inject
66 66 private PropertiesNullClassFieldConfig propertiesNullFieldConfig;
67 67  
... ... @@ -70,9 +70,8 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest {
70 70 JavaArchive deployment = createConfigurationDeployment();
71 71  
72 72 deployment.addPackages(true, ConfigurationClassFieldTest.class.getPackage());
73   - deployment.addAsResource(
74   - new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.properties")),
75   - "demoiselle.properties");
  73 + deployment.addAsResource(new FileAsset(new File(
  74 + "src/test/resources/configuration/field/class/demoiselle.properties")), "demoiselle.properties");
76 75  
77 76 return deployment;
78 77 }
... ... @@ -106,16 +105,25 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest {
106 105 assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
107 106 }
108 107 }
109   -
  108 +
110 109 @Test
111 110 public void loadNullTypedClass() {
112   - assertEquals(null, propertiesNullFieldConfig.getNullTypedClass());
  111 + try {
  112 + propertiesNullFieldConfig.getNullTypedClass();
  113 + fail();
  114 + } catch (ConfigurationException cause) {
  115 + assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
  116 + }
113 117 }
114 118  
115 119 @Test
116 120 public void loadNullUntypedClass() {
117   - assertEquals(null, propertiesNullFieldConfig.getNullUntypedClass());
  121 + try {
  122 + propertiesNullFieldConfig.getNullUntypedClass();
  123 + fail();
  124 + } catch (ConfigurationException cause) {
  125 + assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
  126 + }
118 127 }
119 128  
120   -
121 129 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperEmptyFieldConfig.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 AbstractPrimitiveOrWrapperEmptyFieldConfig {
  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/resources/configuration/field/array/demoiselle.properties
... ... @@ -53,3 +53,15 @@ primitiveDoubles=0
53 53 wrappedDoubles=-456.123456789
54 54 wrappedDoubles=0.0
55 55 wrappedDoubles=52.2
  56 +
  57 +emptyPrimitiveIntegers=1
  58 +emptyPrimitiveIntegers=
  59 +
  60 +emptyWrapperIntegers=1
  61 +emptyWrapperIntegers=
  62 +
  63 +emptyStrings=demoisele
  64 +emptyStrings=
  65 +
  66 +errorTypeWrapperIntegers=1
  67 +errorTypeWrapperIntegers=a
... ...
impl/core/src/test/resources/configuration/field/array/demoiselle.xml
... ... @@ -56,4 +56,8 @@
56 56 <wrappedDoubles>-456.123456789</wrappedDoubles>
57 57 <wrappedDoubles>0.0</wrappedDoubles>
58 58 <wrappedDoubles>52.2</wrappedDoubles>
  59 +
  60 + <emptyIntegers></emptyIntegers>
  61 + <emptyIntegers></emptyIntegers>
  62 + <emptyIntegers></emptyIntegers>
59 63 </ArrayValues>
... ...