Commit 2110451d7927efcd637d5bc7483870004eda6c88
Exists in
master
Merge branch 'master' of git@github.com:demoiselle/framework.git
Showing
79 changed files
with
1545 additions
and
939 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 | 152 | <para> |
160 | - Para remover todas as mensagens existentes no contexto, basta invocar o método <function>clear()</function> da | |
161 | - interface <literal>MessageContext</literal>. | |
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). | |
162 | 156 | </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 | - <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. | |
175 | - </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> |
... | ... | @@ -303,6 +277,41 @@ ALUNO_EXCLUIR_OK=L'étudiant {0} a été supprimé avec succès]]></programlisti |
303 | 277 | </para> |
304 | 278 | </note> |
305 | 279 | </section> |
280 | + | |
281 | + <section> | |
282 | + <title>Destino das mensagens</title> | |
283 | + | |
284 | + <para> | |
285 | + O Framework Demoiselle permite configurar o destino das mensagens enviadas. Por padrão, mensagens enviadas em um ambiente SE (Swing por exemplo) | |
286 | + são exibidas como registros de log no console, já mensagens enviadas em um ambiente WEB usando JSF 2.0 são redirecionadas para a classe | |
287 | + <code>FacesContext</code>. Caso esse comportamento padrão não seja suficiente para você, é possível personalizar o mecanismo de redirecionamento | |
288 | + de mensagens, fazendo-o enviar as mensagens para um local de seu interesse. | |
289 | + </para> | |
290 | + | |
291 | + <para> | |
292 | + Para isso existe a interface <code>MessageAppender</code>. Para toda mensagem enviada, o Framework Demoiselle vai determinar a implementação | |
293 | + mais adequada de <code>MessageAppender</code> a utilizar e vai redirecionar qualquer mensagem para essa implementação. | |
294 | + </para> | |
295 | + | |
296 | + <programlisting role="JAVA">public interface MessageAppender extends Serializable { | |
297 | + | |
298 | + /** | |
299 | + * Method that must hold message in an appropriate way and in an appropriate local. | |
300 | + * Demoiselle holds a message in a Logger or in a FacesContext, depending on the project. | |
301 | + * | |
302 | + * @param message | |
303 | + * message to be stored. | |
304 | + */ | |
305 | + void append(Message message); | |
306 | +}</programlisting> | |
307 | + | |
308 | + <para> | |
309 | + Para criar seu próprio <code>MessageAppender</code>, implemente essa interface e anote-a com a anotação <code>@Priority</code> - o Framework | |
310 | + Demoiselle irá selecionar a implementação adequada paseada na maior prioridade. Não é necessário configurar mais nada, o Framework Demoiselle | |
311 | + selecionará a implementação automaticamente. Cabe-lhe então a tarefa de implementar o método <code>append(Message message)</code> para tratar | |
312 | + a mensagem da forma que melhor se adequar a seu projeto. | |
313 | + </para> | |
314 | + </section> | |
306 | 315 | |
307 | 316 | <section> |
308 | 317 | <title>Exemplos de implementação</title> | ... | ... |
documentation/reference/pt-BR/persistencia.xml
... | ... | @@ -18,6 +18,181 @@ |
18 | 18 | é apenas injetar o recurso adequado em seu código e o Framework Demoiselle se encarregará de |
19 | 19 | produzi-lo e configurá-lo. |
20 | 20 | </para> |
21 | + | |
22 | + <section> | |
23 | + <title>JPA</title> | |
24 | + | |
25 | + <para> | |
26 | + O Framework Demoiselle fornece um produtor padrão para contextos de persistência da JPA. Esse produtor lê o arquivo | |
27 | + de configuração <code>persistence.xml</code> de seu projeto e toma as providências necessárias para fabricar uma instância | |
28 | + da classe <code>EntityManager</code> que pode ser usada para gerenciar as entidades de sua aplicação. Além disso, instâncias | |
29 | + de <code>EntityManager</code> produzidas pelo Framework Demoiselle participam automaticamente de transações abertas através da | |
30 | + anotação <code>@Transactional</code>, conforme apresentado no capítulo sobre <link linkend="transacao">Transações</link>. | |
31 | + </para> | |
32 | + | |
33 | + <tip> | |
34 | + <para> | |
35 | + Para acrescentar a dependência à extensão <literal>demoiselle-jpa</literal>, adicione esse código | |
36 | + em seu arquivo <literal>pom.xml</literal>, na seção <literal>dependencies</literal>. | |
37 | + </para> | |
38 | + | |
39 | + <programlisting role="XML"><![CDATA[<dependency> | |
40 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
41 | + <artifactId>demoiselle-jpa</artifactId> | |
42 | + <scope>compile</scope> | |
43 | +</dependency>]]></programlisting> | |
44 | + </tip> | |
45 | + | |
46 | + <section> | |
47 | + <title>Introdução ao mecanismo</title> | |
48 | + | |
49 | + <para> | |
50 | + Para injetar uma instância de <code>EntityManager</code> em sua aplicação, basta usar a anotação <code>@Inject</code>. | |
51 | + </para> | |
52 | + | |
53 | + <programlisting role="JAVA">@PersistenceController | |
54 | +public class BookmarkDAO extends JPACrud<Bookmark, Long> { | |
55 | + | |
56 | + private static final long serialVersionUID = 1L; | |
57 | + | |
58 | + @Inject | |
59 | + private EntityManager entityManager; | |
60 | + | |
61 | + public void persistBookmark(Bookmark bookmark){ | |
62 | + entityManager.persist(bookmark); | |
63 | + } | |
64 | + | |
65 | +}</programlisting> | |
66 | + | |
67 | + <para> | |
68 | + O produtor padrão injetará o <code>EntityManager</code> configurado no arquivo <code>persistence.xml</code>. Se houver | |
69 | + mais de um contexto de persistência configurado em <code>persistence.xml</code>, será necessário especificar qual será | |
70 | + injetado no ponto de injeção. Para isso use a anotação <code>@Name</code>. | |
71 | + </para> | |
72 | + | |
73 | + <programlisting role="JAVA">@PersistenceController | |
74 | +public class BookmarkDAO extends JPACrud<Bookmark, Long> { | |
75 | + | |
76 | + private static final long serialVersionUID = 1L; | |
77 | + | |
78 | + @Inject | |
79 | + @Name("persistence_unit_1") | |
80 | + private EntityManager entityManager; | |
81 | + | |
82 | + public void persistBookmark(Bookmark bookmark){ | |
83 | + entityManager.persist(bookmark); | |
84 | + } | |
85 | + | |
86 | +}</programlisting> | |
87 | + | |
88 | + <para> | |
89 | + É possível invocar o utilitário <code>Beans</code> para injetar instâncias de <code>EntityManager</code> programaticamente. | |
90 | + </para> | |
91 | + | |
92 | + <programlisting role="JAVA">@PersistenceController | |
93 | +public class BookmarkDAO extends JPACrud<Bookmark, Long> { | |
94 | + | |
95 | + private static final long serialVersionUID = 1L; | |
96 | + | |
97 | + public void persistBookmark(Bookmark bookmark){ | |
98 | + EntityManager entityManager = Beans.getReference(EntityManager.class); | |
99 | + entityManager.persist(bookmark); | |
100 | + } | |
101 | + | |
102 | + public void persistBookmarkInHistory(Bookmark bookmark){ | |
103 | + EntityManager entityManager = Beans.getReference(EntityManager.class , new NameQualifier("history_persistence_unit")); | |
104 | + entityManager.persist(bookmark); | |
105 | + } | |
106 | + | |
107 | +}</programlisting> | |
108 | + </section> | |
109 | + | |
110 | + <section> | |
111 | + <title>Configuração</title> | |
112 | + | |
113 | + <para> | |
114 | + Alguns comportamentos do produtor podem ser configurados através das propriedades abaixo, que devem ser configuradas | |
115 | + no arquivo <code>demoiselle.properties</code>. | |
116 | + </para> | |
117 | + | |
118 | + <informaltable width="100%"> | |
119 | + <tgroup cols="3"> | |
120 | + <colspec align="left"/> | |
121 | + <colspec align="left"/> | |
122 | + <colspec align="right"/> | |
123 | + | |
124 | + <thead> | |
125 | + <row valign="top"> | |
126 | + <entry><emphasis role="bold">Propriedade</emphasis></entry> | |
127 | + <entry><emphasis role="bold">Descrição</emphasis></entry> | |
128 | + <entry><emphasis role="bold">Padrão</emphasis></entry> | |
129 | + </row> | |
130 | + </thead> | |
131 | + | |
132 | + <tbody> | |
133 | + <row valign="top"> | |
134 | + <entry>frameworkdemoiselle.​persistence.​default.​unit.​name</entry> | |
135 | + <entry> | |
136 | + <para> | |
137 | + Define o nome da unidade de persistência padrão (configurada em <code>persistence.xml</code>) que será injetada | |
138 | + caso a anotação <code>@Name</code> não seja usada. Não é necessário se apenas uma unidade de persistência for configurada. | |
139 | + </para> | |
140 | + </entry> | |
141 | + <entry></entry> | |
142 | + </row> | |
143 | + | |
144 | + <row valign="top"> | |
145 | + <entry>frameworkdemoiselle.​persistence.​entitymanager.​scope</entry> | |
146 | + <entry> | |
147 | + <para> | |
148 | + Permite determinar o escopo de unidades de persistência injetadas. Dentro do escopo determinado, todos os pontos | |
149 | + de injeção receberão a mesma instância de <code>EntityManager</code>. | |
150 | + </para> | |
151 | + <para> | |
152 | + Os valores possíveis são: | |
153 | + <simplelist type="inline"> | |
154 | + <member>request</member> | |
155 | + <member>session</member> | |
156 | + <member>view</member> | |
157 | + <member>conversation</member> | |
158 | + <member>application</member> | |
159 | + <member>noscope</member> | |
160 | + </simplelist> | |
161 | + </para> | |
162 | + </entry> | |
163 | + <entry>request</entry> | |
164 | + </row> | |
165 | + </tbody> | |
166 | + </tgroup> | |
167 | + </informaltable> | |
168 | + | |
169 | + <tip> | |
170 | + <para> | |
171 | + O escopo especial <emphasis>noscope</emphasis> desliga o gerenciamento de escopo de instâncias de <code>EntityManager</code> | |
172 | + produzidas pelo Framework Demoiselle. Isso permite ao desenvolvedor controlar totalmente o ciclo de vida de um | |
173 | + <code>EntityManager</code> injetado e ainda reter o recurso do produtor padrão. | |
174 | + </para> | |
175 | + <para> | |
176 | + Note que ao usar a opção <emphasis>noscope</emphasis>, o desenvolvedor é o responsável por controlar o ciclo de vida do gerenciador | |
177 | + de persistência. Ele não participará de transações JPA abertas através da anotação <code>@Transactional</code> (transações JTA funcionam normalmente) | |
178 | + e multiplos pontos de injeção durante uma requisição receberão múltiplas instâncias de <code>EntityManager</code>. | |
179 | + </para> | |
180 | + </tip> | |
181 | + | |
182 | + <caution> | |
183 | + <para> | |
184 | + Deve-se usar cautela ao alterar o escopo padrão das instâncias de <code>EntityManager</code>. Na grande maioria dos casos o escopo | |
185 | + padrão <emphasis>request</emphasis> é o suficiente e alterar esse padrão deve ser feito apenas após extensa análise dos prós e contras | |
186 | + de cada escopo. | |
187 | + </para> | |
188 | + <para> | |
189 | + Dê especial atenção aos escopos que podem ser serializados pelo servidor de aplicação (<emphasis>session</emphasis>, <emphasis>view</emphasis> | |
190 | + e <emphasis>conversation</emphasis>) pois a especificação não define o comportamento de instâncias de <code>EntityManager</code> que são | |
191 | + serializadas. | |
192 | + </para> | |
193 | + </caution> | |
194 | + </section> | |
195 | + </section> | |
21 | 196 | |
22 | 197 | <section> |
23 | 198 | ... | ... |
documentation/reference/pt-BR/properties.xml
... | ... | @@ -251,12 +251,34 @@ |
251 | 251 | <entry>frameworkdemoiselle.​persistence.​default.​unit.​name</entry> |
252 | 252 | <entry> |
253 | 253 | <para> |
254 | - Define a unidade de persistência padrão para aplicações que possuem mais | |
255 | - de um persistence-unit definido no arquivo persistence.xml. | |
254 | + Define o nome da unidade de persistência padrão (configurada em <code>persistence.xml</code>) que será injetada | |
255 | + caso a anotação <code>@Name</code> não seja usada. Não é necessário se apenas uma unidade de persistência for configurada. | |
256 | 256 | </para> |
257 | 257 | </entry> |
258 | 258 | <entry></entry> |
259 | 259 | </row> |
260 | + | |
261 | + <row valign="top"> | |
262 | + <entry>frameworkdemoiselle.​persistence.​entitymanager.​scope</entry> | |
263 | + <entry> | |
264 | + <para> | |
265 | + Permite determinar o escopo de unidades de persistência injetadas. Dentro do escopo determinado, todos os pontos | |
266 | + de injeção receberão a mesma instância de <code>EntityManager</code>. | |
267 | + </para> | |
268 | + <para> | |
269 | + Os valores possíveis são: | |
270 | + <simplelist type="inline"> | |
271 | + <member>request</member> | |
272 | + <member>session</member> | |
273 | + <member>view</member> | |
274 | + <member>conversation</member> | |
275 | + <member>application</member> | |
276 | + <member>noscope</member> | |
277 | + </simplelist> | |
278 | + </para> | |
279 | + </entry> | |
280 | + <entry>request</entry> | |
281 | + </row> | |
260 | 282 | </tbody> |
261 | 283 | </tgroup> |
262 | 284 | </table> | ... | ... |
documentation/reference/pt-BR/security.xml
... | ... | @@ -129,11 +129,16 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee |
129 | 129 | comum e exibir uma tela HTML contendo um formulario que solicita as informacoes. |
130 | 130 | */ |
131 | 131 | |
132 | - securityContext.login(); | |
132 | + try{ | |
133 | + securityContext.login(); | |
133 | 134 | |
134 | - //Executa codigo que requer autenticacao | |
135 | + //Executa codigo que requer autenticacao | |
135 | 136 | |
136 | - securityContext.logout(); | |
137 | + securityContext.logout(); | |
138 | + } | |
139 | + catch(InvalidCredentialsException exception){ | |
140 | + //Trata credenciais inválidas | |
141 | + } | |
137 | 142 | |
138 | 143 | } |
139 | 144 | }]]></programlisting> | ... | ... |
documentation/reference/pt-BR/transacao.xml
... | ... | @@ -135,7 +135,7 @@ public class AbacaxiException { |
135 | 135 | <para> |
136 | 136 | Esta estratégia, que está disponível na extensão <literal>demoiselle-jpa</literal>, delega o |
137 | 137 | controle das transações para o <literal>javax.persistence.EntityManager</literal> da |
138 | - especificação JPA. Você deve escolher esta estratégia quando estiver persisteindo dados | |
138 | + especificação JPA. Você deve escolher esta estratégia quando estiver persistindo dados | |
139 | 139 | com JPA e utilizando apenas uma base de dados em sua aplicação. Como um <literal>EntityManager</literal> |
140 | 140 | acessa apenas uma unidade de persistência, não há como fazer o controle transacional de unidades distintas. |
141 | 141 | </para> | ... | ... |
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/internal/bootstrap/CustomContextBootstrap.java
... | ... | @@ -15,6 +15,7 @@ import br.gov.frameworkdemoiselle.internal.context.TemporarySessionContextImpl; |
15 | 15 | import br.gov.frameworkdemoiselle.internal.context.StaticContextImpl; |
16 | 16 | import br.gov.frameworkdemoiselle.internal.context.TemporaryConversationContextImpl; |
17 | 17 | import br.gov.frameworkdemoiselle.internal.context.TemporaryViewContextImpl; |
18 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This portable extension registers and starts custom contexts used by |
... | ... | @@ -71,13 +72,17 @@ public class CustomContextBootstrap implements Extension{ |
71 | 72 | } |
72 | 73 | } |
73 | 74 | |
75 | + public void terminateContexts(@Observes AfterShutdownProccess event){ | |
76 | + if (contexts!=null){ | |
77 | + for (CustomContext context : contexts){ | |
78 | + context.deactivate(); | |
79 | + } | |
80 | + | |
81 | + contexts.clear(); | |
82 | + } | |
83 | + } | |
84 | + | |
74 | 85 | public List<CustomContext> getCustomContexts(){ |
75 | 86 | return this.contexts; |
76 | 87 | } |
77 | - | |
78 | - /*public void storeContexts(@Observes AfterDeploymentValidation event){ | |
79 | - CustomContextProducer producer = Beans.getReference(CustomContextProducer.class); | |
80 | - producer.addRegisteredContexts(contexts); | |
81 | - }*/ | |
82 | - | |
83 | 88 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java
... | ... | @@ -37,16 +37,12 @@ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.context; |
38 | 38 | |
39 | 39 | import java.lang.annotation.Annotation; |
40 | -import java.util.Collections; | |
41 | -import java.util.HashMap; | |
42 | 40 | import java.util.Locale; |
43 | -import java.util.Map; | |
44 | 41 | |
45 | 42 | import javax.enterprise.context.ContextNotActiveException; |
46 | 43 | import javax.enterprise.context.spi.Context; |
47 | 44 | import javax.enterprise.context.spi.Contextual; |
48 | 45 | import javax.enterprise.context.spi.CreationalContext; |
49 | -import javax.enterprise.inject.spi.Bean; | |
50 | 46 | import javax.enterprise.inject.spi.BeanManager; |
51 | 47 | |
52 | 48 | import org.slf4j.Logger; |
... | ... | @@ -71,7 +67,9 @@ public abstract class AbstractCustomContext implements CustomContext { |
71 | 67 | this.active = false; |
72 | 68 | } |
73 | 69 | |
74 | - protected abstract Store getStore(); | |
70 | + protected abstract BeanStore getStore(); | |
71 | + | |
72 | + protected abstract ContextualStore getContextualStore(); | |
75 | 73 | |
76 | 74 | protected abstract boolean isStoreInitialized(); |
77 | 75 | |
... | ... | @@ -89,22 +87,22 @@ public abstract class AbstractCustomContext implements CustomContext { |
89 | 87 | throw new ContextNotActiveException(); |
90 | 88 | } |
91 | 89 | |
92 | - Class<?> type = getType(contextual); | |
93 | - if (getStore().contains(type)) { | |
94 | - instance = (T) getStore().get(type); | |
95 | - | |
96 | - } else if (creationalContext != null) { | |
90 | + String id = getContextualStore().tryRegisterAndGetId(contextual); | |
91 | + if (getStore().contains(id)) { | |
92 | + instance = (T) getStore().getInstance(id); | |
93 | + } | |
94 | + else if (creationalContext!=null){ | |
97 | 95 | instance = contextual.create(creationalContext); |
98 | - getStore().put(type, instance); | |
96 | + getStore().put(id, instance,creationalContext); | |
99 | 97 | } |
100 | 98 | |
101 | 99 | return instance; |
102 | 100 | } |
103 | 101 | |
104 | - private <T> Class<?> getType(final Contextual<T> contextual) { | |
102 | + /*private <T> Class<?> getType(final Contextual<T> contextual) { | |
105 | 103 | Bean<T> bean = (Bean<T>) contextual; |
106 | 104 | return bean.getBeanClass(); |
107 | - } | |
105 | + }*/ | |
108 | 106 | |
109 | 107 | @Override |
110 | 108 | public boolean isActive() { |
... | ... | @@ -136,15 +134,27 @@ public abstract class AbstractCustomContext implements CustomContext { |
136 | 134 | return this.active; |
137 | 135 | } |
138 | 136 | |
137 | + @SuppressWarnings({ "rawtypes", "unchecked" }) | |
139 | 138 | @Override |
140 | 139 | public void deactivate(){ |
141 | 140 | if (this.active){ |
142 | 141 | if (isStoreInitialized()){ |
142 | + for (String id : getStore()){ | |
143 | + Contextual contextual = getContextualStore().getContextual(id); | |
144 | + Object instance = getStore().getInstance(id); | |
145 | + CreationalContext creationalContext = getStore().getCreationalContext(id); | |
146 | + | |
147 | + if (contextual!=null && instance!=null){ | |
148 | + contextual.destroy(instance, creationalContext); | |
149 | + } | |
150 | + } | |
151 | + | |
143 | 152 | getStore().clear(); |
153 | + getContextualStore().clear(); | |
144 | 154 | } |
145 | - | |
155 | + | |
146 | 156 | this.active = false; |
147 | - | |
157 | + | |
148 | 158 | Logger logger = getLogger(); |
149 | 159 | ResourceBundle bundle = getBundle(); |
150 | 160 | logger.debug( bundle.getString("custom-context-was-deactivated" , this.getClass().getCanonicalName() , this.getScope().getSimpleName() ) ); |
... | ... | @@ -156,8 +166,12 @@ public abstract class AbstractCustomContext implements CustomContext { |
156 | 166 | return this.scope; |
157 | 167 | } |
158 | 168 | |
159 | - protected static Store createStore() { | |
160 | - return new Store(); | |
169 | + protected static BeanStore createStore() { | |
170 | + return new BeanStore(); | |
171 | + } | |
172 | + | |
173 | + protected static ContextualStore createContextualStore() { | |
174 | + return new ContextualStore(); | |
161 | 175 | } |
162 | 176 | |
163 | 177 | private ResourceBundle getBundle(){ |
... | ... | @@ -192,39 +206,4 @@ public abstract class AbstractCustomContext implements CustomContext { |
192 | 206 | return false; |
193 | 207 | return true; |
194 | 208 | } |
195 | - | |
196 | - static class Store { | |
197 | - | |
198 | - private Map<ClassLoader, Map<Class<?>, Object>> cache = Collections | |
199 | - .synchronizedMap(new HashMap<ClassLoader, Map<Class<?>, Object>>()); | |
200 | - | |
201 | - private Store() { | |
202 | - } | |
203 | - | |
204 | - private boolean contains(final Class<?> type) { | |
205 | - return this.getMap().containsKey(type); | |
206 | - } | |
207 | - | |
208 | - private Object get(final Class<?> type) { | |
209 | - return this.getMap().get(type); | |
210 | - } | |
211 | - | |
212 | - private void put(final Class<?> type, final Object instance) { | |
213 | - this.getMap().put(type, instance); | |
214 | - } | |
215 | - | |
216 | - public void clear() { | |
217 | - cache.clear(); | |
218 | - } | |
219 | - | |
220 | - private Map<Class<?>, Object> getMap() { | |
221 | - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
222 | - | |
223 | - if (!cache.containsKey(classLoader)) { | |
224 | - cache.put(classLoader, Collections.synchronizedMap(new HashMap<Class<?>, Object>())); | |
225 | - } | |
226 | - | |
227 | - return cache.get(classLoader); | |
228 | - } | |
229 | - } | |
230 | 209 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractStaticContext.java
... | ... | @@ -37,6 +37,9 @@ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.context; |
38 | 38 | |
39 | 39 | import java.lang.annotation.Annotation; |
40 | +import java.util.Collections; | |
41 | +import java.util.HashMap; | |
42 | +import java.util.Map; | |
40 | 43 | |
41 | 44 | import br.gov.frameworkdemoiselle.annotation.Priority; |
42 | 45 | import br.gov.frameworkdemoiselle.annotation.StaticScoped; |
... | ... | @@ -58,7 +61,9 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; |
58 | 61 | @Priority(Priority.MIN_PRIORITY) |
59 | 62 | public abstract class AbstractStaticContext extends AbstractCustomContext { |
60 | 63 | |
61 | - private final static Store store = createStore(); | |
64 | + private final static Map<String, BeanStore> staticBeanStore = Collections.synchronizedMap(new HashMap<String, BeanStore>()); | |
65 | + | |
66 | + private final static Map<String, ContextualStore> staticContextualStore = Collections.synchronizedMap(new HashMap<String, ContextualStore>()); | |
62 | 67 | |
63 | 68 | /** |
64 | 69 | * Constructs this context to control the provided scope |
... | ... | @@ -68,12 +73,29 @@ public abstract class AbstractStaticContext extends AbstractCustomContext { |
68 | 73 | } |
69 | 74 | |
70 | 75 | @Override |
71 | - protected Store getStore() { | |
76 | + protected BeanStore getStore() { | |
77 | + BeanStore store = staticBeanStore.get( this.getClass().getCanonicalName() ); | |
78 | + if (store==null){ | |
79 | + store = createStore(); | |
80 | + staticBeanStore.put(this.getClass().getCanonicalName(), store); | |
81 | + } | |
82 | + | |
83 | + return store; | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + protected ContextualStore getContextualStore() { | |
88 | + ContextualStore store = staticContextualStore.get( this.getClass().getCanonicalName() ); | |
89 | + if (store==null){ | |
90 | + store = createContextualStore(); | |
91 | + staticContextualStore.put(this.getClass().getCanonicalName(), store); | |
92 | + } | |
93 | + | |
72 | 94 | return store; |
73 | 95 | } |
74 | 96 | |
75 | 97 | @Override |
76 | 98 | protected boolean isStoreInitialized() { |
77 | - return store!=null; | |
99 | + return staticBeanStore!=null; | |
78 | 100 | } |
79 | 101 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractThreadLocalContext.java
... | ... | @@ -59,7 +59,9 @@ import java.lang.annotation.Annotation; |
59 | 59 | */ |
60 | 60 | public abstract class AbstractThreadLocalContext extends AbstractCustomContext { |
61 | 61 | |
62 | - private final ThreadLocal<Store> threadLocal = new ThreadLocal<Store>(); | |
62 | + private final ThreadLocal<BeanStore> threadLocalBeans = new ThreadLocal<BeanStore>(); | |
63 | + | |
64 | + private final ThreadLocal<ContextualStore> threadLocalContextual = new ThreadLocal<ContextualStore>(); | |
63 | 65 | |
64 | 66 | AbstractThreadLocalContext(final Class<? extends Annotation> scope) { |
65 | 67 | super(scope); |
... | ... | @@ -67,15 +69,24 @@ public abstract class AbstractThreadLocalContext extends AbstractCustomContext { |
67 | 69 | |
68 | 70 | @Override |
69 | 71 | protected boolean isStoreInitialized() { |
70 | - return threadLocal.get()!=null; | |
72 | + return threadLocalBeans.get()!=null; | |
71 | 73 | } |
72 | 74 | |
73 | 75 | @Override |
74 | - protected Store getStore() { | |
75 | - if (this.threadLocal.get() == null) { | |
76 | - this.threadLocal.set(createStore()); | |
76 | + protected BeanStore getStore() { | |
77 | + if (this.threadLocalBeans.get() == null) { | |
78 | + this.threadLocalBeans.set(createStore()); | |
79 | + } | |
80 | + | |
81 | + return this.threadLocalBeans.get(); | |
82 | + } | |
83 | + | |
84 | + @Override | |
85 | + protected ContextualStore getContextualStore() { | |
86 | + if (this.threadLocalContextual.get() == null) { | |
87 | + this.threadLocalContextual.set(createContextualStore()); | |
77 | 88 | } |
78 | 89 | |
79 | - return this.threadLocal.get(); | |
90 | + return this.threadLocalContextual.get(); | |
80 | 91 | } |
81 | 92 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/BeanStore.java
0 → 100644
... | ... | @@ -0,0 +1,48 @@ |
1 | +package br.gov.frameworkdemoiselle.internal.context; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.Collections; | |
5 | +import java.util.HashMap; | |
6 | +import java.util.Iterator; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +import javax.enterprise.context.spi.CreationalContext; | |
10 | + | |
11 | +@SuppressWarnings("rawtypes") | |
12 | +public class BeanStore implements Iterable<String>,Serializable { | |
13 | + | |
14 | + private static final long serialVersionUID = 1L; | |
15 | + | |
16 | + private Map<String, Object> instanceCache = Collections.synchronizedMap( new HashMap<String, Object>() ); | |
17 | + private Map<String, CreationalContext> creationalCache = Collections.synchronizedMap( new HashMap<String, CreationalContext>() );; | |
18 | + | |
19 | + public <T> void put(String id, T instance,CreationalContext<T> creationalContext){ | |
20 | + if (!instanceCache.containsKey(id)){ | |
21 | + instanceCache.put(id, instance); | |
22 | + creationalCache.put(id, creationalContext); | |
23 | + } | |
24 | + } | |
25 | + | |
26 | + public Object getInstance(String id){ | |
27 | + return instanceCache.get(id); | |
28 | + } | |
29 | + | |
30 | + public CreationalContext getCreationalContext(String id){ | |
31 | + return creationalCache.get(id); | |
32 | + } | |
33 | + | |
34 | + public void clear(){ | |
35 | + instanceCache.clear(); | |
36 | + creationalCache.clear(); | |
37 | + } | |
38 | + | |
39 | + public boolean contains(String id){ | |
40 | + return instanceCache.containsKey(id); | |
41 | + } | |
42 | + | |
43 | + @Override | |
44 | + public Iterator<String> iterator() { | |
45 | + return instanceCache.keySet().iterator(); | |
46 | + } | |
47 | + | |
48 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ContextualStore.java
0 → 100644
... | ... | @@ -0,0 +1,60 @@ |
1 | +package br.gov.frameworkdemoiselle.internal.context; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.HashMap; | |
5 | +import java.util.concurrent.atomic.AtomicInteger; | |
6 | + | |
7 | +import javax.enterprise.context.spi.Contextual; | |
8 | +import javax.enterprise.inject.spi.PassivationCapable; | |
9 | + | |
10 | + | |
11 | +@SuppressWarnings("rawtypes") | |
12 | +public class ContextualStore implements Serializable { | |
13 | + | |
14 | + private static final long serialVersionUID = 1L; | |
15 | + | |
16 | + private static final String PREFIX = ContextualStore.class.getCanonicalName() + "#"; | |
17 | + | |
18 | + private AtomicInteger idGenerator = new AtomicInteger(); | |
19 | + | |
20 | + private HashMap<String, Contextual> idToContextual = new HashMap<String, Contextual>(); | |
21 | + | |
22 | + private HashMap<Contextual, String> contextualToId = new HashMap<Contextual, String>(); | |
23 | + | |
24 | + /** | |
25 | + * The an unique ID for the given contextual. If it's the first time | |
26 | + * this contextual is accessed, registers the contextual for latter retrieval. | |
27 | + * | |
28 | + * @param contextual The contextual to generate an ID | |
29 | + * @return The unique ID for the contextual | |
30 | + */ | |
31 | + public String tryRegisterAndGetId(Contextual contextual){ | |
32 | + String returnedId; | |
33 | + | |
34 | + if (contextualToId.containsKey(contextual)){ | |
35 | + returnedId = contextualToId.get(contextual); | |
36 | + } | |
37 | + else if (contextual instanceof PassivationCapable){ | |
38 | + returnedId = ((PassivationCapable)contextual).getId(); | |
39 | + idToContextual.put(returnedId, contextual); | |
40 | + contextualToId.put(contextual, returnedId); | |
41 | + } | |
42 | + else{ | |
43 | + returnedId = PREFIX + idGenerator.addAndGet(1); | |
44 | + idToContextual.put(returnedId, contextual); | |
45 | + contextualToId.put(contextual, returnedId); | |
46 | + } | |
47 | + | |
48 | + return returnedId; | |
49 | + } | |
50 | + | |
51 | + public Contextual getContextual(String id){ | |
52 | + return idToContextual.get(id); | |
53 | + } | |
54 | + | |
55 | + public void clear(){ | |
56 | + idToContextual.clear(); | |
57 | + contextualToId.clear(); | |
58 | + } | |
59 | + | |
60 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContextProducer.java
... | ... | @@ -60,6 +60,7 @@ import javax.enterprise.inject.spi.InjectionPoint; |
60 | 60 | |
61 | 61 | import org.slf4j.Logger; |
62 | 62 | |
63 | +import br.gov.frameworkdemoiselle.annotation.Priority; | |
63 | 64 | import br.gov.frameworkdemoiselle.context.ConversationContext; |
64 | 65 | import br.gov.frameworkdemoiselle.context.CustomContext; |
65 | 66 | import br.gov.frameworkdemoiselle.context.RequestContext; |
... | ... | @@ -133,7 +134,7 @@ public class CustomContextProducer { |
133 | 134 | /////////////PRODUCERS/////////////////// |
134 | 135 | |
135 | 136 | @Produces |
136 | - public RequestContext getRequestContext(InjectionPoint ip){ | |
137 | + protected RequestContext getRequestContext(InjectionPoint ip){ | |
137 | 138 | if (ip!=null){ |
138 | 139 | return getContext(ip); |
139 | 140 | } |
... | ... | @@ -143,7 +144,7 @@ public class CustomContextProducer { |
143 | 144 | } |
144 | 145 | |
145 | 146 | @Produces |
146 | - public SessionContext getSessionContext(InjectionPoint ip){ | |
147 | + protected SessionContext getSessionContext(InjectionPoint ip){ | |
147 | 148 | if (ip!=null){ |
148 | 149 | return getContext(ip); |
149 | 150 | } |
... | ... | @@ -153,7 +154,7 @@ public class CustomContextProducer { |
153 | 154 | } |
154 | 155 | |
155 | 156 | @Produces |
156 | - public ViewContext getViewContext(InjectionPoint ip){ | |
157 | + protected ViewContext getViewContext(InjectionPoint ip){ | |
157 | 158 | if (ip!=null){ |
158 | 159 | return getContext(ip); |
159 | 160 | } |
... | ... | @@ -163,7 +164,7 @@ public class CustomContextProducer { |
163 | 164 | } |
164 | 165 | |
165 | 166 | @Produces |
166 | - public StaticContext getStaticContext(InjectionPoint ip){ | |
167 | + protected StaticContext getStaticContext(InjectionPoint ip){ | |
167 | 168 | if (ip!=null){ |
168 | 169 | return getContext(ip); |
169 | 170 | } |
... | ... | @@ -173,7 +174,7 @@ public class CustomContextProducer { |
173 | 174 | } |
174 | 175 | |
175 | 176 | @Produces |
176 | - public ConversationContext getConversationContext(InjectionPoint ip){ | |
177 | + protected ConversationContext getConversationContext(InjectionPoint ip){ | |
177 | 178 | if (ip!=null){ |
178 | 179 | return getContext(ip); |
179 | 180 | } |
... | ... | @@ -184,8 +185,17 @@ public class CustomContextProducer { |
184 | 185 | |
185 | 186 | /////////////END OF PRODUCERS/////////////////// |
186 | 187 | |
188 | + /** | |
189 | + * Obtain a custom context for the provided injection point. | |
190 | + * | |
191 | + * @param ip The object containing information about the injection point - most importantly | |
192 | + * the declared type of the injection point, to decide the context to return | |
193 | + * | |
194 | + * @return A context of a type compatible with the type of the injection point, or <code>null</code> if there is | |
195 | + * no such context. | |
196 | + */ | |
187 | 197 | @SuppressWarnings("unchecked") |
188 | - private <T extends CustomContext> T getContext(InjectionPoint ip){ | |
198 | + public <T extends CustomContext> T getContext(InjectionPoint ip){ | |
189 | 199 | T producedContext = null; |
190 | 200 | |
191 | 201 | if (ip!=null){ |
... | ... | @@ -200,8 +210,16 @@ public class CustomContextProducer { |
200 | 210 | return producedContext; |
201 | 211 | } |
202 | 212 | |
213 | + /** | |
214 | + * Obtain a context compatible with the provided type. | |
215 | + * | |
216 | + * @param contextClass The type of the desired context. The returned context will be compatible with this type, if there | |
217 | + * is more than one compatible type, this method will decide witch one to return based on the {@link Priority} annotation. | |
218 | + * | |
219 | + * @return A context of a type compatible with the informed type, or <code>null</code> if there is no such context. | |
220 | + */ | |
203 | 221 | @SuppressWarnings("unchecked") |
204 | - private <T extends CustomContext> T getContext(Class<T> contextClass){ | |
222 | + public <T extends CustomContext> T getContext(Class<T> contextClass){ | |
205 | 223 | CustomContext producedContext = null; |
206 | 224 | |
207 | 225 | ArrayList<CustomContext> selectableContexts = new ArrayList<CustomContext>(); | ... | ... |
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/context/staticcontext/ConversationBean.java
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +package context.staticcontext; | |
2 | + | |
3 | +import javax.enterprise.context.ConversationScoped; | |
4 | +import java.io.Serializable; | |
5 | + | |
6 | +@ConversationScoped | |
7 | +public class ConversationBean implements Serializable { | |
8 | + | |
9 | + private static final long serialVersionUID = 1L; | |
10 | + | |
11 | + private String data = "test"; | |
12 | + | |
13 | + | |
14 | + public String getData() { | |
15 | + return data; | |
16 | + } | |
17 | + | |
18 | + | |
19 | + public void setData(String data) { | |
20 | + this.data = data; | |
21 | + } | |
22 | + | |
23 | + | |
24 | + | |
25 | +} | ... | ... |
impl/core/src/test/java/context/staticcontext/SessionBean.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package context.staticcontext; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +import javax.enterprise.context.SessionScoped; | |
6 | + | |
7 | +@SessionScoped | |
8 | +public class SessionBean implements Serializable{ | |
9 | + | |
10 | + private static final long serialVersionUID = 1L; | |
11 | + | |
12 | + private String data = "test"; | |
13 | + | |
14 | + | |
15 | + public String getData() { | |
16 | + return data; | |
17 | + } | |
18 | + | |
19 | + | |
20 | + public void setData(String data) { | |
21 | + this.data = data; | |
22 | + } | |
23 | + | |
24 | + | |
25 | + | |
26 | +} | ... | ... |
impl/core/src/test/java/context/staticcontext/StaticContextTest.java
0 → 100644
... | ... | @@ -0,0 +1,88 @@ |
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 context.staticcontext; | |
38 | + | |
39 | +import javax.enterprise.inject.spi.Bean; | |
40 | + | |
41 | +import org.jboss.arquillian.container.test.api.Deployment; | |
42 | +import org.jboss.arquillian.junit.Arquillian; | |
43 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
44 | +import org.junit.Assert; | |
45 | +import org.junit.Test; | |
46 | +import org.junit.runner.RunWith; | |
47 | + | |
48 | +import br.gov.frameworkdemoiselle.context.ConversationContext; | |
49 | +import br.gov.frameworkdemoiselle.context.SessionContext; | |
50 | +import br.gov.frameworkdemoiselle.util.Beans; | |
51 | +import test.Tests; | |
52 | + | |
53 | +@RunWith(Arquillian.class) | |
54 | +public class StaticContextTest { | |
55 | + | |
56 | + @Deployment | |
57 | + public static JavaArchive createDeployment() { | |
58 | + JavaArchive deployment = Tests.createDeployment(StaticContextTest.class); | |
59 | + return deployment; | |
60 | + } | |
61 | + | |
62 | + @Test | |
63 | + public void checkSeparatedStores(){ | |
64 | + | |
65 | + ConversationContext conversationContext = Beans.getReference(ConversationContext.class); | |
66 | + SessionContext sessionContext = Beans.getReference(SessionContext.class); | |
67 | + | |
68 | + conversationContext.activate(); | |
69 | + sessionContext.activate(); | |
70 | + | |
71 | + ConversationBean conversationBean = Beans.getReference(ConversationBean.class); | |
72 | + conversationBean.getData(); | |
73 | + | |
74 | + SessionBean sessionBean = Beans.getReference(SessionBean.class); | |
75 | + sessionBean.getData(); | |
76 | + | |
77 | + Bean<?> conversationContextual = Beans.getBeanManager().getBeans(ConversationBean.class).iterator().next(); | |
78 | + Bean<?> sessionContextual = Beans.getBeanManager().getBeans(SessionBean.class).iterator().next(); | |
79 | + | |
80 | + Assert.assertNotNull( conversationContext.get(conversationContextual) ); | |
81 | + Assert.assertNull( conversationContext.get(sessionContextual) ); | |
82 | + | |
83 | + Assert.assertNotNull( sessionContext.get(sessionContextual) ); | |
84 | + Assert.assertNull( sessionContext.get(conversationContextual) ); | |
85 | + | |
86 | + } | |
87 | + | |
88 | +} | ... | ... |
impl/core/src/test/java/security/authorization/custom/CustomAuthorizer.java
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/main/java/br/gov/frameworkdemoiselle/internal/producer/AbstractEntityManagerStore.java
... | ... | @@ -41,13 +41,11 @@ import java.util.HashMap; |
41 | 41 | import java.util.Map; |
42 | 42 | |
43 | 43 | import javax.enterprise.context.RequestScoped; |
44 | -import javax.inject.Inject; | |
45 | 44 | import javax.persistence.EntityManager; |
46 | 45 | import javax.persistence.FlushModeType; |
47 | 46 | |
48 | 47 | import org.slf4j.Logger; |
49 | 48 | |
50 | -import br.gov.frameworkdemoiselle.annotation.Name; | |
51 | 49 | import br.gov.frameworkdemoiselle.internal.configuration.EntityManagerConfig; |
52 | 50 | import br.gov.frameworkdemoiselle.internal.configuration.EntityManagerConfig.EntityManagerScope; |
53 | 51 | import br.gov.frameworkdemoiselle.util.Beans; |
... | ... | @@ -74,19 +72,6 @@ public abstract class AbstractEntityManagerStore implements EntityManagerStore { |
74 | 72 | |
75 | 73 | private final Map<String, EntityManager> cache = Collections.synchronizedMap(new HashMap<String, EntityManager>()); |
76 | 74 | |
77 | - @Inject | |
78 | - private EntityManagerFactoryProducer factory; | |
79 | - | |
80 | - @Inject | |
81 | - private Logger logger; | |
82 | - | |
83 | - @Inject | |
84 | - @Name("demoiselle-jpa-bundle") | |
85 | - private ResourceBundle bundle; | |
86 | - | |
87 | - @Inject | |
88 | - private EntityManagerConfig configuration; | |
89 | - | |
90 | 75 | public EntityManager getEntityManager(String persistenceUnit) { |
91 | 76 | EntityManager entityManager = null; |
92 | 77 | |
... | ... | @@ -114,6 +99,7 @@ public abstract class AbstractEntityManagerStore implements EntityManagerStore { |
114 | 99 | //Se o produtor não possui escopo, então o ciclo de vida |
115 | 100 | //de EntityManager produzidos é responsabilidade do desenvolvedor. Não |
116 | 101 | //fechamos os EntityManagers aqui. |
102 | + EntityManagerConfig configuration = getConfiguration(); | |
117 | 103 | if (configuration.getEntityManagerScope() != EntityManagerScope.NOSCOPE){ |
118 | 104 | for (EntityManager entityManager : cache.values()) { |
119 | 105 | entityManager.close(); |
... | ... | @@ -131,23 +117,18 @@ public abstract class AbstractEntityManagerStore implements EntityManagerStore { |
131 | 117 | } |
132 | 118 | |
133 | 119 | private EntityManagerFactoryProducer getFactory(){ |
134 | - if (factory==null){ | |
135 | - factory = Beans.getReference(EntityManagerFactoryProducer.class); | |
136 | - } | |
137 | - return factory; | |
120 | + return Beans.getReference(EntityManagerFactoryProducer.class); | |
138 | 121 | } |
139 | 122 | |
140 | 123 | private Logger getLogger(){ |
141 | - if (logger==null){ | |
142 | - logger = Beans.getReference(Logger.class); | |
143 | - } | |
144 | - return logger; | |
124 | + return Beans.getReference(Logger.class); | |
145 | 125 | } |
146 | 126 | |
147 | 127 | private ResourceBundle getBundle(){ |
148 | - if (bundle==null){ | |
149 | - bundle = Beans.getReference(ResourceBundle.class , new NameQualifier("demoiselle-jpa-bundle")); | |
150 | - } | |
151 | - return bundle; | |
128 | + return Beans.getReference(ResourceBundle.class , new NameQualifier("demoiselle-jpa-bundle")); | |
129 | + } | |
130 | + | |
131 | + private EntityManagerConfig getConfiguration(){ | |
132 | + return Beans.getReference(EntityManagerConfig.class); | |
152 | 133 | } |
153 | 134 | } | ... | ... |
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/EntityManagerProxy.java
... | ... | @@ -117,8 +117,8 @@ public class EntityManagerProxy implements EntityManager, Serializable { |
117 | 117 | @Override |
118 | 118 | public void persist(Object entity) { |
119 | 119 | joinTransactionIfNecessary(); |
120 | - checkEntityManagerScopePassivable(entity); | |
121 | 120 | getEntityManagerDelegate().persist(entity); |
121 | + checkEntityManagerScopePassivable(entity); | |
122 | 122 | } |
123 | 123 | |
124 | 124 | /* | ... | ... |
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/context/FacesViewContextImpl.java
... | ... | @@ -70,14 +70,26 @@ public class FacesViewContextImpl extends AbstractCustomContext implements ViewC |
70 | 70 | } |
71 | 71 | |
72 | 72 | @Override |
73 | - protected Store getStore() { | |
73 | + protected BeanStore getStore() { | |
74 | 74 | Map<String, Object> viewMap = Faces.getViewMap(); |
75 | - String key = Store.class.getName(); | |
75 | + String key = BeanStore.class.getName(); | |
76 | 76 | |
77 | 77 | if (!viewMap.containsKey(key)) { |
78 | 78 | viewMap.put(key, createStore()); |
79 | 79 | } |
80 | 80 | |
81 | - return (Store) viewMap.get(key); | |
81 | + return (BeanStore) viewMap.get(key); | |
82 | + } | |
83 | + | |
84 | + @Override | |
85 | + protected ContextualStore getContextualStore() { | |
86 | + Map<String, Object> viewMap = Faces.getViewMap(); | |
87 | + String key = ContextualStore.class.getName(); | |
88 | + | |
89 | + if (!viewMap.containsKey(key)) { | |
90 | + viewMap.put(key, createContextualStore()); | |
91 | + } | |
92 | + | |
93 | + return (ContextualStore) viewMap.get(key); | |
82 | 94 | } |
83 | 95 | } | ... | ... |
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/internal/implementation/FacesMessageAppender.java
... | ... | @@ -37,18 +37,26 @@ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
38 | 38 | |
39 | 39 | import static br.gov.frameworkdemoiselle.annotation.Priority.L3_PRIORITY; |
40 | + | |
41 | +import javax.enterprise.context.ContextNotActiveException; | |
42 | + | |
40 | 43 | import br.gov.frameworkdemoiselle.annotation.Priority; |
41 | 44 | import br.gov.frameworkdemoiselle.message.Message; |
42 | -import br.gov.frameworkdemoiselle.message.MessageAppender; | |
43 | 45 | import br.gov.frameworkdemoiselle.util.Faces; |
44 | 46 | |
45 | 47 | @Priority(L3_PRIORITY) |
46 | -public class FacesMessageAppender implements MessageAppender { | |
48 | +public class FacesMessageAppender extends LoggerMessageAppender { | |
47 | 49 | |
48 | 50 | private static final long serialVersionUID = 1L; |
49 | 51 | |
50 | 52 | @Override |
51 | 53 | public void append(Message message) { |
52 | - Faces.addMessage(message); | |
54 | + try { | |
55 | + Faces.addMessage(message); | |
56 | + } catch (ContextNotActiveException cause) { | |
57 | + // TODO Logar warning... | |
58 | + | |
59 | + super.append(message); | |
60 | + } | |
53 | 61 | } |
54 | 62 | } | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityObserver.java
... | ... | @@ -152,7 +152,8 @@ public class SecurityObserver implements Serializable { |
152 | 152 | |
153 | 153 | } finally { |
154 | 154 | try { |
155 | - Beans.getReference(HttpSession.class).invalidate(); | |
155 | + HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); | |
156 | + session.invalidate(); | |
156 | 157 | } catch (IllegalStateException e) { |
157 | 158 | logger.debug("Esta sessão já foi invalidada."); |
158 | 159 | } | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/FacesContextProxy.java
... | ... | @@ -5,7 +5,9 @@ import java.util.Iterator; |
5 | 5 | import java.util.List; |
6 | 6 | import java.util.Map; |
7 | 7 | |
8 | +import javax.annotation.PostConstruct; | |
8 | 9 | import javax.el.ELContext; |
10 | +import javax.enterprise.context.ContextNotActiveException; | |
9 | 11 | import javax.enterprise.inject.Default; |
10 | 12 | import javax.faces.application.Application; |
11 | 13 | import javax.faces.application.FacesMessage; |
... | ... | @@ -26,8 +28,16 @@ public class FacesContextProxy extends FacesContext implements Serializable { |
26 | 28 | |
27 | 29 | private static final long serialVersionUID = 1L; |
28 | 30 | |
29 | - private FacesContext getDelegate() { | |
30 | - return FacesContext.getCurrentInstance(); | |
31 | + @PostConstruct | |
32 | + public FacesContext getDelegate() { | |
33 | + FacesContext facesContext = FacesContext.getCurrentInstance(); | |
34 | + | |
35 | + if (facesContext == null) { | |
36 | + // TODO Colocar a mensagem correta | |
37 | + throw new ContextNotActiveException(); | |
38 | + } | |
39 | + | |
40 | + return facesContext; | |
31 | 41 | } |
32 | 42 | |
33 | 43 | public int hashCode() { | ... | ... |
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/Faces.java
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/FacesContextProxyBean.java
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
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 javax.servlet.http.HttpServletResponse.SC_ACCEPTED; | |
40 | + | |
41 | +import javax.faces.context.FacesContext; | |
42 | +import javax.inject.Inject; | |
43 | +import javax.inject.Named; | |
44 | +import javax.servlet.http.HttpServletResponse; | |
45 | + | |
46 | +import br.gov.frameworkdemoiselle.util.Beans; | |
47 | + | |
48 | +@Named | |
49 | +public class FacesContextProxyBean { | |
50 | + | |
51 | + @Inject | |
52 | + private HttpServletResponse response; | |
53 | + | |
54 | + public String getOk() { | |
55 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | |
56 | + facesContext.responseComplete(); | |
57 | + | |
58 | + response.setStatus(SC_ACCEPTED); | |
59 | + return null; | |
60 | + } | |
61 | +} | ... | ... |
impl/extension/jsf/src/test/java/proxy/FacesContextProxyServlet.java
... | ... | @@ -36,8 +36,12 @@ |
36 | 36 | */ |
37 | 37 | package proxy; |
38 | 38 | |
39 | +import static javax.servlet.http.HttpServletResponse.SC_EXPECTATION_FAILED; | |
40 | +import static javax.servlet.http.HttpServletResponse.SC_OK; | |
41 | + | |
39 | 42 | import java.io.IOException; |
40 | 43 | |
44 | +import javax.enterprise.context.ContextNotActiveException; | |
41 | 45 | import javax.faces.context.FacesContext; |
42 | 46 | import javax.servlet.ServletException; |
43 | 47 | import javax.servlet.annotation.WebServlet; |
... | ... | @@ -45,9 +49,6 @@ import javax.servlet.http.HttpServlet; |
45 | 49 | import javax.servlet.http.HttpServletRequest; |
46 | 50 | import javax.servlet.http.HttpServletResponse; |
47 | 51 | |
48 | -import org.apache.commons.httpclient.HttpStatus; | |
49 | - | |
50 | -import br.gov.frameworkdemoiselle.internal.proxy.FacesContextProxy; | |
51 | 52 | import br.gov.frameworkdemoiselle.util.Beans; |
52 | 53 | |
53 | 54 | @WebServlet("/index") |
... | ... | @@ -55,15 +56,14 @@ public class FacesContextProxyServlet extends HttpServlet { |
55 | 56 | |
56 | 57 | private static final long serialVersionUID = 1L; |
57 | 58 | |
58 | - private FacesContext facesContext; | |
59 | - | |
60 | 59 | @Override |
61 | 60 | 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); | |
61 | + try { | |
62 | + Beans.getReference(FacesContext.class); | |
63 | + response.setStatus(SC_OK); | |
64 | + | |
65 | + } catch (ContextNotActiveException cause) { | |
66 | + response.setStatus(SC_EXPECTATION_FAILED); | |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } | ... | ... |
impl/extension/jsf/src/test/java/proxy/FacesContextProxyTest.java
... | ... | @@ -36,6 +36,8 @@ |
36 | 36 | */ |
37 | 37 | package proxy; |
38 | 38 | |
39 | +import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED; | |
40 | +import static javax.servlet.http.HttpServletResponse.SC_EXPECTATION_FAILED; | |
39 | 41 | import static org.junit.Assert.assertEquals; |
40 | 42 | |
41 | 43 | import java.io.IOException; |
... | ... | @@ -43,7 +45,6 @@ import java.net.URL; |
43 | 45 | |
44 | 46 | import org.apache.commons.httpclient.HttpClient; |
45 | 47 | import org.apache.commons.httpclient.HttpException; |
46 | -import org.apache.commons.httpclient.HttpStatus; | |
47 | 48 | import org.apache.commons.httpclient.methods.GetMethod; |
48 | 49 | import org.jboss.arquillian.container.test.api.Deployment; |
49 | 50 | import org.jboss.arquillian.junit.Arquillian; |
... | ... | @@ -64,22 +65,26 @@ public class FacesContextProxyTest { |
64 | 65 | |
65 | 66 | @Deployment(testable = false) |
66 | 67 | public static WebArchive createDeployment() { |
67 | - return Tests.createDeployment().addClass(FacesContextProxyServlet.class) | |
68 | + return Tests.createDeployment().addClasses(FacesContextProxyServlet.class, FacesContextProxyBean.class) | |
69 | + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") | |
68 | 70 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); |
69 | 71 | } |
70 | 72 | |
71 | 73 | @Test |
72 | - public void facesContextProxy() { | |
74 | + public void validProxyCreated() 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_ACCEPTED, status); | |
80 | + } | |
81 | + | |
82 | + @Test | |
83 | + public void inValidProxyCreatedCausedByContextNotActiveException() throws HttpException, IOException { | |
73 | 84 | HttpClient client = new HttpClient(); |
74 | 85 | GetMethod method = new GetMethod(deploymentUrl + "/index"); |
75 | 86 | |
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 | - } | |
87 | + int status = client.executeMethod(method); | |
88 | + assertEquals(SC_EXPECTATION_FAILED, status); | |
84 | 89 | } |
85 | 90 | } | ... | ... |
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 | ... | ... |
... | ... | @@ -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 | + #{facesContextProxyBean.ok} | |
41 | + </h:body> | |
42 | + | |
43 | +</html> | ... | ... |
impl/extension/jsf/src/test/resources/proxy/web.xml
... | ... | @@ -48,7 +48,17 @@ |
48 | 48 | <filter-name>Demoiselle Servlet Filter</filter-name> |
49 | 49 | <url-pattern>/*</url-pattern> |
50 | 50 | </filter-mapping> |
51 | - | |
51 | + | |
52 | + <servlet> | |
53 | + <servlet-name>Faces Servlet</servlet-name> | |
54 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | |
55 | + <load-on-startup>1</load-on-startup> | |
56 | + </servlet> | |
57 | + <servlet-mapping> | |
58 | + <servlet-name>Faces Servlet</servlet-name> | |
59 | + <url-pattern>*.jsf</url-pattern> | |
60 | + </servlet-mapping> | |
61 | + | |
52 | 62 | <servlet> |
53 | 63 | <servlet-name>Servlet Class</servlet-name> |
54 | 64 | <servlet-class>proxy.FacesContextProxyServlet</servlet-class> |
... | ... | @@ -56,6 +66,6 @@ |
56 | 66 | <servlet-mapping> |
57 | 67 | <servlet-name>Servlet Class</servlet-name> |
58 | 68 | <url-pattern>/index</url-pattern> |
59 | - </servlet-mapping> | |
69 | + </servlet-mapping> | |
60 | 70 | |
61 | 71 | </web-app> |
62 | 72 | \ 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> | ... | ... |