From 4d02f140be0997cead866194513772d7efcbd18e Mon Sep 17 00:00:00 2001 From: Emerson Oliveira Date: Wed, 27 Mar 2013 16:14:05 -0300 Subject: [PATCH] Adicionados testes para classe de configuração com prefixo --- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java | 7 +++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java | 7 +++++++ impl/core/src/test/resources/configuration/prefix/demoiselle.properties | 37 +++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration/resource/demoiselle.xml | 3 ++- impl/core/src/test/resources/configuration/resource/resource.xml | 3 ++- 7 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java create mode 100644 impl/core/src/test/resources/configuration/prefix/demoiselle.properties diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java new file mode 100644 index 0000000..69f65f7 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java @@ -0,0 +1,50 @@ +/* + * 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.prefix; + +public abstract class AbstractPrefixConfig { + + private String prefixedAttribute; + + public String getPrefixedAttribute() { + return prefixedAttribute; + } + + public void setPrefixedAttribute(String prefixedAttribute) { + this.prefixedAttribute = prefixedAttribute; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java new file mode 100644 index 0000000..a2f0508 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java @@ -0,0 +1,84 @@ +/* + * 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.prefix; + +import static org.junit.Assert.assertEquals; + +import java.io.File; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.asset.FileAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; + +@RunWith(Arquillian.class) +public class ConfigurationPrefixTest extends AbstractConfigurationTest { + + @Inject + private ExistentPrefix existentPrefix; + + @Inject + private MissingPrefix missingPrefix; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = createConfigurationDeployment(); + + deployment.addPackages(true, ConfigurationPrefixTest.class.getPackage()); + deployment.addAsResource( + new FileAsset(new File("src/test/resources/configuration/prefix/demoiselle.properties")), + "demoiselle.properties"); + + return deployment; + } + + @Test + public void loadFromPrefixedExistentProperty(){ + assertEquals("Atributo com prefixo", existentPrefix.getPrefixedAttribute()); + } + + @Test + public void loadFromPrefixedWithouPrefixOnProperty(){ + assertEquals(null, missingPrefix.getPrefixedAttribute()); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java new file mode 100644 index 0000000..d44fd35 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java @@ -0,0 +1,7 @@ +package br.gov.frameworkdemoiselle.configuration.prefix; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(prefix="prefix.") +public class ExistentPrefix extends AbstractPrefixConfig { +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java new file mode 100644 index 0000000..c736b35 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java @@ -0,0 +1,7 @@ +package br.gov.frameworkdemoiselle.configuration.prefix; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(prefix="missing.prefix.") +public class MissingPrefix extends AbstractPrefixConfig{ +} diff --git a/impl/core/src/test/resources/configuration/prefix/demoiselle.properties b/impl/core/src/test/resources/configuration/prefix/demoiselle.properties new file mode 100644 index 0000000..c49070e --- /dev/null +++ b/impl/core/src/test/resources/configuration/prefix/demoiselle.properties @@ -0,0 +1,37 @@ +# 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. + +prefix.prefixedAttribute=Atributo com prefixo +prefixedAttribute=Sem prefixo diff --git a/impl/core/src/test/resources/configuration/resource/demoiselle.xml b/impl/core/src/test/resources/configuration/resource/demoiselle.xml index b288568..61e6c23 100644 --- a/impl/core/src/test/resources/configuration/resource/demoiselle.xml +++ b/impl/core/src/test/resources/configuration/resource/demoiselle.xml @@ -34,6 +34,7 @@ ou escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. --> + demoiselle - \ No newline at end of file + diff --git a/impl/core/src/test/resources/configuration/resource/resource.xml b/impl/core/src/test/resources/configuration/resource/resource.xml index b288568..61e6c23 100644 --- a/impl/core/src/test/resources/configuration/resource/resource.xml +++ b/impl/core/src/test/resources/configuration/resource/resource.xml @@ -34,6 +34,7 @@ ou escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. --> + demoiselle - \ No newline at end of file + -- libgit2 0.21.2