From 595d1c4686d032623132fefdb324e1500dd91668 Mon Sep 17 00:00:00 2001 From: Ednara Oliveira Date: Tue, 9 Apr 2013 17:58:43 -0300 Subject: [PATCH] Ajustes --- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java | 8 +------- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java | 12 ------------ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java | 21 +++++++++++++++------ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java | 2 +- 8 files changed, 227 insertions(+), 26 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java index d532ad8..9eb146d 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationStringValueExtractor.java @@ -50,13 +50,7 @@ public class ConfigurationStringValueExtractor implements ConfigurationValueExtr @Override public Object getValue(String prefix, String key, Field field, Configuration configuration) { - Object value = configuration.getString(prefix + key); - - if (value.equals("")) { - value = null; - } - - return value; + return configuration.getString(prefix + key); } @Override diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java new file mode 100644 index 0000000..9d44309 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperErrorFieldConfig.java @@ -0,0 +1,76 @@ +/* + * 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.primitiveorwrapper; + +public abstract class AbstractPrimitiveOrWrapperErrorFieldConfig { + + private int primitiveInteger; + + private int nullPrimitiveInteger; + + private int errorPrimitiveInteger; + + private Integer wrappedInteger; + + private Integer nullWrappedInteger; + + private Integer errorWrappedInteger; + + public Integer getWrappedInteger() { + return wrappedInteger; + } + + public int getPrimitiveInteger() { + return primitiveInteger; + } + + public int getNullPrimitiveInteger() { + return nullPrimitiveInteger; + } + + public Integer getNullWrappedInteger() { + return nullWrappedInteger; + } + + public int getErrorPrimitiveInteger() { + return errorPrimitiveInteger; + } + + public Integer getErrorWrappedInteger() { + return errorWrappedInteger; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java index 7842da3..0eb6ffb 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/AbstractPrimitiveOrWrapperFieldConfig.java @@ -42,14 +42,10 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { private int nullPrimitiveInteger; - private int errorPrimitiveInteger; - private Integer wrappedInteger; private Integer nullWrappedInteger; - private Integer errorWrappedInteger; - public Integer getWrappedInteger() { return wrappedInteger; } @@ -65,12 +61,4 @@ public abstract class AbstractPrimitiveOrWrapperFieldConfig { public Integer getNullWrappedInteger() { return nullWrappedInteger; } - - public int getErrorPrimitiveInteger() { - return errorPrimitiveInteger; - } - - public Integer getErrorWrappedInteger() { - return errorWrappedInteger; - } } diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java index ad8b908..f9ff71d 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/ConfigurationPrimitiveOrWrapperFieldTest.java @@ -69,6 +69,15 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat @Inject private SystemPrimitiveOrWrapperFieldConfig systemConfig; + + @Inject + private PropertiesPrimitiveOrWrapperErrorFieldConfig propertiesErrorConfig; + + @Inject + private XMLPrimitiveOrWrapperErrorFieldConfig xmlErrorConfig; + + @Inject + private SystemPrimitiveOrWrapperErrorFieldConfig systemErrorConfig; @Deployment public static JavaArchive createDeployment() { @@ -136,21 +145,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat int expected = 0; try { - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger()); + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); } try { - assertEquals(expected, propertiesConfig.getErrorPrimitiveInteger()); + assertEquals(expected, propertiesErrorConfig.getErrorPrimitiveInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); } try { - assertEquals(expected, xmlConfig.getErrorPrimitiveInteger()); + assertEquals(expected, xmlErrorConfig.getErrorPrimitiveInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); @@ -163,21 +172,21 @@ public class ConfigurationPrimitiveOrWrapperFieldTest extends AbstractConfigurat Integer expected = 2; try { - assertEquals(expected, propertiesConfig.getErrorWrappedInteger()); + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); } try { - assertEquals(expected, propertiesConfig.getErrorWrappedInteger()); + assertEquals(expected, propertiesErrorConfig.getErrorWrappedInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); } try { - assertEquals(expected, xmlConfig.getErrorWrappedInteger()); + assertEquals(expected, xmlErrorConfig.getErrorWrappedInteger()); fail(); } catch (ConversionException cause) { Assert.assertEquals(ConversionException.class, cause.getCause().getClass()); diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.java new file mode 100644 index 0000000..672ee5f --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/PropertiesPrimitiveOrWrapperErrorFieldConfig.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.primitiveorwrapper; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = PROPERTIES) +public class PropertiesPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig { +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java new file mode 100644 index 0000000..38cabdc --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/SystemPrimitiveOrWrapperErrorFieldConfig.java @@ -0,0 +1,45 @@ +/* + * 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.primitiveorwrapper; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = SYSTEM) +public class SystemPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig { + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java new file mode 100644 index 0000000..a3af9c1 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/primitiveorwrapper/XMLPrimitiveOrWrapperErrorFieldConfig.java @@ -0,0 +1,45 @@ +/* + * 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.primitiveorwrapper; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = XML) +public class XMLPrimitiveOrWrapperErrorFieldConfig extends AbstractPrimitiveOrWrapperErrorFieldConfig { + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java index e2a1d97..7d707ee 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/string/ConfigurationStringFieldTest.java @@ -105,7 +105,7 @@ public class ConfigurationStringFieldTest extends AbstractConfigurationTest { @Test public void loadEmptyString() { - String expected = null; + String expected = ""; assertEquals(expected, systemConfig.getEmptyString()); assertEquals(expected, propertiesConfig.getEmptyString()); assertEquals(expected, xmlConfig.getEmptyString()); -- libgit2 0.21.2