Commit cb32201177d160773da65c60e253059f1b10793b
1 parent
4c48f361
Exists in
master
Testes de ResourceBundle
Showing
13 changed files
with
719 additions
and
0 deletions
Show diff stats
impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java
0 → 100644
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
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 resourcebundle.file.custom; | ||
38 | + | ||
39 | +import javax.inject.Inject; | ||
40 | + | ||
41 | +import br.gov.frameworkdemoiselle.annotation.Name; | ||
42 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
43 | + | ||
44 | +public class ResourceBundleCustom { | ||
45 | + | ||
46 | + @Inject | ||
47 | + @Name("mymessages") | ||
48 | + private ResourceBundle bundle; | ||
49 | + | ||
50 | + public ResourceBundle getBundle() { | ||
51 | + return bundle; | ||
52 | + } | ||
53 | + | ||
54 | + public String getMessage() { | ||
55 | + return bundle.getString("message"); | ||
56 | + } | ||
57 | +} |
impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java
0 → 100644
@@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
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 resourcebundle.file.custom; | ||
38 | + | ||
39 | +import java.util.Locale; | ||
40 | + | ||
41 | +import junit.framework.Assert; | ||
42 | + | ||
43 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
44 | +import org.jboss.arquillian.junit.Arquillian; | ||
45 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
46 | +import org.junit.Test; | ||
47 | +import org.junit.runner.RunWith; | ||
48 | + | ||
49 | +import test.Tests; | ||
50 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
51 | + | ||
52 | +@RunWith(Arquillian.class) | ||
53 | +public class ResourceBundleCustomTest { | ||
54 | + | ||
55 | + private ResourceBundleCustom bundleCustom; | ||
56 | + | ||
57 | + private static final String PATH = "src/test/resources/resourcebundle/file/custom/"; | ||
58 | + | ||
59 | + @Deployment | ||
60 | + public static JavaArchive createDeployment() { | ||
61 | + JavaArchive deployment = Tests.createDeployment(ResourceBundleCustomTest.class); | ||
62 | + deployment.addAsResource(Tests.createFileAsset(PATH + "mymessages.properties"), "mymessages.properties"); | ||
63 | + deployment.addAsResource(Tests.createFileAsset(PATH + "mymessages_en.properties"), "mymessages_en.properties"); | ||
64 | + | ||
65 | + return deployment; | ||
66 | + } | ||
67 | + | ||
68 | + @Test | ||
69 | + public void testResourceFileCustom() { | ||
70 | + bundleCustom = Beans.getReference(ResourceBundleCustom.class); | ||
71 | + Assert.assertEquals("mensagem em Portugues", bundleCustom.getMessage()); | ||
72 | + } | ||
73 | + | ||
74 | + @Test | ||
75 | + public void testResourceDefaultEnglish() { | ||
76 | + Locale.setDefault(Locale.ENGLISH); | ||
77 | + bundleCustom = Beans.getReference(ResourceBundleCustom.class); | ||
78 | + Assert.assertEquals("message in English", bundleCustom.getMessage()); | ||
79 | + } | ||
80 | +} |
impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefault.java
0 → 100644
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
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 resourcebundle.file.defaultfile; | ||
38 | + | ||
39 | +import java.util.ResourceBundle; | ||
40 | + | ||
41 | +import javax.inject.Inject; | ||
42 | + | ||
43 | +public class ResourceBundleDefault { | ||
44 | + | ||
45 | + @Inject | ||
46 | + private ResourceBundle bundle; | ||
47 | + | ||
48 | + public ResourceBundle getBundle() { | ||
49 | + return bundle; | ||
50 | + } | ||
51 | + | ||
52 | + public String getMessage() { | ||
53 | + return bundle.getString("message"); | ||
54 | + } | ||
55 | +} |
impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java
0 → 100644
@@ -0,0 +1,81 @@ | @@ -0,0 +1,81 @@ | ||
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 resourcebundle.file.defaultfile; | ||
38 | + | ||
39 | +import java.util.Locale; | ||
40 | + | ||
41 | +import junit.framework.Assert; | ||
42 | + | ||
43 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
44 | +import org.jboss.arquillian.junit.Arquillian; | ||
45 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
46 | +import org.junit.Test; | ||
47 | +import org.junit.runner.RunWith; | ||
48 | + | ||
49 | +import test.Tests; | ||
50 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
51 | + | ||
52 | +@RunWith(Arquillian.class) | ||
53 | +public class ResourceBundleDefaultTest { | ||
54 | + | ||
55 | + private ResourceBundleDefault bundleDefault; | ||
56 | + | ||
57 | + private static final String PATH = "src/test/resources/resourcebundle/file/default/"; | ||
58 | + | ||
59 | + @Deployment | ||
60 | + public static JavaArchive createDeployment() { | ||
61 | + JavaArchive deployment = Tests.createDeployment(ResourceBundleDefaultTest.class); | ||
62 | + deployment.addAsResource(Tests.createFileAsset(PATH + "messages.properties"), "messages.properties"); | ||
63 | + deployment.addAsResource(Tests.createFileAsset(PATH + "messages_en.properties"), "messages_en.properties"); | ||
64 | + | ||
65 | + return deployment; | ||
66 | + } | ||
67 | + | ||
68 | + @Test | ||
69 | + public void testResourceDefault() { | ||
70 | + bundleDefault = Beans.getReference(ResourceBundleDefault.class); | ||
71 | + Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage()); | ||
72 | + } | ||
73 | + | ||
74 | + @Test | ||
75 | + public void testResourceDefaultEnglish() { | ||
76 | + Locale.setDefault(Locale.ENGLISH); | ||
77 | + bundleDefault = Beans.getReference(ResourceBundleDefault.class); | ||
78 | + Assert.assertEquals("message in English", bundleDefault.getMessage()); | ||
79 | + } | ||
80 | + | ||
81 | +} |
impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmpty.java
0 → 100644
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
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 resourcebundle.file.empty; | ||
38 | + | ||
39 | +import java.util.ResourceBundle; | ||
40 | + | ||
41 | +import javax.inject.Inject; | ||
42 | + | ||
43 | +public class ResourceBundleEmpty { | ||
44 | + | ||
45 | + @Inject | ||
46 | + private ResourceBundle bundle; | ||
47 | + | ||
48 | + public ResourceBundle getBundle() { | ||
49 | + return bundle; | ||
50 | + } | ||
51 | + | ||
52 | + public String getMessage() { | ||
53 | + return bundle.getString("message"); | ||
54 | + } | ||
55 | +} |
impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java
0 → 100644
@@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
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 resourcebundle.file.empty; | ||
38 | + | ||
39 | +import static junit.framework.Assert.fail; | ||
40 | + | ||
41 | +import java.util.MissingResourceException; | ||
42 | + | ||
43 | +import junit.framework.Assert; | ||
44 | + | ||
45 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
46 | +import org.jboss.arquillian.junit.Arquillian; | ||
47 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
48 | +import org.junit.Test; | ||
49 | +import org.junit.runner.RunWith; | ||
50 | + | ||
51 | +import test.Tests; | ||
52 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
53 | + | ||
54 | +@RunWith(Arquillian.class) | ||
55 | +public class ResourceBundleEmptyTest { | ||
56 | + | ||
57 | + private ResourceBundleEmpty bundleDefault; | ||
58 | + | ||
59 | + private static final String PATH = "src/test/resources/resourcebundle/file/empty/"; | ||
60 | + | ||
61 | + @Deployment | ||
62 | + public static JavaArchive createDeployment() { | ||
63 | + JavaArchive deployment = Tests.createDeployment(ResourceBundleEmptyTest.class); | ||
64 | + deployment.addAsResource(Tests.createFileAsset(PATH + "messages.properties"), "messages.properties"); | ||
65 | + | ||
66 | + return deployment; | ||
67 | + } | ||
68 | + | ||
69 | + @Test | ||
70 | + public void testResourceEmpty() { | ||
71 | + bundleDefault = Beans.getReference(ResourceBundleEmpty.class); | ||
72 | + try { | ||
73 | + bundleDefault.getMessage(); | ||
74 | + fail(); | ||
75 | + } catch (Exception e) { | ||
76 | + Assert.assertEquals(MissingResourceException.class, e.getClass()); | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | +} |
impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExist.java
0 → 100644
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
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 resourcebundle.file.notexist; | ||
38 | + | ||
39 | +import javax.inject.Inject; | ||
40 | + | ||
41 | +import br.gov.frameworkdemoiselle.annotation.Name; | ||
42 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
43 | + | ||
44 | +public class ResourceBundleFileNotExist { | ||
45 | + | ||
46 | + @Inject | ||
47 | + @Name("mymessages") | ||
48 | + private ResourceBundle bundle; | ||
49 | + | ||
50 | + public ResourceBundle getBundle() { | ||
51 | + return bundle; | ||
52 | + } | ||
53 | + | ||
54 | + public String getMessage() { | ||
55 | + return bundle.getString("message"); | ||
56 | + } | ||
57 | +} |
impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java
0 → 100644
@@ -0,0 +1,76 @@ | @@ -0,0 +1,76 @@ | ||
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 resourcebundle.file.notexist; | ||
38 | + | ||
39 | +import static junit.framework.Assert.fail; | ||
40 | + | ||
41 | +import java.util.MissingResourceException; | ||
42 | + | ||
43 | +import junit.framework.Assert; | ||
44 | + | ||
45 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
46 | +import org.jboss.arquillian.junit.Arquillian; | ||
47 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
48 | +import org.junit.Test; | ||
49 | +import org.junit.runner.RunWith; | ||
50 | + | ||
51 | +import test.Tests; | ||
52 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
53 | + | ||
54 | +@RunWith(Arquillian.class) | ||
55 | +public class ResourceBundleFileNotExistTest { | ||
56 | + | ||
57 | + private ResourceBundleFileNotExist bundleFileNotExist; | ||
58 | + | ||
59 | + @Deployment | ||
60 | + public static JavaArchive createDeployment() { | ||
61 | + JavaArchive deployment = Tests.createDeployment(ResourceBundleFileNotExistTest.class); | ||
62 | + | ||
63 | + return deployment; | ||
64 | + } | ||
65 | + | ||
66 | + @Test | ||
67 | + public void testResourceFileCustom() { | ||
68 | + bundleFileNotExist = Beans.getReference(ResourceBundleFileNotExist.class); | ||
69 | + try { | ||
70 | + bundleFileNotExist.getMessage(); | ||
71 | + fail(); | ||
72 | + } catch (Exception e) { | ||
73 | + Assert.assertEquals(MissingResourceException.class, e.getCause().getClass()); | ||
74 | + } | ||
75 | + } | ||
76 | +} |
impl/core/src/test/resources/resourcebundle/file/custom/mymessages.properties
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
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 | +message = mensagem em Portugues | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |
impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
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 | +message = message in English | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |
impl/core/src/test/resources/resourcebundle/file/default/messages.properties
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
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 | +message = mensagem em Portugues | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |
impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
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 | +message = message in English | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |
impl/core/src/test/resources/resourcebundle/file/empty/messages.properties
0 → 100644
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
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. |