Commit 807b241d1a7c7eefc1df973b436d69a8f4b0884e
1 parent
b9ea84c5
Exists in
master
Testes com chaves sem valor
Showing
6 changed files
with
117 additions
and
5 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
@@ -90,6 +90,6 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { | @@ -90,6 +90,6 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { | ||
90 | public void loadDefaultValueWithKey() { | 90 | public void loadDefaultValueWithKey() { |
91 | assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); | 91 | assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); |
92 | assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey()); | 92 | assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey()); |
93 | - assertEquals("", emptyFieldsConfig.getStringDefaultWithKey()); | 93 | + assertEquals("Initialized value and key in the property file", emptyFieldsConfig.getStringDefaultWithKey()); |
94 | } | 94 | } |
95 | } | 95 | } |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/AbstractNullClassFieldConfig.java
0 → 100644
@@ -0,0 +1,52 @@ | @@ -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 br.gov.frameworkdemoiselle.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/br/gov/frameworkdemoiselle/configuration/field/clazz/ConfigurationClassFieldTest.java
@@ -61,6 +61,9 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | @@ -61,6 +61,9 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | ||
61 | 61 | ||
62 | @Inject | 62 | @Inject |
63 | private PropertiesClassNotFoundFieldConfig propertiesNotFoundConfig; | 63 | private PropertiesClassNotFoundFieldConfig propertiesNotFoundConfig; |
64 | + | ||
65 | + @Inject | ||
66 | + private PropertiesNullClassFieldConfig propertiesNullFieldConfig; | ||
64 | 67 | ||
65 | @Deployment | 68 | @Deployment |
66 | public static JavaArchive createDeployment() { | 69 | public static JavaArchive createDeployment() { |
@@ -69,9 +72,7 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | @@ -69,9 +72,7 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | ||
69 | deployment.addPackages(true, ConfigurationClassFieldTest.class.getPackage()); | 72 | deployment.addPackages(true, ConfigurationClassFieldTest.class.getPackage()); |
70 | deployment.addAsResource( | 73 | deployment.addAsResource( |
71 | new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.properties")), | 74 | new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.properties")), |
72 | - "demoiselle.properties").addAsResource( | ||
73 | - new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.xml")), | ||
74 | - "demoiselle.xml"); | 75 | + "demoiselle.properties"); |
75 | 76 | ||
76 | return deployment; | 77 | return deployment; |
77 | } | 78 | } |
@@ -105,4 +106,16 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | @@ -105,4 +106,16 @@ public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | ||
105 | assertEquals(ClassNotFoundException.class, cause.getCause().getClass()); | 106 | assertEquals(ClassNotFoundException.class, cause.getCause().getClass()); |
106 | } | 107 | } |
107 | } | 108 | } |
109 | + | ||
110 | + @Test | ||
111 | + public void loadNullTypedClass() { | ||
112 | + assertEquals(null, propertiesNullFieldConfig.getNullTypedClass()); | ||
113 | + } | ||
114 | + | ||
115 | + @Test | ||
116 | + public void loadNullUntypedClass() { | ||
117 | + assertEquals(null, propertiesNullFieldConfig.getNullUntypedClass()); | ||
118 | + } | ||
119 | + | ||
120 | + | ||
108 | } | 121 | } |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/PropertiesNullClassFieldConfig.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.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 PropertiesNullClassFieldConfig extends AbstractNullClassFieldConfig { | ||
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,7 +105,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest { | ||
105 | 105 | ||
106 | @Test | 106 | @Test |
107 | public void loadEmptyString() { | 107 | public void loadEmptyString() { |
108 | - String expected = ""; | 108 | + String expected = null; |
109 | assertEquals(expected, systemConfig.getEmptyString()); | 109 | assertEquals(expected, systemConfig.getEmptyString()); |
110 | assertEquals(expected, propertiesConfig.getEmptyString()); | 110 | assertEquals(expected, propertiesConfig.getEmptyString()); |
111 | assertEquals(expected, xmlConfig.getEmptyString()); | 111 | assertEquals(expected, xmlConfig.getEmptyString()); |
impl/core/src/test/resources/configuration/field/class/demoiselle.properties
@@ -37,3 +37,5 @@ existentTypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.MyClass | @@ -37,3 +37,5 @@ existentTypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.MyClass | ||
37 | existentUntypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.MyClass | 37 | existentUntypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.MyClass |
38 | nonExistentTypedClass=com.fake.NonExistentClass | 38 | nonExistentTypedClass=com.fake.NonExistentClass |
39 | nonExistentUntypedClass=com.fake.NonExistentClass | 39 | nonExistentUntypedClass=com.fake.NonExistentClass |
40 | +nullTypedClass= | ||
41 | +nullUntypedClass= |