Commit 4d02f140be0997cead866194513772d7efcbd18e

Authored by Emerson Oliveira
1 parent 6ef8af7c
Exists in master

Adicionados testes para classe de configuração com prefixo

impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/AbstractPrefixConfig.java 0 → 100644
... ... @@ -0,0 +1,50 @@
  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.prefix;
  38 +
  39 +public abstract class AbstractPrefixConfig {
  40 +
  41 + private String prefixedAttribute;
  42 +
  43 + public String getPrefixedAttribute() {
  44 + return prefixedAttribute;
  45 + }
  46 +
  47 + public void setPrefixedAttribute(String prefixedAttribute) {
  48 + this.prefixedAttribute = prefixedAttribute;
  49 + }
  50 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ConfigurationPrefixTest.java 0 → 100644
... ... @@ -0,0 +1,84 @@
  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.prefix;
  38 +
  39 +import static org.junit.Assert.assertEquals;
  40 +
  41 +import java.io.File;
  42 +
  43 +import javax.inject.Inject;
  44 +
  45 +import org.jboss.arquillian.container.test.api.Deployment;
  46 +import org.jboss.arquillian.junit.Arquillian;
  47 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  48 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  49 +import org.junit.Test;
  50 +import org.junit.runner.RunWith;
  51 +
  52 +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest;
  53 +
  54 +@RunWith(Arquillian.class)
  55 +public class ConfigurationPrefixTest extends AbstractConfigurationTest {
  56 +
  57 + @Inject
  58 + private ExistentPrefix existentPrefix;
  59 +
  60 + @Inject
  61 + private MissingPrefix missingPrefix;
  62 +
  63 + @Deployment
  64 + public static JavaArchive createDeployment() {
  65 + JavaArchive deployment = createConfigurationDeployment();
  66 +
  67 + deployment.addPackages(true, ConfigurationPrefixTest.class.getPackage());
  68 + deployment.addAsResource(
  69 + new FileAsset(new File("src/test/resources/configuration/prefix/demoiselle.properties")),
  70 + "demoiselle.properties");
  71 +
  72 + return deployment;
  73 + }
  74 +
  75 + @Test
  76 + public void loadFromPrefixedExistentProperty(){
  77 + assertEquals("Atributo com prefixo", existentPrefix.getPrefixedAttribute());
  78 + }
  79 +
  80 + @Test
  81 + public void loadFromPrefixedWithouPrefixOnProperty(){
  82 + assertEquals(null, missingPrefix.getPrefixedAttribute());
  83 + }
  84 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/ExistentPrefix.java 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +package br.gov.frameworkdemoiselle.configuration.prefix;
  2 +
  3 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  4 +
  5 +@Configuration(prefix="prefix.")
  6 +public class ExistentPrefix extends AbstractPrefixConfig {
  7 +}
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/prefix/MissingPrefix.java 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +package br.gov.frameworkdemoiselle.configuration.prefix;
  2 +
  3 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  4 +
  5 +@Configuration(prefix="missing.prefix.")
  6 +public class MissingPrefix extends AbstractPrefixConfig{
  7 +}
... ...
impl/core/src/test/resources/configuration/prefix/demoiselle.properties 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +# Demoiselle Framework
  2 +# Copyright (C) 2010 SERPRO
  3 +# ----------------------------------------------------------------------------
  4 +# This file is part of Demoiselle Framework.
  5 +#
  6 +# Demoiselle Framework is free software; you can redistribute it and/or
  7 +# modify it under the terms of the GNU Lesser General Public License version 3
  8 +# as published by the Free Software Foundation.
  9 +#
  10 +# This program is distributed in the hope that it will be useful,
  11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 +# GNU General Public License for more details.
  14 +#
  15 +# You should have received a copy of the GNU Lesser General Public License version 3
  16 +# along with this program; if not, see <http://www.gnu.org/licenses/>
  17 +# or write to the Free Software Foundation, Inc., 51 Franklin Street,
  18 +# Fifth Floor, Boston, MA 02110-1301, USA.
  19 +# ----------------------------------------------------------------------------
  20 +# Este arquivo é parte do Framework Demoiselle.
  21 +#
  22 +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  23 +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  24 +# do Software Livre (FSF).
  25 +#
  26 +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  27 +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  28 +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  29 +# para maiores detalhes.
  30 +#
  31 +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  32 +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  33 +# ou escreva para a Fundação do Software Livre (FSF) Inc.,
  34 +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  35 +
  36 +prefix.prefixedAttribute=Atributo com prefixo
  37 +prefixedAttribute=Sem prefixo
... ...
impl/core/src/test/resources/configuration/resource/demoiselle.xml
... ... @@ -34,6 +34,7 @@
34 34 ou escreva para a Fundação do Software Livre (FSF) Inc.,
35 35 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
36 36 -->
  37 +
37 38 <configuration>
38 39 <string>demoiselle</string>
39   -</configuration>
40 40 \ No newline at end of file
  41 +</configuration>
... ...
impl/core/src/test/resources/configuration/resource/resource.xml
... ... @@ -34,6 +34,7 @@
34 34 ou escreva para a Fundação do Software Livre (FSF) Inc.,
35 35 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
36 36 -->
  37 +
37 38 <configuration>
38 39 <string>demoiselle</string>
39   -</configuration>
40 40 \ No newline at end of file
  41 +</configuration>
... ...