Commit a72f5cbebcc2a8f61762e1058196359d6c3aaabf

Authored by Dancovich
2 parents 1883b74b 1b9eeaf8
Exists in master

Merge branch 'master' of https://github.com/demoiselle/framework.git

Showing 54 changed files with 757 additions and 807 deletions   Show diff stats
documentation/reference/pt-BR/mensagem.xml
... ... @@ -145,41 +145,15 @@ private MessageContext messageContext;]]></programlisting>
145 145 <programlisting role="JAVA"><![CDATA[Message message = new DefaultMessage("Ocorreu um erro ao excluir o aluno!", SeverityType.ERROR);
146 146 messageContext.add(message);]]></programlisting>
147 147 <para>
148   - Uma vez inseridas no contexto em determinada camada da aplicação, as mensagens podem ser posteriormente
149   - recuperadas. Para tal, é preciso invocar o método <function>getMessages()</function> da interface
150   - <literal>MessageContext</literal>, o qual retornará uma coleção de objetos do tipo <literal>Message</literal>.
  148 + A extensão para <emphasis>demoiselle-jsf</emphasis>
  149 + transfere automaticamente as mensagens incluídas no <literal>MessageContext</literal>
  150 + para o <literal>FacesContext</literal>.
151 151 </para>
152   - <note>
153   - <para>
154   - A extensão para <emphasis>JavaServer Faces</emphasis> no <emphasis>Demoiselle Framework</emphasis>
155   - transfere automaticamente as mensagens incluídas no <literal>MessageContext</literal> para a apresentação
156   - durante a renderização da página pelo <emphasis>JSF</emphasis>.
157   - </para>
158   - </note>
159   - <para>
160   - Para remover todas as mensagens existentes no contexto, basta invocar o método <function>clear()</function> da
161   - interface <literal>MessageContext</literal>.
162   - </para>
163   - <note>
164   - <para>
165   - Especificamente para aplicações Java Web, o contexto de mensagens é automaticamente reinicializado a cada
166   - requisição HTTP. Ou seja, as mensagens incluídas no contexto por uma determinada sessão de usuário não
167   - interferem nas demais sessões existentes no servidor de aplicações. Além disso, ao final da requisição as
168   - mensagens existentes são automaticamente excluídas do contexto.
169   - </para>
170   - </note>
171 152 <para>
172   - O contexto de mensagens <literal>MessageContext</literal> tem o seu ciclo de vida gerenciado pelo CDI e pertence
173   - ao escopo de sessão (i.e., <literal>@SessionScoped</literal>). Ou seja, mensagens incluídas na requisição de um
174   - determinado usuário não serão exibidas para um outro usuário, pois cada um possuirá a sua sessão.
  153 + O contexto de mensagens, representado pela interface <literal>MessageContext</literal>, é capaz de
  154 + armazenar diversas mensagens em uma mesma requisição. Ele não é restrito a aplicações do tipo Web,
  155 + isto é, pode ser usado também para aplicações do tipo desktop (i.e., Swing).
175 156 </para>
176   - <note>
177   - <para>
178   - O contexto de mensagens, representado pela interface <literal>MessageContext</literal>, é capaz de
179   - armazenar diversas mensagens em uma mesma requisição. Ele não é restrito a aplicações do tipo Web,
180   - isto é, pode ser usado também para aplicações do tipo desktop (i.e., Swing).
181   - </para>
182   - </note>
183 157 </section>
184 158  
185 159 <section>
... ...
impl/core/pom.xml
... ... @@ -104,60 +104,7 @@
104 104 <groupId>org.codehaus.mojo</groupId>
105 105 <artifactId>cobertura-maven-plugin</artifactId>
106 106 </plugin>
107   -
108   - <!--
109   - <plugin>
110   - <groupId>org.jacoco</groupId>
111   - <artifactId>jacoco-maven-plugin</artifactId>
112   - <version>${jacoco.version}</version>
113   - <executions>
114   - <execution>
115   - <goals>
116   - <goal>prepare-agent</goal>
117   - </goals>
118   - </execution>
119   - <execution>
120   - <id>report</id>
121   - <phase>prepare-package</phase>
122   - <goals>
123   - <goal>report</goal>
124   - </goals>
125   - </execution>
126   - </executions>
127   - </plugin>
128   - -->
129 107 </plugins>
130   -
131   - <!--
132   - <pluginManagement>
133   - <plugins>
134   - <plugin>
135   - <groupId>org.eclipse.m2e</groupId>
136   - <artifactId>lifecycle-mapping</artifactId>
137   - <version>1.0.0</version>
138   - <configuration>
139   - <lifecycleMappingMetadata>
140   - <pluginExecutions>
141   - <pluginExecution>
142   - <pluginExecutionFilter>
143   - <groupId>org.jacoco</groupId>
144   - <artifactId>jacoco-maven-plugin</artifactId>
145   - <versionRange>[${jacoco.version},)</versionRange>
146   - <goals>
147   - <goal>prepare-agent</goal>
148   - </goals>
149   - </pluginExecutionFilter>
150   - <action>
151   - <ignore></ignore>
152   - </action>
153   - </pluginExecution>
154   - </pluginExecutions>
155   - </lifecycleMappingMetadata>
156   - </configuration>
157   - </plugin>
158   - </plugins>
159   - </pluginManagement>
160   - -->
161 108 </build>
162 109  
163 110 <dependencies>
... ... @@ -196,7 +143,7 @@
196 143 <dependency>
197 144 <groupId>org.jboss.arquillian.container</groupId>
198 145 <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
199   - <version>${arquillian.weld.version}</version>
  146 +<!-- <version>1.0.0.CR7</version> -->
200 147 <scope>test</scope>
201 148 </dependency>
202 149 <dependency>
... ... @@ -214,40 +161,6 @@
214 161 <artifactId>slf4j-log4j12</artifactId>
215 162 <scope>test</scope>
216 163 </dependency>
217   -
218   - <!--
219   - <dependency>
220   - <groupId>javax.servlet</groupId>
221   - <artifactId>servlet-api</artifactId>
222   - <scope>test</scope>
223   - </dependency>
224   -
225   - <dependency>
226   - <groupId>org.jboss.arquillian.extension</groupId>
227   - <artifactId>arquillian-jacoco</artifactId>
228   - <version>1.0.0.Alpha5</version>
229   - <scope>test</scope>
230   - </dependency>
231   - <dependency>
232   - <groupId>org.jacoco</groupId>
233   - <artifactId>org.jacoco.core</artifactId>
234   - <version>${jacoco.version}</version>
235   - <scope>test</scope>
236   - </dependency>
237   -
238   - <dependency>
239   - <groupId>org.jboss.shrinkwrap.descriptors</groupId>
240   - <artifactId>shrinkwrap-descriptors-spi</artifactId>
241   - <version>2.0.0-alpha-4</version>
242   - <scope>test</scope>
243   - </dependency>
244   -
245   - <dependency>
246   - <groupId>javax.el</groupId>
247   - <artifactId>el-api</artifactId>
248   - <scope>test</scope>
249   - </dependency>
250   - -->
251 164 </dependencies>
252 165  
253 166 <repositories>
... ... @@ -276,10 +189,7 @@
276 189 </repositories>
277 190  
278 191 <properties>
279   - <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
280   - <arquillian.weld.version>1.0.0.CR7</arquillian.weld.version>
281   -
282   - <!-- <jacoco.version>0.6.0.201210061924</jacoco.version> -->
283 192 <demoiselle.validation.version>2.4.0-BETA2-SNAPSHOT</demoiselle.validation.version>
  193 + <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
284 194 </properties>
285 195 </project>
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/security/NotLoggedInException.java
... ... @@ -44,7 +44,7 @@ package br.gov.frameworkdemoiselle.security;
44 44 public class NotLoggedInException extends AuthenticationException {
45 45  
46 46 private static final long serialVersionUID = 1L;
47   -
  47 +
48 48 /**
49 49 * Constructs an <code>NotLoggedInException</code> with a message.
50 50 */
... ...
impl/core/src/test/java/security/authorization/custom/CustomAuthorizer.java
... ... @@ -51,7 +51,4 @@ public class CustomAuthorizer implements Authorizer {
51 51 public boolean hasPermission(String resource, String operation) {
52 52 return "resource".equals(resource) && "operation".equals(operation);
53 53 }
54   -
55   -
56   -
57 54 }
... ...
impl/core/src/test/java/security/authorization/custom/CustomAuthorizerTest.java
... ... @@ -36,9 +36,10 @@
36 36 */
37 37 package security.authorization.custom;
38 38  
39   -import javax.inject.Inject;
  39 +import static junit.framework.Assert.assertFalse;
  40 +import static junit.framework.Assert.assertTrue;
40 41  
41   -import junit.framework.Assert;
  42 +import javax.inject.Inject;
42 43  
43 44 import org.jboss.arquillian.container.test.api.Deployment;
44 45 import org.jboss.arquillian.junit.Arquillian;
... ... @@ -66,44 +67,43 @@ public class CustomAuthorizerTest {
66 67 deployment.addClass(CustomAuthorizer.class);
67 68 return deployment;
68 69 }
69   -
  70 +
70 71 @Before
71   - public void loginToTest(){
  72 + public void loginToTest() {
72 73 context.login();
73 74 }
74 75  
75 76 @Test
76   - public void hasPermission(){
77   - Assert.assertTrue(context.hasPermission("resource", "operation"));
  77 + public void hasPermission() {
  78 + assertTrue(context.hasPermission("resource", "operation"));
78 79 }
79   -
  80 +
80 81 @Test
81   - public void hasRole(){
82   - Assert.assertTrue(context.hasRole("role"));
  82 + public void hasRole() {
  83 + assertTrue(context.hasRole("role"));
83 84 }
84   -
  85 +
85 86 /**
86 87 * Verify if when already exist an authorizer, the things keeps working fine.
87 88 */
88 89 @Test
89   - public void hasPermitionAndHasRole(){
90   - Assert.assertTrue(context.hasPermission("resource", "operation"));
91   - Assert.assertTrue(context.hasRole("role"));
  90 + public void hasPermitionAndHasRole() {
  91 + assertTrue(context.hasPermission("resource", "operation"));
  92 + assertTrue(context.hasRole("role"));
92 93 }
93   -
  94 +
94 95 @Test
95   - public void denyPermission(){
96   - Assert.assertFalse(context.hasPermission("falseresource", "falseoperation"));
  96 + public void denyPermission() {
  97 + assertFalse(context.hasPermission("falseresource", "falseoperation"));
97 98 }
98   -
  99 +
99 100 @Test
100   - public void denyRole(){
101   - Assert.assertFalse(context.hasRole("falserole"));
  101 + public void denyRole() {
  102 + assertFalse(context.hasRole("falserole"));
102 103 }
103   -
  104 +
104 105 @After
105   - public void logoutAfterTest(){
  106 + public void logoutAfterTest() {
106 107 context.logout();
107 108 }
108   -
109 109 }
... ...
impl/core/src/test/java/security/authorization/disable/DisabledAuthorizationTest.java
... ... @@ -36,14 +36,13 @@
36 36 */
37 37 package security.authorization.disable;
38 38  
  39 +import static junit.framework.Assert.assertTrue;
39 40 import static org.junit.Assert.assertNull;
40 41  
41 42 import javax.enterprise.context.RequestScoped;
42 43 import javax.enterprise.event.Observes;
43 44 import javax.inject.Inject;
44 45  
45   -import junit.framework.Assert;
46   -
47 46 import org.jboss.arquillian.container.test.api.Deployment;
48 47 import org.jboss.arquillian.junit.Arquillian;
49 48 import org.jboss.shrinkwrap.api.spec.JavaArchive;
... ... @@ -69,10 +68,8 @@ public class DisabledAuthorizationTest {
69 68  
70 69 @Deployment
71 70 public static JavaArchive createDeployment() {
72   - JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class);
73   - deployment.addClass(CustomAuthorizer.class);
74   - deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties");
75   - return deployment;
  71 + return Tests.createDeployment(ConfigurationResourceTest.class).addClasses(CustomAuthorizer.class)
  72 + .addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties");
76 73 }
77 74  
78 75 public void observer(@Observes AfterLoginSuccessful event) {
... ... @@ -81,15 +78,15 @@ public class DisabledAuthorizationTest {
81 78  
82 79 @Test
83 80 public void hasPermissionProcess() {
84   - Assert.assertTrue(context.hasPermission("resource", "operation"));
85   - Assert.assertTrue(context.hasPermission("falseresource", "falseoperation"));
  81 + assertTrue(context.hasPermission("resource", "operation"));
  82 + assertTrue(context.hasPermission("falseresource", "falseoperation"));
86 83 assertNull(event);
87 84 }
88 85  
89 86 @Test
90   - public void hasRoleProcess(){
91   - Assert.assertTrue(context.hasRole("role"));
92   - Assert.assertTrue(context.hasRole("falserole"));
  87 + public void hasRoleProcess() {
  88 + assertTrue(context.hasRole("role"));
  89 + assertTrue(context.hasRole("falserole"));
93 90 assertNull(event);
94 91 }
95 92 }
... ...
impl/extension/jdbc/pom.xml
... ... @@ -74,6 +74,16 @@
74 74  
75 75 <!-- for tests -->
76 76 <dependency>
  77 + <groupId>org.jboss.arquillian.container</groupId>
  78 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  79 + <scope>test</scope>
  80 + </dependency>
  81 + <dependency>
  82 + <groupId>org.glassfish.main.extras</groupId>
  83 + <artifactId>glassfish-embedded-all</artifactId>
  84 + <scope>test</scope>
  85 + </dependency>
  86 + <dependency>
77 87 <groupId>hsqldb</groupId>
78 88 <artifactId>hsqldb</artifactId>
79 89 <scope>test</scope>
... ...
impl/extension/jdbc/src/test/resources/.arquillian-glassfish-embedded.profile
impl/extension/jmx/pom.xml
... ... @@ -57,18 +57,8 @@
57 57  
58 58 <!-- Test dependencies -->
59 59 <dependency>
60   - <groupId>junit</groupId>
61   - <artifactId>junit</artifactId>
62   - <scope>test</scope>
63   - </dependency>
64   - <dependency>
65   - <groupId>org.jboss.arquillian.junit</groupId>
66   - <artifactId>arquillian-junit-container</artifactId>
67   - <scope>test</scope>
68   - </dependency>
69   - <dependency>
70   - <groupId>org.jboss.shrinkwrap.resolver</groupId>
71   - <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
  60 + <groupId>org.jboss.arquillian.container</groupId>
  61 + <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
72 62 <scope>test</scope>
73 63 </dependency>
74 64 <dependency>
... ... @@ -76,13 +66,6 @@
76 66 <artifactId>weld-se-core</artifactId>
77 67 <scope>test</scope>
78 68 </dependency>
79   - <!--
80   - <dependency>
81   - <groupId>org.jboss.arquillian.container</groupId>
82   - <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
83   - <scope>test</scope>
84   - </dependency>
85   - -->
86 69 <dependency>
87 70 <groupId>org.hibernate</groupId>
88 71 <artifactId>hibernate-validator</artifactId>
... ...
impl/extension/jmx/src/test/resources/.arquillian-weld-se-embedded.profile
impl/extension/jpa/pom.xml
... ... @@ -71,6 +71,18 @@
71 71 <groupId>org.eclipse.persistence</groupId>
72 72 <artifactId>javax.persistence</artifactId>
73 73 </dependency>
  74 +
  75 + <!-- for tests -->
  76 + <dependency>
  77 + <groupId>org.jboss.arquillian.container</groupId>
  78 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  79 + <scope>test</scope>
  80 + </dependency>
  81 + <dependency>
  82 + <groupId>org.glassfish.main.extras</groupId>
  83 + <artifactId>glassfish-embedded-all</artifactId>
  84 + <scope>test</scope>
  85 + </dependency>
74 86 </dependencies>
75 87  
76 88 <repositories>
... ...
impl/extension/jpa/src/test/resources/.arquillian-glassfish-embedded.profile
impl/extension/jsf/pom.xml
... ... @@ -80,22 +80,27 @@
80 80 <artifactId>el-impl</artifactId>
81 81 <scope>provided</scope>
82 82 </dependency>
83   - <!-- For Tests -->
  83 +
  84 + <!-- for tests -->
84 85 <dependency>
85 86 <groupId>com.sun.faces</groupId>
86 87 <artifactId>jsf-impl</artifactId>
87 88 <scope>test</scope>
88 89 </dependency>
89 90 <dependency>
90   - <groupId>commons-httpclient</groupId>
91   - <artifactId>commons-httpclient</artifactId>
92   - <version>3.1</version>
  91 + <groupId>org.jboss.arquillian.container</groupId>
  92 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
93 93 <scope>test</scope>
94 94 </dependency>
95 95 <dependency>
96   - <groupId>com.ocpsoft</groupId>
97   - <artifactId>prettyfaces-jsf2</artifactId>
98   - <version>3.3.0</version>
  96 + <groupId>org.glassfish.main.extras</groupId>
  97 + <artifactId>glassfish-embedded-all</artifactId>
  98 + <scope>test</scope>
  99 + </dependency>
  100 + <dependency>
  101 + <groupId>commons-httpclient</groupId>
  102 + <artifactId>commons-httpclient</artifactId>
  103 + <version>3.1</version>
99 104 <scope>test</scope>
100 105 </dependency>
101 106 </dependencies>
... ... @@ -124,4 +129,37 @@
124 129 </releases>
125 130 </repository>
126 131 </repositories>
  132 +
  133 + <profiles>
  134 + <profile>
  135 + <id>arquillian-test</id>
  136 + <dependencies>
  137 + <dependency>
  138 + <groupId>com.sun.faces</groupId>
  139 + <artifactId>jsf-api</artifactId>
  140 + <scope>provided</scope>
  141 + </dependency>
  142 + <dependency>
  143 + <groupId>br.gov.frameworkdemoiselle</groupId>
  144 + <artifactId>demoiselle-servlet</artifactId>
  145 + <exclusions>
  146 + <exclusion>
  147 + <groupId>javax.servlet</groupId>
  148 + <artifactId>javax.servlet-api</artifactId>
  149 + </exclusion>
  150 + </exclusions>
  151 + </dependency>
  152 + <!--
  153 + -->
  154 + <dependency>
  155 + <groupId>com.ocpsoft</groupId>
  156 + <artifactId>prettyfaces-jsf2</artifactId>
  157 + <version>3.3.0</version>
  158 + <scope>runtime</scope>
  159 + </dependency>
  160 + <!--
  161 + -->
  162 + </dependencies>
  163 + </profile>
  164 + </profiles>
127 165 </project>
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionHandler.java
... ... @@ -36,14 +36,20 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.internal.implementation;
38 38  
  39 +import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
  40 +
39 41 import javax.faces.context.ExceptionHandler;
40 42 import javax.faces.context.FacesContext;
  43 +import javax.servlet.http.HttpServletResponse;
41 44  
  45 +import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig;
42 46 import br.gov.frameworkdemoiselle.security.NotLoggedInException;
43 47 import br.gov.frameworkdemoiselle.util.Beans;
44 48  
45 49 public class AuthenticationExceptionHandler extends AbstractExceptionHandler {
46 50  
  51 + private transient JsfSecurityConfig config;
  52 +
47 53 public AuthenticationExceptionHandler(final ExceptionHandler wrapped) {
48 54 super(wrapped);
49 55 }
... ... @@ -53,10 +59,25 @@ public class AuthenticationExceptionHandler extends AbstractExceptionHandler {
53 59  
54 60 if (cause instanceof NotLoggedInException) {
55 61 handled = true;
56   - //TODO Inter [NQ]: remover referência a SecurityObserver criando uma classe comum que faz o redirecionamento e que é compartilhada entre elas.
57   - Beans.getReference(SecurityObserver.class).redirectToLoginPage();
  62 + // TODO Inter [NQ]: remover referência a SecurityObserver criando uma classe comum que faz o
  63 + // redirecionamento e que é compartilhada entre elas.
  64 +
  65 + if (getConfig().isRedirectEnabled()) {
  66 + Beans.getReference(SecurityObserver.class).redirectToLoginPage();
  67 + } else {
  68 + HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
  69 + response.setStatus(SC_FORBIDDEN);
  70 + }
58 71 }
59 72  
60 73 return handled;
61 74 }
  75 +
  76 + public JsfSecurityConfig getConfig() {
  77 + if (this.config == null) {
  78 + this.config = Beans.getReference(JsfSecurityConfig.class);
  79 + }
  80 +
  81 + return this.config;
  82 + }
62 83 }
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandler.java
... ... @@ -36,9 +36,12 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.internal.implementation;
38 38  
  39 +import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
  40 +
39 41 import javax.faces.context.ExceptionHandler;
40 42 import javax.faces.context.FacesContext;
41 43 import javax.faces.event.PhaseId;
  44 +import javax.servlet.http.HttpServletResponse;
42 45  
43 46 import br.gov.frameworkdemoiselle.security.AuthorizationException;
44 47 import br.gov.frameworkdemoiselle.util.Faces;
... ... @@ -53,9 +56,15 @@ public class AuthorizationExceptionHandler extends AbstractExceptionHandler {
53 56 boolean handled = false;
54 57 boolean rendering = PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId());
55 58  
56   - if (!rendering && cause instanceof AuthorizationException) {
57   - Faces.addMessage(cause);
  59 + if (cause instanceof AuthorizationException) {
58 60 handled = true;
  61 +
  62 + if (rendering) {
  63 + HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
  64 + response.setStatus(SC_UNAUTHORIZED);
  65 + } else {
  66 + Faces.addMessage(cause);
  67 + }
59 68 }
60 69  
61 70 return handled;
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
... ... @@ -49,7 +49,7 @@ import br.gov.frameworkdemoiselle.util.Reflections;
49 49 import br.gov.frameworkdemoiselle.util.ResourceBundle;
50 50  
51 51 /**
52   - * Template Managed Bean class that implements the methods defined by the interface EditPageBean.
  52 + * Template Managed AuthenticationBean class that implements the methods defined by the interface EditPageBean.
53 53 *
54 54 * @param <T>
55 55 * bean object type
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractListPageBean.java
... ... @@ -50,7 +50,7 @@ import br.gov.frameworkdemoiselle.pagination.Pagination;
50 50 import br.gov.frameworkdemoiselle.pagination.PaginationContext;
51 51 import br.gov.frameworkdemoiselle.util.Reflections;
52 52 /**
53   - * Template Managed Bean class that implements the methods defined by the interface ListPageBean.
  53 + * Template Managed AuthenticationBean class that implements the methods defined by the interface ListPageBean.
54 54 *
55 55 * @param <T>
56 56 * bean object type
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractPageBean.java
... ... @@ -43,7 +43,7 @@ import br.gov.frameworkdemoiselle.annotation.NextView;
43 43 import br.gov.frameworkdemoiselle.annotation.PreviousView;
44 44  
45 45 /**
46   - * Template Managed Bean class that implements the methods defined by the interface PageBean.
  46 + * Template Managed AuthenticationBean class that implements the methods defined by the interface PageBean.
47 47 *
48 48 * @author SERPRO
49 49 * @see PageBean
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Redirector.java
... ... @@ -48,11 +48,10 @@ import javax.faces.application.ViewHandler;
48 48 import javax.faces.context.FacesContext;
49 49  
50 50 /**
51   - *
52 51 * Utility class to redirect determined page to another one.
53 52 *
54 53 * @author SERPRO
55   - * */
  54 + */
56 55 public class Redirector {
57 56  
58 57 private Redirector() {
... ... @@ -74,6 +73,7 @@ public class Redirector {
74 73 }
75 74  
76 75 } catch (NullPointerException cause) {
  76 + cause.printStackTrace();
77 77 throw new PageNotFoundException(viewId);
78 78  
79 79 } catch (IOException cause) {
... ...
impl/extension/jsf/src/test/java/exception/handler/authentication/AuthenticationBean.java
... ... @@ -46,9 +46,7 @@ public class AuthenticationBean implements Serializable {
46 46  
47 47 private static final long serialVersionUID = 1L;
48 48  
49   - private String msg = "Authentication Exception";
50   -
51 49 public String getMsg() {
52   - throw new NotLoggedInException(msg);
  50 + throw new NotLoggedInException("");
53 51 }
54 52 }
... ...
impl/extension/jsf/src/test/java/exception/handler/authentication/AuthenticationExceptionTest.java
... ... @@ -1,89 +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 exception.handler.authentication;
38   -
39   -import static org.junit.Assert.assertTrue;
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.methods.GetMethod;
47   -import org.jboss.arquillian.container.test.api.Deployment;
48   -import org.jboss.arquillian.junit.Arquillian;
49   -import org.jboss.arquillian.test.api.ArquillianResource;
50   -import org.jboss.shrinkwrap.api.spec.WebArchive;
51   -import org.junit.Test;
52   -import org.junit.runner.RunWith;
53   -
54   -import test.Tests;
55   -
56   -@RunWith(Arquillian.class)
57   -public class AuthenticationExceptionTest {
58   -
59   - @ArquillianResource
60   - private URL deploymentUrl;
61   -
62   - private static final String PATH = "src/test/resources/exception-handler-authentication";
63   -
64   - @Deployment(testable = false)
65   - public static WebArchive createDeployment() {
66   - return Tests.createDeployment().addClass(AuthenticationExceptionTest.class).addClass(AuthenticationBean.class)
67   - .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
68   - .addAsWebResource(Tests.createFileAsset(PATH + "/login.xhtml"), "login.xhtml")
69   - .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
70   - }
71   -
72   - @Test
73   - public void authenticationException() {
74   - HttpClient client = new HttpClient();
75   - GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
76   -
77   - try {
78   - client.executeMethod(method);
79   - String message = method.getResponseBodyAsString();
80   - System.out.println("MESAGE: " + message);
81   - assertTrue(message.contains("Called the page /login"));
82   -
83   - } catch (HttpException e) {
84   - e.printStackTrace();
85   - } catch (IOException e) {
86   - e.printStackTrace();
87   - }
88   - }
89   -}
impl/extension/jsf/src/test/java/exception/handler/authentication/HandledAuthenticationExceptionTest.java 0 → 100644
... ... @@ -0,0 +1,81 @@
  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 exception.handler.authentication;
  38 +
  39 +import static org.junit.Assert.assertTrue;
  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.methods.GetMethod;
  47 +import org.jboss.arquillian.container.test.api.Deployment;
  48 +import org.jboss.arquillian.junit.Arquillian;
  49 +import org.jboss.arquillian.test.api.ArquillianResource;
  50 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  51 +import org.junit.Test;
  52 +import org.junit.runner.RunWith;
  53 +
  54 +import test.Tests;
  55 +
  56 +@RunWith(Arquillian.class)
  57 +public class HandledAuthenticationExceptionTest {
  58 +
  59 + @ArquillianResource
  60 + private URL deploymentUrl;
  61 +
  62 + private static final String PATH = "src/test/resources/exception-handler-authentication";
  63 +
  64 + @Deployment(testable = false)
  65 + public static WebArchive createDeployment() {
  66 + return Tests.createDeployment().addClasses(AuthenticationBean.class)
  67 + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
  68 + .addAsWebResource(Tests.createFileAsset(PATH + "/login.xhtml"), "login.xhtml")
  69 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
  70 + }
  71 +
  72 + @Test
  73 + public void authenticationException() throws HttpException, IOException {
  74 + HttpClient client = new HttpClient();
  75 + GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
  76 +
  77 + client.executeMethod(method);
  78 + String message = method.getResponseBodyAsString();
  79 + assertTrue(message.contains("Called the page /login"));
  80 + }
  81 +}
... ...
impl/extension/jsf/src/test/java/exception/handler/authentication/UnhandledAuthenticationExceptionTest.java 0 → 100644
... ... @@ -0,0 +1,81 @@
  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 exception.handler.authentication;
  38 +
  39 +import static org.apache.http.HttpStatus.SC_FORBIDDEN;
  40 +import static org.junit.Assert.assertEquals;
  41 +
  42 +import java.io.IOException;
  43 +import java.net.URL;
  44 +
  45 +import org.apache.commons.httpclient.HttpClient;
  46 +import org.apache.commons.httpclient.HttpException;
  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 UnhandledAuthenticationExceptionTest {
  59 +
  60 + @ArquillianResource
  61 + private URL deploymentUrl;
  62 +
  63 + private static final String PATH = "src/test/resources/exception-handler-authentication";
  64 +
  65 + @Deployment(testable = false)
  66 + public static WebArchive createDeployment() {
  67 + return Tests.createDeployment().addClasses(AuthenticationBean.class)
  68 + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
  69 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
  70 + .addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties");
  71 + }
  72 +
  73 + @Test
  74 + public void authenticationException() throws HttpException, IOException {
  75 + HttpClient client = new HttpClient();
  76 + GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
  77 +
  78 + int status = client.executeMethod(method);
  79 + assertEquals(SC_FORBIDDEN, status);
  80 + }
  81 +}
... ...
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationBean.java
... ... @@ -46,20 +46,7 @@ public class AuthorizationBean implements Serializable {
46 46  
47 47 private static final long serialVersionUID = 1L;
48 48  
49   - private String correctMessage = "Authorization Message.";
50   -
51   - private String exceptionMessage = "Authorization Exception!";
52   -
53   - public String getCorrectMessage() {
54   - return correctMessage;
55   - }
56   -
57   - public String getExceptionMessage() {
58   - throw new AuthorizationException(exceptionMessage);
  49 + public String getThrowExceptionMessage() {
  50 + throw new AuthorizationException("Authorization Exception!");
59 51 }
60   -
61   - public void loadExceptionMessage() {
62   - throw new AuthorizationException(exceptionMessage);
63   - }
64   -
65 52 }
... ...
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationHandledExceptionTest.java
... ... @@ -1,94 +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 exception.handler.authorization;
38   -
39   -import static org.junit.Assert.assertNotSame;
40   -import static org.junit.Assert.assertTrue;
41   -
42   -import java.io.IOException;
43   -import java.net.URL;
44   -
45   -import org.apache.commons.httpclient.HttpClient;
46   -import org.apache.commons.httpclient.HttpException;
47   -import org.apache.commons.httpclient.HttpStatus;
48   -import org.apache.commons.httpclient.methods.GetMethod;
49   -import org.jboss.arquillian.container.test.api.Deployment;
50   -import org.jboss.arquillian.junit.Arquillian;
51   -import org.jboss.arquillian.test.api.ArquillianResource;
52   -import org.jboss.shrinkwrap.api.spec.WebArchive;
53   -import org.junit.Test;
54   -import org.junit.runner.RunWith;
55   -
56   -import test.Tests;
57   -
58   -@RunWith(Arquillian.class)
59   -public class AuthorizationHandledExceptionTest {
60   -
61   - @ArquillianResource
62   - private URL deploymentUrl;
63   -
64   - private static final String PATH = "src/test/resources/exception-handler-authorization";
65   -
66   - @Deployment(testable = false)
67   - public static WebArchive createDeployment() {
68   - return Tests.createDeployment().addClass(AuthorizationHandledExceptionTest.class).addClass(AuthorizationBean.class)
69   - .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
70   - .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
71   - .addAsWebInfResource(Tests.createFileAsset(PATH + "/pretty-config.xml"), "pretty-config.xml");
72   -
73   - }
74   -
75   - @Test
76   - public void authorizationHandledException() {
77   - HttpClient client = new HttpClient();
78   - GetMethod method = new GetMethod(deploymentUrl + "/index");
79   -
80   - try {
81   - int status = client.executeMethod(method);
82   - String message = method.getResponseBodyAsString();
83   -
84   - assertNotSame(HttpStatus.SC_INTERNAL_SERVER_ERROR, status);
85   - assertTrue(message.contains("Authorization Message."));
86   - assertTrue(message.contains("Authorization Exception!"));
87   -
88   - } catch (HttpException e) {
89   - e.printStackTrace();
90   - } catch (IOException e) {
91   - e.printStackTrace();
92   - }
93   - }
94   -}
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationNotHandledExceptionTest.java
... ... @@ -1,93 +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 exception.handler.authorization;
38   -
39   -import static org.junit.Assert.assertEquals;
40   -import static org.junit.Assert.assertFalse;
41   -import static org.junit.Assert.assertTrue;
42   -
43   -import java.io.IOException;
44   -import java.net.URL;
45   -
46   -import org.apache.commons.httpclient.HttpClient;
47   -import org.apache.commons.httpclient.HttpException;
48   -import org.apache.commons.httpclient.HttpStatus;
49   -import org.apache.commons.httpclient.methods.GetMethod;
50   -import org.jboss.arquillian.container.test.api.Deployment;
51   -import org.jboss.arquillian.junit.Arquillian;
52   -import org.jboss.arquillian.test.api.ArquillianResource;
53   -import org.jboss.shrinkwrap.api.spec.WebArchive;
54   -import org.junit.Test;
55   -import org.junit.runner.RunWith;
56   -
57   -import test.Tests;
58   -
59   -@RunWith(Arquillian.class)
60   -public class AuthorizationNotHandledExceptionTest {
61   -
62   - @ArquillianResource
63   - private URL deploymentUrl;
64   -
65   - private static final String PATH = "src/test/resources/exception-handler-authorization";
66   -
67   - @Deployment(testable = false)
68   - public static WebArchive createDeployment() {
69   - return Tests.createDeployment().addClass(AuthorizationNotHandledExceptionTest.class).addClass(AuthorizationBean.class)
70   - .addAsWebResource(Tests.createFileAsset(PATH + "/page.xhtml"), "page.xhtml")
71   - .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
72   - }
73   -
74   - @Test
75   - public void authorizationNotHandledException() {
76   - HttpClient client = new HttpClient();
77   - GetMethod method = new GetMethod(deploymentUrl + "/page.jsf");
78   -
79   - try {
80   - int status = client.executeMethod(method);
81   - String message = method.getResponseBodyAsString();
82   -
83   - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, status);
84   - assertTrue(message.contains("Authorization Exception!"));
85   - assertFalse(message.contains("Authorization Message."));
86   -
87   - } catch (HttpException e) {
88   - e.printStackTrace();
89   - } catch (IOException e) {
90   - e.printStackTrace();
91   - }
92   - }
93   -}
impl/extension/jsf/src/test/java/exception/handler/authorization/HandledAuthorizationExceptionTest.java 0 → 100644
... ... @@ -0,0 +1,86 @@
  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 exception.handler.authorization;
  38 +
  39 +import static org.apache.commons.httpclient.HttpStatus.SC_OK;
  40 +import static org.junit.Assert.assertEquals;
  41 +import static org.junit.Assert.assertTrue;
  42 +
  43 +import java.io.IOException;
  44 +import java.net.URL;
  45 +
  46 +import org.apache.commons.httpclient.HttpClient;
  47 +import org.apache.commons.httpclient.HttpException;
  48 +import org.apache.commons.httpclient.methods.GetMethod;
  49 +import org.jboss.arquillian.container.test.api.Deployment;
  50 +import org.jboss.arquillian.junit.Arquillian;
  51 +import org.jboss.arquillian.test.api.ArquillianResource;
  52 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  53 +import org.junit.Test;
  54 +import org.junit.runner.RunWith;
  55 +
  56 +import test.Tests;
  57 +
  58 +@RunWith(Arquillian.class)
  59 +public class HandledAuthorizationExceptionTest {
  60 +
  61 + @ArquillianResource
  62 + private URL deploymentUrl;
  63 +
  64 + private static final String PATH = "src/test/resources/exception-handler-authorization";
  65 +
  66 + @Deployment(testable = false)
  67 + public static WebArchive createDeployment() {
  68 + return Tests.createDeployment().addClasses(AuthorizationBean.class)
  69 + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
  70 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
  71 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/pretty-config.xml"), "pretty-config.xml");
  72 +
  73 + }
  74 +
  75 + @Test
  76 + public void authorizationException() throws HttpException, IOException {
  77 + HttpClient client = new HttpClient();
  78 + GetMethod method = new GetMethod(deploymentUrl + "/index");
  79 +
  80 + int status = client.executeMethod(method);
  81 + String message = method.getResponseBodyAsString();
  82 +
  83 + assertEquals(SC_OK, status);
  84 + assertTrue(message.contains("Authorization Exception!"));
  85 + }
  86 +}
... ...
impl/extension/jsf/src/test/java/exception/handler/authorization/UnhandledAuthorizationExceptionTest.java 0 → 100644
... ... @@ -0,0 +1,80 @@
  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 exception.handler.authorization;
  38 +
  39 +import static org.apache.commons.httpclient.HttpStatus.SC_UNAUTHORIZED;
  40 +import static org.junit.Assert.assertEquals;
  41 +
  42 +import java.io.IOException;
  43 +import java.net.URL;
  44 +
  45 +import org.apache.commons.httpclient.HttpClient;
  46 +import org.apache.commons.httpclient.HttpException;
  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 UnhandledAuthorizationExceptionTest {
  59 +
  60 + @ArquillianResource
  61 + private URL deploymentUrl;
  62 +
  63 + private static final String PATH = "src/test/resources/exception-handler-authorization";
  64 +
  65 + @Deployment(testable = false)
  66 + public static WebArchive createDeployment() {
  67 + return Tests.createDeployment().addClasses(AuthorizationBean.class)
  68 + .addAsWebResource(Tests.createFileAsset(PATH + "/error.xhtml"), "error.xhtml")
  69 + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
  70 + }
  71 +
  72 + @Test
  73 + public void authorizationException() throws HttpException, IOException {
  74 + HttpClient client = new HttpClient();
  75 + GetMethod method = new GetMethod(deploymentUrl + "/error.jsf");
  76 +
  77 + int status = client.executeMethod(method);
  78 + assertEquals(SC_UNAUTHORIZED, status);
  79 + }
  80 +}
... ...
impl/extension/jsf/src/test/java/exception/handler/configuration/ExceptionHandlerDefaultConfigTest.java
... ... @@ -51,48 +51,33 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
51 51 import org.junit.Test;
52 52 import org.junit.runner.RunWith;
53 53  
  54 +import test.Tests;
54 55 import exception.handler.common.DummyException;
55 56 import exception.handler.common.ExceptionHandlerConfigBean;
56   -import test.Tests;
57 57  
58 58 @RunWith(Arquillian.class)
59   -public class ExceptionHandlerDefaultConfigTest{
  59 +public class ExceptionHandlerDefaultConfigTest {
60 60  
61 61 @ArquillianResource
62 62 private URL deploymentUrl;
63   -
  63 +
64 64 private static final String PATH = "src/test/resources/exception-handler-config";
65 65  
66 66 @Deployment(testable = false)
67 67 public static WebArchive createDeployment() {
68   - return Tests.createDeployment().addClass(ExceptionHandlerDefaultConfigTest.class)
69   - .addClass(DummyException.class)
70   - .addClass(ExceptionHandlerConfigBean.class)
  68 + return Tests.createDeployment().addClasses(DummyException.class, ExceptionHandlerConfigBean.class)
71 69 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
72 70 .addAsWebResource(Tests.createFileAsset(PATH + "/application_error.xhtml"), "application_error.xhtml")
73 71 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
74 72 }
75   -
  73 +
76 74 @Test
77   - public void defaultConfiguration() {
  75 + public void defaultConfiguration() throws HttpException, IOException {
78 76 HttpClient client = new HttpClient();
79 77 GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
80   -
81   - try {
82   - client.executeMethod(method);
83   - String message = method.getResponseBodyAsString();
84   - assertTrue(message.contains("Called the page /application_error"));
85   -
86   - } catch (HttpException e) {
87   - e.printStackTrace();
88   - } catch (IOException e) {
89   - e.printStackTrace();
90   - }
  78 +
  79 + client.executeMethod(method);
  80 + String message = method.getResponseBodyAsString();
  81 + assertTrue(message.contains("Called the page /application_error"));
91 82 }
92 83 }
93   -
94   -
95   -
96   -
97   -
98   -
... ...
impl/extension/jsf/src/test/java/exception/handler/configuration/ExceptionHandlerRedirectConfigTest.java
... ... @@ -65,8 +65,7 @@ public class ExceptionHandlerRedirectConfigTest {
65 65  
66 66 @Deployment(testable = false)
67 67 public static WebArchive createDeployment() {
68   - return Tests.createDeployment().addClass(ExceptionHandlerRedirectConfigTest.class)
69   - .addClass(DummyException.class).addClass(ExceptionHandlerConfigBean.class)
  68 + return Tests.createDeployment().addClasses(DummyException.class, ExceptionHandlerConfigBean.class)
70 69 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
71 70 .addAsWebResource(Tests.createFileAsset(PATH + "/error_page.xhtml"), "error_page.xhtml")
72 71 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
... ...
impl/extension/jsf/src/test/java/exception/handler/configuration/ExceptionNotHandlerConfigTest.java
... ... @@ -66,8 +66,7 @@ public class ExceptionNotHandlerConfigTest {
66 66  
67 67 @Deployment(testable = false)
68 68 public static WebArchive createDeployment() {
69   - return Tests.createDeployment().addClass(ExceptionNotHandlerConfigTest.class).addClass(DummyException.class)
70   - .addClass(ExceptionHandlerConfigBean.class)
  69 + return Tests.createDeployment().addClasses(DummyException.class, ExceptionHandlerConfigBean.class)
71 70 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
72 71 .addAsWebResource(Tests.createFileAsset(PATH + "/application_error.xhtml"), "application_error.xhtml")
73 72 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
... ... @@ -75,17 +74,10 @@ public class ExceptionNotHandlerConfigTest {
75 74 }
76 75  
77 76 @Test
78   - public void notHandlerConfiguration() {
  77 + public void notHandlerConfiguration() throws HttpException, IOException {
79 78 HttpClient client = new HttpClient();
80 79 GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
81 80  
82   - try {
83   - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, client.executeMethod(method));
84   -
85   - } catch (HttpException e) {
86   - e.printStackTrace();
87   - } catch (IOException e) {
88   - e.printStackTrace();
89   - }
  81 + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, client.executeMethod(method));
90 82 }
91 83 }
... ...
impl/extension/jsf/src/test/java/exception/handler/configuration/compatibility/ExceptionHandlerRedirectConfigTest.java
... ... @@ -65,8 +65,7 @@ public class ExceptionHandlerRedirectConfigTest {
65 65  
66 66 @Deployment(testable = false)
67 67 public static WebArchive createDeployment() {
68   - return Tests.createDeployment().addClass(ExceptionHandlerRedirectConfigTest.class)
69   - .addClass(DummyException.class).addClass(ExceptionHandlerConfigBean.class)
  68 + return Tests.createDeployment().addClasses(DummyException.class, ExceptionHandlerConfigBean.class)
70 69 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
71 70 .addAsWebResource(Tests.createFileAsset(PATH + "/error_page.xhtml"), "error_page.xhtml")
72 71 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
... ... @@ -74,19 +73,12 @@ public class ExceptionHandlerRedirectConfigTest {
74 73 }
75 74  
76 75 @Test
77   - public void notHandlerConfiguration() {
  76 + public void notHandlerConfiguration() throws HttpException, IOException {
78 77 HttpClient client = new HttpClient();
79 78 GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
80 79  
81   - try {
82   - client.executeMethod(method);
83   - String message = method.getResponseBodyAsString();
84   - assertTrue(message.contains("Called the page /error_page"));
85   -
86   - } catch (HttpException e) {
87   - e.printStackTrace();
88   - } catch (IOException e) {
89   - e.printStackTrace();
90   - }
  80 + client.executeMethod(method);
  81 + String message = method.getResponseBodyAsString();
  82 + assertTrue(message.contains("Called the page /error_page"));
91 83 }
92 84 }
... ...
impl/extension/jsf/src/test/java/exception/handler/configuration/compatibility/ExceptionNotHandlerConfigTest.java
... ... @@ -66,8 +66,7 @@ public class ExceptionNotHandlerConfigTest {
66 66  
67 67 @Deployment(testable = false)
68 68 public static WebArchive createDeployment() {
69   - return Tests.createDeployment().addClass(ExceptionNotHandlerConfigTest.class).addClass(DummyException.class)
70   - .addClass(ExceptionHandlerConfigBean.class)
  69 + return Tests.createDeployment().addClasses(DummyException.class, ExceptionHandlerConfigBean.class)
71 70 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
72 71 .addAsWebResource(Tests.createFileAsset(PATH + "/application_error.xhtml"), "application_error.xhtml")
73 72 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml")
... ... @@ -75,18 +74,11 @@ public class ExceptionNotHandlerConfigTest {
75 74 }
76 75  
77 76 @Test
78   - public void notHandlerConfiguration() {
  77 + public void notHandlerConfiguration() throws HttpException, IOException {
79 78 HttpClient client = new HttpClient();
80 79 GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
81 80  
82   - try {
83   - int status = client.executeMethod(method);
84   - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, status);
85   -
86   - } catch (HttpException e) {
87   - e.printStackTrace();
88   - } catch (IOException e) {
89   - e.printStackTrace();
90   - }
  81 + int status = client.executeMethod(method);
  82 + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, status);
91 83 }
92 84 }
... ...
impl/extension/jsf/src/test/java/exception/handler/redirect/RedirectExceptionTest.java
... ... @@ -25,20 +25,18 @@ public class RedirectExceptionTest {
25 25  
26 26 @ArquillianResource
27 27 private URL deploymentUrl;
28   -
  28 +
29 29 private static final String PATH = "src/test/resources/exception-handler-redirect";
30 30  
31 31 @Deployment(testable = false)
32 32 public static WebArchive createDeployment() {
33   - return Tests.createDeployment().addClass(RedirectExceptionTest.class)
34   - .addClass(RedirectBean.class)
35   - .addClass(ExceptionWithCorrectRedirect.class)
  33 + return Tests.createDeployment().addClasses(RedirectBean.class, ExceptionWithCorrectRedirect.class)
36 34 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
37 35 .addAsWebResource(Tests.createFileAsset(PATH + "/page.xhtml"), "page.xhtml")
38 36 .addAsWebResource(Tests.createFileAsset(PATH + "/redirect.xhtml"), "redirect.xhtml")
39 37 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
40 38 }
41   -
  39 +
42 40 @Test
43 41 public void handleExceptionWithCorrectRedirect() {
44 42 HttpClient client = new HttpClient();
... ... @@ -47,7 +45,7 @@ public class RedirectExceptionTest {
47 45 try {
48 46 int status = client.executeMethod(method);
49 47 String message = method.getResponseBodyAsString();
50   -
  48 +
51 49 assertEquals(HttpStatus.SC_OK, status);
52 50 assertFalse(message.contains("Correct Redirect Exception!"));
53 51 assertTrue(message.contains("Page redirected!"));
... ... @@ -58,7 +56,7 @@ public class RedirectExceptionTest {
58 56 e.printStackTrace();
59 57 }
60 58 }
61   -
  59 +
62 60 @Test
63 61 public void handleExceptionWithWrongRedirect() {
64 62 HttpClient client = new HttpClient();
... ... @@ -75,4 +73,3 @@ public class RedirectExceptionTest {
75 73 }
76 74 }
77 75 }
78   -
... ...
impl/extension/jsf/src/test/java/message/MessageTest.java
... ... @@ -63,26 +63,18 @@ public class MessageTest {
63 63  
64 64 @Deployment(testable = false)
65 65 public static WebArchive createDeployment() {
66   - return Tests.createDeployment().addClass(MessageTest.class)
67   - .addClass(MessageBean.class)
  66 + return Tests.createDeployment().addClasses(MessageBean.class)
68 67 .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml")
69 68 .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml");
70 69 }
71 70  
72 71 @Test
73   - public void showMessage() {
  72 + public void showMessage() throws HttpException, IOException {
74 73 HttpClient client = new HttpClient();
75 74 GetMethod method = new GetMethod(deploymentUrl + "/index.jsf");
76 75  
77   - try {
78   - client.executeMethod(method);
79   - String message = method.getResponseBodyAsString();
80   - assertTrue(message.contains("Message shown."));
81   -
82   - } catch (HttpException e) {
83   - e.printStackTrace();
84   - } catch (IOException e) {
85   - e.printStackTrace();
86   - }
  76 + client.executeMethod(method);
  77 + String message = method.getResponseBodyAsString();
  78 + assertTrue(message.contains("Message shown."));
87 79 }
88 80 }
... ...
impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java
... ... @@ -69,17 +69,11 @@ public class FacesContextProxyTest {
69 69 }
70 70  
71 71 @Test
72   - public void facesContextProxy() {
  72 + public void facesContextProxy() throws HttpException, IOException {
73 73 HttpClient client = new HttpClient();
74 74 GetMethod method = new GetMethod(deploymentUrl + "/index");
75 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   - }
  76 + int status = client.executeMethod(method);
  77 + assertEquals(HttpStatus.SC_OK, status);
84 78 }
85 79 }
... ...
impl/extension/jsf/src/test/java/test/Tests.java
... ... @@ -81,15 +81,12 @@ import br.gov.frameworkdemoiselle.util.Parameter;
81 81 import br.gov.frameworkdemoiselle.util.Redirector;
82 82  
83 83 @Ignore
  84 +@SuppressWarnings("deprecation")
84 85 public final class Tests {
85 86  
86 87 private Tests() {
87 88 }
88 89  
89   - public static WebArchive createDeployment(final Class<?> baseClass) {
90   - return createDeployment().addPackages(true, baseClass.getPackage()).addClass(Tests.class);
91   - }
92   -
93 90 public static WebArchive createDeployment() {
94 91 File[] libs = Maven.resolver().offline().loadPomFromFile("pom.xml", "arquillian-test")
95 92 .importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile();
... ...
impl/extension/jsf/src/test/resources/.arquillian-glassfish-embedded.profile
impl/extension/jsf/src/test/resources/exception-handler-authentication/demoiselle.properties 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +# Demoiselle Framework
  2 +# Copyright (C) 2010 SERPRO
  3 +# ----------------------------------------------------------------------------
  4 +# This file is part of Demoiselle Framework.
  5 +#
  6 +# Demoiselle Framework is free software; you can redistribute it and/or
  7 +# modify it under the terms of the GNU Lesser General Public License version 3
  8 +# as published by the Free Software Foundation.
  9 +#
  10 +# This program is distributed in the hope that it will be useful,
  11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 +# GNU General Public License for more details.
  14 +#
  15 +# You should have received a copy of the GNU Lesser General Public License version 3
  16 +# along with this program; if not, see <http://www.gnu.org/licenses/>
  17 +# or write to the Free Software Foundation, Inc., 51 Franklin Street,
  18 +# Fifth Floor, Boston, MA 02110-1301, USA.
  19 +# ----------------------------------------------------------------------------
  20 +# Este arquivo é parte do Framework Demoiselle.
  21 +#
  22 +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  23 +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  24 +# do Software Livre (FSF).
  25 +#
  26 +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  27 +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  28 +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  29 +# para maiores detalhes.
  30 +#
  31 +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  32 +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  33 +# ou escreva para a Fundação do Software Livre (FSF) Inc.,
  34 +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  35 +
  36 +frameworkdemoiselle.security.redirect.enabled=false
0 37 \ No newline at end of file
... ...
impl/extension/jsf/src/test/resources/exception-handler-authorization/error.xhtml 0 → 100644
... ... @@ -0,0 +1,43 @@
  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 +<html xmlns:h="http://java.sun.com/jsf/html">
  38 +
  39 + <h:body>
  40 + #{authorizationBean.throwExceptionMessage}
  41 + </h:body>
  42 +
  43 +</html>
... ...
impl/extension/jsf/src/test/resources/exception-handler-authorization/index.xhtml
1   -<html xmlns:h="http://java.sun.com/jsf/html"
2   - xmlns:ui="http://java.sun.com/jsf/facelets">
  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 +<html xmlns:h="http://java.sun.com/jsf/html">
3 38  
4 39 <h:body>
5   - #{authorizationBean.correctMessage}
6   - <h:messages />
  40 + <h:messages />
7 41 </h:body>
8 42  
9 43 </html>
... ...
impl/extension/jsf/src/test/resources/exception-handler-authorization/page.xhtml
... ... @@ -1,10 +0,0 @@
1   -<html xmlns:h="http://java.sun.com/jsf/html"
2   - xmlns:ui="http://java.sun.com/jsf/facelets">
3   -
4   - <h:body>
5   - #{authorizationBean.correctMessage}
6   - #{authorizationBean.exceptionMessage}
7   - <h:messages />
8   - </h:body>
9   -
10   -</html>
11 0 \ No newline at end of file
impl/extension/jsf/src/test/resources/exception-handler-authorization/pretty-config.xml
... ... @@ -43,7 +43,7 @@
43 43 <url-mapping id="index">
44 44 <pattern value="/index" />
45 45 <view-id value="/index.jsf" />
46   - <action>#{authorizationBean.loadExceptionMessage}</action>
  46 + <action>#{authorizationBean.getThrowExceptionMessage}</action>
47 47 </url-mapping>
48 48  
49 49 </pretty-config>
50 50 \ No newline at end of file
... ...
impl/extension/jsf/src/test/resources/exception-handler-authorization/web.xml
... ... @@ -71,4 +71,9 @@
71 71 <servlet-name>Faces Servlet</servlet-name>
72 72 <url-pattern>*.jsf</url-pattern>
73 73 </servlet-mapping>
  74 +
  75 + <context-param>
  76 + <param-name>facelets.SKIP_COMMENTS</param-name>
  77 + <param-value>true</param-value>
  78 + </context-param>
74 79 </web-app>
75 80 \ No newline at end of file
... ...
impl/extension/jsf/src/test/resources/xxx/web.xml
... ... @@ -1,52 +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   -<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   -</web-app>
53 0 \ No newline at end of file
impl/extension/jta/pom.xml
... ... @@ -72,6 +72,17 @@
72 72 <artifactId>jta</artifactId>
73 73 </dependency>
74 74  
  75 + <!-- for tests -->
  76 + <dependency>
  77 + <groupId>org.jboss.arquillian.container</groupId>
  78 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  79 + <scope>test</scope>
  80 + </dependency>
  81 + <dependency>
  82 + <groupId>org.glassfish.main.extras</groupId>
  83 + <artifactId>glassfish-embedded-all</artifactId>
  84 + <scope>test</scope>
  85 + </dependency>
75 86 <dependency>
76 87 <groupId>org.hibernate</groupId>
77 88 <artifactId>hibernate-entitymanager</artifactId>
... ...
impl/extension/jta/src/test/resources/.arquillian-glassfish-embedded.profile
impl/extension/se/pom.xml
... ... @@ -53,7 +53,21 @@
53 53 Extensão para aplicações SE
54 54 </description>
55 55 <url>http://www.frameworkdemoiselle.gov.br</url>
56   -
  56 +
  57 + <dependencies>
  58 + <!-- for tests -->
  59 + <dependency>
  60 + <groupId>org.jboss.arquillian.container</groupId>
  61 + <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
  62 + <scope>test</scope>
  63 + </dependency>
  64 + <dependency>
  65 + <groupId>org.jboss.weld.se</groupId>
  66 + <artifactId>weld-se-core</artifactId>
  67 + <scope>test</scope>
  68 + </dependency>
  69 + </dependencies>
  70 +
57 71 <licenses>
58 72 <license>
59 73 <name>GNU Lesser General Public License, Version 3</name>
... ...
impl/extension/se/src/test/resources/.arquillian-weld-se-embedded.profile
impl/extension/servlet/pom.xml
... ... @@ -85,6 +85,17 @@
85 85 </dependency>
86 86 -->
87 87  
  88 + <!-- for tests -->
  89 + <dependency>
  90 + <groupId>org.jboss.arquillian.container</groupId>
  91 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  92 + <scope>test</scope>
  93 + </dependency>
  94 + <dependency>
  95 + <groupId>org.glassfish.main.extras</groupId>
  96 + <artifactId>glassfish-embedded-all</artifactId>
  97 + <scope>test</scope>
  98 + </dependency>
88 99 <dependency>
89 100 <groupId>org.apache.httpcomponents</groupId>
90 101 <artifactId>httpclient</artifactId>
... ...
impl/extension/servlet/src/test/resources/.arquillian-glassfish-embedded.profile
parent/bom/pom.xml
... ... @@ -347,6 +347,25 @@
347 347 <artifactId>easymock</artifactId>
348 348 <version>${easymock.version}</version>
349 349 </dependency>
  350 +
  351 + <!-- arquillian -->
  352 + <!--
  353 + -->
  354 + <dependency>
  355 + <groupId>org.jboss.arquillian.container</groupId>
  356 + <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
  357 + <version>${arquillian.container.weld.version}</version>
  358 + </dependency>
  359 + <dependency>
  360 + <groupId>org.jboss.arquillian.container</groupId>
  361 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  362 + <version>${arquillian.container.glassfish.version}</version>
  363 + </dependency>
  364 + <dependency>
  365 + <groupId>org.glassfish.main.extras</groupId>
  366 + <artifactId>glassfish-embedded-all</artifactId>
  367 + <version>${glassfish.embedded.version}</version>
  368 + </dependency>
350 369  
351 370 <!-- Plug-ins -->
352 371 <dependency>
... ... @@ -395,6 +414,14 @@
395 414 <hibernate.version>4.1.7.Final</hibernate.version>
396 415 <hibernate.validator.version>4.2.0.Final</hibernate.validator.version>
397 416  
  417 + <!--
  418 + <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
  419 + -->
  420 + <arquillian.weld.version>1.0.0.CR7</arquillian.weld.version>
  421 + <arquillian.container.glassfish.version>1.0.0.CR4</arquillian.container.glassfish.version>
  422 + <arquillian.container.weld.version>1.0.0.CR7</arquillian.container.weld.version>
  423 + <glassfish.embedded.version>3.1.2.2</glassfish.embedded.version>
  424 +
398 425 <junit.version>4.8.1</junit.version>
399 426 <easymock.version>3.0</easymock.version>
400 427  
... ...
parent/extension/pom.xml
... ... @@ -75,6 +75,8 @@
75 75 <scope>import</scope>
76 76 <type>pom</type>
77 77 </dependency>
  78 + <!--
  79 + -->
78 80 <dependency>
79 81 <groupId>org.jboss.arquillian</groupId>
80 82 <artifactId>arquillian-bom</artifactId>
... ... @@ -83,6 +85,21 @@
83 85 <type>pom</type>
84 86 </dependency>
85 87 </dependencies>
  88 +
  89 + <!--
  90 + <dependency>
  91 + <groupId>org.jboss.arquillian.container</groupId>
  92 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  93 + <version>${arquillian.container.glassfish.version}</version>
  94 + <scope>test</scope>
  95 + </dependency>
  96 + <dependency>
  97 + <groupId>org.glassfish.main.extras</groupId>
  98 + <artifactId>glassfish-embedded-all</artifactId>
  99 + <version>${glassfish.embedded.version}</version>
  100 + <scope>test</scope>
  101 + </dependency>
  102 + -->
86 103 </dependencyManagement>
87 104  
88 105 <build>
... ... @@ -159,6 +176,7 @@
159 176 </repository>
160 177 </repositories>
161 178  
  179 +
162 180 <profiles>
163 181 <profile>
164 182 <id>arquillian-test</id>
... ... @@ -187,18 +205,13 @@
187 205 </dependency>
188 206 </dependencies>
189 207 </profile>
  208 + <!--
190 209 <profile>
191 210 <id>arquillian-weld-se-embedded</id>
192   - <activation>
193   - <file>
194   - <exists>src/test/resources/.arquillian-weld-se-embedded.profile</exists>
195   - </file>
196   - </activation>
197 211 <dependencies>
198 212 <dependency>
199 213 <groupId>org.jboss.arquillian.container</groupId>
200 214 <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
201   - <version>${arquillian.container.weld.version}</version>
202 215 </dependency>
203 216 <dependency>
204 217 <groupId>org.jboss.weld.se</groupId>
... ... @@ -209,12 +222,6 @@
209 222 <profile>
210 223 <id>arquillian-glassfish-embedded</id>
211 224 <activation>
212   - <file>
213   - <exists>src/test/resources/.arquillian-glassfish-embedded.profile</exists>
214   - </file>
215   - <!--
216   - <activeByDefault>true</activeByDefault>
217   - -->
218 225 </activation>
219 226 <dependencies>
220 227 <dependency>
... ... @@ -231,155 +238,21 @@
231 238 </dependency>
232 239 </dependencies>
233 240 </profile>
234   - <profile>
235   - <id>arquillian-jbossas7-managed</id>
236   - <activation>
237   - <file>
238   - <exists>src/test/resources/.arquillian-jbossas7-managed.profile</exists>
239   - </file>
240   - </activation>
241   - <build>
242   - <testResources>
243   - <testResource>
244   - <directory>src/test/resources</directory>
245   - <filtering>true</filtering>
246   - </testResource>
247   - </testResources>
248   - <plugins>
249   - <plugin>
250   - <artifactId>maven-dependency-plugin</artifactId>
251   - <executions>
252   - <execution>
253   - <id>unpack</id>
254   - <phase>process-test-classes</phase>
255   - <goals>
256   - <goal>unpack</goal>
257   - </goals>
258   - <configuration>
259   - <artifactItems>
260   - <artifactItem>
261   - <groupId>org.jboss.as</groupId>
262   - <artifactId>jboss-as-dist</artifactId>
263   - <version>${jboss.as.version}</version>
264   - <type>zip</type>
265   - <overWrite>false</overWrite>
266   - <outputDirectory>target</outputDirectory>
267   - </artifactItem>
268   - </artifactItems>
269   - </configuration>
270   - </execution>
271   - </executions>
272   - </plugin>
273   - <plugin>
274   - <groupId>org.jacoco</groupId>
275   - <artifactId>jacoco-maven-plugin</artifactId>
276   - <version>${jacoco.version}</version>
277   - <executions>
278   - <execution>
279   - <goals>
280   - <goal>prepare-agent</goal>
281   - </goals>
282   - </execution>
283   - <execution>
284   - <id>report</id>
285   - <phase>prepare-package</phase>
286   - <goals>
287   - <goal>report</goal>
288   - </goals>
289   - </execution>
290   - </executions>
291   - </plugin>
292   - </plugins>
293   - </build>
294   - <dependencies>
295   - <dependency>
296   - <groupId>org.jboss.as</groupId>
297   - <artifactId>jboss-as-arquillian-container-managed</artifactId>
298   - <version>${jboss.as.version}</version>
299   - <scope>test</scope>
300   - </dependency>
301   - <dependency>
302   - <groupId>org.jboss.arquillian.protocol</groupId>
303   - <artifactId>arquillian-protocol-servlet</artifactId>
304   - <scope>test</scope>
305   - </dependency>
306   - <dependency>
307   - <groupId>org.jboss.arquillian.extension</groupId>
308   - <artifactId>arquillian-jacoco</artifactId>
309   - <version>${arquillian.jacoco.version}</version>
310   - <scope>test</scope>
311   - </dependency>
312   - <dependency>
313   - <groupId>org.jacoco</groupId>
314   - <artifactId>org.jacoco.core</artifactId>
315   - <version>${jacoco.version}</version>
316   - <scope>test</scope>
317   - </dependency>
318   - </dependencies>
319   - </profile>
320   - <profile>
321   - <id>arquillian-drone</id>
322   - <activation>
323   - <file>
324   - <exists>src/test/resources/.arquillian-drone.profile</exists>
325   - </file>
326   - </activation>
327   - <dependencyManagement>
328   - <dependencies>
329   - <dependency>
330   - <groupId>org.jboss.arquillian.extension</groupId>
331   - <artifactId>arquillian-drone-bom</artifactId>
332   - <version>${arquillian.bom.version}</version>
333   - <type>pom</type>
334   - <scope>import</scope>
335   - </dependency>
336   - </dependencies>
337   - </dependencyManagement>
338   - <dependencies>
339   - <dependency>
340   - <groupId>org.jboss.arquillian.extension</groupId>
341   - <artifactId>arquillian-drone-impl</artifactId>
342   - <scope>test</scope>
343   - </dependency>
344   - <dependency>
345   - <groupId>org.jboss.arquillian.extension</groupId>
346   - <artifactId>arquillian-drone-selenium</artifactId>
347   - <scope>test</scope>
348   - </dependency>
349   - <dependency>
350   - <groupId>org.jboss.arquillian.extension</groupId>
351   - <artifactId>arquillian-drone-selenium-server</artifactId>
352   - <scope>test</scope>
353   - </dependency>
354   - <dependency>
355   - <groupId>org.seleniumhq.selenium</groupId>
356   - <artifactId>selenium-java</artifactId>
357   - <scope>test</scope>
358   - </dependency>
359   - <dependency>
360   - <groupId>org.seleniumhq.selenium</groupId>
361   - <artifactId>selenium-server</artifactId>
362   - <scope>test</scope>
363   - <exclusions>
364   - <exclusion>
365   - <groupId>org.mortbay.jetty</groupId>
366   - <artifactId>servlet-api-2.5</artifactId>
367   - </exclusion>
368   - </exclusions>
369   - </dependency>
370   - </dependencies>
371   - </profile>
  241 + -->
372 242 </profiles>
373 243  
374 244 <properties>
375 245 <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
376   - <arquillian.jacoco.version>1.0.0.Alpha5</arquillian.jacoco.version>
  246 + <!--
  247 +
  248 + <glassfish.embedded.version>3.1.2.2</glassfish.embedded.version>
  249 +
377 250 <arquillian.container.glassfish.version>1.0.0.CR4</arquillian.container.glassfish.version>
378 251 <arquillian.container.weld.version>1.0.0.CR7</arquillian.container.weld.version>
379 252  
380   - <glassfish.embedded.version>3.1.2.2</glassfish.embedded.version>
381 253 <jboss.as.version>7.1.1.Final</jboss.as.version>
382 254  
383 255 <jacoco.version>0.6.0.201210061924</jacoco.version>
  256 + -->
384 257 </properties>
385 258 </project>
... ...
parent/framework/pom.xml
... ... @@ -55,6 +55,26 @@
55 55 Se você é usuário do framework, certamente este POM não servirá para você.
56 56 </description>
57 57 <url>http://www.frameworkdemoiselle.gov.br</url>
  58 +
  59 + <!--
  60 + <dependencyManagement>
  61 + <dependency>
  62 + <groupId>org.jboss.arquillian.container</groupId>
  63 + <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
  64 + <version>${arquillian.weld.version}</version>
  65 + </dependency>
  66 + <dependency>
  67 + <groupId>org.jboss.arquillian.container</groupId>
  68 + <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
  69 + <version>${arquillian.container.glassfish.version}</version>
  70 + </dependency>
  71 + <dependency>
  72 + <groupId>org.glassfish.main.extras</groupId>
  73 + <artifactId>glassfish-embedded-all</artifactId>
  74 + <version>${glassfish.embedded.version}</version>
  75 + </dependency>
  76 + </dependencyManagement>
  77 + -->
58 78  
59 79 <licenses>
60 80 <license>
... ... @@ -92,4 +112,14 @@
92 112 </releases>
93 113 </repository>
94 114 </repositories>
  115 +
  116 + <!--
  117 + <properties>
  118 + <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
  119 + <arquillian.weld.version>1.0.0.CR7</arquillian.weld.version>
  120 + <arquillian.container.glassfish.version>1.0.0.CR4</arquillian.container.glassfish.version>
  121 + <arquillian.container.weld.version>1.0.0.CR7</arquillian.container.weld.version>
  122 + <glassfish.embedded.version>3.2.1.1</glassfish.embedded.version>
  123 + </properties>
  124 + -->
95 125 </project>
... ...