From 76c84182904f85a9bf8a5b46e5575218435c2cde Mon Sep 17 00:00:00 2001 From: Ednara Oliveira Date: Thu, 2 May 2013 11:24:19 -0300 Subject: [PATCH] Pacotes para os testes de Exception --- impl/core/src/test/java/exception/CustomException.java | 46 ---------------------------------------------- impl/core/src/test/java/exception/CustomExceptionHandler.java | 63 --------------------------------------------------------------- impl/core/src/test/java/exception/CustomExceptionTest.java | 68 -------------------------------------------------------------------- impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java | 54 ------------------------------------------------------ impl/core/src/test/java/exception/ExceptionInheritance.java | 75 --------------------------------------------------------------------------- impl/core/src/test/java/exception/ExceptionInheritanceTest.java | 75 --------------------------------------------------------------------------- impl/core/src/test/java/exception/MultiException.java | 81 --------------------------------------------------------------------------------- impl/core/src/test/java/exception/MultiExceptionTest.java | 93 --------------------------------------------------------------------------------------------- impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java | 96 ------------------------------------------------------------------------------------------------ impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java | 90 ------------------------------------------------------------------------------------------ impl/core/src/test/java/exception/OneException.java | 115 ------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/exception/OneExceptionTest.java | 97 ------------------------------------------------------------------------------------------------- impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/basic/ExceptionHandlerTwoParameter.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/basic/MultiExceptionHandler.java | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/custom/CustomException.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/custom/CustomExceptionHandler.java | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/custom/CustomExceptionTest.java | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.java | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 23 files changed, 865 insertions(+), 953 deletions(-) delete mode 100644 impl/core/src/test/java/exception/CustomException.java delete mode 100644 impl/core/src/test/java/exception/CustomExceptionHandler.java delete mode 100644 impl/core/src/test/java/exception/CustomExceptionTest.java delete mode 100644 impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java delete mode 100644 impl/core/src/test/java/exception/ExceptionInheritance.java delete mode 100644 impl/core/src/test/java/exception/ExceptionInheritanceTest.java delete mode 100644 impl/core/src/test/java/exception/MultiException.java delete mode 100644 impl/core/src/test/java/exception/MultiExceptionTest.java delete mode 100644 impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java delete mode 100644 impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java delete mode 100644 impl/core/src/test/java/exception/OneException.java delete mode 100644 impl/core/src/test/java/exception/OneExceptionTest.java create mode 100644 impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java create mode 100644 impl/core/src/test/java/exception/basic/ExceptionHandlerTwoParameter.java create mode 100644 impl/core/src/test/java/exception/basic/MultiExceptionHandler.java create mode 100644 impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java create mode 100644 impl/core/src/test/java/exception/custom/CustomException.java create mode 100644 impl/core/src/test/java/exception/custom/CustomExceptionHandler.java create mode 100644 impl/core/src/test/java/exception/custom/CustomExceptionTest.java create mode 100644 impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java create mode 100644 impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java create mode 100644 impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.java create mode 100644 impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java diff --git a/impl/core/src/test/java/exception/CustomException.java b/impl/core/src/test/java/exception/CustomException.java deleted file mode 100644 index 8ba8ee4..0000000 --- a/impl/core/src/test/java/exception/CustomException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import br.gov.frameworkdemoiselle.exception.ApplicationException; - -@ApplicationException -public class CustomException extends RuntimeException { - - private static final long serialVersionUID = 1L; - -} diff --git a/impl/core/src/test/java/exception/CustomExceptionHandler.java b/impl/core/src/test/java/exception/CustomExceptionHandler.java deleted file mode 100644 index 1a775b2..0000000 --- a/impl/core/src/test/java/exception/CustomExceptionHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class CustomExceptionHandler { - - private boolean exceptionHandler = false; - - public boolean isExceptionHandler() { - return exceptionHandler; - } - - public void setExceptionHandler(boolean exceptionHandler) { - this.exceptionHandler = exceptionHandler; - } - - public void throwExceptionWithMessage() { - throw new CustomException(); - } - - @ExceptionHandler - public void handler(CustomException exception) { - setExceptionHandler(true); - } -} diff --git a/impl/core/src/test/java/exception/CustomExceptionTest.java b/impl/core/src/test/java/exception/CustomExceptionTest.java deleted file mode 100644 index 30057dc..0000000 --- a/impl/core/src/test/java/exception/CustomExceptionTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import static junit.framework.Assert.assertEquals; - -import javax.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; - -@RunWith(Arquillian.class) -public class CustomExceptionTest { - - @Inject - private CustomExceptionHandler exception; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(CustomExceptionTest.class); - return deployment; - } - - @Test - public void testCustomExceptionHandler() { - exception.throwExceptionWithMessage(); - assertEquals(true, exception.isExceptionHandler()); - } -} diff --git a/impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java b/impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java deleted file mode 100644 index d94d97f..0000000 --- a/impl/core/src/test/java/exception/ExceptionHandlerTwoParameter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import java.awt.geom.IllegalPathStateException; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class ExceptionHandlerTwoParameter { - - public void throwIllegalPathException() { - throw new IllegalPathStateException(); - } - - @ExceptionHandler - public void handler(IllegalPathStateException cause, IllegalStateException cause2) { - } -} diff --git a/impl/core/src/test/java/exception/ExceptionInheritance.java b/impl/core/src/test/java/exception/ExceptionInheritance.java deleted file mode 100644 index 9a5b79b..0000000 --- a/impl/core/src/test/java/exception/ExceptionInheritance.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class ExceptionInheritance { - - private boolean handlerSuperClass = false; - - private boolean handlerClass = false; - - public boolean isHandlerSuperClass() { - return handlerSuperClass; - } - - public boolean isHandlerClass() { - return handlerClass; - } - - public void throwNullPointerException() { - throw new NullPointerException(); - } - - public void throwArithmeticException() { - throw new ArithmeticException(); - } - - @ExceptionHandler - public void handle(ArithmeticException e) { - handlerClass = true; - } - - @ExceptionHandler - public void handle(RuntimeException e) { - handlerSuperClass = true; - } - -} diff --git a/impl/core/src/test/java/exception/ExceptionInheritanceTest.java b/impl/core/src/test/java/exception/ExceptionInheritanceTest.java deleted file mode 100644 index d3ceeb0..0000000 --- a/impl/core/src/test/java/exception/ExceptionInheritanceTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import static junit.framework.Assert.assertEquals; - -import javax.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; - -@RunWith(Arquillian.class) -public class ExceptionInheritanceTest { - - @Inject - private ExceptionInheritance exceptionInheritance; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(ExceptionInheritanceTest.class); - return deployment; - } - - @Test - public void testExceptionInheritanceSuperClass() { - exceptionInheritance.throwNullPointerException(); - assertEquals(true, exceptionInheritance.isHandlerSuperClass()); - } - - @Test - public void testExceptionInheritanceClass() { - exceptionInheritance.throwArithmeticException(); - assertEquals(false, exceptionInheritance.isHandlerSuperClass()); - assertEquals(true, exceptionInheritance.isHandlerClass()); - } -} diff --git a/impl/core/src/test/java/exception/MultiException.java b/impl/core/src/test/java/exception/MultiException.java deleted file mode 100644 index a4b87f8..0000000 --- a/impl/core/src/test/java/exception/MultiException.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class MultiException { - - private boolean nullPointerExceptionHandler = false; - - private boolean arithmeticExceptionHandler = false; - - public boolean isNullPointerExceptionHandler() { - return nullPointerExceptionHandler; - } - - public boolean isArithmeticExceptionHandler() { - return arithmeticExceptionHandler; - } - - public void throwNullPointerException() { - throw new NullPointerException(); - } - - public void throwArithmeticException() { - throw new ArithmeticException(); - } - - @SuppressWarnings({ "null", "unused" }) - public void throwTwoException() { - String txt = null; - txt.toString(); - int result = 4 / 0; - } - - @ExceptionHandler - public void handler(NullPointerException cause) { - nullPointerExceptionHandler = true; - } - - @ExceptionHandler - public void handler(ArithmeticException cause) { - arithmeticExceptionHandler = true; - } -} diff --git a/impl/core/src/test/java/exception/MultiExceptionTest.java b/impl/core/src/test/java/exception/MultiExceptionTest.java deleted file mode 100644 index 9e95020..0000000 --- a/impl/core/src/test/java/exception/MultiExceptionTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import javax.inject.Inject; - -import static junit.framework.Assert.fail; -import static junit.framework.Assert.assertEquals; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import br.gov.frameworkdemoiselle.DemoiselleException; - -import test.Tests; - -@RunWith(Arquillian.class) -public class MultiExceptionTest { - - @Inject - private MultiException multiException; - - @Inject - private ExceptionHandlerTwoParameter exceptionTwoParameter; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(MultiExceptionTest.class); - return deployment; - } - - @Test - public void testTwoExceptionTwoMethod() { - multiException.throwArithmeticException(); - multiException.throwNullPointerException(); - assertEquals(true, multiException.isArithmeticExceptionHandler()); - assertEquals(true, multiException.isArithmeticExceptionHandler()); - } - - @Test - public void testTwoExceptionOneMethod() { - multiException.throwTwoException(); - assertEquals(true, multiException.isNullPointerExceptionHandler()); - assertEquals(false, multiException.isArithmeticExceptionHandler()); - } - - @Test - public void testExceptionHandlerWithTwoParameter() { - try { - exceptionTwoParameter.throwIllegalPathException(); - fail(); - } catch (Exception e) { - assertEquals(DemoiselleException.class, e.getClass()); - } - } -} diff --git a/impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java b/impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java deleted file mode 100644 index 3200a6d..0000000 --- a/impl/core/src/test/java/exception/MultiStrategyExceptionHandler.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class MultiStrategyExceptionHandler { - - private boolean exceptionHandler = false; - - private boolean exceptionTryCacth = false; - - String txt = null; - - public boolean isExceptionHandler() { - return exceptionHandler; - } - - public boolean isExceptionTryCacth() { - return exceptionTryCacth; - } - - @SuppressWarnings("unused") - public void exceptionMultiStrategyTryAndHandler() { - try { - int result = 4 / 0; - } catch (ArithmeticException e) { - exceptionTryCacth = true; - } - txt.toString(); - } - - @SuppressWarnings("unused") - public void exceptionMultiStrategyHandlerAndTry() { - txt.toString(); - try { - int result = 4 / 0; - } catch (ArithmeticException e) { - exceptionTryCacth = true; - } - } - - public void exceptionTwoHandler() { - try { - txt.toString(); - } catch (NullPointerException e) { - exceptionTryCacth = true; - } - } - - public void exceptionHandler() { - txt.toString(); - } - - @ExceptionHandler - public void handler(NullPointerException cause) { - exceptionHandler = true; - } - -} diff --git a/impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java b/impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java deleted file mode 100644 index ec2f2e9..0000000 --- a/impl/core/src/test/java/exception/MultiStrategyExceptionHandlerTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import static junit.framework.Assert.assertEquals; - -import javax.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; - -@RunWith(Arquillian.class) -public class MultiStrategyExceptionHandlerTest { - - @Inject - private MultiStrategyExceptionHandler handlerTest; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(OneExceptionTest.class); - return deployment; - } - - @Test - public void testExceptionMultiStrategyTryAndHandler() { - handlerTest.exceptionMultiStrategyTryAndHandler(); - assertEquals(true, handlerTest.isExceptionTryCacth()); - assertEquals(true, handlerTest.isExceptionHandler()); - } - - @Test - public void testExceptionMultiStrategyHandlerAndTry() { - handlerTest.exceptionMultiStrategyHandlerAndTry(); - assertEquals(false, handlerTest.isExceptionTryCacth()); - assertEquals(true, handlerTest.isExceptionHandler()); - } - - @Test - public void testSameExceptionTwoStrategyHandler() { - handlerTest.exceptionTwoHandler(); - assertEquals(true, handlerTest.isExceptionTryCacth()); - assertEquals(false, handlerTest.isExceptionHandler()); - } - - @Test - public void testExceptionOneStrategyHandler() { - handlerTest.exceptionHandler(); - assertEquals(false, handlerTest.isExceptionTryCacth()); - assertEquals(true, handlerTest.isExceptionHandler()); - } -} diff --git a/impl/core/src/test/java/exception/OneException.java b/impl/core/src/test/java/exception/OneException.java deleted file mode 100644 index d8e7527..0000000 --- a/impl/core/src/test/java/exception/OneException.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import java.util.NoSuchElementException; - -import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -import br.gov.frameworkdemoiselle.stereotype.Controller; - -@Controller -public class OneException { - - private boolean exceptionHandler = false; - - private boolean exceptionHandlerIllegalArgument1 = false; - - private boolean exceptionHandlerIllegalArgument2 = false; - - private boolean exceptionHandlerIllegalArgument3 = false; - - public boolean isExceptionHandler() { - return exceptionHandler; - } - - public boolean isExceptionHandlerIllegalArgument1() { - return exceptionHandlerIllegalArgument1; - } - - public boolean isExceptionHandlerIllegalArgument2() { - return exceptionHandlerIllegalArgument2; - } - - public boolean isExceptionHandlerIllegalArgument3() { - return exceptionHandlerIllegalArgument3; - } - - @SuppressWarnings("null") - public void throwExceptionWithHandler() { - String txt = null; - txt.toString(); - } - - @SuppressWarnings("unused") - public void throwExceptionWithoutHandler() { - int result = 4 / 0; - } - - public void throwIllegalArgumentException() { - throw new IllegalArgumentException(); - } - - public void throwNoSuchElementException() { - throw new NoSuchElementException(); - } - - @ExceptionHandler - public void handler(NullPointerException cause) { - exceptionHandler = true; - } - - @ExceptionHandler - public void handler1(IllegalArgumentException cause) { - exceptionHandlerIllegalArgument1 = true; - } - - @ExceptionHandler - public void handler3(IllegalArgumentException cause) { - exceptionHandlerIllegalArgument3 = true; - } - - @ExceptionHandler - public void handler2(IllegalArgumentException cause) { - exceptionHandlerIllegalArgument2 = true; - } - - @ExceptionHandler - @SuppressWarnings("unused") - public void handlerWithError(NoSuchElementException cause) { - int a = 2 / 0; - } -} diff --git a/impl/core/src/test/java/exception/OneExceptionTest.java b/impl/core/src/test/java/exception/OneExceptionTest.java deleted file mode 100644 index 150c80d..0000000 --- a/impl/core/src/test/java/exception/OneExceptionTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package exception; - -import javax.inject.Inject; - -import static junit.framework.Assert.fail; -import static junit.framework.Assert.assertEquals; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; - -@RunWith(Arquillian.class) -public class OneExceptionTest { - - @Inject - private OneException oneException; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(OneExceptionTest.class); - return deployment; - } - - @Test - public void testExceptionWithHandler() { - oneException.throwExceptionWithHandler(); - assertEquals(true, oneException.isExceptionHandler()); - } - - @Test - public void testExceptionWithoutHandler() { - try { - oneException.throwExceptionWithoutHandler(); - fail(); - } catch (Exception cause) { - assertEquals(ArithmeticException.class, cause.getClass()); - } - } - - @Test - public void testExceptionWithMultiHandler() { - oneException.throwIllegalArgumentException(); - assertEquals(false, oneException.isExceptionHandlerIllegalArgument1()); - assertEquals(true, oneException.isExceptionHandlerIllegalArgument2()); - assertEquals(false, oneException.isExceptionHandlerIllegalArgument3()); - } - - @Test - public void testExceptionHandlerWithException() { - try { - oneException.throwNoSuchElementException(); - } catch (Exception e) { - assertEquals(ArithmeticException.class, e.getClass()); - } - - } -} diff --git a/impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java b/impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java new file mode 100644 index 0000000..aa8fdb4 --- /dev/null +++ b/impl/core/src/test/java/exception/basic/ExceptionHandlerTest.java @@ -0,0 +1,122 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.basic; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.DemoiselleException; + +@RunWith(Arquillian.class) +public class ExceptionHandlerTest { + + @Inject + private SimpleExceptionHandler exceptionHandler; + + @Inject + private MultiExceptionHandler multiExceptionHandler; + + @Inject + private ExceptionHandlerTwoParameter exceptionTwoParameter; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ExceptionHandlerTest.class); + return deployment; + } + + @Test + public void exceptionWithHandler() { + exceptionHandler.throwArithmeticException(); + exceptionHandler.throwNullPointerException(); + assertEquals(true, exceptionHandler.isArithmeticExceptionHandler()); + assertEquals(true, exceptionHandler.isArithmeticExceptionHandler()); + } + + @Test + public void exceptionWithoutHandler() { + try { + exceptionHandler.throwExceptionWithoutHandler(); + fail(); + } catch (Exception cause) { + assertEquals(IllegalArgumentException.class, cause.getClass()); + } + } + + @Test + public void twoExceptionOneMethod() { + exceptionHandler.throwTwoException(); + assertEquals(true, exceptionHandler.isNullPointerExceptionHandler()); + assertEquals(false, exceptionHandler.isArithmeticExceptionHandler()); + } + + @Test + public void exceptionWithMultiHandler() { + multiExceptionHandler.throwIllegalArgumentException(); + assertEquals(false, multiExceptionHandler.isExceptionHandlerIllegalArgument1()); + assertEquals(true, multiExceptionHandler.isExceptionHandlerIllegalArgument2()); + assertEquals(false, multiExceptionHandler.isExceptionHandlerIllegalArgument3()); + } + + @Test + public void exceptionHandlerWithException() { + try { + multiExceptionHandler.throwNoSuchElementException(); + } catch (Exception e) { + assertEquals(ArithmeticException.class, e.getClass()); + } + } + + @Test + public void exceptionHandlerWithTwoParameter() { + try { + exceptionTwoParameter.throwIllegalPathException(); + fail(); + } catch (Exception e) { + assertEquals(DemoiselleException.class, e.getClass()); + } + } +} diff --git a/impl/core/src/test/java/exception/basic/ExceptionHandlerTwoParameter.java b/impl/core/src/test/java/exception/basic/ExceptionHandlerTwoParameter.java new file mode 100644 index 0000000..0ebfe8d --- /dev/null +++ b/impl/core/src/test/java/exception/basic/ExceptionHandlerTwoParameter.java @@ -0,0 +1,54 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.basic; + +import java.awt.geom.IllegalPathStateException; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class ExceptionHandlerTwoParameter { + + public void throwIllegalPathException() { + throw new IllegalPathStateException(); + } + + @ExceptionHandler + public void handler(IllegalPathStateException cause, IllegalStateException cause2) { + } +} diff --git a/impl/core/src/test/java/exception/basic/MultiExceptionHandler.java b/impl/core/src/test/java/exception/basic/MultiExceptionHandler.java new file mode 100644 index 0000000..41c77ca --- /dev/null +++ b/impl/core/src/test/java/exception/basic/MultiExceptionHandler.java @@ -0,0 +1,101 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.basic; + +import java.util.NoSuchElementException; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class MultiExceptionHandler { + + private boolean exceptionHandlerIllegalArgument1 = false; + + private boolean exceptionHandlerIllegalArgument2 = false; + + private boolean exceptionHandlerIllegalArgument3 = false; + + public boolean isExceptionHandlerIllegalArgument1() { + return exceptionHandlerIllegalArgument1; + } + + public boolean isExceptionHandlerIllegalArgument2() { + return exceptionHandlerIllegalArgument2; + } + + public boolean isExceptionHandlerIllegalArgument3() { + return exceptionHandlerIllegalArgument3; + } + + @SuppressWarnings("null") + public void throwExceptionWithHandler() { + String txt = null; + txt.toString(); + } + + + + public void throwIllegalArgumentException() { + throw new IllegalArgumentException(); + } + + public void throwNoSuchElementException() { + throw new NoSuchElementException(); + } + + @ExceptionHandler + public void handler1(IllegalArgumentException cause) { + exceptionHandlerIllegalArgument1 = true; + } + + @ExceptionHandler + public void handler3(IllegalArgumentException cause) { + exceptionHandlerIllegalArgument3 = true; + } + + @ExceptionHandler + public void handler2(IllegalArgumentException cause) { + exceptionHandlerIllegalArgument2 = true; + } + + @ExceptionHandler + @SuppressWarnings("unused") + public void handlerWithError(NoSuchElementException cause) { + int a = 2 / 0; + } +} diff --git a/impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java b/impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java new file mode 100644 index 0000000..ece182b --- /dev/null +++ b/impl/core/src/test/java/exception/basic/SimpleExceptionHandler.java @@ -0,0 +1,85 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.basic; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class SimpleExceptionHandler { + + private boolean nullPointerExceptionHandler = false; + + private boolean arithmeticExceptionHandler = false; + + public boolean isNullPointerExceptionHandler() { + return nullPointerExceptionHandler; + } + + public boolean isArithmeticExceptionHandler() { + return arithmeticExceptionHandler; + } + + public void throwNullPointerException() { + throw new NullPointerException(); + } + + public void throwArithmeticException() { + throw new ArithmeticException(); + } + + public void throwExceptionWithoutHandler() { + throw new IllegalArgumentException(); + } + + @SuppressWarnings({ "null", "unused" }) + public void throwTwoException() { + String txt = null; + txt.toString(); + int result = 4 / 0; + } + + @ExceptionHandler + public void handler(NullPointerException cause) { + nullPointerExceptionHandler = true; + } + + @ExceptionHandler + public void handler(ArithmeticException cause) { + arithmeticExceptionHandler = true; + } +} diff --git a/impl/core/src/test/java/exception/custom/CustomException.java b/impl/core/src/test/java/exception/custom/CustomException.java new file mode 100644 index 0000000..40152bf --- /dev/null +++ b/impl/core/src/test/java/exception/custom/CustomException.java @@ -0,0 +1,46 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.custom; + +import br.gov.frameworkdemoiselle.exception.ApplicationException; + +@ApplicationException +public class CustomException extends RuntimeException { + + private static final long serialVersionUID = 1L; + +} diff --git a/impl/core/src/test/java/exception/custom/CustomExceptionHandler.java b/impl/core/src/test/java/exception/custom/CustomExceptionHandler.java new file mode 100644 index 0000000..baf8512 --- /dev/null +++ b/impl/core/src/test/java/exception/custom/CustomExceptionHandler.java @@ -0,0 +1,63 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.custom; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class CustomExceptionHandler { + + private boolean exceptionHandler = false; + + public boolean isExceptionHandler() { + return exceptionHandler; + } + + public void setExceptionHandler(boolean exceptionHandler) { + this.exceptionHandler = exceptionHandler; + } + + public void throwExceptionWithMessage() { + throw new CustomException(); + } + + @ExceptionHandler + public void handler(CustomException exception) { + setExceptionHandler(true); + } +} diff --git a/impl/core/src/test/java/exception/custom/CustomExceptionTest.java b/impl/core/src/test/java/exception/custom/CustomExceptionTest.java new file mode 100644 index 0000000..80db4d7 --- /dev/null +++ b/impl/core/src/test/java/exception/custom/CustomExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.custom; + +import static junit.framework.Assert.assertEquals; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; + +@RunWith(Arquillian.class) +public class CustomExceptionTest { + + @Inject + private CustomExceptionHandler exception; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(CustomExceptionTest.class); + return deployment; + } + + @Test + public void customExceptionHandler() { + exception.throwExceptionWithMessage(); + assertEquals(true, exception.isExceptionHandler()); + } +} diff --git a/impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java b/impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java new file mode 100644 index 0000000..a22fe0b --- /dev/null +++ b/impl/core/src/test/java/exception/inheritance/ExceptionInheritance.java @@ -0,0 +1,75 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.inheritance; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class ExceptionInheritance { + + private boolean handlerSuperClass = false; + + private boolean handlerClass = false; + + public boolean isHandlerSuperClass() { + return handlerSuperClass; + } + + public boolean isHandlerClass() { + return handlerClass; + } + + public void throwNullPointerException() { + throw new NullPointerException(); + } + + public void throwArithmeticException() { + throw new ArithmeticException(); + } + + @ExceptionHandler + public void handle(ArithmeticException e) { + handlerClass = true; + } + + @ExceptionHandler + public void handle(RuntimeException e) { + handlerSuperClass = true; + } + +} diff --git a/impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java b/impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java new file mode 100644 index 0000000..aabfe03 --- /dev/null +++ b/impl/core/src/test/java/exception/inheritance/ExceptionInheritanceTest.java @@ -0,0 +1,75 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.inheritance; + +import static junit.framework.Assert.assertEquals; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; + +@RunWith(Arquillian.class) +public class ExceptionInheritanceTest { + + @Inject + private ExceptionInheritance exceptionInheritance; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ExceptionInheritanceTest.class); + return deployment; + } + + @Test + public void exceptionHandlerSuperClass() { + exceptionInheritance.throwNullPointerException(); + assertEquals(true, exceptionInheritance.isHandlerSuperClass()); + } + + @Test + public void exceptionHandlerClass() { + exceptionInheritance.throwArithmeticException(); + assertEquals(false, exceptionInheritance.isHandlerSuperClass()); + assertEquals(true, exceptionInheritance.isHandlerClass()); + } +} diff --git a/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.java b/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.java new file mode 100644 index 0000000..a00edb6 --- /dev/null +++ b/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandler.java @@ -0,0 +1,92 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.multistrategy; + +import br.gov.frameworkdemoiselle.exception.ExceptionHandler; +import br.gov.frameworkdemoiselle.stereotype.Controller; + +@Controller +public class MultiStrategyExceptionHandler { + + private boolean exceptionHandler = false; + + private boolean exceptionTryCacth = false; + + String txt = null; + + public boolean isExceptionHandler() { + return exceptionHandler; + } + + public boolean isExceptionTryCacth() { + return exceptionTryCacth; + } + + @SuppressWarnings("unused") + public void exceptionMultiStrategyTryAndHandler() { + try { + int result = 4 / 0; + } catch (ArithmeticException e) { + exceptionTryCacth = true; + } + txt.toString(); + } + + @SuppressWarnings("unused") + public void exceptionMultiStrategyHandlerAndTry() { + txt.toString(); + try { + int result = 4 / 0; + } catch (ArithmeticException e) { + exceptionTryCacth = true; + } + } + + public void exceptionTwoHandler() { + try { + txt.toString(); + } catch (NullPointerException e) { + exceptionTryCacth = true; + } + } + + @ExceptionHandler + public void handler(NullPointerException cause) { + exceptionHandler = true; + } + +} diff --git a/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java b/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java new file mode 100644 index 0000000..7baf8fd --- /dev/null +++ b/impl/core/src/test/java/exception/multistrategy/MultiStrategyExceptionHandlerTest.java @@ -0,0 +1,84 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package exception.multistrategy; + +import static junit.framework.Assert.assertEquals; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; + +@RunWith(Arquillian.class) +public class MultiStrategyExceptionHandlerTest { + + @Inject + private MultiStrategyExceptionHandler handlerTest; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(MultiStrategyExceptionHandlerTest.class); + return deployment; + } + + @Test + public void exceptionMultiStrategyTryAndHandler() { + handlerTest.exceptionMultiStrategyTryAndHandler(); + assertEquals(true, handlerTest.isExceptionTryCacth()); + assertEquals(true, handlerTest.isExceptionHandler()); + } + + @Test + public void exceptionMultiStrategyHandlerAndTry() { + handlerTest.exceptionMultiStrategyHandlerAndTry(); + assertEquals(false, handlerTest.isExceptionTryCacth()); + assertEquals(true, handlerTest.isExceptionHandler()); + } + + @Test + public void sameExceptionTwoStrategyHandler() { + handlerTest.exceptionTwoHandler(); + assertEquals(true, handlerTest.isExceptionTryCacth()); + assertEquals(false, handlerTest.isExceptionHandler()); + } + +} -- libgit2 0.21.2