Commit 8937b13e145895922a04e4362e3da1c8d6faacbf
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
13 changed files
with
200 additions
and
34 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/AbstractDefaultValueConfig.java
... | ... | @@ -39,9 +39,9 @@ package br.gov.frameworkdemoiselle.configuration.defaultvalue; |
39 | 39 | |
40 | 40 | public abstract class AbstractDefaultValueConfig { |
41 | 41 | |
42 | - private String stringDefaultWithoutKey = "Valor inicializado e sem chave em arquivo de propriedade"; | |
42 | + private String stringDefaultWithoutKey = "Initialized value and without key in the property file"; | |
43 | 43 | |
44 | - private String stringDefaultWithKey = "Valor inicializado e com chave em arquivo de propriedade"; | |
44 | + private String stringDefaultWithKey = "Initialized value and key in the property file"; | |
45 | 45 | |
46 | 46 | public String getStringDefaultWithoutKey() { |
47 | 47 | return stringDefaultWithoutKey; | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/defaultvalue/ConfigurationDefaultValueTest.java
... | ... | @@ -81,20 +81,17 @@ public class ConfigurationDefaultValueTest extends AbstractConfigurationTest { |
81 | 81 | |
82 | 82 | @Test |
83 | 83 | public void loadDefaultValueWithoutKey(){ |
84 | - String expected = "Valor inicializado e sem chave em arquivo de propriedade"; | |
84 | + String expected = "Initialized value and without key in the property file"; | |
85 | 85 | |
86 | 86 | assertEquals(expected, filledFieldConfig.getStringDefaultWithoutKey()); |
87 | 87 | assertEquals(expected, emptyFieldsConfig.getStringDefaultWithoutKey()); |
88 | 88 | assertEquals(expected, noFileConfig.getStringDefaultWithoutKey()); |
89 | 89 | } |
90 | 90 | |
91 | - @Ignore | |
92 | - @Test(expected = ConfigurationException.class) | |
93 | - /*TODO: Lançar exceção quando uma chave adicionada em arquivo de configuração não | |
94 | - * tiver valor associado*/ | |
91 | + @Test | |
95 | 92 | public void loadDefaultValueWithKey(){ |
96 | - assertEquals("Valor inicializado do arquivo de propriedade", filledFieldConfig.getStringDefaultWithKey()); | |
97 | - assertEquals("Valor inicializado e com chave em arquivo de propriedade", noFileConfig.getStringDefaultWithKey()); | |
98 | - emptyFieldsConfig.getStringDefaultWithKey(); | |
93 | + assertEquals("Initialized value of the property file", filledFieldConfig.getStringDefaultWithKey()); | |
94 | + assertEquals("Initialized value and key in the property file", noFileConfig.getStringDefaultWithKey()); | |
95 | + assertEquals("", emptyFieldsConfig.getStringDefaultWithKey()); | |
99 | 96 | } |
100 | 97 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java
... | ... | @@ -56,6 +56,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
56 | 56 | |
57 | 57 | @Inject |
58 | 58 | private PropertiesArrayFieldConfig propertiesConfig; |
59 | + | |
60 | + @Inject | |
61 | + private XMLArrayFieldConfig xmlConfig; | |
59 | 62 | |
60 | 63 | @Deployment |
61 | 64 | public static JavaArchive createDeployment() { |
... | ... | @@ -63,7 +66,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
63 | 66 | |
64 | 67 | deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage()); |
65 | 68 | deployment.addAsResource(new FileAsset(new File( |
66 | - "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties"); | |
69 | + "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties") | |
70 | + .addAsResource(new FileAsset(new File("src/test/resources/configuration/field/array/demoiselle.xml")), | |
71 | + "demoiselle.xml"); | |
67 | 72 | |
68 | 73 | return deployment; |
69 | 74 | } |
... | ... | @@ -73,6 +78,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
73 | 78 | int[] expected = { 1, 20, 0 }; |
74 | 79 | |
75 | 80 | assertArrayEquals(expected, propertiesConfig.getPrimitiveIntegers()); |
81 | + assertArrayEquals(expected, xmlConfig.getPrimitiveIntegers()); | |
76 | 82 | } |
77 | 83 | |
78 | 84 | @Test |
... | ... | @@ -80,6 +86,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
80 | 86 | Integer[] expected = { -99, 0, 1 }; |
81 | 87 | |
82 | 88 | assertArrayEquals(expected, propertiesConfig.getWrappedIntegers()); |
89 | + assertArrayEquals(expected, xmlConfig.getWrappedIntegers()); | |
83 | 90 | } |
84 | 91 | |
85 | 92 | @Test |
... | ... | @@ -87,6 +94,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
87 | 94 | String[] expected = { "demoisele", "demoiselle framework", "demoiselle,framework", "demoiselle, framework" }; |
88 | 95 | |
89 | 96 | assertArrayEquals(expected, propertiesConfig.getStrings()); |
97 | + assertArrayEquals(expected, xmlConfig.getStrings()); | |
90 | 98 | } |
91 | 99 | |
92 | 100 | @Test |
... | ... | @@ -94,6 +102,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
94 | 102 | double[] expected = { -10, 200000.99999, 0 }; |
95 | 103 | |
96 | 104 | assertArrayEquals(expected, propertiesConfig.getPrimitiveDoubles(), 0); |
105 | + assertArrayEquals(expected, xmlConfig.getPrimitiveDoubles(), 0); | |
97 | 106 | } |
98 | 107 | |
99 | 108 | @Test |
... | ... | @@ -101,5 +110,6 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { |
101 | 110 | Double[] expected = { -456.123456789, 0.0, 52.2 }; |
102 | 111 | |
103 | 112 | assertArrayEquals(expected, propertiesConfig.getWrappedDoubles()); |
113 | + assertArrayEquals(expected, xmlConfig.getWrappedDoubles()); | |
104 | 114 | } |
105 | 115 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java
0 → 100644
... | ... | @@ -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.field.array; | |
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 XMLArrayFieldConfig extends AbstractArrayFieldConfig { | |
44 | +} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java
... | ... | @@ -83,9 +83,6 @@ public class ConfigurationIgnoredFieldTest extends AbstractConfigurationTest { |
83 | 83 | |
84 | 84 | assertEquals(expected, filledFieldConfig.getIgnoredInt()); |
85 | 85 | assertEquals(expected, noFileConfig.getIgnoredInt()); |
86 | - | |
87 | - expected = 2; | |
88 | - emptyFieldsConfig.setIgnoredInt(expected); | |
89 | 86 | assertEquals(expected, emptyFieldsConfig.getIgnoredInt()); |
90 | 87 | } |
91 | 88 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/ConfigurationNamedFieldTest.java
... | ... | @@ -55,8 +55,11 @@ import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; |
55 | 55 | public class ConfigurationNamedFieldTest extends AbstractConfigurationTest { |
56 | 56 | |
57 | 57 | @Inject |
58 | - private PropertyDefault propertyDefault; | |
59 | - | |
58 | + private PropertyNamed propertyNamed; | |
59 | + | |
60 | + @Inject | |
61 | + private XMLNamed xmlNamed; | |
62 | + | |
60 | 63 | @Deployment |
61 | 64 | public static JavaArchive createDeployment() { |
62 | 65 | JavaArchive deployment = createConfigurationDeployment(); |
... | ... | @@ -64,23 +67,28 @@ public class ConfigurationNamedFieldTest extends AbstractConfigurationTest { |
64 | 67 | deployment.addPackages(true, ConfigurationNamedFieldTest.class.getPackage()); |
65 | 68 | deployment.addAsResource( |
66 | 69 | new FileAsset(new File("src/test/resources/configuration/field/named/demoiselle.properties")), |
67 | - "demoiselle.properties"); | |
70 | + "demoiselle.properties").addAsResource( | |
71 | + new FileAsset(new File("src/test/resources/configuration/field/named/demoiselle.xml")), | |
72 | + "demoiselle.xml"); | |
68 | 73 | |
69 | 74 | return deployment; |
70 | 75 | } |
71 | - | |
76 | + | |
72 | 77 | @Test |
73 | - public void loadNamedConfigFromPropertyWithName(){ | |
74 | - assertEquals(1, propertyDefault.getIntUniqueName()); | |
78 | + public void loadNamedConfigFromPropertyWithName() { | |
79 | + assertEquals(1, propertyNamed.getIntUniqueName()); | |
80 | + assertEquals(1, xmlNamed.getIntUniqueName()); | |
75 | 81 | } |
76 | 82 | |
77 | 83 | @Test |
78 | - public void loadNamedConfigFromNonexistentProperty(){ | |
79 | - assertEquals(0, propertyDefault.getIntNotPresent()); | |
84 | + public void loadNamedConfigFromNonexistentProperty() { | |
85 | + assertEquals(0, propertyNamed.getIntNotPresent()); | |
86 | + assertEquals(0, xmlNamed.getIntNotPresent()); | |
80 | 87 | } |
81 | - | |
88 | + | |
82 | 89 | @Test |
83 | - public void loadNamedConfigFromPropertyWithoutField(){ | |
84 | - assertEquals(0, propertyDefault.getIntNamedWithoutFile()); | |
90 | + public void loadNamedConfigFromPropertyWithoutField() { | |
91 | + assertEquals(0, propertyNamed.getIntNamedWithoutFile()); | |
92 | + assertEquals(0, xmlNamed.getIntNamedWithoutFile()); | |
85 | 93 | } |
86 | 94 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/PropertyDefault.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/PropertyNamed.java
0 → 100644
... | ... | @@ -0,0 +1,8 @@ |
1 | +package br.gov.frameworkdemoiselle.configuration.field.named; | |
2 | + | |
3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; | |
4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
5 | + | |
6 | +@Configuration(type = PROPERTIES) | |
7 | +public class PropertyNamed extends AbstractNamedFieldConfig { | |
8 | +} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/named/XMLNamed.java
0 → 100644
... | ... | @@ -0,0 +1,8 @@ |
1 | +package br.gov.frameworkdemoiselle.configuration.field.named; | |
2 | + | |
3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; | |
4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | |
5 | + | |
6 | +@Configuration(type = XML) | |
7 | +public class XMLNamed extends AbstractNamedFieldConfig { | |
8 | +} | ... | ... |
impl/core/src/test/resources/configuration/field/array/demoiselle.xml
0 → 100644
... | ... | @@ -0,0 +1,59 @@ |
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 | +<ArrayValues> | |
39 | + <primitiveIntegers>1</primitiveIntegers> | |
40 | + <primitiveIntegers>20</primitiveIntegers> | |
41 | + <primitiveIntegers>0</primitiveIntegers> | |
42 | + | |
43 | + <wrappedIntegers>-99</wrappedIntegers> | |
44 | + <wrappedIntegers>0</wrappedIntegers> | |
45 | + <wrappedIntegers>1</wrappedIntegers> | |
46 | + | |
47 | + <strings>demoisele</strings> | |
48 | + <strings>demoiselle framework</strings> | |
49 | + <strings>demoiselle,framework</strings> | |
50 | + <strings>demoiselle, framework</strings> | |
51 | + | |
52 | + <primitiveDoubles>-10</primitiveDoubles> | |
53 | + <primitiveDoubles>200000.99999</primitiveDoubles> | |
54 | + <primitiveDoubles>0</primitiveDoubles> | |
55 | + | |
56 | + <wrappedDoubles>-456.123456789</wrappedDoubles> | |
57 | + <wrappedDoubles>0.0</wrappedDoubles> | |
58 | + <wrappedDoubles>52.2</wrappedDoubles> | |
59 | +</ArrayValues> | ... | ... |
impl/core/src/test/resources/configuration/field/default/demoiselle.properties
... | ... | @@ -33,4 +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 | -stringDefaultWithKey=Valor inicializado do arquivo de propriedade | |
36 | +stringDefaultWithKey=Initialized value of the property file | ... | ... |
impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml
impl/core/src/test/resources/configuration/field/named/demoiselle.xml
0 → 100644
... | ... | @@ -0,0 +1,42 @@ |
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 | + <main> | |
39 | + <int>1</int> | |
40 | + </main> | |
41 | + <intNamedWithoutFile>1</intNamedWithoutFile> | |
42 | +</configurations> | ... | ... |