Commit 0e1703135d00a336002faf3a0883f1a700e04e6e

Authored by Emerson Oliveira
2 parents 2db71850 74ae7e0c
Exists in master

Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0

Showing 58 changed files with 2166 additions and 1676 deletions   Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
... ... @@ -11,12 +11,12 @@ import javax.enterprise.inject.spi.AfterDeploymentValidation;
11 11 import javax.enterprise.inject.spi.AnnotatedType;
12 12 import javax.enterprise.inject.spi.Bean;
13 13 import javax.enterprise.inject.spi.BeanManager;
  14 +import javax.enterprise.inject.spi.BeforeShutdown;
14 15 import javax.enterprise.inject.spi.Extension;
15 16 import javax.enterprise.inject.spi.ProcessAnnotatedType;
16 17  
17 18 import br.gov.frameworkdemoiselle.internal.context.ContextManager;
18 19 import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
19   -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
20 20 import br.gov.frameworkdemoiselle.management.annotation.Managed;
21 21 import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;
22 22 import br.gov.frameworkdemoiselle.management.internal.ManagedType;
... ... @@ -60,11 +60,13 @@ public class ManagementBootstrap implements Extension {
60 60 monitoringManager.initialize(managementExtensionCache);
61 61 }
62 62  
63   - public void unregisterAvailableManagedTypes(@Observes final AfterShutdownProccess event) {
  63 + public void unregisterAvailableManagedTypes(@Observes final BeforeShutdown event) {
64 64  
65 65 MonitoringManager manager = Beans.getReference(MonitoringManager.class);
66 66 manager.shutdown(managementExtensionCache);
67   -
  67 +
  68 + managementExtensionCache.clear();
  69 + types.clear();
68 70 }
69 71  
70 72 }
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/MonitoringManager.java
... ... @@ -13,6 +13,7 @@ import javax.management.ReflectionException;
13 13 import org.slf4j.Logger;
14 14  
15 15 import br.gov.frameworkdemoiselle.DemoiselleException;
  16 +import br.gov.frameworkdemoiselle.annotation.Name;
16 17 import br.gov.frameworkdemoiselle.internal.context.ContextManager;
17 18 import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
18 19 import br.gov.frameworkdemoiselle.management.annotation.Managed;
... ... @@ -38,12 +39,14 @@ public class MonitoringManager {
38 39 private Logger logger;
39 40  
40 41 @Inject
  42 + @Name("demoiselle-core-bundle")
41 43 private ResourceBundle bundle;
42 44  
43 45 private final List<ManagedType> managedTypes = new ArrayList<ManagedType>();
44 46  
45 47 public void addManagedType(ManagedType managedType) {
46 48 managedTypes.add(managedType);
  49 + logger.debug(bundle.getString("management-debug-registering-managed-type",managedType.getType().getCanonicalName()));
47 50 }
48 51  
49 52 /**
... ... @@ -189,8 +192,13 @@ public class MonitoringManager {
189 192 //Manda uma notificação de mudança de atributo
190 193 NotificationManager notificationManager = Beans.getReference(NotificationManager.class);
191 194 Class<? extends Object> attributeType = newValue!=null ? newValue.getClass() : null;
192   - AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString(""), propertyName, attributeType, oldValue, newValue);
193   - notificationManager.sendAttributeChangedMessage(notification);
  195 +
  196 + AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString("management-notification-attribute-changed",propertyName,managedType.getType().getCanonicalName())
  197 + , propertyName
  198 + , attributeType
  199 + , oldValue
  200 + , newValue);
  201 + notificationManager.sendNotification(notification);
194 202  
195 203 } catch (Exception e) {
196 204 throw new DemoiselleException(bundle.getString(
... ... @@ -233,6 +241,8 @@ public class MonitoringManager {
233 241 ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass);
234 242  
235 243 monitoringExtension.shutdown(this.getManagedTypes());
  244 +
  245 + logger.debug( bundle.getString("management-debug-removing-management-extension",monitoringExtension.getClass().getCanonicalName()) );
236 246  
237 247 }
238 248  
... ... @@ -246,6 +256,8 @@ public class MonitoringManager {
246 256 .getReference(monitoringExtensionClass);
247 257  
248 258 monitoringExtension.initialize(this.getManagedTypes());
  259 +
  260 + logger.debug( bundle.getString("management-debug-processing-management-extension",monitoringExtension.getClass().getCanonicalName()) );
249 261  
250 262 }
251 263  
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/notification/NotificationManager.java
... ... @@ -5,6 +5,7 @@ import java.io.Serializable;
5 5 import javax.enterprise.context.ApplicationScoped;
6 6 import javax.enterprise.event.Event;
7 7 import javax.enterprise.event.Observes;
  8 +import javax.enterprise.util.AnnotationLiteral;
8 9 import javax.inject.Inject;
9 10  
10 11 import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;
... ... @@ -48,16 +49,32 @@ public class NotificationManager implements Serializable{
48 49 * @param notification The notification to send
49 50 */
50 51 public void sendNotification(Notification notification) {
51   - genericNotificationEvent.fire(new NotificationEvent(notification));
  52 + if (! AttributeChangeNotification.class.isInstance(notification) ){
  53 + getGenericNotificationEvent().fire(new NotificationEvent(notification));
  54 + }
  55 + else{
  56 + getAttributeChangeNotificationEvent().fire(new NotificationEvent(notification));
  57 + }
  58 + }
  59 +
  60 + @SuppressWarnings("unchecked")
  61 + private Event<NotificationEvent> getGenericNotificationEvent() {
  62 + if (genericNotificationEvent==null){
  63 + genericNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<Generic>() {});
  64 + }
  65 +
  66 + return genericNotificationEvent;
52 67 }
53 68  
54   - /**
55   - * Sends a notification comunicating about a change of value for an attribute.
56   - *
57   - * @param notification Special notification communicating a change of value in an attribute.
58   - *
59   - */
60   - public void sendAttributeChangedMessage(AttributeChangeNotification notification){
61   - attributeChangeNotificationEvent.fire(new NotificationEvent(notification));
  69 + @SuppressWarnings("unchecked")
  70 + private Event<NotificationEvent> getAttributeChangeNotificationEvent() {
  71 + if (attributeChangeNotificationEvent==null){
  72 + attributeChangeNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<AttributeChange>() {});
  73 + }
  74 +
  75 + return attributeChangeNotificationEvent;
62 76 }
  77 +
  78 +
  79 +
63 80 }
... ...
impl/core/src/main/resources/demoiselle-core-bundle.properties
... ... @@ -98,15 +98,19 @@ user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1}
98 98  
99 99 authenticator-not-defined=Nenhum mecanismo de autentica\u00E7\u00E3o foi definido. Para utilizar {0} \u00E9 preciso definir a propriedade frameworkdemoiselle.security.authenticator.class como mecanismo de autentica\u00E7\u00E3o desejado no arquivo demoiselle.properties.
100 100  
101   -management-null-class-defined=A classe gerenciada informada n\u00E3o pode ser nula.
102   -management-no-annotation-found=Classe {0} precisa ser anotada com @Managed.
103   -management-invalid-property-no-getter-setter=Falha ao inicializar classe gerenciada {0}, n\u00E3o foi encontrado um m\u00E9todo get ou m\u00E9todo set para a propriedade {1}.
104   -management-invalid-property-as-operation=Falha ao inicializar classe gerenciada {0}, n\u00E3o \u00E9 poss\u00EDvel declarar uma propriedade cujo m\u00E9todo get ou set \u00E9 uma opera\u00E7\u00E3o.
105   -management-introspection-error=Erro ao ler atributos da classe gerenciada {0}.
106   -management-type-not-found=A classe gerenciada informada n\u00E3o existe: {0}.
107   -management-invoke-error=Erro ao tentar invocar a opera\u00E7\u00E3o "{0}" da classe gerenciada, a opera\u00E7\u00E3o n\u00E3o foi encontrada.
108   -management-debug-acessing-property=Acessando propriedade {0} da classe gerenciada {1}.
109   -management-debug-setting-property=Definindo novo valor para propriedade {0} da classe gerenciada {1}.
110   -management-debug-invoking-operation=Invocando opera\u00E7\u00E3o {0} da classe gerenciada {1}.
111   -management-debug-starting-custom-context=Levantando contexto {0} para executar comando na classe gerenciada {1}.
112   -management-debug-stoping-custom-context=Desligando contexto {0} para classe gerenciada {1}.
  101 +management-notification-attribute-changed=O atributo [{0}] da classe gerenciada [{1}] foi alterado
  102 +management-null-class-defined=A classe gerenciada informada n\u00E3o pode ser nula
  103 +management-no-annotation-found=Classe {0} precisa ser anotada com @Managed
  104 +management-invalid-property-no-getter-setter=Falha ao inicializar classe gerenciada {0}, n\u00E3o foi encontrado um m\u00E9todo get ou m\u00E9todo set para a propriedade {1}
  105 +management-invalid-property-as-operation=Falha ao inicializar classe gerenciada {0}, n\u00E3o \u00E9 poss\u00EDvel declarar uma propriedade cujo m\u00E9todo get ou set \u00E9 uma opera\u00E7\u00E3o
  106 +management-introspection-error=Erro ao ler atributos da classe gerenciada {0}
  107 +management-type-not-found=A classe gerenciada informada n\u00E3o existe\: {0}
  108 +management-invoke-error=Erro ao tentar invocar a opera\u00E7\u00E3o "{0}" da classe gerenciada, a opera\u00E7\u00E3o n\u00E3o foi encontrada
  109 +management-debug-acessing-property=Acessando propriedade {0} da classe gerenciada {1}
  110 +management-debug-setting-property=Definindo novo valor para propriedade {0} da classe gerenciada {1}
  111 +management-debug-invoking-operation=Invocando opera\u00E7\u00E3o {0} da classe gerenciada {1}
  112 +management-debug-starting-custom-context=Levantando contexto {0} para executar comando na classe gerenciada {1}
  113 +management-debug-stoping-custom-context=Desligando contexto {0} para classe gerenciada {1}
  114 +management-debug-registering-managed-type=Registrando classe gerenciada [{0}]
  115 +management-debug-processing-management-extension=Processando extens\u00E3o de gerenciamento [{0}]
  116 +management-debug-removing-management-extension=Desativando extens\u00E3o de gerenciamento [{0}]
113 117 \ No newline at end of file
... ...
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 +}
... ...
impl/core/src/test/java/lifecycle/LifecycleClassWithPriority.java
... ... @@ -1,89 +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 lifecycle;
38   -
39   -import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY;
40   -import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY;
41   -
42   -import java.util.ArrayList;
43   -import java.util.List;
44   -
45   -import javax.enterprise.context.ApplicationScoped;
46   -
47   -import br.gov.frameworkdemoiselle.annotation.Priority;
48   -import br.gov.frameworkdemoiselle.lifecycle.Shutdown;
49   -import br.gov.frameworkdemoiselle.lifecycle.Startup;
50   -
51   -@ApplicationScoped
52   -public class LifecycleClassWithPriority {
53   -
54   - private List<Integer> priorityStartup = new ArrayList<Integer>();
55   -
56   - private List<Integer> priorityShutdown = new ArrayList<Integer>();
57   -
58   - public List<Integer> getPriorityStartup() {
59   - return priorityStartup;
60   - }
61   -
62   - public List<Integer> getPriorityShutdown() {
63   - return priorityShutdown;
64   - }
65   -
66   - @Startup
67   - @Priority(MIN_PRIORITY)
68   - public void loadWithMinPriority() {
69   - priorityStartup.add(2);
70   - }
71   -
72   - @Startup
73   - @Priority(MAX_PRIORITY)
74   - public void loadWithMaxPriority() {
75   - priorityStartup.add(1);
76   - }
77   -
78   - @Shutdown
79   - @Priority(MIN_PRIORITY)
80   - public void unloadWithMinPriority() {
81   - priorityShutdown.add(1);
82   - }
83   -
84   - @Shutdown
85   - @Priority(MAX_PRIORITY)
86   - public void unloadWithMaxPriority() {
87   - priorityShutdown.add(2);
88   - }
89   -}
impl/core/src/test/java/lifecycle/LifecycleSimple.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 lifecycle;
38   -
39   -import javax.enterprise.context.ApplicationScoped;
40   -
41   -import br.gov.frameworkdemoiselle.lifecycle.Shutdown;
42   -import br.gov.frameworkdemoiselle.lifecycle.Startup;
43   -
44   -@ApplicationScoped
45   -public class LifecycleSimple {
46   -
47   - private boolean startup = false;
48   -
49   - private boolean shutdown = false;
50   -
51   - public boolean isStartup() {
52   - return startup;
53   - }
54   -
55   - public boolean isShutdown() {
56   - return shutdown;
57   - }
58   -
59   - @Startup
60   - public void load() {
61   - startup = true;
62   - }
63   -
64   - @Shutdown
65   - public void unload() {
66   - shutdown = true;
67   - }
68   -}
impl/core/src/test/java/lifecycle/LifecycleSimpleTest.java
... ... @@ -1,83 +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 lifecycle;
38   -
39   -import javax.inject.Inject;
40   -
41   -import junit.framework.Assert;
42   -
43   -import org.jboss.arquillian.container.test.api.Deployment;
44   -import org.jboss.arquillian.junit.Arquillian;
45   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
46   -import org.junit.Test;
47   -import org.junit.runner.RunWith;
48   -
49   -import test.Tests;
50   -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
51   -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
52   -import br.gov.frameworkdemoiselle.util.Beans;
53   -
54   -@RunWith(Arquillian.class)
55   -public class LifecycleSimpleTest {
56   -
57   - @Inject
58   - private LifecycleSimple simpleClass;
59   -
60   - @Deployment
61   - public static JavaArchive createDeployment() {
62   - JavaArchive deployment = Tests.createDeployment(LifecycleSimpleTest.class);
63   - return deployment;
64   - }
65   -
66   - @Test
67   - public void testStartup() {
68   - Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
69   - });
70   -
71   - Assert.assertEquals(true, simpleClass.isStartup());
72   - }
73   -
74   - @Test
75   - public void testShutdown() {
76   - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
77   - });
78   -
79   - Assert.assertEquals(true, simpleClass.isShutdown());
80   - }
81   -
82   -}
83   -
impl/core/src/test/java/lifecycle/LifecycleWithPriorityTest.java
... ... @@ -1,91 +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 lifecycle;
38   -
39   -import java.util.ArrayList;
40   -import java.util.List;
41   -
42   -import javax.inject.Inject;
43   -
44   -import junit.framework.Assert;
45   -
46   -import org.jboss.arquillian.container.test.api.Deployment;
47   -import org.jboss.arquillian.junit.Arquillian;
48   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
49   -import org.junit.Test;
50   -import org.junit.runner.RunWith;
51   -
52   -import test.Tests;
53   -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
54   -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
55   -import br.gov.frameworkdemoiselle.util.Beans;
56   -
57   -@RunWith(Arquillian.class)
58   -public class LifecycleWithPriorityTest {
59   -
60   - @Inject
61   - private LifecycleClassWithPriority lifecycleClassWithPriority;
62   -
63   - List<Integer> expected = new ArrayList<Integer>();
64   -
65   - @Deployment
66   - public static JavaArchive createDeployment() {
67   - JavaArchive deployment = Tests.createDeployment(LifecycleWithPriorityTest.class);
68   - return deployment;
69   - }
70   -
71   - @Test
72   - public void testStartup() {
73   - Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
74   - });
75   - expected.add(1);
76   - expected.add(2);
77   -
78   - Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityStartup());
79   - }
80   -
81   - @Test
82   - public void testShutdown() {
83   - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
84   - });
85   - expected.clear();
86   - expected.add(2);
87   - expected.add(1);
88   -
89   - Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityShutdown());
90   - }
91   -}
impl/core/src/test/java/lifecycle/LifecycleWithoutPriority.java
... ... @@ -1,92 +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 lifecycle;
38   -
39   -import java.util.ArrayList;
40   -import java.util.List;
41   -
42   -import javax.enterprise.context.ApplicationScoped;
43   -
44   -import br.gov.frameworkdemoiselle.lifecycle.Shutdown;
45   -import br.gov.frameworkdemoiselle.lifecycle.Startup;
46   -
47   -@ApplicationScoped
48   -public class LifecycleWithoutPriority {
49   -
50   - private List<Integer> priorityStartup = new ArrayList<Integer>();
51   -
52   - private List<Integer> priorityShutdown = new ArrayList<Integer>();
53   -
54   - public List<Integer> getPriorityStartup() {
55   - return priorityStartup;
56   - }
57   -
58   - public List<Integer> getPriorityShutdown() {
59   - return priorityShutdown;
60   - }
61   -
62   - @Startup
63   - public void loadWithoutPriorityFirst() {
64   - priorityStartup.add(1);
65   - }
66   -
67   - @Startup
68   - public void loadWithoutPrioritySecond() {
69   - priorityStartup.add(3);
70   - }
71   -
72   - @Startup
73   - public void loadWithoutPriorityThird() {
74   - priorityStartup.add(2);
75   - }
76   -
77   - @Shutdown
78   - public void unloadWithoutPriorityFirst() {
79   - priorityShutdown.add(3);
80   - }
81   -
82   - @Shutdown
83   - public void unloadWithoutPrioritySecond() {
84   - priorityShutdown.add(2);
85   - }
86   -
87   - @Shutdown
88   - public void unloadWithoutPriorityThird() {
89   - priorityShutdown.add(1);
90   - }
91   -
92   -}
impl/core/src/test/java/lifecycle/LifecycleWithoutPriorityTest.java
... ... @@ -1,94 +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 lifecycle;
38   -
39   -import java.util.ArrayList;
40   -import java.util.List;
41   -
42   -import javax.inject.Inject;
43   -
44   -import junit.framework.Assert;
45   -
46   -import org.jboss.arquillian.container.test.api.Deployment;
47   -import org.jboss.arquillian.junit.Arquillian;
48   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
49   -import org.junit.Test;
50   -import org.junit.runner.RunWith;
51   -
52   -import test.Tests;
53   -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
54   -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
55   -import br.gov.frameworkdemoiselle.util.Beans;
56   -
57   -@RunWith(Arquillian.class)
58   -public class LifecycleWithoutPriorityTest {
59   -
60   - @Inject
61   - private LifecycleWithoutPriority lifecycleWithoutPriority;
62   -
63   - List<Integer> expected = new ArrayList<Integer>();
64   -
65   - @Deployment
66   - public static JavaArchive createDeployment() {
67   - JavaArchive deployment = Tests.createDeployment(LifecycleWithoutPriorityTest.class);
68   - return deployment;
69   - }
70   -
71   - @Test
72   - public void testStartup() {
73   - Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
74   - });
75   - expected.add(1);
76   - expected.add(3);
77   - expected.add(2);
78   -
79   - Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityStartup());
80   - }
81   -
82   - @Test
83   - public void testShutdown() {
84   - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
85   - });
86   - expected.clear();
87   - expected.add(3);
88   - expected.add(2);
89   - expected.add(1);
90   -
91   - Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityShutdown());
92   - }
93   -
94   -}
impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java 0 → 100644
... ... @@ -0,0 +1,76 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package lifecycle.shutdown.priority;
  38 +
  39 +import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY;
  40 +import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY;
  41 +
  42 +import java.util.ArrayList;
  43 +import java.util.List;
  44 +
  45 +import javax.enterprise.context.ApplicationScoped;
  46 +
  47 +import br.gov.frameworkdemoiselle.annotation.Priority;
  48 +import br.gov.frameworkdemoiselle.lifecycle.Shutdown;
  49 +
  50 +@ApplicationScoped
  51 +public class ShutdownWithPriority {
  52 +
  53 + private List<Integer> listShutdown = new ArrayList<Integer>();
  54 +
  55 + public List<Integer> getListShutdown() {
  56 + return listShutdown;
  57 + }
  58 +
  59 + @Shutdown
  60 + @Priority(MIN_PRIORITY)
  61 + public void unloadWithMinPriority() {
  62 + listShutdown.add(3);
  63 + }
  64 +
  65 + @Shutdown
  66 + @Priority(1)
  67 + public void unloadWithPriority1() {
  68 + listShutdown.add(2);
  69 + }
  70 +
  71 + @Shutdown
  72 + @Priority(MAX_PRIORITY)
  73 + public void unloadWithMaxPriority() {
  74 + listShutdown.add(1);
  75 + }
  76 +}
... ...
impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriorityTest.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 lifecycle.shutdown.priority;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.inject.Inject;
  43 +
  44 +import junit.framework.Assert;
  45 +
  46 +import org.jboss.arquillian.container.test.api.Deployment;
  47 +import org.jboss.arquillian.junit.Arquillian;
  48 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  49 +import org.junit.Before;
  50 +import org.junit.Test;
  51 +import org.junit.runner.RunWith;
  52 +
  53 +import test.Tests;
  54 +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
  55 +import br.gov.frameworkdemoiselle.util.Beans;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +public class ShutdownWithPriorityTest {
  59 +
  60 + @Inject
  61 + private ShutdownWithPriority shutdownWithPriority;
  62 +
  63 + List<Integer> expected = new ArrayList<Integer>();
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(ShutdownWithPriorityTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Before
  72 + public void fireEvent() {
  73 + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
  74 + });
  75 + }
  76 +
  77 + @Test
  78 + public void shutdownWithPriority() {
  79 + expected.add(1);
  80 + expected.add(2);
  81 + expected.add(3);
  82 +
  83 + Assert.assertEquals(expected, shutdownWithPriority.getListShutdown());
  84 + }
  85 +}
... ...
impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimple.java 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package lifecycle.shutdown.simple;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.enterprise.context.ApplicationScoped;
  43 +
  44 +import br.gov.frameworkdemoiselle.lifecycle.Shutdown;
  45 +
  46 +@ApplicationScoped
  47 +public class ShutdownSimple {
  48 +
  49 + private List<Integer> listShutdown = new ArrayList<Integer>();
  50 +
  51 + public List<Integer> getListShutdown() {
  52 + return listShutdown;
  53 + }
  54 +
  55 + @Shutdown
  56 + public void unloadWithoutPriorityFirst() {
  57 + listShutdown.add(3);
  58 + }
  59 +
  60 + @Shutdown
  61 + public void unloadWithoutPrioritySecond() {
  62 + listShutdown.add(2);
  63 + }
  64 +
  65 + @Shutdown
  66 + public void unloadWithoutPriorityThird() {
  67 + listShutdown.add(1);
  68 + }
  69 +}
... ...
impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimpleTest.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 lifecycle.shutdown.simple;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.inject.Inject;
  43 +
  44 +import junit.framework.Assert;
  45 +
  46 +import org.jboss.arquillian.container.test.api.Deployment;
  47 +import org.jboss.arquillian.junit.Arquillian;
  48 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  49 +import org.junit.Before;
  50 +import org.junit.Test;
  51 +import org.junit.runner.RunWith;
  52 +
  53 +import test.Tests;
  54 +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
  55 +import br.gov.frameworkdemoiselle.util.Beans;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +public class ShutdownSimpleTest {
  59 +
  60 + @Inject
  61 + private ShutdownSimple shutdownSimple;
  62 +
  63 + List<Integer> expected = new ArrayList<Integer>();
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(ShutdownSimpleTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Before
  72 + public void fireEvent() {
  73 + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
  74 + });
  75 + }
  76 +
  77 + @Test
  78 + public void testShutdown() {
  79 + expected.add(3);
  80 + expected.add(2);
  81 + expected.add(1);
  82 +
  83 + Assert.assertEquals(expected, shutdownSimple.getListShutdown());
  84 + }
  85 +}
... ...
impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriority.java 0 → 100644
... ... @@ -0,0 +1,76 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package lifecycle.startup.priority;
  38 +
  39 +import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY;
  40 +import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY;
  41 +
  42 +import java.util.ArrayList;
  43 +import java.util.List;
  44 +
  45 +import javax.enterprise.context.ApplicationScoped;
  46 +
  47 +import br.gov.frameworkdemoiselle.annotation.Priority;
  48 +import br.gov.frameworkdemoiselle.lifecycle.Startup;
  49 +
  50 +@ApplicationScoped
  51 +public class StartupWithPriority {
  52 +
  53 + private List<Integer> priorityStartup = new ArrayList<Integer>();
  54 +
  55 + public List<Integer> getPriorityStartup() {
  56 + return priorityStartup;
  57 + }
  58 +
  59 + @Startup
  60 + @Priority(MIN_PRIORITY)
  61 + public void loadWithMinPriority() {
  62 + priorityStartup.add(3);
  63 + }
  64 +
  65 + @Startup
  66 + @Priority(1)
  67 + public void loadWithPriority1() {
  68 + priorityStartup.add(2);
  69 + }
  70 +
  71 + @Startup
  72 + @Priority(MAX_PRIORITY)
  73 + public void loadWithMaxPriority() {
  74 + priorityStartup.add(1);
  75 + }
  76 +}
... ...
impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.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 lifecycle.startup.priority;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.inject.Inject;
  43 +
  44 +import junit.framework.Assert;
  45 +
  46 +import org.jboss.arquillian.container.test.api.Deployment;
  47 +import org.jboss.arquillian.junit.Arquillian;
  48 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  49 +import org.junit.Before;
  50 +import org.junit.Test;
  51 +import org.junit.runner.RunWith;
  52 +
  53 +import test.Tests;
  54 +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
  55 +import br.gov.frameworkdemoiselle.util.Beans;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +public class StartupWithPriorityTest {
  59 +
  60 + @Inject
  61 + private StartupWithPriority stratupWithPriority;
  62 +
  63 + List<Integer> expected = new ArrayList<Integer>();
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(StartupWithPriorityTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Before
  72 + public void fireEvent() {
  73 + Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
  74 + });
  75 + }
  76 +
  77 + @Test
  78 + public void startupWithPriority() {
  79 + expected.add(1);
  80 + expected.add(2);
  81 + expected.add(3);
  82 +
  83 + Assert.assertEquals(expected, stratupWithPriority.getPriorityStartup());
  84 + }
  85 +}
... ...
impl/core/src/test/java/lifecycle/startup/simple/StartupSimple.java 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package lifecycle.startup.simple;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.enterprise.context.ApplicationScoped;
  43 +
  44 +import br.gov.frameworkdemoiselle.lifecycle.Startup;
  45 +
  46 +@ApplicationScoped
  47 +public class StartupSimple {
  48 +
  49 + private List<Integer> listStartup = new ArrayList<Integer>();
  50 +
  51 + public List<Integer> getListStartup() {
  52 + return listStartup;
  53 + }
  54 +
  55 + @Startup
  56 + public void loadWithoutPriorityFirst() {
  57 + listStartup.add(1);
  58 + }
  59 +
  60 + @Startup
  61 + public void loadWithoutPrioritySecond() {
  62 + listStartup.add(3);
  63 + }
  64 +
  65 + @Startup
  66 + public void loadWithoutPriorityThird() {
  67 + listStartup.add(2);
  68 + }
  69 +}
... ...
impl/core/src/test/java/lifecycle/startup/simple/StartupSimpleTest.java 0 → 100644
... ... @@ -0,0 +1,86 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package lifecycle.startup.simple;
  38 +
  39 +import java.util.ArrayList;
  40 +import java.util.List;
  41 +
  42 +import javax.inject.Inject;
  43 +
  44 +import junit.framework.Assert;
  45 +
  46 +import org.jboss.arquillian.container.test.api.Deployment;
  47 +import org.jboss.arquillian.junit.Arquillian;
  48 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  49 +import org.junit.Before;
  50 +import org.junit.Test;
  51 +import org.junit.runner.RunWith;
  52 +
  53 +import test.Tests;
  54 +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
  55 +import br.gov.frameworkdemoiselle.util.Beans;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +public class StartupSimpleTest {
  59 +
  60 + @Inject
  61 + private StartupSimple startupSimple;
  62 +
  63 + List<Integer> expected = new ArrayList<Integer>();
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(StartupSimpleTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Before
  72 + public void fireEvent() {
  73 + Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
  74 + });
  75 + }
  76 +
  77 + @Test
  78 + public void startup() {
  79 + expected.add(1);
  80 + expected.add(3);
  81 + expected.add(2);
  82 +
  83 + Assert.assertEquals(expected, startupSimple.getListStartup());
  84 + }
  85 +}
  86 +
... ...
impl/core/src/test/java/management/DummyManagedClass.java
... ... @@ -1,74 +0,0 @@
1   -package management;
2   -
3   -import java.util.UUID;
4   -
5   -import br.gov.frameworkdemoiselle.management.annotation.Managed;
6   -import br.gov.frameworkdemoiselle.management.annotation.Operation;
7   -import br.gov.frameworkdemoiselle.management.annotation.Property;
8   -import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues;
9   -import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues.ValueType;
10   -
11   -@Managed
12   -public class DummyManagedClass {
13   -
14   - @Property
15   - @AllowedValues(allows={"f","m","F","M"},valueType=ValueType.INTEGER)
16   - private Integer id;
17   -
18   - @Property
19   - private String uuid;
20   -
21   - @Property
22   - private String writeOnlyProperty;
23   -
24   - /**
25   - * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas uma letra.
26   - */
27   - @Property
28   - private Integer a;
29   -
30   - /**
31   - * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas letras maiúsculas.
32   - */
33   - @Property
34   - private Integer MAIUSCULO;
35   -
36   - public Integer getId() {
37   - return id;
38   - }
39   -
40   - public void setId(Integer id) {
41   - this.id = id;
42   - }
43   -
44   - public String getUuid() {
45   - return uuid;
46   - }
47   -
48   - public void setWriteOnlyProperty(String newValue){
49   - this.writeOnlyProperty = newValue;
50   - }
51   -
52   - public Integer getA() {
53   - return a;
54   - }
55   -
56   - public void setA(Integer a) {
57   - this.a = a;
58   - }
59   -
60   - public Integer getMAIUSCULO() {
61   - return MAIUSCULO;
62   - }
63   -
64   -
65   - public void setMAIUSCULO(Integer mAIUSCULO) {
66   - MAIUSCULO = mAIUSCULO;
67   - }
68   -
69   - @Operation(description="Generates a random UUID")
70   - public String generateUUID(){
71   - this.uuid = UUID.randomUUID().toString();
72   - return this.uuid;
73   - }
74   -}
impl/core/src/test/java/management/DummyManagementExtension.java
... ... @@ -1,29 +0,0 @@
1   -package management;
2   -
3   -import java.util.List;
4   -
5   -import javax.inject.Inject;
6   -
7   -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;
8   -import br.gov.frameworkdemoiselle.management.internal.ManagedType;
9   -
10   -public class DummyManagementExtension implements ManagementExtension {
11   -
12   - @Inject
13   - private ManagedClassStore store;
14   -
15   - @Override
16   - public void initialize(List<ManagedType> managedTypes) {
17   - // Armazena os beans managed detectados neste store,
18   - // para depois serem testados.
19   - store.setManagedTypes(managedTypes);
20   - }
21   -
22   - @Override
23   - public void shutdown(List<ManagedType> managedTypes) {
24   - // Limpa o store, depois o teste verificará se
25   - // o processo de shutdown rodou e limpou o store.
26   - store.setManagedTypes(null);
27   - }
28   -
29   -}
impl/core/src/test/java/management/ManagedClassStore.java
1 1 package management;
2 2  
  3 +import java.util.ArrayList;
  4 +import java.util.Collection;
3 5 import java.util.List;
4 6  
5 7 import javax.enterprise.context.ApplicationScoped;
... ... @@ -9,15 +11,15 @@ import br.gov.frameworkdemoiselle.management.internal.ManagedType;
9 11 @ApplicationScoped
10 12 public class ManagedClassStore {
11 13  
12   - private List<ManagedType> managedTypes = null;
  14 + private List<ManagedType> managedTypes = new ArrayList<ManagedType>();
13 15  
14 16  
15 17 public List<ManagedType> getManagedTypes() {
16 18 return managedTypes;
17 19 }
18 20  
19   - public void setManagedTypes(List<ManagedType> managedTypes) {
20   - this.managedTypes = managedTypes;
  21 + public void addManagedTypes(Collection<ManagedType> managedTypes){
  22 + this.managedTypes.addAll(managedTypes);
21 23 }
22 24  
23 25 }
... ...
impl/core/src/test/java/management/ManagementBootstrapTest.java
... ... @@ -1,68 +0,0 @@
1   -package management;
2   -
3   -import javax.inject.Inject;
4   -
5   -import org.jboss.arquillian.container.test.api.Deployment;
6   -import org.jboss.arquillian.junit.Arquillian;
7   -import org.jboss.shrinkwrap.api.spec.JavaArchive;
8   -import org.junit.Assert;
9   -import org.junit.Test;
10   -import org.junit.runner.RunWith;
11   -
12   -import test.Tests;
13   -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
14   -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;
15   -import br.gov.frameworkdemoiselle.util.Beans;
16   -
17   -
18   -@RunWith(Arquillian.class)
19   -public class ManagementBootstrapTest {
20   -
21   - @Inject
22   - private ManagedClassStore store;
23   -
24   - @Deployment
25   - public static JavaArchive createDeployment() {
26   - JavaArchive deployment = Tests.createDeployment(ManagementBootstrapTest.class);
27   -
28   - /*deployment
29   - .addClass(ManagedClassStore.class)
30   - .addClass(DummyManagedClass.class)
31   - .addClass(DummyManagementExtension.class);*/
32   -
33   - return deployment;
34   - }
35   -
36   - /**
37   - * Test if a a management extension (a library that implements {@link ManagementExtension}) is correctly detected.
38   - */
39   - @Test
40   - public void testManagementExtensionRegistration(){
41   -
42   - //"store" é application scoped e é usado pelo DummyManagementExtension para
43   - //armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente,
44   - //ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
45   - Assert.assertNotNull(store.getManagedTypes());
46   - Assert.assertEquals(1, store.getManagedTypes().size());
47   -
48   - }
49   -
50   - /**
51   - * Test if a a management extension's (a library that implements {@link ManagementExtension}) shutdown
52   - * method is correctly called upon application shutdown.
53   - */
54   - @Test
55   - public void testManagementExtensionShutdown(){
56   -
57   - //"store" é application scoped e é usado pelo DummyManagementExtension para
58   - //armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente,
59   - //ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
60   - //Nós então disparamos o evento de shutdown onde ele deverá limpar o store.
61   - Assert.assertNotNull(store.getManagedTypes());
62   - Assert.assertEquals(1, store.getManagedTypes().size());
63   -
64   - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {});
65   - Assert.assertNull(store.getManagedTypes());
66   - }
67   -
68   -}
impl/core/src/test/java/management/ManagementBootstrapTestCase.java 0 → 100644
... ... @@ -0,0 +1,124 @@
  1 +package management;
  2 +
  3 +import java.io.File;
  4 +import java.util.List;
  5 +
  6 +import management.testclasses.DummyManagedClass;
  7 +import management.testclasses.DummyManagedClassPropertyError;
  8 +import management.testclasses.DummyManagementExtension;
  9 +
  10 +import org.jboss.arquillian.container.test.api.Deployer;
  11 +import org.jboss.arquillian.container.test.api.Deployment;
  12 +import org.jboss.arquillian.junit.Arquillian;
  13 +import org.jboss.arquillian.test.api.ArquillianResource;
  14 +import org.jboss.shrinkwrap.api.ShrinkWrap;
  15 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  16 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  17 +import org.junit.Assert;
  18 +import org.junit.Test;
  19 +import org.junit.runner.RunWith;
  20 +
  21 +import test.LocaleProducer;
  22 +import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;
  23 +import br.gov.frameworkdemoiselle.management.internal.ManagedType;
  24 +import br.gov.frameworkdemoiselle.util.Beans;
  25 +
  26 +@RunWith(Arquillian.class)
  27 +public class ManagementBootstrapTestCase {
  28 +
  29 + @ArquillianResource
  30 + private Deployer deployer;
  31 +
  32 + /**
  33 + * Deployment to test normal deployment behaviour
  34 + *
  35 + */
  36 + @Deployment(name = "default",managed=false,testable=false)
  37 + public static JavaArchive createDeployment() {
  38 + return ShrinkWrap
  39 + .create(JavaArchive.class)
  40 + .addClass(LocaleProducer.class)
  41 + .addPackages(true, "br")
  42 + .addAsResource(new FileAsset(new File("src/test/resources/test/beans.xml")), "beans.xml")
  43 + .addAsManifestResource(
  44 + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
  45 + "services/javax.enterprise.inject.spi.Extension")
  46 + .addPackages(false, ManagementBootstrapTestCase.class.getPackage())
  47 + .addClasses(DummyManagementExtension.class,DummyManagedClass.class);
  48 + }
  49 +
  50 + /**
  51 + * Deployment containing a malformed managed class. Tests using this deployment will
  52 + * check if deployment fails (it has to).
  53 + *
  54 + */
  55 + @Deployment(name = "wrong_annotation",managed=false,testable=false)
  56 + public static JavaArchive createWrongAnnotationDeployment() {
  57 + return ShrinkWrap
  58 + .create(JavaArchive.class)
  59 + .addClass(LocaleProducer.class)
  60 + .addPackages(true, "br")
  61 + .addAsResource(new FileAsset(new File("src/test/resources/test/beans.xml")), "beans.xml")
  62 + .addAsManifestResource(
  63 + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
  64 + "services/javax.enterprise.inject.spi.Extension")
  65 + .addPackages(false, ManagementBootstrapTestCase.class.getPackage())
  66 + .addClasses(DummyManagementExtension.class,DummyManagedClassPropertyError.class);
  67 + }
  68 +
  69 + /**
  70 + * Test if a a management extension (a library that implements {@link ManagementExtension}) is correctly detected.
  71 + */
  72 + @Test
  73 + public void testManagementExtensionRegistration() {
  74 + deployer.deploy("default");
  75 +
  76 + // "store" é application scoped e é usado pelo DummyManagementExtension para
  77 + // armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente,
  78 + // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
  79 + ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
  80 +
  81 + Assert.assertEquals(1, store.getManagedTypes().size());
  82 +
  83 + deployer.undeploy("default");
  84 + }
  85 +
  86 + /**
  87 + * Test if a a management extension's shutdown method is
  88 + * correctly called upon application shutdown.
  89 + */
  90 + @Test
  91 + public void testManagementExtensionShutdown() {
  92 + deployer.deploy("default");
  93 +
  94 + // "store" é application scoped e é usado pelo DummyManagementExtension para
  95 + // armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente,
  96 + // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
  97 + // Nós então disparamos o evento de shutdown onde ele deverá limpar o store.
  98 + ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
  99 +
  100 + //Detecta se a classe anotada foi detectada
  101 + List<ManagedType> managedTypes = store.getManagedTypes();
  102 + Assert.assertEquals(1, managedTypes.size());
  103 +
  104 + deployer.undeploy("default");
  105 +
  106 + //Após o "undeploy", o ciclo de vida precisa ter removido a classe gerenciada da lista.
  107 + Assert.assertEquals(0, managedTypes.size());
  108 + }
  109 +
  110 + @Test
  111 + public void testWrongAnnotation(){
  112 +
  113 + try{
  114 + deployer.deploy("wrong_annotation");
  115 +
  116 + //O processo de deploy precisa falhar, pois temos uma classe anotada com falhas.
  117 + Assert.fail();
  118 + }
  119 + catch(Exception e){
  120 + deployer.undeploy("wrong_annotation");
  121 + }
  122 + }
  123 +
  124 +}
... ...
impl/core/src/test/java/management/NotificationTestCase.java 0 → 100644
... ... @@ -0,0 +1,100 @@
  1 +package management;
  2 +
  3 +import java.io.File;
  4 +
  5 +import javax.inject.Inject;
  6 +
  7 +import junit.framework.Assert;
  8 +import management.testclasses.DummyManagedClass;
  9 +import management.testclasses.DummyNotificationListener;
  10 +
  11 +import org.jboss.arquillian.container.test.api.Deployment;
  12 +import org.jboss.arquillian.junit.Arquillian;
  13 +import org.jboss.shrinkwrap.api.ShrinkWrap;
  14 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  15 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  16 +import org.junit.Test;
  17 +import org.junit.runner.RunWith;
  18 +
  19 +import test.LocaleProducer;
  20 +import br.gov.frameworkdemoiselle.annotation.Name;
  21 +import br.gov.frameworkdemoiselle.management.internal.ManagedType;
  22 +import br.gov.frameworkdemoiselle.management.internal.MonitoringManager;
  23 +import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;
  24 +import br.gov.frameworkdemoiselle.management.notification.Notification;
  25 +import br.gov.frameworkdemoiselle.management.notification.NotificationManager;
  26 +import br.gov.frameworkdemoiselle.util.Beans;
  27 +import br.gov.frameworkdemoiselle.util.ResourceBundle;
  28 +
  29 +/**
  30 + * Test the {@link NotificationManager} with a dummy extension
  31 + * to check if notifications are correctly propagated
  32 + *
  33 + * @author serpro
  34 + *
  35 + */
  36 +@RunWith(Arquillian.class)
  37 +public class NotificationTestCase {
  38 +
  39 + @Inject
  40 + private NotificationManager manager;
  41 +
  42 + @Inject
  43 + @Name("demoiselle-core-bundle")
  44 + private ResourceBundle bundle;
  45 +
  46 + @Deployment
  47 + public static JavaArchive createDeployment() {
  48 + return ShrinkWrap
  49 + .create(JavaArchive.class)
  50 + .addClass(LocaleProducer.class)
  51 + .addPackages(true, "br")
  52 + .addAsResource(new FileAsset(new File("src/test/resources/test/beans.xml")), "beans.xml")
  53 + .addAsManifestResource(
  54 + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
  55 + "services/javax.enterprise.inject.spi.Extension")
  56 + .addPackages(false, ManagementBootstrapTestCase.class.getPackage())
  57 + .addClasses(DummyNotificationListener.class,DummyManagedClass.class);
  58 + }
  59 +
  60 + /**
  61 + * Test sending a normal notification
  62 + */
  63 + @Test
  64 + public void testSendGenericNotification(){
  65 + manager.sendNotification(new Notification("Test Message"));
  66 + DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
  67 + Assert.assertEquals("Test Message", listener.getMessage());
  68 + }
  69 +
  70 + /**
  71 + * Test sending a notification of change in attribute
  72 + */
  73 + @Test
  74 + public void testSendAttributeChangeNotification(){
  75 + manager.sendNotification(new AttributeChangeNotification("Test Message", "attribute", String.class, "old", "new"));
  76 + DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
  77 + Assert.assertEquals("Test Message - attribute", listener.getMessage());
  78 + }
  79 +
  80 + /**
  81 + * Test if notifications are automatically sent when an attribute from a managed
  82 + * class change values
  83 + */
  84 + @Test
  85 + public void testNotifyChangeManagedClass(){
  86 + MonitoringManager manager = Beans.getReference(MonitoringManager.class);
  87 +
  88 + for (ManagedType type : manager.getManagedTypes()){
  89 + if (type.getType().equals(DummyManagedClass.class)){
  90 + manager.setProperty(type, "id", new Integer(10));
  91 + break;
  92 + }
  93 + }
  94 +
  95 + DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
  96 + Assert.assertEquals( bundle.getString("management-notification-attribute-changed","id",DummyManagedClass.class.getCanonicalName()) + " - id"
  97 + , listener.getMessage());
  98 + }
  99 +
  100 +}
... ...
impl/core/src/test/java/management/testclasses/DummyManagedClass.java 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +package management.testclasses;
  2 +
  3 +import java.util.UUID;
  4 +
  5 +import br.gov.frameworkdemoiselle.management.annotation.Managed;
  6 +import br.gov.frameworkdemoiselle.management.annotation.Operation;
  7 +import br.gov.frameworkdemoiselle.management.annotation.Property;
  8 +import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues;
  9 +import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues.ValueType;
  10 +
  11 +@Managed
  12 +public class DummyManagedClass {
  13 +
  14 + @Property
  15 + @AllowedValues(allows={"f","m","F","M"},valueType=ValueType.INTEGER)
  16 + private Integer id;
  17 +
  18 + @Property
  19 + private String uuid;
  20 +
  21 + @Property
  22 + private String writeOnlyProperty;
  23 +
  24 + /**
  25 + * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas uma letra.
  26 + */
  27 + @Property
  28 + private Integer a;
  29 +
  30 + /**
  31 + * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas letras maiúsculas.
  32 + */
  33 + @Property
  34 + private Integer MAIUSCULO;
  35 +
  36 + public Integer getId() {
  37 + return id;
  38 + }
  39 +
  40 + public void setId(Integer id) {
  41 + this.id = id;
  42 + }
  43 +
  44 + public String getUuid() {
  45 + return uuid;
  46 + }
  47 +
  48 + public void setWriteOnlyProperty(String newValue){
  49 + this.writeOnlyProperty = newValue;
  50 + }
  51 +
  52 + public Integer getA() {
  53 + return a;
  54 + }
  55 +
  56 + public void setA(Integer a) {
  57 + this.a = a;
  58 + }
  59 +
  60 + public Integer getMAIUSCULO() {
  61 + return MAIUSCULO;
  62 + }
  63 +
  64 +
  65 + public void setMAIUSCULO(Integer mAIUSCULO) {
  66 + MAIUSCULO = mAIUSCULO;
  67 + }
  68 +
  69 + @Operation(description="Generates a random UUID")
  70 + public String generateUUID(){
  71 + this.uuid = UUID.randomUUID().toString();
  72 + return this.uuid;
  73 + }
  74 +}
... ...
impl/core/src/test/java/management/testclasses/DummyManagedClassPropertyError.java 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +package management.testclasses;
  2 +
  3 +import br.gov.frameworkdemoiselle.management.annotation.Managed;
  4 +import br.gov.frameworkdemoiselle.management.annotation.Property;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * Used in tests to detect if the bootstrap detects wrong annotations
  10 + *
  11 + * @author serpro
  12 + *
  13 + */
  14 +@Managed
  15 +public class DummyManagedClassPropertyError {
  16 +
  17 + /**
  18 + * Property with no setter or getter
  19 + */
  20 + @Property
  21 + private Long property;
  22 +
  23 +}
... ...
impl/core/src/test/java/management/testclasses/DummyManagementExtension.java 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +package management.testclasses;
  2 +
  3 +import java.util.List;
  4 +
  5 +import javax.inject.Inject;
  6 +
  7 +import management.ManagedClassStore;
  8 +
  9 +import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;
  10 +import br.gov.frameworkdemoiselle.management.internal.ManagedType;
  11 +
  12 +public class DummyManagementExtension implements ManagementExtension {
  13 +
  14 + @Inject
  15 + private ManagedClassStore store;
  16 +
  17 + @Override
  18 + public void initialize(List<ManagedType> managedTypes) {
  19 + // Armazena os beans managed detectados neste store,
  20 + // para depois serem testados.
  21 + store.addManagedTypes(managedTypes);
  22 + }
  23 +
  24 + @Override
  25 + public void shutdown(List<ManagedType> managedTypes) {
  26 + // Limpa o store, depois o teste verificará se
  27 + // o processo de shutdown rodou e limpou o store.
  28 + store.getManagedTypes().clear();
  29 + }
  30 +
  31 +}
... ...
impl/core/src/test/java/management/testclasses/DummyNotificationListener.java 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +package management.testclasses;
  2 +
  3 +import javax.enterprise.context.ApplicationScoped;
  4 +import javax.enterprise.event.Observes;
  5 +
  6 +import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;
  7 +import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.AttributeChange;
  8 +import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.Generic;
  9 +import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;
  10 +import br.gov.frameworkdemoiselle.management.notification.NotificationManager;
  11 +
  12 +/**
  13 + * Dummy class to test receiving of notifications sent by the {@link NotificationManager}
  14 + *
  15 + * @author serpro
  16 + *
  17 + */
  18 +@ApplicationScoped
  19 +public class DummyNotificationListener {
  20 +
  21 + private String message = null;
  22 +
  23 + public void listenNotification(@Observes @Generic NotificationEvent event){
  24 + message = event.getNotification().getMessage().toString();
  25 + }
  26 +
  27 + public void listenAttributeChangeNotification(@Observes @AttributeChange NotificationEvent event){
  28 + AttributeChangeNotification notification = (AttributeChangeNotification)event.getNotification();
  29 + message = notification.getMessage().toString() + " - " + notification.getAttributeName();
  30 + }
  31 +
  32 + public String getMessage() {
  33 + return message;
  34 + }
  35 +}
... ...
impl/core/src/test/java/resourcebundle/file/custom/ResourceBundleCustomTest.java
... ... @@ -66,13 +66,13 @@ public class ResourceBundleCustomTest {
66 66 }
67 67  
68 68 @Test
69   - public void testResourceFileCustom() {
  69 + public void loadResourceFileCustom() {
70 70 bundleCustom = Beans.getReference(ResourceBundleCustom.class);
71 71 Assert.assertEquals("mensagem em Portugues", bundleCustom.getMessage());
72 72 }
73 73  
74 74 @Test
75   - public void testResourceDefaultEnglish() {
  75 + public void loadResourceFileCustomEnglish() {
76 76 Locale.setDefault(Locale.ENGLISH);
77 77 bundleCustom = Beans.getReference(ResourceBundleCustom.class);
78 78 Assert.assertEquals("message in English", bundleCustom.getMessage());
... ...
impl/core/src/test/java/resourcebundle/file/defaultfile/ResourceBundleDefaultTest.java
... ... @@ -66,16 +66,23 @@ public class ResourceBundleDefaultTest {
66 66 }
67 67  
68 68 @Test
69   - public void testResourceDefault() {
  69 + public void loadResourceDefault() {
70 70 bundleDefault = Beans.getReference(ResourceBundleDefault.class);
71 71 Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage());
72 72 }
73 73  
74 74 @Test
75   - public void testResourceDefaultEnglish() {
  75 + public void loadResourceDefaultEnglish() {
76 76 Locale.setDefault(Locale.ENGLISH);
77 77 bundleDefault = Beans.getReference(ResourceBundleDefault.class);
78 78 Assert.assertEquals("message in English", bundleDefault.getMessage());
79 79 }
  80 +
  81 + @Test
  82 + public void loadResourceWithLocaleNotExist() {
  83 + Locale.setDefault(Locale.ITALY);
  84 + bundleDefault = Beans.getReference(ResourceBundleDefault.class);
  85 + Assert.assertEquals("mensagem em Portugues", bundleDefault.getMessage());
  86 + }
80 87  
81 88 }
... ...
impl/core/src/test/java/resourcebundle/file/empty/ResourceBundleEmptyTest.java
... ... @@ -67,7 +67,7 @@ public class ResourceBundleEmptyTest {
67 67 }
68 68  
69 69 @Test
70   - public void testResourceEmpty() {
  70 + public void loadEmptyFileResource() {
71 71 bundleDefault = Beans.getReference(ResourceBundleEmpty.class);
72 72 try {
73 73 bundleDefault.getMessage();
... ...
impl/core/src/test/java/resourcebundle/file/notexist/ResourceBundleFileNotExistTest.java
... ... @@ -64,7 +64,7 @@ public class ResourceBundleFileNotExistTest {
64 64 }
65 65  
66 66 @Test
67   - public void testResourceFileCustom() {
  67 + public void loadResourceFileNotExist() {
68 68 bundleFileNotExist = Beans.getReference(ResourceBundleFileNotExist.class);
69 69 try {
70 70 bundleFileNotExist.getMessage();
... ...
impl/core/src/test/java/resourcebundle/parameter/ResourceBundleWithParameter.java 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package resourcebundle.parameter;
  38 +
  39 +import javax.inject.Inject;
  40 +
  41 +import br.gov.frameworkdemoiselle.util.ResourceBundle;
  42 +
  43 +public class ResourceBundleWithParameter {
  44 +
  45 + @Inject
  46 + private ResourceBundle bundle;
  47 +
  48 + public ResourceBundle getBundle() {
  49 + return bundle;
  50 + }
  51 +}
... ...
impl/core/src/test/java/resourcebundle/parameter/ResourceBundleWithParameterTest.java 0 → 100644
... ... @@ -0,0 +1,115 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package resourcebundle.parameter;
  38 +
  39 +import junit.framework.Assert;
  40 +
  41 +import org.jboss.arquillian.container.test.api.Deployment;
  42 +import org.jboss.arquillian.junit.Arquillian;
  43 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  44 +import org.junit.Test;
  45 +import org.junit.runner.RunWith;
  46 +
  47 +import test.Tests;
  48 +import br.gov.frameworkdemoiselle.util.Beans;
  49 +
  50 +@RunWith(Arquillian.class)
  51 +public class ResourceBundleWithParameterTest {
  52 +
  53 + private ResourceBundleWithParameter bundleCustom;
  54 +
  55 + private static final String PATH = "src/test/resources/resourcebundle/parameter/";
  56 +
  57 + @Deployment
  58 + public static JavaArchive createDeployment() {
  59 + JavaArchive deployment = Tests.createDeployment(ResourceBundleWithParameterTest.class);
  60 + deployment.addAsResource(Tests.createFileAsset(PATH + "messages.properties"), "messages.properties");
  61 +
  62 + return deployment;
  63 + }
  64 +
  65 + @Test
  66 + public void loadKeyWithOneParameter() {
  67 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  68 + String expected = "Mensagem número 1";
  69 + String value = bundleCustom.getBundle().getString("messageOneParameter", "1");
  70 + Assert.assertEquals(expected, value);
  71 + }
  72 +
  73 + @Test
  74 + public void loadKeyWithTwoParameter() {
  75 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  76 + String expected = "Mensagem número 1 com 2 parâmetros";
  77 + String value = bundleCustom.getBundle().getString("messageTwoParameter", "1", "2");
  78 + Assert.assertEquals(expected, value);
  79 + }
  80 +
  81 + @Test
  82 + public void loadKeyWithoutParameter() {
  83 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  84 + String expected = "Mensagem";
  85 + String value = bundleCustom.getBundle().getString("messageWithoutParameter", "1", "2", "3");
  86 + Assert.assertEquals(expected, value);
  87 + }
  88 +
  89 + @Test
  90 + public void loadKeyWithStringParameter() {
  91 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  92 + String expected = "Mensagem número 1";
  93 + String value = bundleCustom.getBundle().getString("messageParameterString", "1");
  94 + Assert.assertNotSame(expected, value);
  95 +
  96 + expected = "Mensagem número {numero}";
  97 + Assert.assertEquals(expected, value);
  98 + }
  99 +
  100 + @Test
  101 + public void loadKeyWithMoreParameter() {
  102 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  103 + String expected = "Mensagem número 1";
  104 + String value = bundleCustom.getBundle().getString("messageOneParameter", "1", "2", "3");
  105 + Assert.assertEquals(expected, value);
  106 + }
  107 +
  108 + @Test
  109 + public void loadKeyWithLessParameter() {
  110 + bundleCustom = Beans.getReference(ResourceBundleWithParameter.class);
  111 + String expected = "Mensagem número 1 com {1} parâmetros";
  112 + String value = bundleCustom.getBundle().getString("messageTwoParameter", "1");
  113 + Assert.assertEquals(expected, value);
  114 + }
  115 +}
... ...
impl/core/src/test/resources/resourcebundle/parameter/messages.properties 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +# Demoiselle Framework
  2 +# Copyright (C) 2010 SERPRO
  3 +# ----------------------------------------------------------------------------
  4 +# This file is part of Demoiselle Framework.
  5 +#
  6 +# Demoiselle Framework is free software; you can redistribute it and/or
  7 +# modify it under the terms of the GNU Lesser General Public License version 3
  8 +# as published by the Free Software Foundation.
  9 +#
  10 +# This program is distributed in the hope that it will be useful,
  11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 +# GNU General Public License for more details.
  14 +#
  15 +# You should have received a copy of the GNU Lesser General Public License version 3
  16 +# along with this program; if not, see <http://www.gnu.org/licenses/>
  17 +# or write to the Free Software Foundation, Inc., 51 Franklin Street,
  18 +# Fifth Floor, Boston, MA 02110-1301, USA.
  19 +# ----------------------------------------------------------------------------
  20 +# Este arquivo é parte do Framework Demoiselle.
  21 +#
  22 +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  23 +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  24 +# do Software Livre (FSF).
  25 +#
  26 +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  27 +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  28 +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  29 +# para maiores detalhes.
  30 +#
  31 +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  32 +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  33 +# ou escreva para a Fundação do Software Livre (FSF) Inc.,
  34 +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  35 +messageWithoutParameter=Mensagem
  36 +messageOneParameter=Mensagem n\u00FAmero {0}
  37 +messageTwoParameter=Mensagem n\u00FAmero {0} com {1} par\u00E2metros
  38 +messageParameterString=Mensagem n\u00FAmero {numero}
0 39 \ No newline at end of file
... ...