diff --git a/impl/core/src/test/java/message/DummyMessageAppender.java b/impl/core/src/test/java/message/DummyMessageAppender.java
new file mode 100644
index 0000000..3490f41
--- /dev/null
+++ b/impl/core/src/test/java/message/DummyMessageAppender.java
@@ -0,0 +1,62 @@
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
+package message;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.context.RequestScoped;
+
+import br.gov.frameworkdemoiselle.internal.implementation.MessageAppender;
+import br.gov.frameworkdemoiselle.message.Message;
+
+@RequestScoped
+public class DummyMessageAppender implements MessageAppender {
+
+ private static final long serialVersionUID = 1L;
+
+ private List messages = new ArrayList();
+
+ @Override
+ public void append(Message message) {
+ messages.add(message);
+ }
+
+ public List getMessages() {
+ return messages;
+ }
+}
diff --git a/impl/core/src/test/java/message/MessageContextTest.java b/impl/core/src/test/java/message/MessageContextTest.java
index 17272ff..de59de6 100644
--- a/impl/core/src/test/java/message/MessageContextTest.java
+++ b/impl/core/src/test/java/message/MessageContextTest.java
@@ -1,3 +1,39 @@
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
package message;
import static junit.framework.Assert.assertEquals;
@@ -46,8 +82,10 @@ public class MessageContextTest {
public void testAddMessageWithoutParams() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Menssage without param");
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
+
messageContext.add(message);
- assertEquals(messageContext.getMessages().size(), 1);
+ assertEquals(appender.getMessages().size(), 1);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -55,8 +93,10 @@ public class MessageContextTest {
public void testAddMessageWithoutParamsIfSeverityIsInfo() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Menssage without param");
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
+
messageContext.add(message);
- assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.INFO);
+ assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.INFO);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -64,8 +104,10 @@ public class MessageContextTest {
public void testAddMessageWitSeverityInfo() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Menssage without param", SeverityType.INFO);
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
+
messageContext.add(message);
- assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.INFO);
+ assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.INFO);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -73,8 +115,10 @@ public class MessageContextTest {
public void testAddMessageWitSeverityWarn() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Menssage without param", SeverityType.WARN);
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
+
messageContext.add(message);
- assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.WARN);
+ assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.WARN);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -82,19 +126,10 @@ public class MessageContextTest {
public void testAddMessageWitSeverityErro() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Menssage without param", SeverityType.ERROR);
- messageContext.add(message);
- assertEquals(messageContext.getMessages().get(0).getSeverity(), SeverityType.ERROR);
- ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
- }
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
- @Test
- public void testCleanMessageContext() {
- ContextManager.activate(ManagedContext.class, RequestScoped.class);
- Message message = new DefaultMessage("Menssage without param");
messageContext.add(message);
- assertEquals(messageContext.getMessages().size(), 1);
- messageContext.clear();
- assertEquals(messageContext.getMessages().size(), 0);
+ assertEquals(appender.getMessages().get(0).getSeverity(), SeverityType.ERROR);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -102,8 +137,10 @@ public class MessageContextTest {
public void testRecoverMessageWithParams() {
ContextManager.activate(ManagedContext.class, RequestScoped.class);
Message message = new DefaultMessage("Message with {0} param");
+ DummyMessageAppender appender = Beans.getReference(DummyMessageAppender.class);
+
messageContext.add(message, 1);
- assertTrue(messageContext.getMessages().get(0).getText().equals("Message with 1 param"));
+ assertTrue(appender.getMessages().get(0).getText().equals("Message with 1 param"));
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
@@ -134,5 +171,4 @@ public class MessageContextTest {
Assert.assertEquals(expected, value);
ContextManager.deactivate(ManagedContext.class, RequestScoped.class);
}
-
}
diff --git a/impl/core/src/test/java/message/MessageWithResourceBundle.java b/impl/core/src/test/java/message/MessageWithResourceBundle.java
index dbc9b49..8671264 100644
--- a/impl/core/src/test/java/message/MessageWithResourceBundle.java
+++ b/impl/core/src/test/java/message/MessageWithResourceBundle.java
@@ -1,10 +1,46 @@
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
package message;
import javax.inject.Inject;
import br.gov.frameworkdemoiselle.util.ResourceBundle;
-public class MessageWithResourceBundle{
+public class MessageWithResourceBundle {
@Inject
private ResourceBundle bundle;
--
libgit2 0.21.2