Commit 779589dbe5c1f0db5f235b096623a1fd59364898
1 parent
5db1c2ab
Exists in
master
Adicionados testes para propriedades com valores padrão
Showing
5 changed files
with
292 additions
and
0 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/AbstractDefaultValueConfig.java
0 → 100644
@@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
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.defaultvalue; | ||
38 | + | ||
39 | + | ||
40 | +public abstract class AbstractDefaultValueConfig { | ||
41 | + | ||
42 | + private String stringDefaultWithoutKey = "Valor inicializado e sem chave em arquivo de propriedade"; | ||
43 | + | ||
44 | + private String stringDefaultWithKey = "Valor inicializado e com chave em arquivo de propriedade"; | ||
45 | + | ||
46 | + public String getStringDefaultWithoutKey() { | ||
47 | + return stringDefaultWithoutKey; | ||
48 | + } | ||
49 | + | ||
50 | + public String getStringDefaultWithKey() { | ||
51 | + return stringDefaultWithKey; | ||
52 | + } | ||
53 | + | ||
54 | + public void setStringDefaultWithoutKey(String stringDefaultWithoutKey) { | ||
55 | + this.stringDefaultWithoutKey = stringDefaultWithoutKey; | ||
56 | + } | ||
57 | + | ||
58 | + public void setStringDefaultWithKey(String stringDefaultWithKey) { | ||
59 | + this.stringDefaultWithKey = stringDefaultWithKey; | ||
60 | + } | ||
61 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
0 → 100644
@@ -0,0 +1,100 @@ | @@ -0,0 +1,100 @@ | ||
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.defaultvalue; | ||
38 | + | ||
39 | +import static junit.framework.Assert.assertEquals; | ||
40 | + | ||
41 | +import java.io.File; | ||
42 | + | ||
43 | +import javax.inject.Inject; | ||
44 | + | ||
45 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
46 | +import org.jboss.arquillian.junit.Arquillian; | ||
47 | +import org.jboss.shrinkwrap.api.asset.FileAsset; | ||
48 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
49 | +import org.junit.Test; | ||
50 | +import org.junit.runner.RunWith; | ||
51 | + | ||
52 | +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | ||
53 | + | ||
54 | +@RunWith(Arquillian.class) | ||
55 | +public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { | ||
56 | + | ||
57 | + @Inject | ||
58 | + private FilledDefaultValueConfig filledFieldConfig; | ||
59 | + | ||
60 | + @Inject | ||
61 | + private EmptyDefaultValueConfig emptyFieldsConfig; | ||
62 | + | ||
63 | + @Inject | ||
64 | + private PropertyWithInexistenceFileConfig noFileConfig; | ||
65 | + | ||
66 | + @Deployment | ||
67 | + public static JavaArchive createDeployment() { | ||
68 | + JavaArchive deployment = createConfigurationDeployment(); | ||
69 | + | ||
70 | + deployment.addPackages(true, ConfigurationDefaultValueTest.class.getPackage()); | ||
71 | + deployment.addAsResource( | ||
72 | + new FileAsset(new File("src/test/resources/configuration/field/basic/demoiselle.properties")), | ||
73 | + "demoiselle.properties").addAsResource( | ||
74 | + new FileAsset(new File("src/test/resources/configuration/field/basic/demoiselle.xml")), | ||
75 | + "demoiselle.xml"); | ||
76 | + | ||
77 | + return deployment; | ||
78 | + } | ||
79 | + | ||
80 | + @Test | ||
81 | + public void loadDefaultValueWithoutKey(){ | ||
82 | + String expected = "Valor inicializado e sem chave em arquivo de propriedade"; | ||
83 | + | ||
84 | + assertEquals(expected, filledFieldConfig.getStringDefaultWithoutKey()); | ||
85 | + assertEquals(expected, emptyFieldsConfig.getStringDefaultWithoutKey()); | ||
86 | + assertEquals(expected, noFileConfig.getStringDefaultWithoutKey()); | ||
87 | + } | ||
88 | + | ||
89 | + //@Test(expected = ConfigurationException.class) | ||
90 | + /*TODO: Lançar exceção quando uma chave adicionada em arquivo de configuração não | ||
91 | + * tiver valor associado*/ | ||
92 | + public void loadDefaultValueWithKey(){ | ||
93 | + String expectedFilled = "Valor inicializado do arquivo de propriedade"; | ||
94 | + String expectedNoFile = "Valor inicializado e com chave em arquivo de propriedade"; | ||
95 | + | ||
96 | + assertEquals(expectedFilled, filledFieldConfig.getStringDefaultWithKey()); | ||
97 | + assertEquals(expectedNoFile, noFileConfig.getStringDefaultWithKey()); | ||
98 | + emptyFieldsConfig.getStringDefaultWithKey(); | ||
99 | + } | ||
100 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/EmptyDefaultValueConfig.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.defaultvalue; | ||
38 | + | ||
39 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; | ||
40 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
41 | + | ||
42 | +@Configuration(resource = "demoiselle", type = XML) | ||
43 | +public class EmptyDefaultValueConfig extends AbstractDefaultValueConfig{ | ||
44 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/FilledDefaultValueConfig.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.defaultvalue; | ||
38 | + | ||
39 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; | ||
40 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
41 | + | ||
42 | +@Configuration(resource = "demoiselle", type = PROPERTIES) | ||
43 | +public class FilledDefaultValueConfig extends AbstractDefaultValueConfig{ | ||
44 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/PropertyWithInexistenceFileConfig.java
0 → 100644
@@ -0,0 +1,43 @@ | @@ -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 | +package br.gov.frameworkdemoiselle.configuration.defaultvalue; | ||
38 | + | ||
39 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
40 | + | ||
41 | +@Configuration(resource = "nofile") | ||
42 | +public class PropertyWithInexistenceFileConfig extends AbstractDefaultValueConfig{ | ||
43 | +} |