From 7e349fdcc1500adcbf25c32fa923d372ce0aea50 Mon Sep 17 00:00:00 2001 From: Emerson Oliveira Date: Wed, 3 Apr 2013 16:33:05 -0300 Subject: [PATCH] Adicionados testes de array com as propriedades sendo carregadas a partir de arquivo xml --- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java | 12 +++++++++++- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration/field/array/demoiselle.xml | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java create mode 100644 impl/core/src/test/resources/configuration/field/array/demoiselle.xml diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java index ec5ff6e..6e99b08 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java @@ -56,6 +56,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { @Inject private PropertiesArrayFieldConfig propertiesConfig; + + @Inject + private XMLArrayFieldConfig xmlConfig; @Deployment public static JavaArchive createDeployment() { @@ -63,7 +66,9 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage()); deployment.addAsResource(new FileAsset(new File( - "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties"); + "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties") + .addAsResource(new FileAsset(new File("src/test/resources/configuration/field/array/demoiselle.xml")), + "demoiselle.xml"); return deployment; } @@ -73,6 +78,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { int[] expected = { 1, 20, 0 }; assertArrayEquals(expected, propertiesConfig.getPrimitiveIntegers()); + assertArrayEquals(expected, xmlConfig.getPrimitiveIntegers()); } @Test @@ -80,6 +86,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { Integer[] expected = { -99, 0, 1 }; assertArrayEquals(expected, propertiesConfig.getWrappedIntegers()); + assertArrayEquals(expected, xmlConfig.getWrappedIntegers()); } @Test @@ -87,6 +94,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { String[] expected = { "demoisele", "demoiselle framework", "demoiselle,framework", "demoiselle, framework" }; assertArrayEquals(expected, propertiesConfig.getStrings()); + assertArrayEquals(expected, xmlConfig.getStrings()); } @Test @@ -94,6 +102,7 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { double[] expected = { -10, 200000.99999, 0 }; assertArrayEquals(expected, propertiesConfig.getPrimitiveDoubles(), 0); + assertArrayEquals(expected, xmlConfig.getPrimitiveDoubles(), 0); } @Test @@ -101,5 +110,6 @@ public class ConfigurationArrayFieldTest extends AbstractConfigurationTest { Double[] expected = { -456.123456789, 0.0, 52.2 }; assertArrayEquals(expected, propertiesConfig.getWrappedDoubles()); + assertArrayEquals(expected, xmlConfig.getWrappedDoubles()); } } diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java new file mode 100644 index 0000000..bf7286c --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/XMLArrayFieldConfig.java @@ -0,0 +1,44 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.configuration.field.array; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(resource = "demoiselle", type = XML) +public class XMLArrayFieldConfig extends AbstractArrayFieldConfig { +} diff --git a/impl/core/src/test/resources/configuration/field/array/demoiselle.xml b/impl/core/src/test/resources/configuration/field/array/demoiselle.xml new file mode 100644 index 0000000..37e33c8 --- /dev/null +++ b/impl/core/src/test/resources/configuration/field/array/demoiselle.xml @@ -0,0 +1,59 @@ + + + + 1 + 20 + 0 + + -99 + 0 + 1 + + demoisele + demoiselle framework + demoiselle,framework + demoiselle, framework + + -10 + 200000.99999 + 0 + + -456.123456789 + 0.0 + 52.2 + -- libgit2 0.21.2