Commit c57c2964f49613e2f5461a4fde0f2a0b978079f4

Authored by Cleverson Sacramento
1 parent e753ae50
Exists in master

Criação da estratégia de conversão das mensagens do MessageContext em

mensagens específicas da camada de apresentação
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java
... ... @@ -139,7 +139,7 @@ public class ConfigurationBootstrap extends AbstractStrategyBootstrap<Configurat
139 139 @Override
140 140 protected Logger getLogger() {
141 141 if (logger == null) {
142   - logger = LoggerProducer.create(TransactionBootstrap.class);
  142 + logger = LoggerProducer.create(ConfigurationBootstrap.class);
143 143 }
144 144  
145 145 return logger;
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConsoleMessageAppender.java 0 → 100644
... ... @@ -0,0 +1,52 @@
  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 br.gov.frameworkdemoiselle.internal.implementation;
  38 +
  39 +import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.CORE_PRIORITY;
  40 +import br.gov.frameworkdemoiselle.annotation.Priority;
  41 +import br.gov.frameworkdemoiselle.message.Message;
  42 +
  43 +@Priority(CORE_PRIORITY)
  44 +public class ConsoleMessageAppender implements MessageAppender {
  45 +
  46 + private static final long serialVersionUID = 1L;
  47 +
  48 + @Override
  49 + public void append(Message message) {
  50 + System.out.println(message.getText());
  51 + }
  52 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessageAppender.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 br.gov.frameworkdemoiselle.internal.implementation;
  38 +
  39 +import java.io.Serializable;
  40 +
  41 +import br.gov.frameworkdemoiselle.message.Message;
  42 +
  43 +public interface MessageAppender extends Serializable {
  44 +
  45 + void append(Message message);
  46 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImpl.java
... ... @@ -50,6 +50,7 @@ import br.gov.frameworkdemoiselle.message.DefaultMessage;
50 50 import br.gov.frameworkdemoiselle.message.Message;
51 51 import br.gov.frameworkdemoiselle.message.MessageContext;
52 52 import br.gov.frameworkdemoiselle.message.SeverityType;
  53 +import br.gov.frameworkdemoiselle.util.Beans;
53 54 import br.gov.frameworkdemoiselle.util.ResourceBundle;
54 55  
55 56 /**
... ... @@ -79,7 +80,13 @@ public class MessageContextImpl implements Serializable, MessageContext {
79 80 }
80 81  
81 82 getLogger().debug(getBundle().getString("adding-message-to-context", message.toString()));
82   - messages.add(aux);
  83 + getAppender().append(aux);
  84 + }
  85 +
  86 + private MessageAppender getAppender() {
  87 + Class<? extends MessageAppender> appenderClass = StrategySelector.selectClass(MessageAppender.class);
  88 +
  89 + return Beans.getReference(appenderClass);
83 90 }
84 91  
85 92 @Override
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
... ... @@ -42,8 +42,6 @@ import java.security.Principal;
42 42 import javax.inject.Named;
43 43  
44 44 import br.gov.frameworkdemoiselle.DemoiselleException;
45   -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap;
46   -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap;
47 45 import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig;
48 46 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
49 47 import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful;
... ... @@ -74,11 +72,10 @@ public class SecurityContextImpl implements SecurityContext {
74 72  
75 73 private Authenticator getAuthenticator() {
76 74 if (this.authenticator == null) {
77   - AuthenticatorBootstrap bootstrap = Beans.getReference(AuthenticatorBootstrap.class);
78 75 Class<? extends Authenticator> clazz = getConfig().getAuthenticatorClass();
79 76  
80 77 if (clazz == null) {
81   - clazz = StrategySelector.selectClass(Authenticator.class, bootstrap.getCache());
  78 + clazz = StrategySelector.selectClass(Authenticator.class);
82 79 }
83 80  
84 81 this.authenticator = Beans.getReference(clazz);
... ... @@ -89,11 +86,10 @@ public class SecurityContextImpl implements SecurityContext {
89 86  
90 87 private Authorizer getAuthorizer() {
91 88 if (this.authorizer == null) {
92   - AuthorizerBootstrap bootstrap = Beans.getReference(AuthorizerBootstrap.class);
93 89 Class<? extends Authorizer> clazz = getConfig().getAuthorizerClass();
94 90  
95 91 if (clazz == null) {
96   - clazz = StrategySelector.selectClass(Authorizer.class, bootstrap.getCache());
  92 + clazz = StrategySelector.selectClass(Authorizer.class);
97 93 }
98 94  
99 95 this.authorizer = Beans.getReference(clazz);
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
... ... @@ -42,14 +42,18 @@ import java.io.Serializable;
42 42 import java.util.ArrayList;
43 43 import java.util.Collection;
44 44 import java.util.HashMap;
  45 +import java.util.HashSet;
45 46 import java.util.List;
46 47 import java.util.Map;
  48 +import java.util.Set;
47 49  
48 50 import javax.enterprise.inject.AmbiguousResolutionException;
  51 +import javax.enterprise.inject.spi.Bean;
49 52  
50 53 import br.gov.frameworkdemoiselle.DemoiselleException;
51 54 import br.gov.frameworkdemoiselle.annotation.Priority;
52 55 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
  56 +import br.gov.frameworkdemoiselle.util.Beans;
53 57 import br.gov.frameworkdemoiselle.util.ResourceBundle;
54 58  
55 59 public final class StrategySelector implements Serializable {
... ... @@ -92,7 +96,7 @@ public final class StrategySelector implements Serializable {
92 96 return map.get(elected);
93 97 }
94 98  
95   - public static <T> Class<? extends T> selectClass(Class<T> type, Collection<Class<? extends T>> options) {
  99 + private static <T> Class<? extends T> selectClass(Class<T> type, Collection<Class<? extends T>> options) {
96 100 Class<? extends T> selected = null;
97 101  
98 102 for (Class<? extends T> option : options) {
... ... @@ -102,13 +106,28 @@ public final class StrategySelector implements Serializable {
102 106 }
103 107  
104 108 if (selected != null) {
105   - checkForAmbiguity(type, selected, options);
  109 + performAmbiguityCheck(type, selected, options);
106 110 }
107 111  
108 112 return selected;
109 113 }
110 114  
111   - private static <T> void checkForAmbiguity(Class<T> type, Class<? extends T> selected,
  115 + public static <T> Class<? extends T> selectClass(Class<T> type) {
  116 + return selectClass(type, getOptions(type));
  117 + }
  118 +
  119 + @SuppressWarnings("unchecked")
  120 + private static <T> Collection<Class<? extends T>> getOptions(Class<T> type) {
  121 + Set<Class<? extends T>> result = new HashSet<Class<? extends T>>();
  122 +
  123 + for (Bean<?> bean : Beans.getBeanManager().getBeans(type)) {
  124 + result.add((Class<? extends T>) bean.getBeanClass());
  125 + }
  126 +
  127 + return result;
  128 + }
  129 +
  130 + private static <T> void performAmbiguityCheck(Class<T> type, Class<? extends T> selected,
112 131 Collection<Class<? extends T>> options) {
113 132 int selectedPriority = getPriority(selected);
114 133  
... ...
impl/core/src/test/java/message/MessageContextTest.java
... ... @@ -14,7 +14,6 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
14 14 import org.junit.Test;
15 15 import org.junit.runner.RunWith;
16 16  
17   -import resourcebundle.parameter.ResourceBundleWithParameter;
18 17 import test.Tests;
19 18 import br.gov.frameworkdemoiselle.internal.context.ContextManager;
20 19 import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
... ... @@ -34,7 +33,7 @@ public class MessageContextTest {
34 33 private MessageWithResourceBundle bundleCustom;
35 34  
36 35 private static final String PATH = "src/test/resources/message/";
37   -
  36 +
38 37 @Deployment
39 38 public static JavaArchive createDeployment() {
40 39 JavaArchive deployment = Tests.createDeployment(MessageContextTest.class);
... ... @@ -78,7 +77,7 @@ public class MessageContextTest {
78 77 assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.WARN);
79 78 ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
80 79 }
81   -
  80 +
82 81 @Test
83 82 public void testAddMessageWitSeverityErro() {
84 83 ContextManager.activate(ManagedContext.class, RequestScoped.class);
... ... @@ -87,7 +86,7 @@ public class MessageContextTest {
87 86 assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.ERROR);
88 87 ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
89 88 }
90   -
  89 +
91 90 @Test
92 91 public void testCleanMessageContext() {
93 92 ContextManager.activate(ManagedContext.class, RequestScoped.class);
... ... @@ -107,7 +106,7 @@ public class MessageContextTest {
107 106 assertTrue(messageContext.getMessages().get(0).getText().equals("Message with 1 param"));
108 107 ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
109 108 }
110   -
  109 +
111 110 @Test
112 111 public void testMessageWithResourceBundle() {
113 112 bundleCustom = Beans.getReference(MessageWithResourceBundle.class);
... ... @@ -115,9 +114,9 @@ public class MessageContextTest {
115 114 String value = bundleCustom.getBundle().getString("MESSAGE_WITHOUT_PARAMETER");
116 115 Assert.assertEquals(expected, value);
117 116 }
118   -
  117 +
119 118 @Test
120   - public void testMessageParsedText(){
  119 + public void testMessageParsedText() {
121 120 ContextManager.activate(ManagedContext.class, RequestScoped.class);
122 121 Message MESSAGE_PARSED = new DefaultMessage("{MESSAGE_PARSED}");
123 122 String expected = "Message parsed";
... ... @@ -125,9 +124,9 @@ public class MessageContextTest {
125 124 Assert.assertEquals(expected, value);
126 125 ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
127 126 }
128   -
  127 +
129 128 @Test
130   - public void testMessageIsNull(){
  129 + public void testMessageIsNull() {
131 130 ContextManager.activate(ManagedContext.class, RequestScoped.class);
132 131 Message NULL_MESSAGE = new DefaultMessage(null);
133 132 String expected = null;
... ... @@ -135,5 +134,5 @@ public class MessageContextTest {
135 134 Assert.assertEquals(expected, value);
136 135 ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
137 136 }
138   -
  137 +
139 138 }
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/FacesMessageAppender.java 0 → 100644
... ... @@ -0,0 +1,53 @@
  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 br.gov.frameworkdemoiselle.internal.implementation;
  38 +
  39 +import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelector.EXTENSIONS_L2_PRIORITY;
  40 +import br.gov.frameworkdemoiselle.annotation.Priority;
  41 +import br.gov.frameworkdemoiselle.message.Message;
  42 +import br.gov.frameworkdemoiselle.util.Faces;
  43 +
  44 +@Priority(EXTENSIONS_L2_PRIORITY)
  45 +public class FacesMessageAppender implements MessageAppender {
  46 +
  47 + private static final long serialVersionUID = 1L;
  48 +
  49 + @Override
  50 + public void append(Message message) {
  51 + Faces.addMessage(message);
  52 + }
  53 +}
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessagePhaseListener.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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import javax.faces.event.PhaseEvent;
40   -import javax.faces.event.PhaseId;
41   -import javax.faces.event.PhaseListener;
42   -
43   -import org.slf4j.Logger;
44   -
45   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
46   -import br.gov.frameworkdemoiselle.message.MessageContext;
47   -import br.gov.frameworkdemoiselle.util.Beans;
48   -import br.gov.frameworkdemoiselle.util.Faces;
49   -
50   -/**
51   - * This class is a JSF phase listener intended to transfer messages from Demoiselle Context to JSF own context.
52   - *
53   - * @author SERPRO
54   - */
55   -public class MessagePhaseListener implements PhaseListener {
56   -
57   - private static final long serialVersionUID = 1L;
58   -
59   - private final Logger logger = LoggerProducer.create(this.getClass());
60   -
61   - public void beforePhase(PhaseEvent e) {
62   - transferMessages(e);
63   - }
64   -
65   - public void afterPhase(PhaseEvent e) {
66   - }
67   -
68   - /**
69   - * Transfers messages from a context to another.
70   - *
71   - * @param e
72   - * PhaseEvent
73   - */
74   - private void transferMessages(PhaseEvent e) {
75   -
76   - logger.debug(this.getClass().getSimpleName() + " " + e.getPhaseId());
77   -
78   - MessageContext messageContext = Beans.getReference(MessageContext.class);
79   -
80   - // TODO: usar o bundle nas mensagens de log
81   - logger.debug("Moving " + messageContext.getMessages().size()
82   - + " message(s) from MessageContext to FacesContext.");
83   -
84   - Faces.addMessages(messageContext.getMessages());
85   - messageContext.clear();
86   - }
87   -
88   - public PhaseId getPhaseId() {
89   - return PhaseId.RENDER_RESPONSE;
90   - }
91   -
92   -}
impl/extension/jsf/src/main/resources/META-INF/faces-config.xml
... ... @@ -37,10 +37,6 @@
37 37 <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
38 38 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
39 39  
40   - <lifecycle>
41   - <phase-listener>br.gov.frameworkdemoiselle.internal.implementation.MessagePhaseListener</phase-listener>
42   - </lifecycle>
43   -
44 40 <factory>
45 41 <exception-handler-factory>br.gov.frameworkdemoiselle.internal.implementation.AuthenticationExceptionHandlerFactory</exception-handler-factory>
46 42 <exception-handler-factory>br.gov.frameworkdemoiselle.internal.implementation.AuthorizationExceptionHandlerFactory</exception-handler-factory>
... ...
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessagePhaseListenerTest.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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import static org.easymock.EasyMock.expect;
40   -import static org.powermock.api.easymock.PowerMock.mockStatic;
41   -import static org.powermock.api.easymock.PowerMock.replayAll;
42   -import static org.powermock.api.easymock.PowerMock.verifyAll;
43   -
44   -import java.util.ArrayList;
45   -import java.util.List;
46   -
47   -import javax.faces.event.PhaseEvent;
48   -import javax.faces.event.PhaseId;
49   -
50   -import org.easymock.EasyMock;
51   -import org.junit.Assert;
52   -import org.junit.Before;
53   -import org.junit.Test;
54   -import org.junit.runner.RunWith;
55   -import org.powermock.api.easymock.PowerMock;
56   -import org.powermock.core.classloader.annotations.PrepareForTest;
57   -import org.powermock.modules.junit4.PowerMockRunner;
58   -import org.slf4j.Logger;
59   -
60   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
61   -import br.gov.frameworkdemoiselle.message.Message;
62   -import br.gov.frameworkdemoiselle.message.MessageContext;
63   -import br.gov.frameworkdemoiselle.util.Beans;
64   -import br.gov.frameworkdemoiselle.util.Faces;
65   -
66   -@RunWith(PowerMockRunner.class)
67   -@PrepareForTest({ LoggerProducer.class, Beans.class, Faces.class })
68   -public class MessagePhaseListenerTest {
69   -
70   - private MessagePhaseListener m;
71   -
72   - private Logger logger;
73   -
74   - @Before
75   - public void before() {
76   - PowerMock.mockStatic(LoggerProducer.class);
77   - logger = PowerMock.createMock(Logger.class);
78   - expect(LoggerProducer.create(MessagePhaseListener.class)).andReturn(logger);
79   - }
80   -
81   - @Test
82   - public void testGetPhaseId() {
83   - m = new MessagePhaseListener();
84   - Assert.assertEquals(PhaseId.RENDER_RESPONSE, m.getPhaseId());
85   - }
86   -
87   - @Test
88   - public void testBeforePhase() {
89   -
90   - mockStatic(Beans.class);
91   - mockStatic(Faces.class);
92   -
93   - PhaseEvent event = PowerMock.createMock(PhaseEvent.class);
94   - MessageContext mc = PowerMock.createMock(MessageContext.class);
95   -
96   - logger.debug(EasyMock.anyObject(String.class));
97   - logger.debug(EasyMock.anyObject(String.class));
98   -
99   - List<Message> list = new ArrayList<Message>();
100   -
101   - expect(event.getPhaseId()).andReturn(PhaseId.RENDER_RESPONSE);
102   - expect(Beans.getReference(MessageContext.class)).andReturn(mc);
103   - expect(mc.getMessages()).andReturn(list).anyTimes();
104   -
105   - mc.clear();
106   - Faces.addMessages(list);
107   -
108   - replayAll();
109   - m = new MessagePhaseListener();
110   - m.beforePhase(event);
111   - m.afterPhase(event);
112   - verifyAll();
113   - }
114   -
115   -}
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/InternalProcessorFilterImpl.java
... ... @@ -24,7 +24,9 @@ public class InternalProcessorFilterImpl implements InternalProcessorFilter {
24 24  
25 25 filters.add(new HttpServletRequestProducerFilter());
26 26 filters.add(new HttpServletResponseProducerFilter());
27   - filters.add(new BasicAuthenticationFilter());
  27 +
  28 + // TODO Analizar o uso do BasicAuthenticationFilter
  29 + // filters.add(new BasicAuthenticationFilter());
28 30 }
29 31  
30 32 @Override
... ...