Commit 340200a3f465edc4de25a418c0c160ec2593f0e1

Authored by Emerson Oliveira
1 parent 694d39c9
Exists in master

Incremento dos testes com atributos anotados com @NotNull, adicionando

propriedades sendo carregadas a partir de arquivo xml e refatoração com
modificação do nome da variável anotada
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/AbstractNotNullFieldConfig.java
... ... @@ -41,9 +41,9 @@ import javax.validation.constraints.NotNull;
41 41 public abstract class AbstractNotNullFieldConfig {
42 42  
43 43 @NotNull
44   - private Integer integerNotNull;
  44 + private Integer attibuteNotNull;
45 45  
46   - public Integer getIntegerNotNull() {
47   - return integerNotNull;
  46 + public Integer getAttributeNotNull() {
  47 + return attibuteNotNull;
48 48 }
49 49 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/ConfigurationNotNullFieldTest.java
... ... @@ -59,16 +59,28 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
59 59 public class ConfigurationNotNullFieldTest extends AbstractConfigurationTest {
60 60  
61 61 @Inject
62   - private PropertyWithFilledFieldConfig filledFieldConfig;
  62 + private PropertyWithFilledFieldConfig propertyFilledFieldConfig;
63 63  
64 64 @Inject
65   - private PropertyWithEmptyFieldConfig emptyFieldsConfig;
  65 + private PropertyWithEmptyFieldConfig propertyEmptyFieldsConfig;
66 66  
67 67 @Inject
68   - private PropertyWithoutNotNullField withoutNotNullField;
  68 + private PropertyWithoutNotNullField propertyWithoutNotNullField;
69 69  
70 70 @Inject
71   - private PropertyWithoutFileConfig noFileConfig;
  71 + private PropertyWithoutFileConfig propertyNoFileConfig;
  72 +
  73 + @Inject
  74 + private XMLWithFilledFieldConfig xmlFilledFieldConfig;
  75 +
  76 + @Inject
  77 + private XMLWithEmptyFieldConfig xmlEmptyFieldsConfig;
  78 +
  79 + @Inject
  80 + private XMLWithoutNotNullField xmlWithoutNotNullField;
  81 +
  82 + @Inject
  83 + private XMLWithoutFileConfig xmlNoFileConfig;
72 84  
73 85 @Deployment
74 86 public static JavaArchive createDeployment() {
... ... @@ -85,22 +97,40 @@ public class ConfigurationNotNullFieldTest extends AbstractConfigurationTest {
85 97 .addAsResource(
86 98 new FileAsset(new File(
87 99 "src/test/resources/configuration/field/notnull/without-field.properties")),
88   - "without-field.properties");
  100 + "without-field.properties")
  101 + .addAsResource(
  102 + new FileAsset(new File("src/test/resources/configuration/field/notnull/demoiselle.xml")),
  103 + "demoiselle.xml")
  104 + .addAsResource(
  105 + new FileAsset(new File("src/test/resources/configuration/field/notnull/empty-field.xml")),
  106 + "empty-field.xml")
  107 + .addAsResource(
  108 + new FileAsset(new File(
  109 + "src/test/resources/configuration/field/notnull/without-field.xml")),
  110 + "without-field.xml");
89 111  
90 112 return deployment;
91 113 }
92 114  
93 115 @Test
94   - public void loadFieldNotNullFromFilledProperty() {
  116 + public void loadFieldNotNullFromFilledFile() {
95 117 Integer expected = 1;
96 118  
97   - assertEquals(expected, filledFieldConfig.getIntegerNotNull());
  119 + assertEquals(expected, propertyFilledFieldConfig.getAttributeNotNull());
  120 + assertEquals(expected, xmlFilledFieldConfig.getAttributeNotNull());
98 121 }
99 122  
100 123 @Test
101 124 public void loadFieldNotNullFromEmptyProperty() {
102 125 try {
103   - emptyFieldsConfig.getIntegerNotNull();
  126 + propertyEmptyFieldsConfig.getAttributeNotNull();
  127 + fail();
  128 + } catch (ConfigurationException cause) {
  129 + Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
  130 + }
  131 +
  132 + try {
  133 + xmlEmptyFieldsConfig.getAttributeNotNull();
104 134 fail();
105 135 } catch (ConfigurationException cause) {
106 136 Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
... ... @@ -110,7 +140,14 @@ public class ConfigurationNotNullFieldTest extends AbstractConfigurationTest {
110 140 @Test
111 141 public void loadFieldFromPropertyFileWithoutNotNullField() {
112 142 try {
113   - withoutNotNullField.getIntegerNotNull();
  143 + propertyWithoutNotNullField.getAttributeNotNull();
  144 + fail();
  145 + } catch (ConfigurationException cause) {
  146 + Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
  147 + }
  148 +
  149 + try {
  150 + xmlWithoutNotNullField.getAttributeNotNull();
114 151 fail();
115 152 } catch (ConfigurationException cause) {
116 153 Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
... ... @@ -120,7 +157,14 @@ public class ConfigurationNotNullFieldTest extends AbstractConfigurationTest {
120 157 @Test
121 158 public void loadFieldNotNullFromInexistentPropertyFile() {
122 159 try {
123   - noFileConfig.getIntegerNotNull();
  160 + propertyNoFileConfig.getAttributeNotNull();
  161 + fail();
  162 + } catch (ConfigurationException cause) {
  163 + Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
  164 + }
  165 +
  166 + try {
  167 + xmlNoFileConfig.getAttributeNotNull();
124 168 fail();
125 169 } catch (ConfigurationException cause) {
126 170 Assert.assertEquals(NullPointerException.class, cause.getCause().getClass());
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/PropertyWithoutFileConfig.java
... ... @@ -36,8 +36,9 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.configuration.field.notnull;
38 38  
  39 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES;
39 40 import br.gov.frameworkdemoiselle.configuration.Configuration;
40 41  
41   -@Configuration(resource = "nofile")
  42 +@Configuration(resource = "nofile", type = PROPERTIES)
42 43 public class PropertyWithoutFileConfig extends AbstractNotNullFieldConfig {
43 44 }
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/XMLWithEmptyFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.notnull;
  2 +
  3 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML;
  4 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  5 +
  6 +@Configuration(resource = "empty-field", type = XML)
  7 +public class XMLWithEmptyFieldConfig extends AbstractNotNullFieldConfig {
  8 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/XMLWithFilledFieldConfig.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.notnull;
  2 +
  3 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML;
  4 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  5 +
  6 +@Configuration(resource = "demoiselle", type = XML)
  7 +public class XMLWithFilledFieldConfig extends AbstractNotNullFieldConfig {
  8 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/XMLWithoutFileConfig.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.notnull;
  2 +
  3 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML;
  4 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  5 +
  6 +@Configuration(resource = "nofile", type = XML)
  7 +public class XMLWithoutFileConfig extends AbstractNotNullFieldConfig {
  8 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/notnull/XMLWithoutNotNullField.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.notnull;
  2 +
  3 +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML;
  4 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  5 +
  6 +@Configuration(resource = "without-field", type = XML)
  7 +public class XMLWithoutNotNullField extends AbstractNotNullFieldConfig {
  8 +}
... ...
impl/core/src/test/resources/configuration/field/notnull/demoiselle.properties
... ... @@ -33,12 +33,4 @@
33 33 # ou escreva para a Fundação do Software Livre (FSF) Inc.,
34 34 # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
35 35  
36   -integerNotNull=1
37   -byteNotNull=2
38   -shortNotNull=3
39   -intNotNull=4
40   -longNotNull=5
41   -charNotNull=a
42   -floatNotNull=6.6
43   -doubleNotNull=7.7
44   -booleanNotNull=true
  36 +attibuteNotNull=1
... ...
impl/core/src/test/resources/configuration/field/notnull/demoiselle.xml 0 → 100644
... ... @@ -0,0 +1,40 @@
  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 +<configurations>
  39 + <attibuteNotNull>1</attibuteNotNull>
  40 +</configurations>
... ...
impl/core/src/test/resources/configuration/field/notnull/empty-field.xml 0 → 100644
... ... @@ -0,0 +1,39 @@
  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 +<configurations>
  38 + <integerNotNull></integerNotNull>
  39 +</configurations>
... ...
impl/core/src/test/resources/configuration/field/notnull/without-field.xml 0 → 100644
... ... @@ -0,0 +1,39 @@
  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 +<configurations>
  38 + <propertyNotNull>1</propertyNotNull>
  39 +</configurations>
... ...