Commit e0bcac42ddd2de81a3ed0ba0769592ea993e539f
1 parent
c6d910ef
Exists in
master
Adicionados alguns testes para campos anotados com @Name
Showing
4 changed files
with
205 additions
and
0 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/AbstractNamedFieldConfig.java
0 → 100644
@@ -0,0 +1,76 @@ | @@ -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.named; | ||
38 | + | ||
39 | +import br.gov.frameworkdemoiselle.annotation.Name; | ||
40 | + | ||
41 | + | ||
42 | +public abstract class AbstractNamedFieldConfig { | ||
43 | + | ||
44 | + @Name("main.int") | ||
45 | + private int intUniqueName; | ||
46 | + | ||
47 | + @Name("nonexistent.property") | ||
48 | + private int intNotPresent; | ||
49 | + | ||
50 | + @Name("attribute.without.file") | ||
51 | + private int intNamedWithoutFile; | ||
52 | + | ||
53 | + public int getIntUniqueName() { | ||
54 | + return intUniqueName; | ||
55 | + } | ||
56 | + | ||
57 | + public void setIntUniqueName(int intUniqueName) { | ||
58 | + this.intUniqueName = intUniqueName; | ||
59 | + } | ||
60 | + | ||
61 | + public int getIntNotPresent() { | ||
62 | + return intNotPresent; | ||
63 | + } | ||
64 | + | ||
65 | + public void setIntNotPresent(int intNotPresent) { | ||
66 | + this.intNotPresent = intNotPresent; | ||
67 | + } | ||
68 | + | ||
69 | + public int getIntNamedWithoutFile() { | ||
70 | + return intNamedWithoutFile; | ||
71 | + } | ||
72 | + | ||
73 | + public void setIntNamedWithoutFile(int intNamedWithoutFile) { | ||
74 | + this.intNamedWithoutFile = intNamedWithoutFile; | ||
75 | + } | ||
76 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/ConfigurationNamedFieldTest.java
0 → 100644
@@ -0,0 +1,86 @@ | @@ -0,0 +1,86 @@ | ||
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.named; | ||
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 ConfigurationNamedFieldTest extends AbstractConfigurationTest { | ||
56 | + | ||
57 | + @Inject | ||
58 | + private PropertyDefault propertyDefault; | ||
59 | + | ||
60 | + @Deployment | ||
61 | + public static JavaArchive createDeployment() { | ||
62 | + JavaArchive deployment = createConfigurationDeployment(); | ||
63 | + | ||
64 | + deployment.addPackages(true, ConfigurationNamedFieldTest.class.getPackage()); | ||
65 | + deployment.addAsResource( | ||
66 | + new FileAsset(new File("src/test/resources/configuration/field/named/demoiselle.properties")), | ||
67 | + "demoiselle.properties"); | ||
68 | + | ||
69 | + return deployment; | ||
70 | + } | ||
71 | + | ||
72 | + @Test | ||
73 | + public void loadNamedConfigFromPropertyWithName(){ | ||
74 | + assertEquals(1, propertyDefault.getIntUniqueName()); | ||
75 | + } | ||
76 | + | ||
77 | + @Test | ||
78 | + public void loadNamedConfigFromNonexistentProperty(){ | ||
79 | + assertEquals(0, propertyDefault.getIntNotPresent()); | ||
80 | + } | ||
81 | + | ||
82 | + @Test | ||
83 | + public void loadNamedConfigFromPropertyWithoutField(){ | ||
84 | + assertEquals(0, propertyDefault.getIntNamedWithoutFile()); | ||
85 | + } | ||
86 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/PropertyDefault.java
0 → 100644
impl/core/src/test/resources/configuration/field/named/demoiselle.properties
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
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 | +main.int=1 | ||
36 | +intNamedWithoutFile=1 |