diff --git a/impl/extension/jsf/src/test/java/proxy/FacesContextProxyServlet.java b/impl/extension/jsf/src/test/java/proxy/FacesContextProxyServlet.java new file mode 100644 index 0000000..29cf2b0 --- /dev/null +++ b/impl/extension/jsf/src/test/java/proxy/FacesContextProxyServlet.java @@ -0,0 +1,69 @@ +/* + * 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 proxy; + +import java.io.IOException; + +import javax.faces.context.FacesContext; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.httpclient.HttpStatus; + +import br.gov.frameworkdemoiselle.internal.proxy.FacesContextProxy; +import br.gov.frameworkdemoiselle.util.Beans; + +@WebServlet("/index") +public class FacesContextProxyServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + private FacesContext facesContext; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + facesContext = Beans.getReference(FacesContext.class); + if (facesContext.getClass() == FacesContextProxy.class) { + response.setStatus(HttpStatus.SC_OK); + } else { + response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); + } + } +} diff --git a/impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java b/impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java new file mode 100644 index 0000000..14f6ff0 --- /dev/null +++ b/impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java @@ -0,0 +1,85 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package proxy; + +import static org.junit.Assert.assertEquals; + +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.HttpStatus; +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 FacesContextProxyTest { + + @ArquillianResource + private URL deploymentUrl; + + private static final String PATH = "src/test/resources/proxy"; + + @Deployment(testable = false) + public static WebArchive createDeployment() { + return Tests.createDeployment().addClass(FacesContextProxyServlet.class) + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); + } + + @Test + public void facesContextProxy() { + HttpClient client = new HttpClient(); + GetMethod method = new GetMethod(deploymentUrl + "/index"); + + try { + int status = client.executeMethod(method); + assertEquals( HttpStatus.SC_OK, status); + } catch (HttpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/impl/extension/jsf/src/test/java/test/Tests.java b/impl/extension/jsf/src/test/java/test/Tests.java index 4eb1c30..64929b1 100644 --- a/impl/extension/jsf/src/test/java/test/Tests.java +++ b/impl/extension/jsf/src/test/java/test/Tests.java @@ -48,6 +48,7 @@ import br.gov.frameworkdemoiselle.annotation.NextView; import br.gov.frameworkdemoiselle.annotation.PreviousView; import br.gov.frameworkdemoiselle.annotation.Redirect; import br.gov.frameworkdemoiselle.internal.bootstrap.JsfBootstrap; +import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfigCompatible; import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig; import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig; import br.gov.frameworkdemoiselle.internal.context.FacesViewContextImpl; @@ -102,6 +103,7 @@ public final class Tests { .addClass(Redirector.class) .addClass(FileRenderer.class) .addClass(JsfSecurityConfig.class) + .addClass(ExceptionHandlerConfigCompatible.class) .addClass(ExceptionHandlerConfig.class) .addClass(FacesViewContextImpl.class) .addClass(AuthorizationExceptionHandlerFactory.class) diff --git a/impl/extension/jsf/src/test/resources/.arquillian-drone.profile b/impl/extension/jsf/src/test/resources/.arquillian-drone.profile deleted file mode 100644 index e69de29..0000000 --- a/impl/extension/jsf/src/test/resources/.arquillian-drone.profile +++ /dev/null diff --git a/impl/extension/jsf/src/test/resources/proxy/web.xml b/impl/extension/jsf/src/test/resources/proxy/web.xml new file mode 100644 index 0000000..8217490 --- /dev/null +++ b/impl/extension/jsf/src/test/resources/proxy/web.xml @@ -0,0 +1,63 @@ + + + + + br.gov.frameworkdemoiselle.util.ServletListener + + + Demoiselle Servlet Filter + br.gov.frameworkdemoiselle.util.ServletFilter + + + Demoiselle Servlet Filter + /* + + + + Servlet Class + proxy.FacesContextProxyServlet + + + + + Servlet Class + /index + + + \ No newline at end of file -- libgit2 0.21.2