Commit 01a2be5ab57781e8ad29db60f79a5297e6232309

Authored by Luciano Borges
2 parents f2be871b 96237624
Exists in master

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

documentation/reference/pt-BR/properties.xml
@@ -129,7 +129,7 @@ @@ -129,7 +129,7 @@
129 <entry>true</entry> 129 <entry>true</entry>
130 </row> 130 </row>
131 <row valign="top"> 131 <row valign="top">
132 - <entry>frameworkdemoiselle.&#8203;handle.&#8203;application.&#8203;exception</entry> 132 + <entry>frameworkdemoiselle.&#8203;exception.&#8203;application.&#8203;handle</entry>
133 <entry> 133 <entry>
134 <para> 134 <para>
135 Habilita o tratamento automático das exceções da aplicação anotadas com @ApplicationException. 135 Habilita o tratamento automático das exceções da aplicação anotadas com @ApplicationException.
@@ -138,7 +138,7 @@ @@ -138,7 +138,7 @@
138 <entry>true</entry> 138 <entry>true</entry>
139 </row> 139 </row>
140 <row valign="top"> 140 <row valign="top">
141 - <entry>frameworkdemoiselle.&#8203;handle.&#8203;application.&#8203;exception.&#8203;page</entry> 141 + <entry>frameworkdemoiselle.&#8203;exception.&#8203;default.&#8203;redirect.&#8203;page</entry>
142 <entry> 142 <entry>
143 <para> 143 <para>
144 Define o redirecionamento das exceções da aplicação anotadas com @ApplicationException ocorridas 144 Define o redirecionamento das exceções da aplicação anotadas com @ApplicationException ocorridas
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java
@@ -49,10 +49,17 @@ public class ConfigurationImpl implements Serializable { @@ -49,10 +49,17 @@ public class ConfigurationImpl implements Serializable {
49 private boolean loaded = false; 49 private boolean loaded = false;
50 50
51 @SuppressWarnings("unused") 51 @SuppressWarnings("unused")
52 - private synchronized void load(Object instance) { 52 + private synchronized void load(Object instance) throws Throwable {
53 if (!loaded) { 53 if (!loaded) {
54 - Beans.getReference(ConfigurationLoader.class).load(instance);  
55 loaded = true; 54 loaded = true;
  55 +
  56 + try {
  57 + Beans.getReference(ConfigurationLoader.class).load(instance);
  58 +
  59 + } catch (Throwable cause) {
  60 + loaded = false;
  61 + throw cause;
  62 + }
56 } 63 }
57 } 64 }
58 } 65 }
impl/core/src/test/java/configuration/field/beanvalidation/ConfigurationBeanValidationFieldTest.java
@@ -42,8 +42,6 @@ import static junit.framework.Assert.fail; @@ -42,8 +42,6 @@ import static junit.framework.Assert.fail;
42 import javax.inject.Inject; 42 import javax.inject.Inject;
43 import javax.validation.ConstraintViolationException; 43 import javax.validation.ConstraintViolationException;
44 44
45 -import junit.framework.Assert;  
46 -  
47 import org.jboss.arquillian.container.test.api.Deployment; 45 import org.jboss.arquillian.container.test.api.Deployment;
48 import org.jboss.arquillian.junit.Arquillian; 46 import org.jboss.arquillian.junit.Arquillian;
49 import org.jboss.shrinkwrap.api.spec.JavaArchive; 47 import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -107,14 +105,14 @@ public class ConfigurationBeanValidationFieldTest { @@ -107,14 +105,14 @@ public class ConfigurationBeanValidationFieldTest {
107 propertyBeanValidationWithEmptyNotNullFieldConfig.getIntAttributeNull(); 105 propertyBeanValidationWithEmptyNotNullFieldConfig.getIntAttributeNull();
108 fail(); 106 fail();
109 } catch (ConfigurationException cause) { 107 } catch (ConfigurationException cause) {
110 - Assert.assertEquals(ConstraintViolationException.class, cause.getCause().getClass()); 108 + assertEquals(ConstraintViolationException.class, cause.getCause().getClass());
111 } 109 }
112 110
113 try { 111 try {
114 xmlBeanValidationWithEmptyNotNullFieldConfig.getIntAttributeNull(); 112 xmlBeanValidationWithEmptyNotNullFieldConfig.getIntAttributeNull();
115 fail(); 113 fail();
116 } catch (ConfigurationException cause) { 114 } catch (ConfigurationException cause) {
117 - Assert.assertEquals(ConstraintViolationException.class, cause.getCause().getClass()); 115 + assertEquals(ConstraintViolationException.class, cause.getCause().getClass());
118 } 116 }
119 } 117 }
120 118
@@ -124,14 +122,14 @@ public class ConfigurationBeanValidationFieldTest { @@ -124,14 +122,14 @@ public class ConfigurationBeanValidationFieldTest {
124 propertyBeanValidationWithEmptyNotNullFieldConfig.getStringAttributeNull(); 122 propertyBeanValidationWithEmptyNotNullFieldConfig.getStringAttributeNull();
125 fail(); 123 fail();
126 } catch (ConfigurationException cause) { 124 } catch (ConfigurationException cause) {
127 - Assert.assertEquals(ConstraintViolationException.class, cause.getCause().getClass()); 125 + assertEquals(ConstraintViolationException.class, cause.getCause().getClass());
128 } 126 }
129 127
130 try { 128 try {
131 xmlBeanValidationWithEmptyNotNullFieldConfig.getStringAttributeNull(); 129 xmlBeanValidationWithEmptyNotNullFieldConfig.getStringAttributeNull();
132 fail(); 130 fail();
133 } catch (ConfigurationException cause) { 131 } catch (ConfigurationException cause) {
134 - Assert.assertEquals(ConstraintViolationException.class, cause.getCause().getClass()); 132 + assertEquals(ConstraintViolationException.class, cause.getCause().getClass());
135 } 133 }
136 } 134 }
137 135
@@ -141,7 +139,7 @@ public class ConfigurationBeanValidationFieldTest { @@ -141,7 +139,7 @@ public class ConfigurationBeanValidationFieldTest {
141 propertyWithTwoConstrainViolations.getAttributeWithTwoConstrainValidations(); 139 propertyWithTwoConstrainViolations.getAttributeWithTwoConstrainValidations();
142 fail(); 140 fail();
143 } catch (ConfigurationException cause) { 141 } catch (ConfigurationException cause) {
144 - Assert.assertEquals(ConstraintViolationException.class, cause.getCause().getClass()); 142 + assertEquals(ConstraintViolationException.class, cause.getCause().getClass());
145 } 143 }
146 } 144 }
147 } 145 }
impl/extension/jsf/pom.xml
@@ -81,6 +81,12 @@ @@ -81,6 +81,12 @@
81 <scope>test</scope> 81 <scope>test</scope>
82 </dependency> 82 </dependency>
83 <dependency> 83 <dependency>
  84 + <groupId>commons-httpclient</groupId>
  85 + <artifactId>commons-httpclient</artifactId>
  86 + <version>3.1</version>
  87 + <scope>test</scope>
  88 + </dependency>
  89 + <dependency>
84 <groupId>org.glassfish.web</groupId> 90 <groupId>org.glassfish.web</groupId>
85 <artifactId>el-impl</artifactId> 91 <artifactId>el-impl</artifactId>
86 <scope>provided</scope> 92 <scope>provided</scope>
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfig.java
@@ -41,22 +41,22 @@ import java.io.Serializable; @@ -41,22 +41,22 @@ import java.io.Serializable;
41 import br.gov.frameworkdemoiselle.annotation.Name; 41 import br.gov.frameworkdemoiselle.annotation.Name;
42 import br.gov.frameworkdemoiselle.configuration.Configuration; 42 import br.gov.frameworkdemoiselle.configuration.Configuration;
43 43
44 -@Configuration(prefix = "frameworkdemoiselle.handle.") 44 +@Configuration(prefix = "frameworkdemoiselle.exception")
45 public class ExceptionHandlerConfig implements Serializable { 45 public class ExceptionHandlerConfig implements Serializable {
46 46
47 private static final long serialVersionUID = 1L; 47 private static final long serialVersionUID = 1L;
48 48
49 - @Name("application.exception")  
50 - private boolean handleApplicationException = true; 49 + @Name("application.handle")
  50 + private boolean applicationExceptionHandle = true;
51 51
52 - @Name("application.exception.page")  
53 - private String exceptionPage = "/application_error"; 52 + @Name("default.redirect.page")
  53 + private String defaultRedirectExceptionPage = "/application_error";
54 54
55 - public String getExceptionPage() {  
56 - return exceptionPage; 55 + public boolean isApplicationExceptionHandle() {
  56 + return applicationExceptionHandle;
57 } 57 }
58 -  
59 - public boolean isHandleApplicationException() {  
60 - return handleApplicationException; 58 +
  59 + public String getDefaultRedirectExceptionPage() {
  60 + return defaultRedirectExceptionPage;
61 } 61 }
62 } 62 }
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigCompatible.java 0 → 100644
@@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
  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.configuration;
  38 +
  39 +import java.io.Serializable;
  40 +
  41 +import org.slf4j.Logger;
  42 +
  43 +import br.gov.frameworkdemoiselle.annotation.Name;
  44 +import br.gov.frameworkdemoiselle.configuration.Configuration;
  45 +import br.gov.frameworkdemoiselle.util.Beans;
  46 +
  47 +@Deprecated
  48 +@Configuration(prefix = "frameworkdemoiselle.handle")
  49 +public class ExceptionHandlerConfigCompatible implements Serializable {
  50 +
  51 + private static final long serialVersionUID = 1L;
  52 +
  53 + @Deprecated
  54 + @Name("application.exception")
  55 + private boolean handleApplicationException = true;
  56 +
  57 + @Deprecated
  58 + @Name("application.exception.page")
  59 + private String exceptionPage = "/application_error";
  60 +
  61 + @Deprecated
  62 + public boolean isHandleApplicationException() {
  63 + Logger logger = Beans.getReference(Logger.class);
  64 + logger.warn("A propriedade frameworkdemoiselle.handle.application.exception="
  65 + + handleApplicationException
  66 + + " não será suportada nas próximas versões do framework. Para evitar futuros problemas atualize a propriedade para frameworkdemoiselle.exception.application.handle="
  67 + + handleApplicationException);
  68 +
  69 + return handleApplicationException;
  70 + }
  71 +
  72 + @Deprecated
  73 + public String getExceptionPage() {
  74 + Logger logger = Beans.getReference(Logger.class);
  75 + logger.warn("A propriedade frameworkdemoiselle.handle.application.exception.page="
  76 + + exceptionPage
  77 + + " não será suportada nas próximas versões do framework. Para evitar futuros problemas atualize a propriedade para frameworkdemoiselle.exception.default.redirect.page="
  78 + + exceptionPage);
  79 +
  80 + return exceptionPage;
  81 + }
  82 +}
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandler.java
@@ -43,7 +43,10 @@ import javax.faces.context.ExceptionHandler; @@ -43,7 +43,10 @@ import javax.faces.context.ExceptionHandler;
43 import javax.faces.context.FacesContext; 43 import javax.faces.context.FacesContext;
44 import javax.faces.event.PhaseId; 44 import javax.faces.event.PhaseId;
45 45
  46 +import org.slf4j.Logger;
  47 +
46 import br.gov.frameworkdemoiselle.DemoiselleException; 48 import br.gov.frameworkdemoiselle.DemoiselleException;
  49 +import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfigCompatible;
47 import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig; 50 import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig;
48 import br.gov.frameworkdemoiselle.util.Beans; 51 import br.gov.frameworkdemoiselle.util.Beans;
49 import br.gov.frameworkdemoiselle.util.Exceptions; 52 import br.gov.frameworkdemoiselle.util.Exceptions;
@@ -58,19 +61,69 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler { @@ -58,19 +61,69 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
58 } 61 }
59 62
60 protected boolean handleException(final Throwable cause, FacesContext facesContext) { 63 protected boolean handleException(final Throwable cause, FacesContext facesContext) {
  64 + // Apenas para manter compatibilidade entre 2.3.x e 2.4.0-RCx
  65 + ExceptionHandlerConfigCompatible compatibleConfig = Beans.getReference(ExceptionHandlerConfigCompatible.class);
  66 + // Usuário está utilizando pelo menos uma das propriedades com a forma depreciada de forma explícita
  67 + if (!(compatibleConfig.getExceptionPage().equals("/application_error") && compatibleConfig.isHandleApplicationException())) {
  68 + Logger logger = Beans.getReference(Logger.class);
  69 + logger.warn("As propriedades frameworkdemoiselle.handle.application.exception e"
  70 + + " frameworkdemoiselle.handle.application.exception.page"
  71 + + " não serão suportadas nas próximas versões do framework."
  72 + + " Para evitar futuros problemas atualize as propriedades para"
  73 + + " frameworkdemoiselle.exception.application.handle e"
  74 + + " frameworkdemoiselle.exception.default.redirect.page, respectivamente.");
  75 + return handleExceptionCompatibleConfiguration(compatibleConfig, cause, facesContext);
  76 + }
  77 +
  78 + boolean handled = false;
61 ExceptionHandlerConfig config = Beans.getReference(ExceptionHandlerConfig.class); 79 ExceptionHandlerConfig config = Beans.getReference(ExceptionHandlerConfig.class);
  80 +
  81 + if (config.isApplicationExceptionHandle() && Exceptions.isApplicationException(cause)) {
  82 +
  83 + if (isRendering(facesContext)) {
  84 + handled = handlingDuringRenderResponse(cause, config);
  85 + } else {
  86 + Faces.addMessage(cause);
  87 + handled = true;
  88 + }
  89 + }
  90 +
  91 + return handled;
  92 + }
  93 +
  94 + @Deprecated
  95 + private boolean handleExceptionCompatibleConfiguration(ExceptionHandlerConfigCompatible config, final Throwable cause,
  96 + FacesContext facesContext) {
62 boolean handled = false; 97 boolean handled = false;
63 98
64 if (config.isHandleApplicationException() && Exceptions.isApplicationException(cause)) { 99 if (config.isHandleApplicationException() && Exceptions.isApplicationException(cause)) {
65 100
66 if (isRendering(facesContext)) { 101 if (isRendering(facesContext)) {
67 - handled = handlingDuringRenderResponse(cause, config); 102 + handled = handlingDuringRenderResponseCompatible(cause, config);
68 } else { 103 } else {
69 Faces.addMessage(cause); 104 Faces.addMessage(cause);
70 handled = true; 105 handled = true;
71 } 106 }
72 } 107 }
  108 + return handled;
  109 + }
73 110
  111 + @Deprecated
  112 + private boolean handlingDuringRenderResponseCompatible(final Throwable cause, final ExceptionHandlerConfigCompatible config) {
  113 + boolean handled = false;
  114 + try {
  115 + Map<String, Object> map = new HashMap<String, Object>();
  116 + map.put("exception", cause.getMessage());
  117 + Redirector.redirect(config.getExceptionPage(), map);
  118 + handled = true;
  119 + } catch (PageNotFoundException ex) {
  120 + // TODO Colocar a mensagem no bundle
  121 + throw new DemoiselleException(
  122 + "A tela de exibição de erros: \""
  123 + + ex.getViewId()
  124 + + "\" não foi encontrada. Caso o seu projeto possua outra, defina no arquivo de configuração a chave \""
  125 + + "frameworkdemoiselle.handle.application.exception.page" + "\"", ex);
  126 + }
74 return handled; 127 return handled;
75 } 128 }
76 129
@@ -82,7 +135,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler { @@ -82,7 +135,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
82 * In render response phase an exception interrupt the renderization. So this method will redirect the renderingo to 135 * In render response phase an exception interrupt the renderization. So this method will redirect the renderingo to
83 * an page configured in demoiselle.properties 136 * an page configured in demoiselle.properties
84 * 137 *
85 - * @see ExceptionHandlerConfig 138 + * @see ExceptionHandlerConfigCompatible
86 * @param cause 139 * @param cause
87 * @param config 140 * @param config
88 * @return 141 * @return
@@ -92,7 +145,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler { @@ -92,7 +145,7 @@ public class ApplicationExceptionHandler extends AbstractExceptionHandler {
92 try { 145 try {
93 Map<String, Object> map = new HashMap<String, Object>(); 146 Map<String, Object> map = new HashMap<String, Object>();
94 map.put("exception", cause.getMessage()); 147 map.put("exception", cause.getMessage());
95 - Redirector.redirect(config.getExceptionPage(), map); 148 + Redirector.redirect(config.getDefaultRedirectExceptionPage(), map);
96 handled = true; 149 handled = true;
97 } catch (PageNotFoundException ex) { 150 } catch (PageNotFoundException ex) {
98 // TODO Colocar a mensagem no bundle 151 // TODO Colocar a mensagem no bundle
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigTest.java
@@ -16,12 +16,12 @@ public class ExceptionHandlerConfigTest { @@ -16,12 +16,12 @@ public class ExceptionHandlerConfigTest {
16 16
17 @Test 17 @Test
18 public void testGetExceptionPage() { 18 public void testGetExceptionPage() {
19 - assertEquals("/application_error", config.getExceptionPage()); 19 + assertEquals("/application_error", config.getDefaultRedirectExceptionPage());
20 } 20 }
21 21
22 @Test 22 @Test
23 public void testIsHandleApplicationException() { 23 public void testIsHandleApplicationException() {
24 - assertEquals(true, config.isHandleApplicationException()); 24 + assertEquals(true, config.isApplicationExceptionHandle());
25 } 25 }
26 26
27 } 27 }
impl/extension/jsf/src/test/java/proxy/FacesContextProxyServlet.java 0 → 100644
@@ -0,0 +1,69 @@ @@ -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 proxy;
  38 +
  39 +import java.io.IOException;
  40 +
  41 +import javax.faces.context.FacesContext;
  42 +import javax.servlet.ServletException;
  43 +import javax.servlet.annotation.WebServlet;
  44 +import javax.servlet.http.HttpServlet;
  45 +import javax.servlet.http.HttpServletRequest;
  46 +import javax.servlet.http.HttpServletResponse;
  47 +
  48 +import org.apache.commons.httpclient.HttpStatus;
  49 +
  50 +import br.gov.frameworkdemoiselle.internal.proxy.FacesContextProxy;
  51 +import br.gov.frameworkdemoiselle.util.Beans;
  52 +
  53 +@WebServlet("/index")
  54 +public class FacesContextProxyServlet extends HttpServlet {
  55 +
  56 + private static final long serialVersionUID = 1L;
  57 +
  58 + private FacesContext facesContext;
  59 +
  60 + @Override
  61 + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  62 + facesContext = Beans.getReference(FacesContext.class);
  63 + if (facesContext.getClass() == FacesContextProxy.class) {
  64 + response.setStatus(HttpStatus.SC_OK);
  65 + } else {
  66 + response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
  67 + }
  68 + }
  69 +}
impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java 0 → 100644
@@ -0,0 +1,85 @@ @@ -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 proxy;
  38 +
  39 +import static org.junit.Assert.assertEquals;
  40 +
  41 +import java.io.IOException;
  42 +import java.net.URL;
  43 +
  44 +import org.apache.commons.httpclient.HttpClient;
  45 +import org.apache.commons.httpclient.HttpException;
  46 +import org.apache.commons.httpclient.HttpStatus;
  47 +import org.apache.commons.httpclient.methods.GetMethod;
  48 +import org.jboss.arquillian.container.test.api.Deployment;
  49 +import org.jboss.arquillian.junit.Arquillian;
  50 +import org.jboss.arquillian.test.api.ArquillianResource;
  51 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  52 +import org.junit.Test;
  53 +import org.junit.runner.RunWith;
  54 +
  55 +import test.Tests;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +public class FacesContextProxyTest {
  59 +
  60 + @ArquillianResource
  61 + private URL deploymentUrl;
  62 +
  63 + private static final String PATH = "src/test/resources/proxy";
  64 +
  65 + @Deployment(testable = false)
  66 + public static WebArchive createDeployment() {
  67 + return Tests.createDeployment().addClass(FacesContextProxyServlet.class)
  68 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
  69 + }
  70 +
  71 + @Test
  72 + public void facesContextProxy() {
  73 + HttpClient client = new HttpClient();
  74 + GetMethod method = new GetMethod(deploymentUrl + "/index");
  75 +
  76 + try {
  77 + int status = client.executeMethod(method);
  78 + assertEquals( HttpStatus.SC_OK, status);
  79 + } catch (HttpException e) {
  80 + e.printStackTrace();
  81 + } catch (IOException e) {
  82 + e.printStackTrace();
  83 + }
  84 + }
  85 +}
impl/extension/jsf/src/test/java/test/Tests.java
@@ -48,6 +48,7 @@ import br.gov.frameworkdemoiselle.annotation.NextView; @@ -48,6 +48,7 @@ import br.gov.frameworkdemoiselle.annotation.NextView;
48 import br.gov.frameworkdemoiselle.annotation.PreviousView; 48 import br.gov.frameworkdemoiselle.annotation.PreviousView;
49 import br.gov.frameworkdemoiselle.annotation.Redirect; 49 import br.gov.frameworkdemoiselle.annotation.Redirect;
50 import br.gov.frameworkdemoiselle.internal.bootstrap.JsfBootstrap; 50 import br.gov.frameworkdemoiselle.internal.bootstrap.JsfBootstrap;
  51 +import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfigCompatible;
51 import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig; 52 import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig;
52 import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig; 53 import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig;
53 import br.gov.frameworkdemoiselle.internal.context.FacesViewContextImpl; 54 import br.gov.frameworkdemoiselle.internal.context.FacesViewContextImpl;
@@ -102,6 +103,7 @@ public final class Tests { @@ -102,6 +103,7 @@ public final class Tests {
102 .addClass(Redirector.class) 103 .addClass(Redirector.class)
103 .addClass(FileRenderer.class) 104 .addClass(FileRenderer.class)
104 .addClass(JsfSecurityConfig.class) 105 .addClass(JsfSecurityConfig.class)
  106 + .addClass(ExceptionHandlerConfigCompatible.class)
105 .addClass(ExceptionHandlerConfig.class) 107 .addClass(ExceptionHandlerConfig.class)
106 .addClass(FacesViewContextImpl.class) 108 .addClass(FacesViewContextImpl.class)
107 .addClass(AuthorizationExceptionHandlerFactory.class) 109 .addClass(AuthorizationExceptionHandlerFactory.class)
impl/extension/jsf/src/test/java/xxxx/XTest.java
1 package xxxx; 1 package xxxx;
2 2
3 -import java.net.URL; 3 +//import java.net.URL;
4 4
5 -import org.jboss.arquillian.container.test.api.Deployment;  
6 -import org.jboss.arquillian.drone.api.annotation.Drone;  
7 -import org.jboss.arquillian.junit.Arquillian;  
8 -import org.jboss.arquillian.test.api.ArquillianResource;  
9 -import org.jboss.shrinkwrap.api.spec.WebArchive;  
10 -import org.junit.Test;  
11 -import org.junit.runner.RunWith; 5 +//import org.jboss.arquillian.container.test.api.Deployment;
  6 +//import org.jboss.arquillian.drone.api.annotation.Drone;
  7 +//import org.jboss.arquillian.junit.Arquillian;
  8 +//import org.jboss.arquillian.test.api.ArquillianResource;
  9 +//import org.jboss.shrinkwrap.api.spec.WebArchive;
  10 +//import org.junit.Test;
  11 +//import org.junit.runner.RunWith;
12 12
13 -import test.Tests; 13 +//import test.Tests;
14 14
15 -import com.thoughtworks.selenium.DefaultSelenium; 15 +//import com.thoughtworks.selenium.DefaultSelenium;
16 16
17 -@RunWith(Arquillian.class) 17 +//@RunWith(Arquillian.class)
18 public class XTest { 18 public class XTest {
19 19
20 - private static final String PATH = "src/test/resources/xxx";  
21 -  
22 - @Drone  
23 - private DefaultSelenium browser;  
24 -  
25 - @ArquillianResource  
26 - private URL deploymentUrl;  
27 -  
28 - @Deployment(testable = false)  
29 - public static WebArchive createDeployment() {  
30 - return Tests.createDeployment().addClass(XServlet.class)  
31 - .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");  
32 - }  
33 -  
34 - @Test  
35 - public void xxxx() {  
36 - browser.open(deploymentUrl + "/login"); 20 +// private static final String PATH = "src/test/resources/xxx";
  21 +//
  22 +// @Drone
  23 +// private DefaultSelenium browser;
  24 +//
  25 +// @ArquillianResource
  26 +// private URL deploymentUrl;
  27 +//
  28 +// @Deployment(testable = false)
  29 +// public static WebArchive createDeployment() {
  30 +// return Tests.createDeployment().addClass(XServlet.class)
  31 +// .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
  32 +// }
  33 +//
  34 +// @Test
  35 +// public void xxxx() {
  36 +// browser.open(deploymentUrl + "/login");
37 37
38 // browser.type("id=xxx-input", "demo"); 38 // browser.type("id=xxx-input", "demo");
39 // browser.waitForPageToLoad("15000"); 39 // browser.waitForPageToLoad("15000");
@@ -42,5 +42,5 @@ public class XTest { @@ -42,5 +42,5 @@ public class XTest {
42 // browser.isElementPresent("xpath=//li[contains(text(), 'Welcome')]")); 42 // browser.isElementPresent("xpath=//li[contains(text(), 'Welcome')]"));
43 // assertTrue("Username should be shown!", 43 // assertTrue("Username should be shown!",
44 // browser.isElementPresent("xpath=//p[contains(text(), 'You are signed in as demo.')]")); 44 // browser.isElementPresent("xpath=//p[contains(text(), 'You are signed in as demo.')]"));
45 - } 45 +// }
46 } 46 }
impl/extension/jsf/src/test/resources/.arquillian-drone.profile
impl/extension/jsf/src/test/resources/proxy/web.xml 0 → 100644
@@ -0,0 +1,63 @@ @@ -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 +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  38 + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  39 +
  40 + <listener>
  41 + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class>
  42 + </listener>
  43 + <filter>
  44 + <filter-name>Demoiselle Servlet Filter</filter-name>
  45 + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class>
  46 + </filter>
  47 + <filter-mapping>
  48 + <filter-name>Demoiselle Servlet Filter</filter-name>
  49 + <url-pattern>/*</url-pattern>
  50 + </filter-mapping>
  51 +
  52 + <servlet>
  53 + <servlet-name>Servlet Class</servlet-name>
  54 + <servlet-class>proxy.FacesContextProxyServlet</servlet-class>
  55 + <!-- <load-on-startup>1</load-on-startup> -->
  56 + </servlet>
  57 +
  58 + <servlet-mapping>
  59 + <servlet-name>Servlet Class</servlet-name>
  60 + <url-pattern>/index</url-pattern>
  61 + </servlet-mapping>
  62 +
  63 +</web-app>
0 \ No newline at end of file 64 \ No newline at end of file