From cb32201177d160773da65c60e253059f1b10793b Mon Sep 17 00:00:00 2001 From: Ednara Oliveira Date: Tue, 23 Apr 2013 18:43:16 -0300 Subject: [PATCH] Testes de ResourceBundle --- impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/resourcebundle/file/custom/mymessages.properties | 36 ++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties | 36 ++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/resourcebundle/file/default/messages.properties | 36 ++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties | 36 ++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/resourcebundle/file/empty/messages.properties | 34 ++++++++++++++++++++++++++++++++++ 13 files changed, 719 insertions(+), 0 deletions(-) create mode 100644 impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java create mode 100644 impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java create mode 100644 impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java create mode 100644 impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java create mode 100644 impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java create mode 100644 impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java create mode 100644 impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java create mode 100644 impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java create mode 100644 impl/core/src/test/resources/resourcebundle/file/custom/mymessages.properties create mode 100644 impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties create mode 100644 impl/core/src/test/resources/resourcebundle/file/default/messages.properties create mode 100644 impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties create mode 100644 impl/core/src/test/resources/resourcebundle/file/empty/messages.properties diff --git a/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java b/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java new file mode 100644 index 0000000..03d537a --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java @@ -0,0 +1,57 @@ +/* + * 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 resourcebundle.file.custom; + +import javax.inject.Inject; + +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +public class ResourceBundleCustom { + + @Inject + @Name("mymessages") + private ResourceBundle bundle; + + public ResourceBundle getBundle() { + return bundle; + } + + public String getMessage() { + return bundle.getString("message"); + } +} diff --git a/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java b/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java new file mode 100644 index 0000000..e7334a0 --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java @@ -0,0 +1,80 @@ +/* + * 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 resourcebundle.file.custom; + +import java.util.Locale; + +import junit.framework.Assert; + +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 test.Tests; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ResourceBundleCustomTest { + + private ResourceBundleCustom bundleCustom; + + private static final String PATH = "src/test/resources/resourcebundle/file/custom/"; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ResourceBundleCustomTest.class); + deployment.addAsResource(Tests.createFileAsset(PATH + "mymessages.properties"), "mymessages.properties"); + deployment.addAsResource(Tests.createFileAsset(PATH + "mymessages_en.properties"), "mymessages_en.properties"); + + return deployment; + } + + @Test + public void testResourceFileCustom() { + bundleCustom = Beans.getReference(ResourceBundleCustom.class); + Assert.assertEquals("mensagem em Portugues", bundleCustom.getMessage()); + } + + @Test + public void testResourceDefaultEnglish() { + Locale.setDefault(Locale.ENGLISH); + bundleCustom = Beans.getReference(ResourceBundleCustom.class); + Assert.assertEquals("message in English", bundleCustom.getMessage()); + } +} diff --git a/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java b/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java new file mode 100644 index 0000000..51324c8 --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java @@ -0,0 +1,55 @@ +/* + * 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 resourcebundle.file.defaultfile; + +import java.util.ResourceBundle; + +import javax.inject.Inject; + +public class ResourceBundleDefault { + + @Inject + private ResourceBundle bundle; + + public ResourceBundle getBundle() { + return bundle; + } + + public String getMessage() { + return bundle.getString("message"); + } +} diff --git a/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java b/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java new file mode 100644 index 0000000..0c86fe6 --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java @@ -0,0 +1,81 @@ +/* + * 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 resourcebundle.file.defaultfile; + +import java.util.Locale; + +import junit.framework.Assert; + +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 test.Tests; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ResourceBundleDefaultTest { + + private ResourceBundleDefault bundleDefault; + + private static final String PATH = "src/test/resources/resourcebundle/file/default/"; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ResourceBundleDefaultTest.class); + deployment.addAsResource(Tests.createFileAsset(PATH + "messages.properties"), "messages.properties"); + deployment.addAsResource(Tests.createFileAsset(PATH + "messages_en.properties"), "messages_en.properties"); + + return deployment; + } + + @Test + public void testResourceDefault() { + bundleDefault = Beans.getReference(ResourceBundleDefault.class); + Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); + } + + @Test + public void testResourceDefaultEnglish() { + Locale.setDefault(Locale.ENGLISH); + bundleDefault = Beans.getReference(ResourceBundleDefault.class); + Assert.assertEquals("message in English", bundleDefault.getMessage()); + } + +} diff --git a/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java b/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java new file mode 100644 index 0000000..0eedb2c --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java @@ -0,0 +1,55 @@ +/* + * 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 resourcebundle.file.empty; + +import java.util.ResourceBundle; + +import javax.inject.Inject; + +public class ResourceBundleEmpty { + + @Inject + private ResourceBundle bundle; + + public ResourceBundle getBundle() { + return bundle; + } + + public String getMessage() { + return bundle.getString("message"); + } +} diff --git a/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java b/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java new file mode 100644 index 0000000..ddbb7f0 --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java @@ -0,0 +1,80 @@ +/* + * 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 resourcebundle.file.empty; + +import static junit.framework.Assert.fail; + +import java.util.MissingResourceException; + +import junit.framework.Assert; + +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 test.Tests; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ResourceBundleEmptyTest { + + private ResourceBundleEmpty bundleDefault; + + private static final String PATH = "src/test/resources/resourcebundle/file/empty/"; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ResourceBundleEmptyTest.class); + deployment.addAsResource(Tests.createFileAsset(PATH + "messages.properties"), "messages.properties"); + + return deployment; + } + + @Test + public void testResourceEmpty() { + bundleDefault = Beans.getReference(ResourceBundleEmpty.class); + try { + bundleDefault.getMessage(); + fail(); + } catch (Exception e) { + Assert.assertEquals(MissingResourceException.class, e.getClass()); + } + } + +} diff --git a/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java b/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java new file mode 100644 index 0000000..06919b9 --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java @@ -0,0 +1,57 @@ +/* + * 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 resourcebundle.file.notexist; + +import javax.inject.Inject; + +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +public class ResourceBundleFileNotExist { + + @Inject + @Name("mymessages") + private ResourceBundle bundle; + + public ResourceBundle getBundle() { + return bundle; + } + + public String getMessage() { + return bundle.getString("message"); + } +} diff --git a/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java b/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java new file mode 100644 index 0000000..8a9221e --- /dev/null +++ b/impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.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 resourcebundle.file.notexist; + +import static junit.framework.Assert.fail; + +import java.util.MissingResourceException; + +import junit.framework.Assert; + +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 test.Tests; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ResourceBundleFileNotExistTest { + + private ResourceBundleFileNotExist bundleFileNotExist; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ResourceBundleFileNotExistTest.class); + + return deployment; + } + + @Test + public void testResourceFileCustom() { + bundleFileNotExist = Beans.getReference(ResourceBundleFileNotExist.class); + try { + bundleFileNotExist.getMessage(); + fail(); + } catch (Exception e) { + Assert.assertEquals(MissingResourceException.class, e.getCause().getClass()); + } + } +} diff --git a/impl/core/src/test/resources/resourcebundle/file/custom/mymessages.properties b/impl/core/src/test/resources/resourcebundle/file/custom/mymessages.properties new file mode 100644 index 0000000..8ce9be4 --- /dev/null +++ b/impl/core/src/test/resources/resourcebundle/file/custom/mymessages.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. + +message = mensagem em Portugues \ No newline at end of file diff --git a/impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties b/impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties new file mode 100644 index 0000000..8226f4e --- /dev/null +++ b/impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.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. + +message = message in English \ No newline at end of file diff --git a/impl/core/src/test/resources/resourcebundle/file/default/messages.properties b/impl/core/src/test/resources/resourcebundle/file/default/messages.properties new file mode 100644 index 0000000..8ce9be4 --- /dev/null +++ b/impl/core/src/test/resources/resourcebundle/file/default/messages.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. + +message = mensagem em Portugues \ No newline at end of file diff --git a/impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties b/impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties new file mode 100644 index 0000000..8226f4e --- /dev/null +++ b/impl/core/src/test/resources/resourcebundle/file/default/messages_en.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. + +message = message in English \ No newline at end of file diff --git a/impl/core/src/test/resources/resourcebundle/file/empty/messages.properties b/impl/core/src/test/resources/resourcebundle/file/empty/messages.properties new file mode 100644 index 0000000..3f1fa2e --- /dev/null +++ b/impl/core/src/test/resources/resourcebundle/file/empty/messages.properties @@ -0,0 +1,34 @@ +# 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. -- libgit2 0.21.2