Commit 76c84182904f85a9bf8a5b46e5575218435c2cde

Authored by Ednara Oliveira
1 parent 7c6c4e7f
Exists in master

Pacotes para os testes de Exception

Showing 23 changed files with 865 additions and 953 deletions   Show diff stats
impl/core/src/test/java/exception/CustomException.java
... ... @@ -1,46 +0,0 @@
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 br.gov.frameworkdemoiselle.exception.ApplicationException;
40   -
41   -@ApplicationException
42   -public class CustomException extends RuntimeException {
43   -
44   - private static final long serialVersionUID = 1L;
45   -
46   -}
impl/core/src/test/java/exception/CustomExceptionHandler.java
... ... @@ -1,63 +0,0 @@
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 br.gov.frameworkdemoiselle.exception.ExceptionHandler;
40   -import br.gov.frameworkdemoiselle.stereotype.Controller;
41   -
42   -@Controller
43   -public class CustomExceptionHandler {
44   -
45   - private boolean exceptionHandler = false;
46   -
47   - public boolean isExceptionHandler() {
48   - return exceptionHandler;
49   - }
50   -
51   - public void setExceptionHandler(boolean exceptionHandler) {
52   - this.exceptionHandler = exceptionHandler;
53   - }
54   -
55   - public void throwExceptionWithMessage() {
56   - throw new CustomException();
57   - }
58   -
59   - @ExceptionHandler
60   - public void handler(CustomException exception) {
61   - setExceptionHandler(true);
62   - }
63   -}
impl/core/src/test/java/exception/CustomExceptionTest.java
... ... @@ -1,68 +0,0 @@
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 static junit.framework.Assert.assertEquals;
40   -
41   -import javax.inject.Inject;
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   -
51   -@RunWith(Arquillian.class)
52   -public class CustomExceptionTest {
53   -
54   - @Inject
55   - private CustomExceptionHandler exception;
56   -
57   - @Deployment
58   - public static JavaArchive createDeployment() {
59   - JavaArchive deployment = Tests.createDeployment(CustomExceptionTest.class);
60   - return deployment;
61   - }
62   -
63   - @Test
64   - public void testCustomExceptionHandler() {
65   - exception.throwExceptionWithMessage();
66   - assertEquals(true, exception.isExceptionHandler());
67   - }
68   -}
impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java
... ... @@ -1,54 +0,0 @@
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,75 +0,0 @@
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 br.gov.frameworkdemoiselle.exception.ExceptionHandler;
40   -import br.gov.frameworkdemoiselle.stereotype.Controller;
41   -
42   -@Controller
43   -public class ExceptionInheritance {
44   -
45   - private boolean handlerSuperClass = false;
46   -
47   - private boolean handlerClass = false;
48   -
49   - public boolean isHandlerSuperClass() {
50   - return handlerSuperClass;
51   - }
52   -
53   - public boolean isHandlerClass() {
54   - return handlerClass;
55   - }
56   -
57   - public void throwNullPointerException() {
58   - throw new NullPointerException();
59   - }
60   -
61   - public void throwArithmeticException() {
62   - throw new ArithmeticException();
63   - }
64   -
65   - @ExceptionHandler
66   - public void handle(ArithmeticException e) {
67   - handlerClass = true;
68   - }
69   -
70   - @ExceptionHandler
71   - public void handle(RuntimeException e) {
72   - handlerSuperClass = true;
73   - }
74   -
75   -}
impl/core/src/test/java/exception/ExceptionInheritanceTest.java
... ... @@ -1,75 +0,0 @@
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 static junit.framework.Assert.assertEquals;
40   -
41   -import javax.inject.Inject;
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   -
51   -@RunWith(Arquillian.class)
52   -public class ExceptionInheritanceTest {
53   -
54   - @Inject
55   - private ExceptionInheritance exceptionInheritance;
56   -
57   - @Deployment
58   - public static JavaArchive createDeployment() {
59   - JavaArchive deployment = Tests.createDeployment(ExceptionInheritanceTest.class);
60   - return deployment;
61   - }
62   -
63   - @Test
64   - public void testExceptionInheritanceSuperClass() {
65   - exceptionInheritance.throwNullPointerException();
66   - assertEquals(true, exceptionInheritance.isHandlerSuperClass());
67   - }
68   -
69   - @Test
70   - public void testExceptionInheritanceClass() {
71   - exceptionInheritance.throwArithmeticException();
72   - assertEquals(false, exceptionInheritance.isHandlerSuperClass());
73   - assertEquals(true, exceptionInheritance.isHandlerClass());
74   - }
75   -}
impl/core/src/test/java/exception/MultiException.java
... ... @@ -1,81 +0,0 @@
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 br.gov.frameworkdemoiselle.exception.ExceptionHandler;
40   -import br.gov.frameworkdemoiselle.stereotype.Controller;
41   -
42   -@Controller
43   -public class MultiException {
44   -
45   - private boolean nullPointerExceptionHandler = false;
46   -
47   - private boolean arithmeticExceptionHandler = false;
48   -
49   - public boolean isNullPointerExceptionHandler() {
50   - return nullPointerExceptionHandler;
51   - }
52   -
53   - public boolean isArithmeticExceptionHandler() {
54   - return arithmeticExceptionHandler;
55   - }
56   -
57   - public void throwNullPointerException() {
58   - throw new NullPointerException();
59   - }
60   -
61   - public void throwArithmeticException() {
62   - throw new ArithmeticException();
63   - }
64   -
65   - @SuppressWarnings({ "null", "unused" })
66   - public void throwTwoException() {
67   - String txt = null;
68   - txt.toString();
69   - int result = 4 / 0;
70   - }
71   -
72   - @ExceptionHandler
73   - public void handler(NullPointerException cause) {
74   - nullPointerExceptionHandler = true;
75   - }
76   -
77   - @ExceptionHandler
78   - public void handler(ArithmeticException cause) {
79   - arithmeticExceptionHandler = true;
80   - }
81   -}
impl/core/src/test/java/exception/MultiExceptionTest.java
... ... @@ -1,93 +0,0 @@
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 javax.inject.Inject;
40   -
41   -import static junit.framework.Assert.fail;
42   -import static junit.framework.Assert.assertEquals;
43   -
44   -import org.jboss.arquillian.container.test.api.Deployment;
45   -import org.jboss.arquillian.junit.Arquillian;
46   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
47   -import org.junit.Test;
48   -import org.junit.runner.RunWith;
49   -
50   -import br.gov.frameworkdemoiselle.DemoiselleException;
51   -
52   -import test.Tests;
53   -
54   -@RunWith(Arquillian.class)
55   -public class MultiExceptionTest {
56   -
57   - @Inject
58   - private MultiException multiException;
59   -
60   - @Inject
61   - private ExceptionHandlerTwoParameter exceptionTwoParameter;
62   -
63   - @Deployment
64   - public static JavaArchive createDeployment() {
65   - JavaArchive deployment = Tests.createDeployment(MultiExceptionTest.class);
66   - return deployment;
67   - }
68   -
69   - @Test
70   - public void testTwoExceptionTwoMethod() {
71   - multiException.throwArithmeticException();
72   - multiException.throwNullPointerException();
73   - assertEquals(true, multiException.isArithmeticExceptionHandler());
74   - assertEquals(true, multiException.isArithmeticExceptionHandler());
75   - }
76   -
77   - @Test
78   - public void testTwoExceptionOneMethod() {
79   - multiException.throwTwoException();
80   - assertEquals(true, multiException.isNullPointerExceptionHandler());
81   - assertEquals(false, multiException.isArithmeticExceptionHandler());
82   - }
83   -
84   - @Test
85   - public void testExceptionHandlerWithTwoParameter() {
86   - try {
87   - exceptionTwoParameter.throwIllegalPathException();
88   - fail();
89   - } catch (Exception e) {
90   - assertEquals(DemoiselleException.class, e.getClass());
91   - }
92   - }
93   -}
impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java
... ... @@ -1,96 +0,0 @@
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 br.gov.frameworkdemoiselle.exception.ExceptionHandler;
40   -import br.gov.frameworkdemoiselle.stereotype.Controller;
41   -
42   -@Controller
43   -public class MultiStrategyExceptionHandler {
44   -
45   - private boolean exceptionHandler = false;
46   -
47   - private boolean exceptionTryCacth = false;
48   -
49   - String txt = null;
50   -
51   - public boolean isExceptionHandler() {
52   - return exceptionHandler;
53   - }
54   -
55   - public boolean isExceptionTryCacth() {
56   - return exceptionTryCacth;
57   - }
58   -
59   - @SuppressWarnings("unused")
60   - public void exceptionMultiStrategyTryAndHandler() {
61   - try {
62   - int result = 4 / 0;
63   - } catch (ArithmeticException e) {
64   - exceptionTryCacth = true;
65   - }
66   - txt.toString();
67   - }
68   -
69   - @SuppressWarnings("unused")
70   - public void exceptionMultiStrategyHandlerAndTry() {
71   - txt.toString();
72   - try {
73   - int result = 4 / 0;
74   - } catch (ArithmeticException e) {
75   - exceptionTryCacth = true;
76   - }
77   - }
78   -
79   - public void exceptionTwoHandler() {
80   - try {
81   - txt.toString();
82   - } catch (NullPointerException e) {
83   - exceptionTryCacth = true;
84   - }
85   - }
86   -
87   - public void exceptionHandler() {
88   - txt.toString();
89   - }
90   -
91   - @ExceptionHandler
92   - public void handler(NullPointerException cause) {
93   - exceptionHandler = true;
94   - }
95   -
96   -}
impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java
... ... @@ -1,90 +0,0 @@
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 static junit.framework.Assert.assertEquals;
40   -
41   -import javax.inject.Inject;
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   -
51   -@RunWith(Arquillian.class)
52   -public class MultiStrategyExceptionHandlerTest {
53   -
54   - @Inject
55   - private MultiStrategyExceptionHandler handlerTest;
56   -
57   - @Deployment
58   - public static JavaArchive createDeployment() {
59   - JavaArchive deployment = Tests.createDeployment(OneExceptionTest.class);
60   - return deployment;
61   - }
62   -
63   - @Test
64   - public void testExceptionMultiStrategyTryAndHandler() {
65   - handlerTest.exceptionMultiStrategyTryAndHandler();
66   - assertEquals(true, handlerTest.isExceptionTryCacth());
67   - assertEquals(true, handlerTest.isExceptionHandler());
68   - }
69   -
70   - @Test
71   - public void testExceptionMultiStrategyHandlerAndTry() {
72   - handlerTest.exceptionMultiStrategyHandlerAndTry();
73   - assertEquals(false, handlerTest.isExceptionTryCacth());
74   - assertEquals(true, handlerTest.isExceptionHandler());
75   - }
76   -
77   - @Test
78   - public void testSameExceptionTwoStrategyHandler() {
79   - handlerTest.exceptionTwoHandler();
80   - assertEquals(true, handlerTest.isExceptionTryCacth());
81   - assertEquals(false, handlerTest.isExceptionHandler());
82   - }
83   -
84   - @Test
85   - public void testExceptionOneStrategyHandler() {
86   - handlerTest.exceptionHandler();
87   - assertEquals(false, handlerTest.isExceptionTryCacth());
88   - assertEquals(true, handlerTest.isExceptionHandler());
89   - }
90   -}
impl/core/src/test/java/exception/OneException.java
... ... @@ -1,115 +0,0 @@
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.util.NoSuchElementException;
40   -
41   -import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
42   -import br.gov.frameworkdemoiselle.stereotype.Controller;
43   -
44   -@Controller
45   -public class OneException {
46   -
47   - private boolean exceptionHandler = false;
48   -
49   - private boolean exceptionHandlerIllegalArgument1 = false;
50   -
51   - private boolean exceptionHandlerIllegalArgument2 = false;
52   -
53   - private boolean exceptionHandlerIllegalArgument3 = false;
54   -
55   - public boolean isExceptionHandler() {
56   - return exceptionHandler;
57   - }
58   -
59   - public boolean isExceptionHandlerIllegalArgument1() {
60   - return exceptionHandlerIllegalArgument1;
61   - }
62   -
63   - public boolean isExceptionHandlerIllegalArgument2() {
64   - return exceptionHandlerIllegalArgument2;
65   - }
66   -
67   - public boolean isExceptionHandlerIllegalArgument3() {
68   - return exceptionHandlerIllegalArgument3;
69   - }
70   -
71   - @SuppressWarnings("null")
72   - public void throwExceptionWithHandler() {
73   - String txt = null;
74   - txt.toString();
75   - }
76   -
77   - @SuppressWarnings("unused")
78   - public void throwExceptionWithoutHandler() {
79   - int result = 4 / 0;
80   - }
81   -
82   - public void throwIllegalArgumentException() {
83   - throw new IllegalArgumentException();
84   - }
85   -
86   - public void throwNoSuchElementException() {
87   - throw new NoSuchElementException();
88   - }
89   -
90   - @ExceptionHandler
91   - public void handler(NullPointerException cause) {
92   - exceptionHandler = true;
93   - }
94   -
95   - @ExceptionHandler
96   - public void handler1(IllegalArgumentException cause) {
97   - exceptionHandlerIllegalArgument1 = true;
98   - }
99   -
100   - @ExceptionHandler
101   - public void handler3(IllegalArgumentException cause) {
102   - exceptionHandlerIllegalArgument3 = true;
103   - }
104   -
105   - @ExceptionHandler
106   - public void handler2(IllegalArgumentException cause) {
107   - exceptionHandlerIllegalArgument2 = true;
108   - }
109   -
110   - @ExceptionHandler
111   - @SuppressWarnings("unused")
112   - public void handlerWithError(NoSuchElementException cause) {
113   - int a = 2 / 0;
114   - }
115   -}
impl/core/src/test/java/exception/OneExceptionTest.java
... ... @@ -1,97 +0,0 @@
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 javax.inject.Inject;
40   -
41   -import static junit.framework.Assert.fail;
42   -import static junit.framework.Assert.assertEquals;
43   -
44   -import org.jboss.arquillian.container.test.api.Deployment;
45   -import org.jboss.arquillian.junit.Arquillian;
46   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
47   -import org.junit.Test;
48   -import org.junit.runner.RunWith;
49   -
50   -import test.Tests;
51   -
52   -@RunWith(Arquillian.class)
53   -public class OneExceptionTest {
54   -
55   - @Inject
56   - private OneException oneException;
57   -
58   - @Deployment
59   - public static JavaArchive createDeployment() {
60   - JavaArchive deployment = Tests.createDeployment(OneExceptionTest.class);
61   - return deployment;
62   - }
63   -
64   - @Test
65   - public void testExceptionWithHandler() {
66   - oneException.throwExceptionWithHandler();
67   - assertEquals(true, oneException.isExceptionHandler());
68   - }
69   -
70   - @Test
71   - public void testExceptionWithoutHandler() {
72   - try {
73   - oneException.throwExceptionWithoutHandler();
74   - fail();
75   - } catch (Exception cause) {
76   - assertEquals(ArithmeticException.class, cause.getClass());
77   - }
78   - }
79   -
80   - @Test
81   - public void testExceptionWithMultiHandler() {
82   - oneException.throwIllegalArgumentException();
83   - assertEquals(false, oneException.isExceptionHandlerIllegalArgument1());
84   - assertEquals(true, oneException.isExceptionHandlerIllegalArgument2());
85   - assertEquals(false, oneException.isExceptionHandlerIllegalArgument3());
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   - }
97   -}
impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java 0 → 100644
... ... @@ -0,0 +1,122 @@
  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.basic;
  38 +
  39 +import static junit.framework.Assert.assertEquals;
  40 +import static junit.framework.Assert.fail;
  41 +
  42 +import javax.inject.Inject;
  43 +
  44 +import org.jboss.arquillian.container.test.api.Deployment;
  45 +import org.jboss.arquillian.junit.Arquillian;
  46 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  47 +import org.junit.Test;
  48 +import org.junit.runner.RunWith;
  49 +
  50 +import test.Tests;
  51 +import br.gov.frameworkdemoiselle.DemoiselleException;
  52 +
  53 +@RunWith(Arquillian.class)
  54 +public class ExceptionHandlerTest {
  55 +
  56 + @Inject
  57 + private SimpleExceptionHandler exceptionHandler;
  58 +
  59 + @Inject
  60 + private MultiExceptionHandler multiExceptionHandler;
  61 +
  62 + @Inject
  63 + private ExceptionHandlerTwoParameter exceptionTwoParameter;
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(ExceptionHandlerTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Test
  72 + public void exceptionWithHandler() {
  73 + exceptionHandler.throwArithmeticException();
  74 + exceptionHandler.throwNullPointerException();
  75 + assertEquals(true, exceptionHandler.isArithmeticExceptionHandler());
  76 + assertEquals(true, exceptionHandler.isArithmeticExceptionHandler());
  77 + }
  78 +
  79 + @Test
  80 + public void exceptionWithoutHandler() {
  81 + try {
  82 + exceptionHandler.throwExceptionWithoutHandler();
  83 + fail();
  84 + } catch (Exception cause) {
  85 + assertEquals(IllegalArgumentException.class, cause.getClass());
  86 + }
  87 + }
  88 +
  89 + @Test
  90 + public void twoExceptionOneMethod() {
  91 + exceptionHandler.throwTwoException();
  92 + assertEquals(true, exceptionHandler.isNullPointerExceptionHandler());
  93 + assertEquals(false, exceptionHandler.isArithmeticExceptionHandler());
  94 + }
  95 +
  96 + @Test
  97 + public void exceptionWithMultiHandler() {
  98 + multiExceptionHandler.throwIllegalArgumentException();
  99 + assertEquals(false, multiExceptionHandler.isExceptionHandlerIllegalArgument1());
  100 + assertEquals(true, multiExceptionHandler.isExceptionHandlerIllegalArgument2());
  101 + assertEquals(false, multiExceptionHandler.isExceptionHandlerIllegalArgument3());
  102 + }
  103 +
  104 + @Test
  105 + public void exceptionHandlerWithException() {
  106 + try {
  107 + multiExceptionHandler.throwNoSuchElementException();
  108 + } catch (Exception e) {
  109 + assertEquals(ArithmeticException.class, e.getClass());
  110 + }
  111 + }
  112 +
  113 + @Test
  114 + public void exceptionHandlerWithTwoParameter() {
  115 + try {
  116 + exceptionTwoParameter.throwIllegalPathException();
  117 + fail();
  118 + } catch (Exception e) {
  119 + assertEquals(DemoiselleException.class, e.getClass());
  120 + }
  121 + }
  122 +}
... ...
impl/core/src/test/java/exception/basic/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.basic;
  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/basic/MultiExceptionHandler.java 0 → 100644
... ... @@ -0,0 +1,101 @@
  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.basic;
  38 +
  39 +import java.util.NoSuchElementException;
  40 +
  41 +import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
  42 +import br.gov.frameworkdemoiselle.stereotype.Controller;
  43 +
  44 +@Controller
  45 +public class MultiExceptionHandler {
  46 +
  47 + private boolean exceptionHandlerIllegalArgument1 = false;
  48 +
  49 + private boolean exceptionHandlerIllegalArgument2 = false;
  50 +
  51 + private boolean exceptionHandlerIllegalArgument3 = false;
  52 +
  53 + public boolean isExceptionHandlerIllegalArgument1() {
  54 + return exceptionHandlerIllegalArgument1;
  55 + }
  56 +
  57 + public boolean isExceptionHandlerIllegalArgument2() {
  58 + return exceptionHandlerIllegalArgument2;
  59 + }
  60 +
  61 + public boolean isExceptionHandlerIllegalArgument3() {
  62 + return exceptionHandlerIllegalArgument3;
  63 + }
  64 +
  65 + @SuppressWarnings("null")
  66 + public void throwExceptionWithHandler() {
  67 + String txt = null;
  68 + txt.toString();
  69 + }
  70 +
  71 +
  72 +
  73 + public void throwIllegalArgumentException() {
  74 + throw new IllegalArgumentException();
  75 + }
  76 +
  77 + public void throwNoSuchElementException() {
  78 + throw new NoSuchElementException();
  79 + }
  80 +
  81 + @ExceptionHandler
  82 + public void handler1(IllegalArgumentException cause) {
  83 + exceptionHandlerIllegalArgument1 = true;
  84 + }
  85 +
  86 + @ExceptionHandler
  87 + public void handler3(IllegalArgumentException cause) {
  88 + exceptionHandlerIllegalArgument3 = true;
  89 + }
  90 +
  91 + @ExceptionHandler
  92 + public void handler2(IllegalArgumentException cause) {
  93 + exceptionHandlerIllegalArgument2 = true;
  94 + }
  95 +
  96 + @ExceptionHandler
  97 + @SuppressWarnings("unused")
  98 + public void handlerWithError(NoSuchElementException cause) {
  99 + int a = 2 / 0;
  100 + }
  101 +}
... ...
impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java 0 → 100644
... ... @@ -0,0 +1,85 @@
  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.basic;
  38 +
  39 +import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
  40 +import br.gov.frameworkdemoiselle.stereotype.Controller;
  41 +
  42 +@Controller
  43 +public class SimpleExceptionHandler {
  44 +
  45 + private boolean nullPointerExceptionHandler = false;
  46 +
  47 + private boolean arithmeticExceptionHandler = false;
  48 +
  49 + public boolean isNullPointerExceptionHandler() {
  50 + return nullPointerExceptionHandler;
  51 + }
  52 +
  53 + public boolean isArithmeticExceptionHandler() {
  54 + return arithmeticExceptionHandler;
  55 + }
  56 +
  57 + public void throwNullPointerException() {
  58 + throw new NullPointerException();
  59 + }
  60 +
  61 + public void throwArithmeticException() {
  62 + throw new ArithmeticException();
  63 + }
  64 +
  65 + public void throwExceptionWithoutHandler() {
  66 + throw new IllegalArgumentException();
  67 + }
  68 +
  69 + @SuppressWarnings({ "null", "unused" })
  70 + public void throwTwoException() {
  71 + String txt = null;
  72 + txt.toString();
  73 + int result = 4 / 0;
  74 + }
  75 +
  76 + @ExceptionHandler
  77 + public void handler(NullPointerException cause) {
  78 + nullPointerExceptionHandler = true;
  79 + }
  80 +
  81 + @ExceptionHandler
  82 + public void handler(ArithmeticException cause) {
  83 + arithmeticExceptionHandler = true;
  84 + }
  85 +}
... ...
impl/core/src/test/java/exception/custom/CustomException.java 0 → 100644
... ... @@ -0,0 +1,46 @@
  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.custom;
  38 +
  39 +import br.gov.frameworkdemoiselle.exception.ApplicationException;
  40 +
  41 +@ApplicationException
  42 +public class CustomException extends RuntimeException {
  43 +
  44 + private static final long serialVersionUID = 1L;
  45 +
  46 +}
... ...
impl/core/src/test/java/exception/custom/CustomExceptionHandler.java 0 → 100644
... ... @@ -0,0 +1,63 @@
  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.custom;
  38 +
  39 +import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
  40 +import br.gov.frameworkdemoiselle.stereotype.Controller;
  41 +
  42 +@Controller
  43 +public class CustomExceptionHandler {
  44 +
  45 + private boolean exceptionHandler = false;
  46 +
  47 + public boolean isExceptionHandler() {
  48 + return exceptionHandler;
  49 + }
  50 +
  51 + public void setExceptionHandler(boolean exceptionHandler) {
  52 + this.exceptionHandler = exceptionHandler;
  53 + }
  54 +
  55 + public void throwExceptionWithMessage() {
  56 + throw new CustomException();
  57 + }
  58 +
  59 + @ExceptionHandler
  60 + public void handler(CustomException exception) {
  61 + setExceptionHandler(true);
  62 + }
  63 +}
... ...
impl/core/src/test/java/exception/custom/CustomExceptionTest.java 0 → 100644
... ... @@ -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 exception.custom;
  38 +
  39 +import static junit.framework.Assert.assertEquals;
  40 +
  41 +import javax.inject.Inject;
  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 +
  51 +@RunWith(Arquillian.class)
  52 +public class CustomExceptionTest {
  53 +
  54 + @Inject
  55 + private CustomExceptionHandler exception;
  56 +
  57 + @Deployment
  58 + public static JavaArchive createDeployment() {
  59 + JavaArchive deployment = Tests.createDeployment(CustomExceptionTest.class);
  60 + return deployment;
  61 + }
  62 +
  63 + @Test
  64 + public void customExceptionHandler() {
  65 + exception.throwExceptionWithMessage();
  66 + assertEquals(true, exception.isExceptionHandler());
  67 + }
  68 +}
... ...
impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java 0 → 100644
... ... @@ -0,0 +1,75 @@
  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.inheritance;
  38 +
  39 +import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
  40 +import br.gov.frameworkdemoiselle.stereotype.Controller;
  41 +
  42 +@Controller
  43 +public class ExceptionInheritance {
  44 +
  45 + private boolean handlerSuperClass = false;
  46 +
  47 + private boolean handlerClass = false;
  48 +
  49 + public boolean isHandlerSuperClass() {
  50 + return handlerSuperClass;
  51 + }
  52 +
  53 + public boolean isHandlerClass() {
  54 + return handlerClass;
  55 + }
  56 +
  57 + public void throwNullPointerException() {
  58 + throw new NullPointerException();
  59 + }
  60 +
  61 + public void throwArithmeticException() {
  62 + throw new ArithmeticException();
  63 + }
  64 +
  65 + @ExceptionHandler
  66 + public void handle(ArithmeticException e) {
  67 + handlerClass = true;
  68 + }
  69 +
  70 + @ExceptionHandler
  71 + public void handle(RuntimeException e) {
  72 + handlerSuperClass = true;
  73 + }
  74 +
  75 +}
... ...
impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java 0 → 100644
... ... @@ -0,0 +1,75 @@
  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.inheritance;
  38 +
  39 +import static junit.framework.Assert.assertEquals;
  40 +
  41 +import javax.inject.Inject;
  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 +
  51 +@RunWith(Arquillian.class)
  52 +public class ExceptionInheritanceTest {
  53 +
  54 + @Inject
  55 + private ExceptionInheritance exceptionInheritance;
  56 +
  57 + @Deployment
  58 + public static JavaArchive createDeployment() {
  59 + JavaArchive deployment = Tests.createDeployment(ExceptionInheritanceTest.class);
  60 + return deployment;
  61 + }
  62 +
  63 + @Test
  64 + public void exceptionHandlerSuperClass() {
  65 + exceptionInheritance.throwNullPointerException();
  66 + assertEquals(true, exceptionInheritance.isHandlerSuperClass());
  67 + }
  68 +
  69 + @Test
  70 + public void exceptionHandlerClass() {
  71 + exceptionInheritance.throwArithmeticException();
  72 + assertEquals(false, exceptionInheritance.isHandlerSuperClass());
  73 + assertEquals(true, exceptionInheritance.isHandlerClass());
  74 + }
  75 +}
... ...
impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.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 exception.multistrategy;
  38 +
  39 +import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
  40 +import br.gov.frameworkdemoiselle.stereotype.Controller;
  41 +
  42 +@Controller
  43 +public class MultiStrategyExceptionHandler {
  44 +
  45 + private boolean exceptionHandler = false;
  46 +
  47 + private boolean exceptionTryCacth = false;
  48 +
  49 + String txt = null;
  50 +
  51 + public boolean isExceptionHandler() {
  52 + return exceptionHandler;
  53 + }
  54 +
  55 + public boolean isExceptionTryCacth() {
  56 + return exceptionTryCacth;
  57 + }
  58 +
  59 + @SuppressWarnings("unused")
  60 + public void exceptionMultiStrategyTryAndHandler() {
  61 + try {
  62 + int result = 4 / 0;
  63 + } catch (ArithmeticException e) {
  64 + exceptionTryCacth = true;
  65 + }
  66 + txt.toString();
  67 + }
  68 +
  69 + @SuppressWarnings("unused")
  70 + public void exceptionMultiStrategyHandlerAndTry() {
  71 + txt.toString();
  72 + try {
  73 + int result = 4 / 0;
  74 + } catch (ArithmeticException e) {
  75 + exceptionTryCacth = true;
  76 + }
  77 + }
  78 +
  79 + public void exceptionTwoHandler() {
  80 + try {
  81 + txt.toString();
  82 + } catch (NullPointerException e) {
  83 + exceptionTryCacth = true;
  84 + }
  85 + }
  86 +
  87 + @ExceptionHandler
  88 + public void handler(NullPointerException cause) {
  89 + exceptionHandler = true;
  90 + }
  91 +
  92 +}
... ...
impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java 0 → 100644
... ... @@ -0,0 +1,84 @@
  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.multistrategy;
  38 +
  39 +import static junit.framework.Assert.assertEquals;
  40 +
  41 +import javax.inject.Inject;
  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 +
  51 +@RunWith(Arquillian.class)
  52 +public class MultiStrategyExceptionHandlerTest {
  53 +
  54 + @Inject
  55 + private MultiStrategyExceptionHandler handlerTest;
  56 +
  57 + @Deployment
  58 + public static JavaArchive createDeployment() {
  59 + JavaArchive deployment = Tests.createDeployment(MultiStrategyExceptionHandlerTest.class);
  60 + return deployment;
  61 + }
  62 +
  63 + @Test
  64 + public void exceptionMultiStrategyTryAndHandler() {
  65 + handlerTest.exceptionMultiStrategyTryAndHandler();
  66 + assertEquals(true, handlerTest.isExceptionTryCacth());
  67 + assertEquals(true, handlerTest.isExceptionHandler());
  68 + }
  69 +
  70 + @Test
  71 + public void exceptionMultiStrategyHandlerAndTry() {
  72 + handlerTest.exceptionMultiStrategyHandlerAndTry();
  73 + assertEquals(false, handlerTest.isExceptionTryCacth());
  74 + assertEquals(true, handlerTest.isExceptionHandler());
  75 + }
  76 +
  77 + @Test
  78 + public void sameExceptionTwoStrategyHandler() {
  79 + handlerTest.exceptionTwoHandler();
  80 + assertEquals(true, handlerTest.isExceptionTryCacth());
  81 + assertEquals(false, handlerTest.isExceptionHandler());
  82 + }
  83 +
  84 +}
... ...