diff --git a/impl/extension/jsf/src/test/java/message/MessageBean.java b/impl/extension/jsf/src/test/java/message/MessageBean.java new file mode 100644 index 0000000..c1c1496 --- /dev/null +++ b/impl/extension/jsf/src/test/java/message/MessageBean.java @@ -0,0 +1,56 @@ +/* + * 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.message.MessageContext; +import br.gov.frameworkdemoiselle.stereotype.ViewController; + +@ViewController +public class MessageBean { + + private String msg = "Message shown."; + + @Inject + private MessageContext messageContext; + + public String getMsg() { + messageContext.add(msg); + return ""; + } +} diff --git a/impl/extension/jsf/src/test/java/message/MessageTest.java b/impl/extension/jsf/src/test/java/message/MessageTest.java new file mode 100644 index 0000000..73f091a --- /dev/null +++ b/impl/extension/jsf/src/test/java/message/MessageTest.java @@ -0,0 +1,88 @@ +/* + * 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 org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URL; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.GetMethod; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; + +@RunWith(Arquillian.class) +public class MessageTest { + + @ArquillianResource + private URL deploymentUrl; + + private static final String PATH = "src/test/resources/message"; + + @Deployment(testable = false) + public static WebArchive createDeployment() { + return Tests.createDeployment().addClass(MessageTest.class) + .addClass(MessageBean.class) + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); + } + + @Test + public void showMessage() { + HttpClient client = new HttpClient(); + GetMethod method = new GetMethod(deploymentUrl + "/index.jsf"); + + try { + client.executeMethod(method); + String message = method.getResponseBodyAsString(); + assertTrue(message.contains("Message shown.")); + + } catch (HttpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/impl/extension/jsf/src/test/resources/message/index.xhtml b/impl/extension/jsf/src/test/resources/message/index.xhtml new file mode 100644 index 0000000..df18c4f --- /dev/null +++ b/impl/extension/jsf/src/test/resources/message/index.xhtml @@ -0,0 +1,11 @@ + + + + + #{messageBean.msg} + + + + + diff --git a/impl/extension/jsf/src/test/resources/message/web.xml b/impl/extension/jsf/src/test/resources/message/web.xml new file mode 100644 index 0000000..c2a321e --- /dev/null +++ b/impl/extension/jsf/src/test/resources/message/web.xml @@ -0,0 +1,61 @@ + + + + + br.gov.frameworkdemoiselle.util.ServletListener + + + Demoiselle Servlet Filter + br.gov.frameworkdemoiselle.util.ServletFilter + + + Demoiselle Servlet Filter + /* + + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + *.jsf + + \ No newline at end of file -- libgit2 0.21.2