Commit 7e349fdcc1500adcbf25c32fa923d372ce0aea50
1 parent
2808792f
Exists in
master
Adicionados testes de array com as propriedades sendo carregadas a
partir de arquivo xml
Showing
3 changed files
with
114 additions
and
1 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java
| @@ -56,6 +56,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -56,6 +56,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 56 | 56 | ||
| 57 | @Inject | 57 | @Inject |
| 58 | private PropertiesArrayFieldConfig propertiesConfig; | 58 | private PropertiesArrayFieldConfig propertiesConfig; |
| 59 | + | ||
| 60 | + @Inject | ||
| 61 | + private XMLArrayFieldConfig xmlConfig; | ||
| 59 | 62 | ||
| 60 | @Deployment | 63 | @Deployment |
| 61 | public static JavaArchive createDeployment() { | 64 | public static JavaArchive createDeployment() { |
| @@ -63,7 +66,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -63,7 +66,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 63 | 66 | ||
| 64 | deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage()); | 67 | deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage()); |
| 65 | deployment.addAsResource(new FileAsset(new File( | 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 | return deployment; | 73 | return deployment; |
| 69 | } | 74 | } |
| @@ -73,6 +78,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -73,6 +78,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 73 | int[] expected = { 1, 20, 0 }; | 78 | int[] expected = { 1, 20, 0 }; |
| 74 | 79 | ||
| 75 | assertArrayEquals(expected, propertiesConfig.getPrimitiveIntegers()); | 80 | assertArrayEquals(expected, propertiesConfig.getPrimitiveIntegers()); |
| 81 | + assertArrayEquals(expected, xmlConfig.getPrimitiveIntegers()); | ||
| 76 | } | 82 | } |
| 77 | 83 | ||
| 78 | @Test | 84 | @Test |
| @@ -80,6 +86,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -80,6 +86,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 80 | Integer[] expected = { -99, 0, 1 }; | 86 | Integer[] expected = { -99, 0, 1 }; |
| 81 | 87 | ||
| 82 | assertArrayEquals(expected, propertiesConfig.getWrappedIntegers()); | 88 | assertArrayEquals(expected, propertiesConfig.getWrappedIntegers()); |
| 89 | + assertArrayEquals(expected, xmlConfig.getWrappedIntegers()); | ||
| 83 | } | 90 | } |
| 84 | 91 | ||
| 85 | @Test | 92 | @Test |
| @@ -87,6 +94,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -87,6 +94,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 87 | String[] expected = { "demoisele", "demoiselle framework", "demoiselle,framework", "demoiselle, framework" }; | 94 | String[] expected = { "demoisele", "demoiselle framework", "demoiselle,framework", "demoiselle, framework" }; |
| 88 | 95 | ||
| 89 | assertArrayEquals(expected, propertiesConfig.getStrings()); | 96 | assertArrayEquals(expected, propertiesConfig.getStrings()); |
| 97 | + assertArrayEquals(expected, xmlConfig.getStrings()); | ||
| 90 | } | 98 | } |
| 91 | 99 | ||
| 92 | @Test | 100 | @Test |
| @@ -94,6 +102,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -94,6 +102,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 94 | double[] expected = { -10, 200000.99999, 0 }; | 102 | double[] expected = { -10, 200000.99999, 0 }; |
| 95 | 103 | ||
| 96 | assertArrayEquals(expected, propertiesConfig.getPrimitiveDoubles(), 0); | 104 | assertArrayEquals(expected, propertiesConfig.getPrimitiveDoubles(), 0); |
| 105 | + assertArrayEquals(expected, xmlConfig.getPrimitiveDoubles(), 0); | ||
| 97 | } | 106 | } |
| 98 | 107 | ||
| 99 | @Test | 108 | @Test |
| @@ -101,5 +110,6 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | @@ -101,5 +110,6 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { | ||
| 101 | Double[] expected = { -456.123456789, 0.0, 52.2 }; | 110 | Double[] expected = { -456.123456789, 0.0, 52.2 }; |
| 102 | 111 | ||
| 103 | assertArrayEquals(expected, propertiesConfig.getWrappedDoubles()); | 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 @@ | @@ -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/resources/configuration/field/array/demoiselle.xml
0 → 100644
| @@ -0,0 +1,59 @@ | @@ -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> |