From 3f6f7720f0ffca0f41ddf5b6f9b5b4cc0880fd91 Mon Sep 17 00:00:00 2001 From: Emerson Oliveira Date: Mon, 25 Mar 2013 14:08:44 -0300 Subject: [PATCH] Adicionados testes para atributos nas classes de configuração anotados com @Ignore --- impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java | 43 +++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration/field/ignored/demoiselle.properties | 35 +++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml | 39 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 349 insertions(+), 0 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java create mode 100644 impl/core/src/test/resources/configuration/field/ignored/demoiselle.properties create mode 100644 impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java new file mode 100644 index 0000000..f50c545 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/AbstractIgnoredFieldConfig.java @@ -0,0 +1,53 @@ +/* + * 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.ignored; + +import br.gov.frameworkdemoiselle.annotation.Ignore; + +public abstract class AbstractIgnoredFieldConfig { + + @Ignore + private int ignoredInt; + + public int getIgnoredInt() { + return ignoredInt; + } + + public void setIgnoredInt(int ignoredInt) { + this.ignoredInt = ignoredInt; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java new file mode 100644 index 0000000..261ac65 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/ConfigurationIgnoredFieldTest.java @@ -0,0 +1,91 @@ +/* + * 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.ignored; + +import static junit.framework.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 ConfigurationIgnoredFieldTest extends AbstractConfigurationTest { + + @Inject + private FilledIgnoredFieldConfig filledFieldConfig; + + @Inject + private EmptyIgnoredFieldConfig emptyFieldsConfig; + + @Inject + private PropertyWithoutFileConfig noFileConfig; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = createConfigurationDeployment(); + + deployment.addPackages(true, ConfigurationIgnoredFieldTest.class.getPackage()); + deployment.addAsResource( + new FileAsset(new File("src/test/resources/configuration/field/ignored/demoiselle.properties")), + "demoiselle.properties").addAsResource( + new FileAsset(new File("src/test/resources/configuration/field/ignored/demoiselle.xml")), + "demoiselle.xml"); + + return deployment; + } + + @Test + public void loadIgnoredInt(){ + int expected = 0; + + assertEquals(expected, filledFieldConfig.getIgnoredInt()); + assertEquals(expected, noFileConfig.getIgnoredInt()); + + expected = 2; + emptyFieldsConfig.setIgnoredInt(expected); + assertEquals(expected, emptyFieldsConfig.getIgnoredInt()); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.java new file mode 100644 index 0000000..ebd603f --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/EmptyIgnoredFieldConfig.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.ignored; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(resource = "demoiselle", type = XML) +public class EmptyIgnoredFieldConfig extends AbstractIgnoredFieldConfig{ +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.java new file mode 100644 index 0000000..cfdc9ea --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/FilledIgnoredFieldConfig.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.ignored; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(resource = "demoiselle", type = PROPERTIES) +public class FilledIgnoredFieldConfig extends AbstractIgnoredFieldConfig{ +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java new file mode 100644 index 0000000..d666540 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/ignored/PropertyWithoutFileConfig.java @@ -0,0 +1,43 @@ +/* + * 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.ignored; + +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(resource = "nofile") +public class PropertyWithoutFileConfig extends AbstractIgnoredFieldConfig{ +} diff --git a/impl/core/src/test/resources/configuration/field/ignored/demoiselle.properties b/impl/core/src/test/resources/configuration/field/ignored/demoiselle.properties new file mode 100644 index 0000000..9e38d5e --- /dev/null +++ b/impl/core/src/test/resources/configuration/field/ignored/demoiselle.properties @@ -0,0 +1,35 @@ +# 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. +ignoredInt=1 diff --git a/impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml b/impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml new file mode 100644 index 0000000..d5d0c99 --- /dev/null +++ b/impl/core/src/test/resources/configuration/field/ignored/demoiselle.xml @@ -0,0 +1,39 @@ + + + + -- libgit2 0.21.2