Commit 042cff66d9d174b0bb96bceb0ad700c77bbcd355

Authored by Emerson Oliveira
1 parent 6a9ae948
Exists in master

Refatoração e adição de teste para situação na qual o atributo de

configuração do tipo calsse é nulo.
impl/core/src/test/java/configuration/field/clazz/AbstractClassNotFoundFieldConfig.java
... ... @@ -41,7 +41,7 @@ public abstract class AbstractClassNotFoundFieldConfig {
41 41 private Class<MyClass> nonExistentTypedClass;
42 42  
43 43 private Class<?> nonExistentUntypedClass;
44   -
  44 +
45 45 public Class<MyClass> getNonExistentTypedClass() {
46 46 return nonExistentTypedClass;
47 47 }
... ...
impl/core/src/test/java/configuration/field/clazz/AbstractEmptyClassFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,52 @@
  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 configuration.field.clazz;
  38 +
  39 +public abstract class AbstractEmptyClassFieldConfig {
  40 +
  41 + private Class<MyClass> emptyTypedClass;
  42 +
  43 + private Class<?> emptyUntypedClass;
  44 +
  45 + public Class<MyClass> getEmptyTypedClass() {
  46 + return emptyTypedClass;
  47 + }
  48 +
  49 + public Class<?> getEmptyUntypedClass() {
  50 + return emptyUntypedClass;
  51 + }
  52 +}
... ...
impl/core/src/test/java/configuration/field/clazz/AbstractNullClassFieldConfig.java
... ... @@ -1,52 +0,0 @@
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 configuration.field.clazz;
38   -
39   -public abstract class AbstractNullClassFieldConfig {
40   -
41   - private Class<MyClass> nullTypedClass;
42   -
43   - private Class<?> nullUntypedClass;
44   -
45   - public Class<MyClass> getNullTypedClass() {
46   - return nullTypedClass;
47   - }
48   -
49   - public Class<?> getNullUntypedClass() {
50   - return nullUntypedClass;
51   - }
52   -}
impl/core/src/test/java/configuration/field/clazz/ConfigurationClassFieldTest.java
... ... @@ -37,6 +37,7 @@
37 37 package configuration.field.clazz;
38 38  
39 39 import static junit.framework.Assert.assertEquals;
  40 +import static junit.framework.Assert.assertNull;
40 41 import static junit.framework.Assert.fail;
41 42  
42 43 import javax.inject.Inject;
... ... @@ -62,7 +63,10 @@ public class ConfigurationClassFieldTest {
62 63 private PropertiesClassNotFoundFieldConfig propertiesNotFoundConfig;
63 64  
64 65 @Inject
65   - private PropertiesNullClassFieldConfig propertiesNullFieldConfig;
  66 + private PropertiesEmptyClassFieldConfig propertiesEmptyFieldConfig;
  67 +
  68 + @Inject
  69 + private PropertiesNullClassFieldConfig propertiesNullFieldClassConfig;
66 70  
67 71 @Deployment
68 72 public static JavaArchive createDeployment() {
... ... @@ -87,7 +91,6 @@ public class ConfigurationClassFieldTest {
87 91 propertiesNotFoundConfig.getNonExistentTypedClass();
88 92 fail();
89 93 } catch (ConfigurationException cause) {
90   - cause.printStackTrace();
91 94 assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
92 95 }
93 96 }
... ... @@ -103,24 +106,27 @@ public class ConfigurationClassFieldTest {
103 106 }
104 107  
105 108 @Test
106   - public void loadNullTypedClass() {
  109 + public void loadTypedClassFromEmptyKey() {
107 110 try {
108   - propertiesNullFieldConfig.getNullTypedClass();
  111 + propertiesEmptyFieldConfig.getEmptyTypedClass();
109 112 fail();
110 113 } catch (ConfigurationException cause) {
111   - cause.printStackTrace();
112 114 assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
113 115 }
114 116 }
115 117  
116 118 @Test
117   - public void loadNullUntypedClass() {
  119 + public void loadUntypedClassFromEmptyKey() {
118 120 try {
119   - propertiesNullFieldConfig.getNullUntypedClass();
  121 + propertiesEmptyFieldConfig.getEmptyUntypedClass();
120 122 fail();
121 123 } catch (ConfigurationException cause) {
122 124 assertEquals(ClassNotFoundException.class, cause.getCause().getClass());
123 125 }
124 126 }
125 127  
  128 + @Test
  129 + public void loadNullClass() {
  130 + assertNull(propertiesNullFieldClassConfig.getNullClass());
  131 + }
126 132 }
... ...
impl/core/src/test/java/configuration/field/clazz/PropertiesEmptyClassFieldConfig.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 configuration.field.clazz;
  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 PropertiesEmptyClassFieldConfig extends AbstractEmptyClassFieldConfig {
  44 +
  45 +}
... ...
impl/core/src/test/java/configuration/field/clazz/PropertiesNullClassFieldConfig.java
... ... @@ -36,10 +36,14 @@
36 36 */
37 37 package configuration.field.clazz;
38 38  
39   -import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES;
40 39 import br.gov.frameworkdemoiselle.configuration.Configuration;
41 40  
42   -@Configuration(type = PROPERTIES)
43   -public class PropertiesNullClassFieldConfig extends AbstractNullClassFieldConfig {
44   -
  41 +@Configuration
  42 +public class PropertiesNullClassFieldConfig {
  43 +
  44 + private Class<MyClass> nullClass;
  45 +
  46 + public Class<MyClass> getNullClass() {
  47 + return nullClass;
  48 + }
45 49 }
... ...
impl/core/src/test/resources/configuration/field/class/demoiselle.properties
... ... @@ -1,41 +0,0 @@
1   -# Demoiselle Framework
2   -# Copyright (C) 2010 SERPRO
3   -# ----------------------------------------------------------------------------
4   -# This file is part of Demoiselle Framework.
5   -#
6   -# Demoiselle Framework is free software; you can redistribute it and/or
7   -# modify it under the terms of the GNU Lesser General Public License version 3
8   -# as published by the Free Software Foundation.
9   -#
10   -# This program is distributed in the hope that it will be useful,
11   -# but WITHOUT ANY WARRANTY; without even the implied warranty of
12   -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   -# GNU General Public License for more details.
14   -#
15   -# You should have received a copy of the GNU Lesser General Public License version 3
16   -# along with this program; if not, see <http://www.gnu.org/licenses/>
17   -# or write to the Free Software Foundation, Inc., 51 Franklin Street,
18   -# Fifth Floor, Boston, MA 02110-1301, USA.
19   -# ----------------------------------------------------------------------------
20   -# Este arquivo é parte do Framework Demoiselle.
21   -#
22   -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
23   -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
24   -# do Software Livre (FSF).
25   -#
26   -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
27   -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
28   -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
29   -# para maiores detalhes.
30   -#
31   -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
32   -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
33   -# ou escreva para a Fundação do Software Livre (FSF) Inc.,
34   -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
35   -
36   -existentTypedClass=configuration.field.clazz.MyClass
37   -existentUntypedClass=configuration.field.clazz.MyClass
38   -nonExistentTypedClass=com.fake.NonExistentClass
39   -nonExistentUntypedClass=com.fake.NonExistentClass
40   -nullTypedClass=
41   -nullUntypedClass=
impl/core/src/test/resources/configuration/field/class/demoiselle.xml
... ... @@ -1,43 +0,0 @@
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   -
38   -<configuration>
39   - <primitiveInteger>1</primitiveInteger>
40   - <wrappedInteger>2</wrappedInteger>
41   - <stringWithSpace>demoiselle framework</stringWithSpace>
42   - <stringWithComma>demoiselle,framework</stringWithComma>
43   -</configuration>
impl/core/src/test/resources/configuration/field/clazz/demoiselle.properties 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +# Demoiselle Framework
  2 +# Copyright (C) 2010 SERPRO
  3 +# ----------------------------------------------------------------------------
  4 +# This file is part of Demoiselle Framework.
  5 +#
  6 +# Demoiselle Framework is free software; you can redistribute it and/or
  7 +# modify it under the terms of the GNU Lesser General Public License version 3
  8 +# as published by the Free Software Foundation.
  9 +#
  10 +# This program is distributed in the hope that it will be useful,
  11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 +# GNU General Public License for more details.
  14 +#
  15 +# You should have received a copy of the GNU Lesser General Public License version 3
  16 +# along with this program; if not, see <http://www.gnu.org/licenses/>
  17 +# or write to the Free Software Foundation, Inc., 51 Franklin Street,
  18 +# Fifth Floor, Boston, MA 02110-1301, USA.
  19 +# ----------------------------------------------------------------------------
  20 +# Este arquivo é parte do Framework Demoiselle.
  21 +#
  22 +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  23 +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  24 +# do Software Livre (FSF).
  25 +#
  26 +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  27 +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  28 +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  29 +# para maiores detalhes.
  30 +#
  31 +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  32 +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  33 +# ou escreva para a Fundação do Software Livre (FSF) Inc.,
  34 +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  35 +
  36 +existentTypedClass=configuration.field.clazz.MyClass
  37 +existentUntypedClass=configuration.field.clazz.MyClass
  38 +nonExistentTypedClass=com.fake.NonExistentClass
  39 +nonExistentUntypedClass=com.fake.NonExistentClass
  40 +emptyTypedClass=
  41 +emptyUntypedClass=
... ...
impl/core/src/test/resources/configuration/field/clazz/demoiselle.xml 0 → 100644
... ... @@ -0,0 +1,43 @@
  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 +
  38 +<configuration>
  39 + <primitiveInteger>1</primitiveInteger>
  40 + <wrappedInteger>2</wrappedInteger>
  41 + <stringWithSpace>demoiselle framework</stringWithSpace>
  42 + <stringWithComma>demoiselle,framework</stringWithComma>
  43 +</configuration>
... ...