Commit d0c8450c44906696d4a6fbda79f4ae79af0582d3
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
32 changed files
with
1755 additions
and
90 deletions
Show diff stats
impl/core/src/test/java/exception/CustomException.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import br.gov.frameworkdemoiselle.exception.ApplicationException; |
4 | 40 | |
5 | - | |
6 | 41 | @ApplicationException |
7 | 42 | public class CustomException extends RuntimeException { |
8 | 43 | |
9 | 44 | private static final long serialVersionUID = 1L; |
10 | 45 | |
11 | -} | |
12 | 46 | \ No newline at end of file |
47 | +} | ... | ... |
impl/core/src/test/java/exception/CustomExceptionHandler.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | ... | ... |
impl/core/src/test/java/exception/CustomExceptionTest.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import static junit.framework.Assert.assertEquals; |
... | ... | @@ -14,16 +50,16 @@ import test.Tests; |
14 | 50 | |
15 | 51 | @RunWith(Arquillian.class) |
16 | 52 | public class CustomExceptionTest { |
17 | - | |
53 | + | |
18 | 54 | @Inject |
19 | 55 | private CustomExceptionHandler exception; |
20 | - | |
56 | + | |
21 | 57 | @Deployment |
22 | 58 | public static JavaArchive createDeployment() { |
23 | 59 | JavaArchive deployment = Tests.createDeployment(CustomExceptionTest.class); |
24 | 60 | return deployment; |
25 | 61 | } |
26 | - | |
62 | + | |
27 | 63 | @Test |
28 | 64 | public void testCustomExceptionHandler() { |
29 | 65 | exception.throwExceptionWithMessage(); | ... | ... |
impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java
0 → 100644
... | ... | @@ -0,0 +1,54 @@ |
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 exception; | |
38 | + | |
39 | +import java.awt.geom.IllegalPathStateException; | |
40 | + | |
41 | +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | |
42 | +import br.gov.frameworkdemoiselle.stereotype.Controller; | |
43 | + | |
44 | +@Controller | |
45 | +public class ExceptionHandlerTwoParameter { | |
46 | + | |
47 | + public void throwIllegalPathException() { | |
48 | + throw new IllegalPathStateException(); | |
49 | + } | |
50 | + | |
51 | + @ExceptionHandler | |
52 | + public void handler(IllegalPathStateException cause, IllegalStateException cause2) { | |
53 | + } | |
54 | +} | ... | ... |
impl/core/src/test/java/exception/ExceptionInheritance.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import br.gov.frameworkdemoiselle.exception.ExceptionHandler; |
... | ... | @@ -7,13 +43,13 @@ import br.gov.frameworkdemoiselle.stereotype.Controller; |
7 | 43 | public class ExceptionInheritance { |
8 | 44 | |
9 | 45 | private boolean handlerSuperClass = false; |
10 | - | |
46 | + | |
11 | 47 | private boolean handlerClass = false; |
12 | - | |
48 | + | |
13 | 49 | public boolean isHandlerSuperClass() { |
14 | 50 | return handlerSuperClass; |
15 | 51 | } |
16 | - | |
52 | + | |
17 | 53 | public boolean isHandlerClass() { |
18 | 54 | return handlerClass; |
19 | 55 | } |
... | ... | @@ -21,7 +57,7 @@ public class ExceptionInheritance { |
21 | 57 | public void throwNullPointerException() { |
22 | 58 | throw new NullPointerException(); |
23 | 59 | } |
24 | - | |
60 | + | |
25 | 61 | public void throwArithmeticException() { |
26 | 62 | throw new ArithmeticException(); |
27 | 63 | } |
... | ... | @@ -30,10 +66,10 @@ public class ExceptionInheritance { |
30 | 66 | public void handle(ArithmeticException e) { |
31 | 67 | handlerClass = true; |
32 | 68 | } |
33 | - | |
69 | + | |
34 | 70 | @ExceptionHandler |
35 | 71 | public void handle(RuntimeException e) { |
36 | 72 | handlerSuperClass = true; |
37 | 73 | } |
38 | - | |
74 | + | |
39 | 75 | } | ... | ... |
impl/core/src/test/java/exception/ExceptionInheritanceTest.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import static junit.framework.Assert.assertEquals; |
... | ... | @@ -14,16 +50,16 @@ import test.Tests; |
14 | 50 | |
15 | 51 | @RunWith(Arquillian.class) |
16 | 52 | public class ExceptionInheritanceTest { |
17 | - | |
53 | + | |
18 | 54 | @Inject |
19 | 55 | private ExceptionInheritance exceptionInheritance; |
20 | - | |
56 | + | |
21 | 57 | @Deployment |
22 | 58 | public static JavaArchive createDeployment() { |
23 | 59 | JavaArchive deployment = Tests.createDeployment(ExceptionInheritanceTest.class); |
24 | 60 | return deployment; |
25 | 61 | } |
26 | - | |
62 | + | |
27 | 63 | @Test |
28 | 64 | public void testExceptionInheritanceSuperClass() { |
29 | 65 | exceptionInheritance.throwNullPointerException(); |
... | ... | @@ -35,5 +71,5 @@ public class ExceptionInheritanceTest { |
35 | 71 | exceptionInheritance.throwArithmeticException(); |
36 | 72 | assertEquals(false, exceptionInheritance.isHandlerSuperClass()); |
37 | 73 | assertEquals(true, exceptionInheritance.isHandlerClass()); |
38 | - } | |
74 | + } | |
39 | 75 | } | ... | ... |
impl/core/src/test/java/exception/MultiException.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | -import java.awt.geom.IllegalPathStateException; | |
4 | - | |
5 | 39 | import br.gov.frameworkdemoiselle.exception.ExceptionHandler; |
6 | 40 | import br.gov.frameworkdemoiselle.stereotype.Controller; |
7 | 41 | ... | ... |
impl/core/src/test/java/exception/MultiExceptionOneHandler.java
... | ... | @@ -1,18 +0,0 @@ |
1 | -package exception; | |
2 | - | |
3 | -import java.awt.geom.IllegalPathStateException; | |
4 | - | |
5 | -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | |
6 | -import br.gov.frameworkdemoiselle.stereotype.Controller; | |
7 | - | |
8 | -@Controller | |
9 | -public class MultiExceptionOneHandler { | |
10 | - | |
11 | - public void throwIllegalPathException() { | |
12 | - throw new IllegalPathStateException(); | |
13 | - } | |
14 | - | |
15 | - @ExceptionHandler | |
16 | - public void handler(IllegalPathStateException cause, IllegalStateException cause2) { | |
17 | - } | |
18 | -} |
impl/core/src/test/java/exception/MultiExceptionTest.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import javax.inject.Inject; |
... | ... | @@ -20,9 +56,9 @@ public class MultiExceptionTest { |
20 | 56 | |
21 | 57 | @Inject |
22 | 58 | private MultiException multiException; |
23 | - | |
59 | + | |
24 | 60 | @Inject |
25 | - private MultiExceptionOneHandler multiExceptionOneHandler; | |
61 | + private ExceptionHandlerTwoParameter exceptionTwoParameter; | |
26 | 62 | |
27 | 63 | @Deployment |
28 | 64 | public static JavaArchive createDeployment() { |
... | ... | @@ -31,28 +67,24 @@ public class MultiExceptionTest { |
31 | 67 | } |
32 | 68 | |
33 | 69 | @Test |
34 | - public void testNullPointerExceptionHandler() { | |
35 | - multiException.throwNullPointerException(); | |
36 | - assertEquals(true, multiException.isNullPointerExceptionHandler()); | |
37 | - } | |
38 | - | |
39 | - @Test | |
40 | - public void testArithmeticExceptionHandler() { | |
70 | + public void testTwoExceptionTwoMethod() { | |
41 | 71 | multiException.throwArithmeticException(); |
72 | + multiException.throwNullPointerException(); | |
73 | + assertEquals(true, multiException.isArithmeticExceptionHandler()); | |
42 | 74 | assertEquals(true, multiException.isArithmeticExceptionHandler()); |
43 | 75 | } |
44 | - | |
76 | + | |
45 | 77 | @Test |
46 | - public void testMultiExceptionHandler() { | |
78 | + public void testTwoExceptionOneMethod() { | |
47 | 79 | multiException.throwTwoException(); |
48 | 80 | assertEquals(true, multiException.isNullPointerExceptionHandler()); |
49 | - assertEquals(true, multiException.isArithmeticExceptionHandler()); | |
81 | + assertEquals(false, multiException.isArithmeticExceptionHandler()); | |
50 | 82 | } |
51 | - | |
83 | + | |
52 | 84 | @Test |
53 | - public void testExceptionHandlerWithTwoException() { | |
85 | + public void testExceptionHandlerWithTwoParameter() { | |
54 | 86 | try { |
55 | - multiExceptionOneHandler.throwIllegalPathException(); | |
87 | + exceptionTwoParameter.throwIllegalPathException(); | |
56 | 88 | fail(); |
57 | 89 | } catch (Exception e) { |
58 | 90 | assertEquals(DemoiselleException.class, e.getClass()); | ... | ... |
impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import br.gov.frameworkdemoiselle.exception.ExceptionHandler; |
... | ... | @@ -29,17 +65,7 @@ public class MultiStrategyExceptionHandler { |
29 | 65 | } |
30 | 66 | txt.toString(); |
31 | 67 | } |
32 | - | |
33 | - @SuppressWarnings("unused") | |
34 | - public void exceptionMultiStrategyHandlerInTry() { | |
35 | - try { | |
36 | - txt.toString(); | |
37 | - int result = 4 / 0; | |
38 | - } catch (ArithmeticException e) { | |
39 | - exceptionTryCacth = true; | |
40 | - } | |
41 | - } | |
42 | - | |
68 | + | |
43 | 69 | @SuppressWarnings("unused") |
44 | 70 | public void exceptionMultiStrategyHandlerAndTry() { |
45 | 71 | txt.toString(); |
... | ... | @@ -48,7 +74,7 @@ public class MultiStrategyExceptionHandler { |
48 | 74 | } catch (ArithmeticException e) { |
49 | 75 | exceptionTryCacth = true; |
50 | 76 | } |
51 | - } | |
77 | + } | |
52 | 78 | |
53 | 79 | public void exceptionTwoHandler() { |
54 | 80 | try { | ... | ... |
impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import static junit.framework.Assert.assertEquals; |
... | ... | @@ -30,32 +66,25 @@ public class MultiStrategyExceptionHandlerTest { |
30 | 66 | assertEquals(true, handlerTest.isExceptionTryCacth()); |
31 | 67 | assertEquals(true, handlerTest.isExceptionHandler()); |
32 | 68 | } |
33 | - | |
34 | - @Test | |
35 | - public void testExceptionMultiStrategyHandlerInTry() { | |
36 | - handlerTest.exceptionMultiStrategyHandlerInTry(); | |
37 | - assertEquals(true, handlerTest.isExceptionTryCacth()); | |
38 | - assertEquals(true, handlerTest.isExceptionHandler()); | |
39 | - } | |
40 | - | |
69 | + | |
41 | 70 | @Test |
42 | 71 | public void testExceptionMultiStrategyHandlerAndTry() { |
43 | 72 | handlerTest.exceptionMultiStrategyHandlerAndTry(); |
44 | - assertEquals(true, handlerTest.isExceptionTryCacth()); | |
73 | + assertEquals(false, handlerTest.isExceptionTryCacth()); | |
45 | 74 | assertEquals(true, handlerTest.isExceptionHandler()); |
46 | - } | |
47 | - | |
75 | + } | |
76 | + | |
48 | 77 | @Test |
49 | 78 | public void testSameExceptionTwoStrategyHandler() { |
50 | 79 | handlerTest.exceptionTwoHandler(); |
51 | 80 | assertEquals(true, handlerTest.isExceptionTryCacth()); |
52 | 81 | assertEquals(false, handlerTest.isExceptionHandler()); |
53 | 82 | } |
54 | - | |
83 | + | |
55 | 84 | @Test |
56 | 85 | public void testExceptionOneStrategyHandler() { |
57 | 86 | handlerTest.exceptionHandler(); |
58 | 87 | assertEquals(false, handlerTest.isExceptionTryCacth()); |
59 | 88 | assertEquals(true, handlerTest.isExceptionHandler()); |
60 | - } | |
89 | + } | |
61 | 90 | } | ... | ... |
impl/core/src/test/java/exception/OneException.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
39 | +import java.util.NoSuchElementException; | |
40 | + | |
3 | 41 | import br.gov.frameworkdemoiselle.exception.ExceptionHandler; |
4 | 42 | import br.gov.frameworkdemoiselle.stereotype.Controller; |
5 | 43 | |
6 | 44 | @Controller |
7 | 45 | public class OneException { |
8 | - | |
46 | + | |
9 | 47 | private boolean exceptionHandler = false; |
10 | - | |
48 | + | |
11 | 49 | private boolean exceptionHandlerIllegalArgument1 = false; |
12 | 50 | |
13 | 51 | private boolean exceptionHandlerIllegalArgument2 = false; |
14 | 52 | |
15 | - private boolean exceptionHandlerIllegalArgument3 = false; | |
53 | + private boolean exceptionHandlerIllegalArgument3 = false; | |
16 | 54 | |
17 | 55 | public boolean isExceptionHandler() { |
18 | 56 | return exceptionHandler; |
19 | 57 | } |
20 | - | |
58 | + | |
21 | 59 | public boolean isExceptionHandlerIllegalArgument1() { |
22 | 60 | return exceptionHandlerIllegalArgument1; |
23 | 61 | } |
... | ... | @@ -28,8 +66,8 @@ public class OneException { |
28 | 66 | |
29 | 67 | public boolean isExceptionHandlerIllegalArgument3() { |
30 | 68 | return exceptionHandlerIllegalArgument3; |
31 | - } | |
32 | - | |
69 | + } | |
70 | + | |
33 | 71 | @SuppressWarnings("null") |
34 | 72 | public void throwExceptionWithHandler() { |
35 | 73 | String txt = null; |
... | ... | @@ -38,31 +76,40 @@ public class OneException { |
38 | 76 | |
39 | 77 | @SuppressWarnings("unused") |
40 | 78 | public void throwExceptionWithoutHandler() { |
41 | - int result = 4/0; | |
79 | + int result = 4 / 0; | |
42 | 80 | } |
43 | - | |
44 | - public void throwExceptionIllegalArgument() { | |
81 | + | |
82 | + public void throwIllegalArgumentException() { | |
45 | 83 | throw new IllegalArgumentException(); |
46 | 84 | } |
47 | 85 | |
86 | + public void throwNoSuchElementException() { | |
87 | + throw new NoSuchElementException(); | |
88 | + } | |
89 | + | |
48 | 90 | @ExceptionHandler |
49 | 91 | public void handler(NullPointerException cause) { |
50 | 92 | exceptionHandler = true; |
51 | 93 | } |
52 | 94 | |
53 | - | |
54 | 95 | @ExceptionHandler |
55 | 96 | public void handler1(IllegalArgumentException cause) { |
56 | 97 | exceptionHandlerIllegalArgument1 = true; |
57 | 98 | } |
58 | - | |
99 | + | |
59 | 100 | @ExceptionHandler |
60 | 101 | public void handler3(IllegalArgumentException cause) { |
61 | 102 | exceptionHandlerIllegalArgument3 = true; |
62 | 103 | } |
63 | - | |
104 | + | |
64 | 105 | @ExceptionHandler |
65 | 106 | public void handler2(IllegalArgumentException cause) { |
66 | 107 | exceptionHandlerIllegalArgument2 = true; |
67 | 108 | } |
109 | + | |
110 | + @ExceptionHandler | |
111 | + @SuppressWarnings("unused") | |
112 | + public void handlerWithError(NoSuchElementException cause) { | |
113 | + int a = 2 / 0; | |
114 | + } | |
68 | 115 | } | ... | ... |
impl/core/src/test/java/exception/OneExceptionTest.java
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 | + */ | |
1 | 37 | package exception; |
2 | 38 | |
3 | 39 | import javax.inject.Inject; |
... | ... | @@ -40,12 +76,22 @@ public class OneExceptionTest { |
40 | 76 | assertEquals(ArithmeticException.class, cause.getClass()); |
41 | 77 | } |
42 | 78 | } |
43 | - | |
79 | + | |
44 | 80 | @Test |
45 | 81 | public void testExceptionWithMultiHandler() { |
46 | - oneException.throwExceptionIllegalArgument(); | |
82 | + oneException.throwIllegalArgumentException(); | |
47 | 83 | assertEquals(false, oneException.isExceptionHandlerIllegalArgument1()); |
48 | 84 | assertEquals(true, oneException.isExceptionHandlerIllegalArgument2()); |
49 | 85 | assertEquals(false, oneException.isExceptionHandlerIllegalArgument3()); |
50 | - } | |
86 | + } | |
87 | + | |
88 | + @Test | |
89 | + public void testExceptionHandlerWithException() { | |
90 | + try { | |
91 | + oneException.throwNoSuchElementException(); | |
92 | + } catch (Exception e) { | |
93 | + assertEquals(ArithmeticException.class, e.getClass()); | |
94 | + } | |
95 | + | |
96 | + } | |
51 | 97 | } | ... | ... |
impl/core/src/test/java/lifecycle/LifecycleClassWithPriority.java
0 → 100644
... | ... | @@ -0,0 +1,89 @@ |
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 lifecycle; | |
38 | + | |
39 | +import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY; | |
40 | +import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY; | |
41 | + | |
42 | +import java.util.ArrayList; | |
43 | +import java.util.List; | |
44 | + | |
45 | +import javax.enterprise.context.ApplicationScoped; | |
46 | + | |
47 | +import br.gov.frameworkdemoiselle.annotation.Priority; | |
48 | +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | |
49 | +import br.gov.frameworkdemoiselle.lifecycle.Startup; | |
50 | + | |
51 | +@ApplicationScoped | |
52 | +public class LifecycleClassWithPriority { | |
53 | + | |
54 | + private List<Integer> priorityStartup = new ArrayList<Integer>(); | |
55 | + | |
56 | + private List<Integer> priorityShutdown = new ArrayList<Integer>(); | |
57 | + | |
58 | + public List<Integer> getPriorityStartup() { | |
59 | + return priorityStartup; | |
60 | + } | |
61 | + | |
62 | + public List<Integer> getPriorityShutdown() { | |
63 | + return priorityShutdown; | |
64 | + } | |
65 | + | |
66 | + @Startup | |
67 | + @Priority(MIN_PRIORITY) | |
68 | + public void loadWithMinPriority() { | |
69 | + priorityStartup.add(2); | |
70 | + } | |
71 | + | |
72 | + @Startup | |
73 | + @Priority(MAX_PRIORITY) | |
74 | + public void loadWithMaxPriority() { | |
75 | + priorityStartup.add(1); | |
76 | + } | |
77 | + | |
78 | + @Shutdown | |
79 | + @Priority(MIN_PRIORITY) | |
80 | + public void unloadWithMinPriority() { | |
81 | + priorityShutdown.add(1); | |
82 | + } | |
83 | + | |
84 | + @Shutdown | |
85 | + @Priority(MAX_PRIORITY) | |
86 | + public void unloadWithMaxPriority() { | |
87 | + priorityShutdown.add(2); | |
88 | + } | |
89 | +} | ... | ... |
... | ... | @@ -0,0 +1,68 @@ |
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 lifecycle; | |
38 | + | |
39 | +import javax.enterprise.context.ApplicationScoped; | |
40 | + | |
41 | +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | |
42 | +import br.gov.frameworkdemoiselle.lifecycle.Startup; | |
43 | + | |
44 | +@ApplicationScoped | |
45 | +public class LifecycleSimple { | |
46 | + | |
47 | + private boolean startup = false; | |
48 | + | |
49 | + private boolean shutdown = false; | |
50 | + | |
51 | + public boolean isStartup() { | |
52 | + return startup; | |
53 | + } | |
54 | + | |
55 | + public boolean isShutdown() { | |
56 | + return shutdown; | |
57 | + } | |
58 | + | |
59 | + @Startup | |
60 | + public void load() { | |
61 | + startup = true; | |
62 | + } | |
63 | + | |
64 | + @Shutdown | |
65 | + public void unload() { | |
66 | + shutdown = true; | |
67 | + } | |
68 | +} | ... | ... |
impl/core/src/test/java/lifecycle/LifecycleSimpleTest.java
0 → 100644
... | ... | @@ -0,0 +1,83 @@ |
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 lifecycle; | |
38 | + | |
39 | +import javax.inject.Inject; | |
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.lifecycle.AfterShutdownProccess; | |
51 | +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | |
52 | +import br.gov.frameworkdemoiselle.util.Beans; | |
53 | + | |
54 | +@RunWith(Arquillian.class) | |
55 | +public class LifecycleSimpleTest { | |
56 | + | |
57 | + @Inject | |
58 | + private LifecycleSimple simpleClass; | |
59 | + | |
60 | + @Deployment | |
61 | + public static JavaArchive createDeployment() { | |
62 | + JavaArchive deployment = Tests.createDeployment(LifecycleSimpleTest.class); | |
63 | + return deployment; | |
64 | + } | |
65 | + | |
66 | + @Test | |
67 | + public void testStartup() { | |
68 | + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | |
69 | + }); | |
70 | + | |
71 | + Assert.assertEquals(true, simpleClass.isStartup()); | |
72 | + } | |
73 | + | |
74 | + @Test | |
75 | + public void testShutdown() { | |
76 | + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { | |
77 | + }); | |
78 | + | |
79 | + Assert.assertEquals(true, simpleClass.isShutdown()); | |
80 | + } | |
81 | + | |
82 | +} | |
83 | + | ... | ... |
impl/core/src/test/java/lifecycle/LifecycleWithPriorityTest.java
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
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 lifecycle; | |
38 | + | |
39 | +import java.util.ArrayList; | |
40 | +import java.util.List; | |
41 | + | |
42 | +import javax.inject.Inject; | |
43 | + | |
44 | +import junit.framework.Assert; | |
45 | + | |
46 | +import org.jboss.arquillian.container.test.api.Deployment; | |
47 | +import org.jboss.arquillian.junit.Arquillian; | |
48 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
49 | +import org.junit.Test; | |
50 | +import org.junit.runner.RunWith; | |
51 | + | |
52 | +import test.Tests; | |
53 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
54 | +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | |
55 | +import br.gov.frameworkdemoiselle.util.Beans; | |
56 | + | |
57 | +@RunWith(Arquillian.class) | |
58 | +public class LifecycleWithPriorityTest { | |
59 | + | |
60 | + @Inject | |
61 | + private LifecycleClassWithPriority lifecycleClassWithPriority; | |
62 | + | |
63 | + List<Integer> expected = new ArrayList<Integer>(); | |
64 | + | |
65 | + @Deployment | |
66 | + public static JavaArchive createDeployment() { | |
67 | + JavaArchive deployment = Tests.createDeployment(LifecycleWithPriorityTest.class); | |
68 | + return deployment; | |
69 | + } | |
70 | + | |
71 | + @Test | |
72 | + public void testStartup() { | |
73 | + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | |
74 | + }); | |
75 | + expected.add(1); | |
76 | + expected.add(2); | |
77 | + | |
78 | + Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityStartup()); | |
79 | + } | |
80 | + | |
81 | + @Test | |
82 | + public void testShutdown() { | |
83 | + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { | |
84 | + }); | |
85 | + expected.clear(); | |
86 | + expected.add(2); | |
87 | + expected.add(1); | |
88 | + | |
89 | + Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityShutdown()); | |
90 | + } | |
91 | +} | ... | ... |
impl/core/src/test/java/lifecycle/LifecycleWithoutPriority.java
0 → 100644
... | ... | @@ -0,0 +1,92 @@ |
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 lifecycle; | |
38 | + | |
39 | +import java.util.ArrayList; | |
40 | +import java.util.List; | |
41 | + | |
42 | +import javax.enterprise.context.ApplicationScoped; | |
43 | + | |
44 | +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; | |
45 | +import br.gov.frameworkdemoiselle.lifecycle.Startup; | |
46 | + | |
47 | +@ApplicationScoped | |
48 | +public class LifecycleWithoutPriority { | |
49 | + | |
50 | + private List<Integer> priorityStartup = new ArrayList<Integer>(); | |
51 | + | |
52 | + private List<Integer> priorityShutdown = new ArrayList<Integer>(); | |
53 | + | |
54 | + public List<Integer> getPriorityStartup() { | |
55 | + return priorityStartup; | |
56 | + } | |
57 | + | |
58 | + public List<Integer> getPriorityShutdown() { | |
59 | + return priorityShutdown; | |
60 | + } | |
61 | + | |
62 | + @Startup | |
63 | + public void loadWithoutPriorityFirst() { | |
64 | + priorityStartup.add(1); | |
65 | + } | |
66 | + | |
67 | + @Startup | |
68 | + public void loadWithoutPrioritySecond() { | |
69 | + priorityStartup.add(3); | |
70 | + } | |
71 | + | |
72 | + @Startup | |
73 | + public void loadWithoutPriorityThird() { | |
74 | + priorityStartup.add(2); | |
75 | + } | |
76 | + | |
77 | + @Shutdown | |
78 | + public void unloadWithoutPriorityFirst() { | |
79 | + priorityShutdown.add(3); | |
80 | + } | |
81 | + | |
82 | + @Shutdown | |
83 | + public void unloadWithoutPrioritySecond() { | |
84 | + priorityShutdown.add(2); | |
85 | + } | |
86 | + | |
87 | + @Shutdown | |
88 | + public void unloadWithoutPriorityThird() { | |
89 | + priorityShutdown.add(1); | |
90 | + } | |
91 | + | |
92 | +} | ... | ... |
impl/core/src/test/java/lifecycle/LifecycleWithoutPriorityTest.java
0 → 100644
... | ... | @@ -0,0 +1,94 @@ |
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 lifecycle; | |
38 | + | |
39 | +import java.util.ArrayList; | |
40 | +import java.util.List; | |
41 | + | |
42 | +import javax.inject.Inject; | |
43 | + | |
44 | +import junit.framework.Assert; | |
45 | + | |
46 | +import org.jboss.arquillian.container.test.api.Deployment; | |
47 | +import org.jboss.arquillian.junit.Arquillian; | |
48 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
49 | +import org.junit.Test; | |
50 | +import org.junit.runner.RunWith; | |
51 | + | |
52 | +import test.Tests; | |
53 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
54 | +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | |
55 | +import br.gov.frameworkdemoiselle.util.Beans; | |
56 | + | |
57 | +@RunWith(Arquillian.class) | |
58 | +public class LifecycleWithoutPriorityTest { | |
59 | + | |
60 | + @Inject | |
61 | + private LifecycleWithoutPriority lifecycleWithoutPriority; | |
62 | + | |
63 | + List<Integer> expected = new ArrayList<Integer>(); | |
64 | + | |
65 | + @Deployment | |
66 | + public static JavaArchive createDeployment() { | |
67 | + JavaArchive deployment = Tests.createDeployment(LifecycleWithoutPriorityTest.class); | |
68 | + return deployment; | |
69 | + } | |
70 | + | |
71 | + @Test | |
72 | + public void testStartup() { | |
73 | + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | |
74 | + }); | |
75 | + expected.add(1); | |
76 | + expected.add(3); | |
77 | + expected.add(2); | |
78 | + | |
79 | + Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityStartup()); | |
80 | + } | |
81 | + | |
82 | + @Test | |
83 | + public void testShutdown() { | |
84 | + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { | |
85 | + }); | |
86 | + expected.clear(); | |
87 | + expected.add(3); | |
88 | + expected.add(2); | |
89 | + expected.add(1); | |
90 | + | |
91 | + Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityShutdown()); | |
92 | + } | |
93 | + | |
94 | +} | ... | ... |
impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustom.java
0 → 100644
... | ... | @@ -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 @@ |
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 @@ |
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 @@ |
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 @@ |
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 @@ |
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 @@ |
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 @@ |
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 @@ |
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 | 37 | \ No newline at end of file | ... | ... |
impl/core/src/test/resources/resourcebundle/file/custom/mymessages_en.properties
0 → 100644
... | ... | @@ -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 | 37 | \ No newline at end of file | ... | ... |
impl/core/src/test/resources/resourcebundle/file/default/messages.properties
0 → 100644
... | ... | @@ -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 | 37 | \ No newline at end of file | ... | ... |
impl/core/src/test/resources/resourcebundle/file/default/messages_en.properties
0 → 100644
... | ... | @@ -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 | 37 | \ No newline at end of file | ... | ... |
impl/core/src/test/resources/resourcebundle/file/empty/messages.properties
0 → 100644
... | ... | @@ -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. | ... | ... |