From 8094530839b67a46b29c5ad1d3784574701e4691 Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Sat, 23 Mar 2013 18:32:25 -0300 Subject: [PATCH] Implementação inicial dos testes de escopo das classes de configuração --- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/AbstractScopedConfig.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.java | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DefaultScopeWithoutSuperClassConfig.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DependentScopeWithoutSuperClassConfig.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration/scope/demoiselle.properties | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/AbstractScopedConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DefaultScopeWithoutSuperClassConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DependentScopeWithoutSuperClassConfig.java create mode 100644 impl/core/src/test/resources/configuration/scope/demoiselle.properties diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/AbstractScopedConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/AbstractScopedConfig.java new file mode 100644 index 0000000..a6138c5 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/AbstractScopedConfig.java @@ -0,0 +1,49 @@ +/* + * 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.scope; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration +public abstract class AbstractScopedConfig { + + private String string; + + public String getStringWithComma() { + return string; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.java new file mode 100644 index 0000000..1e3788c --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/ConfigurationScopeTest.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.scope; + +import static junit.framework.Assert.assertNotSame; +import static junit.framework.Assert.assertSame; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ConfigurationScopeTest extends AbstractConfigurationTest { + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = createConfigurationDeployment(); + deployment.addPackages(true, ConfigurationScopeTest.class.getPackage()); + return deployment; + } + + @Test + public void twoInvocationsSameInstance() { + DefaultScopeWithoutSuperClassConfig config1 = Beans.getReference(DefaultScopeWithoutSuperClassConfig.class); + DefaultScopeWithoutSuperClassConfig config2 = Beans.getReference(DefaultScopeWithoutSuperClassConfig.class); + + assertSame(config1, config2); + } + + @Test + public void twoInvocationsDifferentInstances() { + DependentScopeWithoutSuperClassConfig config1 = Beans.getReference(DependentScopeWithoutSuperClassConfig.class); + DependentScopeWithoutSuperClassConfig config2 = Beans.getReference(DependentScopeWithoutSuperClassConfig.class); + + assertNotSame(config1, config2); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DefaultScopeWithoutSuperClassConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DefaultScopeWithoutSuperClassConfig.java new file mode 100644 index 0000000..572e355 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DefaultScopeWithoutSuperClassConfig.java @@ -0,0 +1,49 @@ +/* + * 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.scope; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration +public class DefaultScopeWithoutSuperClassConfig { + + private String string; + + public String getString() { + return string; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DependentScopeWithoutSuperClassConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DependentScopeWithoutSuperClassConfig.java new file mode 100644 index 0000000..0d653b6 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/scope/DependentScopeWithoutSuperClassConfig.java @@ -0,0 +1,52 @@ +/* + * 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.scope; + +import javax.enterprise.context.Dependent; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Dependent +@Configuration +public class DependentScopeWithoutSuperClassConfig { + + private String string; + + public String getString() { + return string; + } +} diff --git a/impl/core/src/test/resources/configuration/scope/demoiselle.properties b/impl/core/src/test/resources/configuration/scope/demoiselle.properties new file mode 100644 index 0000000..0569d37 --- /dev/null +++ b/impl/core/src/test/resources/configuration/scope/demoiselle.properties @@ -0,0 +1,36 @@ +# 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. + +string=demoiselle -- libgit2 0.21.2