Commit ddf2a6e8c2865b9d03b7bd3546958cf688d0e98d
1 parent
d340702b
Exists in
master
Diversos ajustes no framework referentes à serialização de objetos
internos
Showing
42 changed files
with
2694 additions
and
1907 deletions
Show diff stats
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/java/persistence/BookmarkDAO.java
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/resources/demoiselle.properties
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 | 1 | frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction |
37 | 2 | #frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction | ... | ... |
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" |
4 | 4 | version="3.0"> |
5 | 5 | |
6 | - <!-- If you are using tomcat6/tomcat7 then uncomment this listener --> | |
6 | + <!-- If you are using tomcat6/tomcat7/gae then uncomment this listener --> | |
7 | 7 | <!-- |
8 | 8 | <listener> |
9 | 9 | <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> |
... | ... | @@ -13,8 +13,16 @@ |
13 | 13 | <!-- If you are using servlet 2.5 then uncomment this listener --> |
14 | 14 | <!-- |
15 | 15 | <listener> |
16 | - <listener-class>br.gov.frameworkdemoiselle.util.ServletContextListener</listener-class> | |
16 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | |
17 | 17 | </listener> |
18 | + <filter> | |
19 | + <filter-name>Demoiselle Servlet Filter</filter-name> | |
20 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | |
21 | + </filter> | |
22 | + <filter-mapping> | |
23 | + <filter-name>Demoiselle Servlet Filter</filter-name> | |
24 | + <url-pattern>/*</url-pattern> | |
25 | + </filter-mapping> | |
18 | 26 | --> |
19 | 27 | |
20 | 28 | <servlet> | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
... | ... | @@ -36,6 +36,7 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.configuration; |
38 | 38 | |
39 | +import java.io.Serializable; | |
39 | 40 | import java.lang.reflect.Field; |
40 | 41 | import java.lang.reflect.Method; |
41 | 42 | import java.util.HashSet; |
... | ... | @@ -67,7 +68,9 @@ import br.gov.frameworkdemoiselle.util.Strings; |
67 | 68 | * |
68 | 69 | * @author SERPRO |
69 | 70 | */ |
70 | -public class ConfigurationLoader { | |
71 | +public class ConfigurationLoader implements Serializable { | |
72 | + | |
73 | + private static final long serialVersionUID = 1L; | |
71 | 74 | |
72 | 75 | @Inject |
73 | 76 | @Name("demoiselle-core-bundle") | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
... | ... | @@ -55,7 +55,6 @@ import javax.enterprise.inject.Produces; |
55 | 55 | import javax.enterprise.inject.spi.InjectionPoint; |
56 | 56 | |
57 | 57 | import org.slf4j.Logger; |
58 | -import org.slf4j.LoggerFactory; | |
59 | 58 | |
60 | 59 | import br.gov.frameworkdemoiselle.internal.proxy.Slf4jLoggerProxy; |
61 | 60 | |
... | ... | @@ -78,6 +77,6 @@ public class LoggerProducer implements Serializable { |
78 | 77 | } |
79 | 78 | |
80 | 79 | public static <T> Logger create(Class<T> type) { |
81 | - return new Slf4jLoggerProxy(LoggerFactory.getLogger(type)); | |
80 | + return new Slf4jLoggerProxy(type); | |
82 | 81 | } |
83 | 82 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducer.java
... | ... | @@ -67,8 +67,7 @@ public class ResourceBundleProducer implements Serializable { |
67 | 67 | ResourceBundle bundle = null; |
68 | 68 | |
69 | 69 | try { |
70 | - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
71 | - bundle = new ResourceBundle(ResourceBundle.getBundle(baseName, locale, classLoader)); | |
70 | + bundle = new ResourceBundle(baseName, locale); | |
72 | 71 | |
73 | 72 | } catch (MissingResourceException e) { |
74 | 73 | throw new DemoiselleException("File " + baseName + " not found!"); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxy.java
... | ... | @@ -51,321 +51,332 @@ package br.gov.frameworkdemoiselle.internal.proxy; |
51 | 51 | import java.io.Serializable; |
52 | 52 | |
53 | 53 | import org.slf4j.Logger; |
54 | +import org.slf4j.LoggerFactory; | |
54 | 55 | import org.slf4j.Marker; |
55 | 56 | |
56 | 57 | public class Slf4jLoggerProxy implements Logger, Serializable { |
57 | 58 | |
58 | 59 | private static final long serialVersionUID = 1L; |
59 | 60 | |
60 | - private transient final Logger delegate; | |
61 | + private transient Logger delegate; | |
61 | 62 | |
62 | - public Slf4jLoggerProxy(final Logger logger) { | |
63 | - this.delegate = logger; | |
63 | + private final Class<?> type; | |
64 | + | |
65 | + private Logger getDelegate() { | |
66 | + if(delegate == null) { | |
67 | + delegate = LoggerFactory.getLogger(type); | |
68 | + } | |
69 | + | |
70 | + return delegate; | |
71 | + } | |
72 | + | |
73 | + public Slf4jLoggerProxy(final Class<?> type) { | |
74 | + this.type = type; | |
64 | 75 | } |
65 | 76 | |
66 | 77 | @Override |
67 | 78 | public void debug(final Marker marker, final String msg) { |
68 | - this.delegate.debug(marker, msg); | |
79 | + getDelegate().debug(marker, msg); | |
69 | 80 | } |
70 | 81 | |
71 | 82 | @Override |
72 | 83 | public void debug(final Marker marker, final String format, final Object arg) { |
73 | - this.delegate.debug(marker, format, arg); | |
84 | + getDelegate().debug(marker, format, arg); | |
74 | 85 | } |
75 | 86 | |
76 | 87 | @Override |
77 | 88 | public void debug(final Marker marker, final String format, final Object arg1, final Object arg2) { |
78 | - this.delegate.debug(marker, format, arg1, arg2); | |
89 | + getDelegate().debug(marker, format, arg1, arg2); | |
79 | 90 | } |
80 | 91 | |
81 | 92 | @Override |
82 | 93 | public void debug(final Marker marker, final String format, final Object[] argArray) { |
83 | - this.delegate.debug(marker, format, argArray); | |
94 | + getDelegate().debug(marker, format, argArray); | |
84 | 95 | } |
85 | 96 | |
86 | 97 | @Override |
87 | 98 | public void debug(final Marker marker, final String msg, final Throwable t) { |
88 | - this.delegate.debug(marker, msg, t); | |
99 | + getDelegate().debug(marker, msg, t); | |
89 | 100 | } |
90 | 101 | |
91 | 102 | @Override |
92 | 103 | public void debug(final String msg) { |
93 | - this.delegate.debug(msg); | |
104 | + getDelegate().debug(msg); | |
94 | 105 | } |
95 | 106 | |
96 | 107 | @Override |
97 | 108 | public void debug(final String format, final Object arg) { |
98 | - this.delegate.debug(format, arg); | |
109 | + getDelegate().debug(format, arg); | |
99 | 110 | } |
100 | 111 | |
101 | 112 | @Override |
102 | 113 | public void debug(final String format, final Object arg1, final Object arg2) { |
103 | - this.delegate.debug(format, arg1, arg2); | |
114 | + getDelegate().debug(format, arg1, arg2); | |
104 | 115 | } |
105 | 116 | |
106 | 117 | @Override |
107 | 118 | public void debug(final String format, final Object[] argArray) { |
108 | - this.delegate.debug(format, argArray); | |
119 | + getDelegate().debug(format, argArray); | |
109 | 120 | } |
110 | 121 | |
111 | 122 | @Override |
112 | 123 | public void debug(final String msg, final Throwable t) { |
113 | - this.delegate.debug(msg, t); | |
124 | + getDelegate().debug(msg, t); | |
114 | 125 | } |
115 | 126 | |
116 | 127 | @Override |
117 | 128 | public void error(final Marker marker, final String msg) { |
118 | - this.delegate.error(marker, msg); | |
129 | + getDelegate().error(marker, msg); | |
119 | 130 | } |
120 | 131 | |
121 | 132 | @Override |
122 | 133 | public void error(final Marker marker, final String format, final Object arg) { |
123 | - this.delegate.error(marker, format, arg); | |
134 | + getDelegate().error(marker, format, arg); | |
124 | 135 | } |
125 | 136 | |
126 | 137 | @Override |
127 | 138 | public void error(final Marker marker, final String format, final Object arg1, final Object arg2) { |
128 | - this.delegate.error(marker, format, arg1, arg2); | |
139 | + getDelegate().error(marker, format, arg1, arg2); | |
129 | 140 | } |
130 | 141 | |
131 | 142 | @Override |
132 | 143 | public void error(final Marker marker, final String format, final Object[] argArray) { |
133 | - this.delegate.error(marker, format, argArray); | |
144 | + getDelegate().error(marker, format, argArray); | |
134 | 145 | } |
135 | 146 | |
136 | 147 | @Override |
137 | 148 | public void error(final Marker marker, final String msg, final Throwable t) { |
138 | - this.delegate.error(marker, msg, t); | |
149 | + getDelegate().error(marker, msg, t); | |
139 | 150 | } |
140 | 151 | |
141 | 152 | @Override |
142 | 153 | public void error(final String msg) { |
143 | - this.delegate.error(msg); | |
154 | + getDelegate().error(msg); | |
144 | 155 | } |
145 | 156 | |
146 | 157 | @Override |
147 | 158 | public void error(final String format, final Object arg) { |
148 | - this.delegate.error(format, arg); | |
159 | + getDelegate().error(format, arg); | |
149 | 160 | } |
150 | 161 | |
151 | 162 | @Override |
152 | 163 | public void error(final String format, final Object arg1, final Object arg2) { |
153 | - this.delegate.error(format, arg1, arg2); | |
164 | + getDelegate().error(format, arg1, arg2); | |
154 | 165 | } |
155 | 166 | |
156 | 167 | @Override |
157 | 168 | public void error(final String format, final Object[] argArray) { |
158 | - this.delegate.error(format, argArray); | |
169 | + getDelegate().error(format, argArray); | |
159 | 170 | } |
160 | 171 | |
161 | 172 | @Override |
162 | 173 | public void error(final String msg, final Throwable t) { |
163 | - this.delegate.error(msg, t); | |
174 | + getDelegate().error(msg, t); | |
164 | 175 | } |
165 | 176 | |
166 | 177 | @Override |
167 | 178 | public String getName() { |
168 | - return this.delegate.getName(); | |
179 | + return getDelegate().getName(); | |
169 | 180 | } |
170 | 181 | |
171 | 182 | @Override |
172 | 183 | public void info(final Marker marker, final String msg) { |
173 | - this.delegate.info(marker, msg); | |
184 | + getDelegate().info(marker, msg); | |
174 | 185 | } |
175 | 186 | |
176 | 187 | @Override |
177 | 188 | public void info(final Marker marker, final String format, final Object arg) { |
178 | - this.delegate.info(marker, format, arg); | |
189 | + getDelegate().info(marker, format, arg); | |
179 | 190 | } |
180 | 191 | |
181 | 192 | @Override |
182 | 193 | public void info(final Marker marker, final String format, final Object arg1, final Object arg2) { |
183 | - this.delegate.info(marker, format, arg1, arg2); | |
194 | + getDelegate().info(marker, format, arg1, arg2); | |
184 | 195 | } |
185 | 196 | |
186 | 197 | @Override |
187 | 198 | public void info(final Marker marker, final String format, final Object[] argArray) { |
188 | - this.delegate.info(marker, format, argArray); | |
199 | + getDelegate().info(marker, format, argArray); | |
189 | 200 | } |
190 | 201 | |
191 | 202 | @Override |
192 | 203 | public void info(final Marker marker, final String msg, final Throwable t) { |
193 | - this.delegate.info(marker, msg, t); | |
204 | + getDelegate().info(marker, msg, t); | |
194 | 205 | } |
195 | 206 | |
196 | 207 | @Override |
197 | 208 | public void info(final String msg) { |
198 | - this.delegate.info(msg); | |
209 | + getDelegate().info(msg); | |
199 | 210 | } |
200 | 211 | |
201 | 212 | @Override |
202 | 213 | public void info(final String format, final Object arg) { |
203 | - this.delegate.info(format, arg); | |
214 | + getDelegate().info(format, arg); | |
204 | 215 | } |
205 | 216 | |
206 | 217 | @Override |
207 | 218 | public void info(final String format, final Object arg1, final Object arg2) { |
208 | - this.delegate.info(format, arg1, arg2); | |
219 | + getDelegate().info(format, arg1, arg2); | |
209 | 220 | } |
210 | 221 | |
211 | 222 | @Override |
212 | 223 | public void info(final String format, final Object[] argArray) { |
213 | - this.delegate.info(format, argArray); | |
224 | + getDelegate().info(format, argArray); | |
214 | 225 | } |
215 | 226 | |
216 | 227 | @Override |
217 | 228 | public void info(final String msg, final Throwable t) { |
218 | - this.delegate.info(msg, t); | |
229 | + getDelegate().info(msg, t); | |
219 | 230 | } |
220 | 231 | |
221 | 232 | @Override |
222 | 233 | public boolean isDebugEnabled() { |
223 | - return this.delegate.isDebugEnabled(); | |
234 | + return getDelegate().isDebugEnabled(); | |
224 | 235 | } |
225 | 236 | |
226 | 237 | @Override |
227 | 238 | public boolean isDebugEnabled(final Marker marker) { |
228 | - return this.delegate.isDebugEnabled(marker); | |
239 | + return getDelegate().isDebugEnabled(marker); | |
229 | 240 | } |
230 | 241 | |
231 | 242 | @Override |
232 | 243 | public boolean isErrorEnabled() { |
233 | - return this.delegate.isErrorEnabled(); | |
244 | + return getDelegate().isErrorEnabled(); | |
234 | 245 | } |
235 | 246 | |
236 | 247 | @Override |
237 | 248 | public boolean isErrorEnabled(final Marker marker) { |
238 | - return this.delegate.isErrorEnabled(marker); | |
249 | + return getDelegate().isErrorEnabled(marker); | |
239 | 250 | } |
240 | 251 | |
241 | 252 | @Override |
242 | 253 | public boolean isInfoEnabled() { |
243 | - return this.delegate.isInfoEnabled(); | |
254 | + return getDelegate().isInfoEnabled(); | |
244 | 255 | } |
245 | 256 | |
246 | 257 | @Override |
247 | 258 | public boolean isInfoEnabled(final Marker marker) { |
248 | - return this.delegate.isInfoEnabled(marker); | |
259 | + return getDelegate().isInfoEnabled(marker); | |
249 | 260 | } |
250 | 261 | |
251 | 262 | @Override |
252 | 263 | public boolean isTraceEnabled() { |
253 | - return this.delegate.isTraceEnabled(); | |
264 | + return getDelegate().isTraceEnabled(); | |
254 | 265 | } |
255 | 266 | |
256 | 267 | @Override |
257 | 268 | public boolean isTraceEnabled(final Marker marker) { |
258 | - return this.delegate.isTraceEnabled(marker); | |
269 | + return getDelegate().isTraceEnabled(marker); | |
259 | 270 | } |
260 | 271 | |
261 | 272 | @Override |
262 | 273 | public boolean isWarnEnabled() { |
263 | - return this.delegate.isWarnEnabled(); | |
274 | + return getDelegate().isWarnEnabled(); | |
264 | 275 | } |
265 | 276 | |
266 | 277 | @Override |
267 | 278 | public boolean isWarnEnabled(final Marker marker) { |
268 | - return this.delegate.isWarnEnabled(marker); | |
279 | + return getDelegate().isWarnEnabled(marker); | |
269 | 280 | } |
270 | 281 | |
271 | 282 | @Override |
272 | 283 | public void trace(final Marker marker, final String msg) { |
273 | - this.delegate.trace(marker, msg); | |
284 | + getDelegate().trace(marker, msg); | |
274 | 285 | } |
275 | 286 | |
276 | 287 | @Override |
277 | 288 | public void trace(final Marker marker, final String format, final Object arg) { |
278 | - this.delegate.trace(marker, format, arg); | |
289 | + getDelegate().trace(marker, format, arg); | |
279 | 290 | } |
280 | 291 | |
281 | 292 | @Override |
282 | 293 | public void trace(final Marker marker, final String format, final Object arg1, final Object arg2) { |
283 | - this.delegate.trace(marker, format, arg1, arg2); | |
294 | + getDelegate().trace(marker, format, arg1, arg2); | |
284 | 295 | } |
285 | 296 | |
286 | 297 | @Override |
287 | 298 | public void trace(final Marker marker, final String format, final Object[] argArray) { |
288 | - this.delegate.trace(marker, format, argArray); | |
299 | + getDelegate().trace(marker, format, argArray); | |
289 | 300 | } |
290 | 301 | |
291 | 302 | @Override |
292 | 303 | public void trace(final Marker marker, final String msg, final Throwable t) { |
293 | - this.delegate.trace(marker, msg, t); | |
304 | + getDelegate().trace(marker, msg, t); | |
294 | 305 | } |
295 | 306 | |
296 | 307 | @Override |
297 | 308 | public void trace(final String msg) { |
298 | - this.delegate.trace(msg); | |
309 | + getDelegate().trace(msg); | |
299 | 310 | } |
300 | 311 | |
301 | 312 | @Override |
302 | 313 | public void trace(final String format, final Object arg) { |
303 | - this.delegate.trace(format, arg); | |
314 | + getDelegate().trace(format, arg); | |
304 | 315 | } |
305 | 316 | |
306 | 317 | @Override |
307 | 318 | public void trace(final String format, final Object arg1, final Object arg2) { |
308 | - this.delegate.trace(format, arg1, arg2); | |
319 | + getDelegate().trace(format, arg1, arg2); | |
309 | 320 | } |
310 | 321 | |
311 | 322 | @Override |
312 | 323 | public void trace(final String format, final Object[] argArray) { |
313 | - this.delegate.trace(format, argArray); | |
324 | + getDelegate().trace(format, argArray); | |
314 | 325 | } |
315 | 326 | |
316 | 327 | @Override |
317 | 328 | public void trace(final String msg, final Throwable t) { |
318 | - this.delegate.trace(msg, t); | |
329 | + getDelegate().trace(msg, t); | |
319 | 330 | } |
320 | 331 | |
321 | 332 | @Override |
322 | 333 | public void warn(final Marker marker, final String msg) { |
323 | - this.delegate.warn(marker, msg); | |
334 | + getDelegate().warn(marker, msg); | |
324 | 335 | } |
325 | 336 | |
326 | 337 | @Override |
327 | 338 | public void warn(final Marker marker, final String format, final Object arg) { |
328 | - this.delegate.warn(marker, format, arg); | |
339 | + getDelegate().warn(marker, format, arg); | |
329 | 340 | } |
330 | 341 | |
331 | 342 | @Override |
332 | 343 | public void warn(final Marker marker, final String format, final Object arg1, final Object arg2) { |
333 | - this.delegate.warn(marker, format, arg1, arg2); | |
344 | + getDelegate().warn(marker, format, arg1, arg2); | |
334 | 345 | } |
335 | 346 | |
336 | 347 | @Override |
337 | 348 | public void warn(final Marker marker, final String format, final Object[] argArray) { |
338 | - this.delegate.warn(marker, format, argArray); | |
349 | + getDelegate().warn(marker, format, argArray); | |
339 | 350 | } |
340 | 351 | |
341 | 352 | @Override |
342 | 353 | public void warn(final Marker marker, final String msg, final Throwable t) { |
343 | - this.delegate.warn(marker, msg, t); | |
354 | + getDelegate().warn(marker, msg, t); | |
344 | 355 | } |
345 | 356 | |
346 | 357 | @Override |
347 | 358 | public void warn(final String msg) { |
348 | - this.delegate.warn(msg); | |
359 | + getDelegate().warn(msg); | |
349 | 360 | } |
350 | 361 | |
351 | 362 | @Override |
352 | 363 | public void warn(final String format, final Object arg) { |
353 | - this.delegate.warn(format, arg); | |
364 | + getDelegate().warn(format, arg); | |
354 | 365 | } |
355 | 366 | |
356 | 367 | @Override |
357 | 368 | public void warn(final String format, final Object arg1, final Object arg2) { |
358 | - this.delegate.warn(format, arg1, arg2); | |
369 | + getDelegate().warn(format, arg1, arg2); | |
359 | 370 | } |
360 | 371 | |
361 | 372 | @Override |
362 | 373 | public void warn(final String format, final Object[] argArray) { |
363 | - this.delegate.warn(format, argArray); | |
374 | + getDelegate().warn(format, argArray); | |
364 | 375 | } |
365 | 376 | |
366 | 377 | @Override |
367 | 378 | public void warn(final String msg, final Throwable t) { |
368 | - this.delegate.warn(msg, t); | |
379 | + getDelegate().warn(msg, t); | |
369 | 380 | } |
370 | 381 | |
371 | 382 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
... | ... | @@ -39,6 +39,8 @@ package br.gov.frameworkdemoiselle.template; |
39 | 39 | import java.util.List; |
40 | 40 | import java.util.ListIterator; |
41 | 41 | |
42 | +import br.gov.frameworkdemoiselle.internal.implementation.DefaultTransaction; | |
43 | +import br.gov.frameworkdemoiselle.transaction.Transaction; | |
42 | 44 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
43 | 45 | import br.gov.frameworkdemoiselle.util.Beans; |
44 | 46 | import br.gov.frameworkdemoiselle.util.Reflections; |
... | ... | @@ -50,21 +52,45 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
50 | 52 | private Class<C> delegateClass; |
51 | 53 | |
52 | 54 | private C delegate; |
53 | - | |
55 | + | |
54 | 56 | @Override |
55 | - @Transactional | |
56 | 57 | public void delete(final I id) { |
57 | - this.getDelegate().delete(id); | |
58 | + if(isRunningTransactionalOperations()) { | |
59 | + transactionalDelete(id); | |
60 | + } else { | |
61 | + nonTransactionalDelete(id); | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + @Transactional | |
66 | + private void transactionalDelete(final I id) { | |
67 | + nonTransactionalDelete(id); | |
68 | + } | |
69 | + | |
70 | + private void nonTransactionalDelete(final I id) { | |
71 | + getDelegate().delete(id); | |
72 | + } | |
73 | + | |
74 | + public void delete(final List<I> ids) { | |
75 | + if(isRunningTransactionalOperations()) { | |
76 | + transactionalDelete(ids); | |
77 | + } else { | |
78 | + nonTransactionalDelete(ids); | |
79 | + } | |
58 | 80 | } |
59 | 81 | |
60 | 82 | @Transactional |
61 | - public void delete(final List<I> idList) { | |
62 | - ListIterator<I> iter = idList.listIterator(); | |
83 | + private void transactionalDelete(final List<I> ids) { | |
84 | + nonTransactionalDelete(ids); | |
85 | + } | |
86 | + | |
87 | + private void nonTransactionalDelete(final List<I> ids) { | |
88 | + ListIterator<I> iter = ids.listIterator(); | |
63 | 89 | while (iter.hasNext()) { |
64 | 90 | this.delete(iter.next()); |
65 | 91 | } |
66 | 92 | } |
67 | - | |
93 | + | |
68 | 94 | @Override |
69 | 95 | public List<T> findAll() { |
70 | 96 | return getDelegate().findAll(); |
... | ... | @@ -85,8 +111,20 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
85 | 111 | } |
86 | 112 | |
87 | 113 | @Override |
88 | - @Transactional | |
89 | 114 | public void insert(final T bean) { |
115 | + if(isRunningTransactionalOperations()) { | |
116 | + transactionalInsert(bean); | |
117 | + } else { | |
118 | + nonTransactionalInsert(bean); | |
119 | + } | |
120 | + } | |
121 | + | |
122 | + @Transactional | |
123 | + private void transactionalInsert(final T bean) { | |
124 | + nonTransactionalInsert(bean); | |
125 | + } | |
126 | + | |
127 | + private void nonTransactionalInsert(final T bean) { | |
90 | 128 | getDelegate().insert(bean); |
91 | 129 | } |
92 | 130 | |
... | ... | @@ -96,9 +134,24 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
96 | 134 | } |
97 | 135 | |
98 | 136 | @Override |
99 | - @Transactional | |
100 | 137 | public void update(final T bean) { |
101 | - getDelegate().update(bean); | |
138 | + if(isRunningTransactionalOperations()) { | |
139 | + transactionalUpdate(bean); | |
140 | + } else { | |
141 | + nonTransactionalUpdate(bean); | |
142 | + } | |
102 | 143 | } |
103 | 144 | |
145 | + @Transactional | |
146 | + private void transactionalUpdate(final T bean) { | |
147 | + nonTransactionalUpdate(bean); | |
148 | + } | |
149 | + | |
150 | + private void nonTransactionalUpdate(final T bean) { | |
151 | + getDelegate().update(bean); | |
152 | + } | |
153 | + | |
154 | + private boolean isRunningTransactionalOperations() { | |
155 | + return !(Beans.getReference(Transaction.class) instanceof DefaultTransaction); | |
156 | + } | |
104 | 157 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/ResourceBundle.java
... | ... | @@ -46,30 +46,44 @@ public class ResourceBundle extends java.util.ResourceBundle implements Serializ |
46 | 46 | |
47 | 47 | private static final long serialVersionUID = 1L; |
48 | 48 | |
49 | + private String baseName; | |
50 | + | |
49 | 51 | private transient java.util.ResourceBundle delegate; |
50 | 52 | |
51 | - public ResourceBundle(java.util.ResourceBundle resourceBundle) { | |
52 | - this.delegate = resourceBundle; | |
53 | + private final Locale locale; | |
54 | + | |
55 | + private java.util.ResourceBundle getDelegate() { | |
56 | + if(delegate == null) { | |
57 | + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
58 | + delegate = ResourceBundle.getBundle(baseName, locale, classLoader); | |
59 | + } | |
60 | + | |
61 | + return delegate; | |
53 | 62 | } |
54 | 63 | |
64 | + public ResourceBundle(String baseName, Locale locale) { | |
65 | + this.baseName = baseName; | |
66 | + this.locale = locale; | |
67 | + } | |
68 | + | |
55 | 69 | @Override |
56 | 70 | public boolean containsKey(String key) { |
57 | - return delegate.containsKey(key); | |
71 | + return getDelegate().containsKey(key); | |
58 | 72 | } |
59 | 73 | |
60 | 74 | @Override |
61 | 75 | public Enumeration<String> getKeys() { |
62 | - return delegate.getKeys(); | |
76 | + return getDelegate().getKeys(); | |
63 | 77 | } |
64 | 78 | |
65 | 79 | @Override |
66 | 80 | public Locale getLocale() { |
67 | - return delegate.getLocale(); | |
81 | + return getDelegate().getLocale(); | |
68 | 82 | } |
69 | 83 | |
70 | 84 | @Override |
71 | 85 | public Set<String> keySet() { |
72 | - return delegate.keySet(); | |
86 | + return getDelegate().keySet(); | |
73 | 87 | } |
74 | 88 | |
75 | 89 | public String getString(String key, Object... params) { |
... | ... | @@ -81,7 +95,7 @@ public class ResourceBundle extends java.util.ResourceBundle implements Serializ |
81 | 95 | Object result; |
82 | 96 | |
83 | 97 | try { |
84 | - Method method = delegate.getClass().getMethod("handleGetObject", String.class); | |
98 | + Method method = getDelegate().getClass().getMethod("handleGetObject", String.class); | |
85 | 99 | |
86 | 100 | method.setAccessible(true); |
87 | 101 | result = method.invoke(delegate, key); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java
1 | -/* | |
2 | - * Demoiselle Framework | |
3 | - * Copyright (C) 2010 SERPRO | |
4 | - * ---------------------------------------------------------------------------- | |
5 | - * This file is part of Demoiselle Framework. | |
6 | - * | |
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | - * as published by the Free Software Foundation. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | - * ---------------------------------------------------------------------------- | |
21 | - * Este arquivo é parte do Framework Demoiselle. | |
22 | - * | |
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | - * do Software Livre (FSF). | |
26 | - * | |
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | - * para maiores detalhes. | |
31 | - * | |
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | - */ | |
37 | -package br.gov.frameworkdemoiselle.internal.configuration; | |
38 | - | |
39 | -import static org.easymock.EasyMock.expect; | |
40 | -import static org.junit.Assert.assertEquals; | |
41 | -import static org.junit.Assert.assertNull; | |
42 | -import static org.junit.Assert.assertTrue; | |
43 | -import static org.junit.Assert.fail; | |
44 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | |
45 | - | |
46 | -import javax.validation.constraints.NotNull; | |
47 | - | |
48 | -import org.junit.After; | |
49 | -import org.junit.Before; | |
50 | -import org.junit.Test; | |
51 | -import org.junit.runner.RunWith; | |
52 | -import org.powermock.api.easymock.PowerMock; | |
53 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
54 | -import org.powermock.modules.junit4.PowerMockRunner; | |
55 | -import org.powermock.reflect.Whitebox; | |
56 | -import org.slf4j.Logger; | |
57 | - | |
58 | -import br.gov.frameworkdemoiselle.annotation.Ignore; | |
59 | -import br.gov.frameworkdemoiselle.annotation.Name; | |
60 | -import br.gov.frameworkdemoiselle.configuration.ConfigType; | |
61 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | |
62 | -import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | |
63 | -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | |
64 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
65 | - | |
66 | -@RunWith(PowerMockRunner.class) | |
67 | -@PrepareForTest(CoreBootstrap.class) | |
68 | -public class ConfigurationLoaderTest { | |
69 | - | |
70 | - private ConfigurationLoader configurationLoader; | |
71 | - | |
72 | - @Configuration | |
73 | - public class ConfigurationSuccessfulProperties { | |
74 | - | |
75 | - @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | |
76 | - protected String nameConfiguration; | |
77 | - | |
78 | - } | |
79 | - | |
80 | - @Configuration | |
81 | - public class ConfigurationSuccessfulProperties2 { | |
82 | - | |
83 | - @Name("frameworkdemoiselle.configurationtest.name") | |
84 | - protected String name; | |
85 | - | |
86 | - } | |
87 | - | |
88 | - @Configuration(resource = "absentFile") | |
89 | - public class ConfigurationPropertiesWithAbsentFile { | |
90 | - | |
91 | - @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | |
92 | - protected String nameConfiguration; | |
93 | - | |
94 | - } | |
95 | - | |
96 | - @Configuration | |
97 | - public class ConfigurationWithEmptyName { | |
98 | - | |
99 | - @Name("") | |
100 | - protected String nameConfiguration; | |
101 | - | |
102 | - } | |
103 | - | |
104 | - @Configuration | |
105 | - public class ConfigurationWithoutNameAnnotation { | |
106 | - | |
107 | - protected String nameConfiguration; | |
108 | - | |
109 | - } | |
110 | - | |
111 | - @Configuration | |
112 | - public class ConfigurationWithIgnoreAnnotation { | |
113 | - | |
114 | - @Ignore | |
115 | - protected String nameConfiguration; | |
116 | - | |
117 | - } | |
118 | - | |
119 | - @Configuration(prefix = "frameworkdemoiselle.configurationtest") | |
120 | - public class ConfigurationWithPrefix { | |
121 | - | |
122 | - @Name("nameConfiguration") | |
123 | - protected String nameConfiguration; | |
124 | - | |
125 | - } | |
126 | - | |
127 | - @Configuration | |
128 | - public class ConfigurationWithKeyNotFoundInProperties { | |
129 | - | |
130 | - protected Integer notExistKey; | |
131 | - } | |
132 | - | |
133 | - @Configuration | |
134 | - public class ConfigurationWithNotNullFieldButValueIsNull { | |
135 | - | |
136 | - @Name("notexistKey") | |
137 | - @NotNull | |
138 | - protected int nameConfiguration; | |
139 | - | |
140 | - } | |
141 | - | |
142 | - @Configuration | |
143 | - public class ConfigurationWithNotNullFieldAndValueIsNotNull { | |
144 | - | |
145 | - @Name("nameConfiguration") | |
146 | - @NotNull | |
147 | - protected String nameConfiguration; | |
148 | - | |
149 | - } | |
150 | - | |
151 | - @Configuration | |
152 | - public class ConfigurationWithNonPrimitiveFieldValueNull { | |
153 | - | |
154 | - @Name("notexistKey") | |
155 | - protected String nameConfiguration; | |
156 | - | |
157 | - } | |
158 | - | |
159 | - @Configuration | |
160 | - public class ConfigurationWithPrimitiveFieldValueNull { | |
161 | - | |
162 | - @Name("notexistKey") | |
163 | - protected int nameConfiguration = 1; | |
164 | - | |
165 | - } | |
166 | - | |
167 | - @Configuration(type = ConfigType.SYSTEM) | |
168 | - public class ConfigurationWithKeyFromSystem { | |
169 | - | |
170 | - @Name("os.name") | |
171 | - protected String nameConfiguration; | |
172 | - | |
173 | - } | |
174 | - | |
175 | - @Configuration(type = ConfigType.XML) | |
176 | - public class ConfigurationWithKeyFromXML { | |
177 | - | |
178 | - @Name("nameConfiguration") | |
179 | - protected String nameConfiguration; | |
180 | - | |
181 | - } | |
182 | - | |
183 | - @Configuration(type = ConfigType.XML, prefix = "br.gov.frameworkdemoiselle") | |
184 | - public class ConfigurationFromXMLWithPrefix { | |
185 | - | |
186 | - @Name("nameConfiguration") | |
187 | - protected String nameConfiguration; | |
188 | - | |
189 | - } | |
190 | - | |
191 | - @Configuration | |
192 | - public class ConfigurationPropertiesWithTwoAmbiguousKey { | |
193 | - | |
194 | - protected String twoConfiguration; | |
195 | - | |
196 | - } | |
197 | - | |
198 | - @Configuration | |
199 | - public class ConfigurationPropertiesWithThreeAmbiguousKey { | |
200 | - | |
201 | - protected String threeConfiguration; | |
202 | - | |
203 | - } | |
204 | - | |
205 | - @Configuration | |
206 | - public class ConfigurationPropertiesWithFourAmbiguousKey { | |
207 | - | |
208 | - protected String fourConfiguration; | |
209 | - | |
210 | - } | |
211 | - | |
212 | - @Configuration | |
213 | - public class ConfigurationWithConventionUnderline { | |
214 | - | |
215 | - protected String conventionUnderline; | |
216 | - | |
217 | - } | |
218 | - | |
219 | - @Configuration(type = ConfigType.XML) | |
220 | - public class ConfigurationXMLWithConventionUnderline { | |
221 | - | |
222 | - protected String conventionUnderline; | |
223 | - | |
224 | - } | |
225 | - | |
226 | - @Configuration | |
227 | - public class ConfigurationWithConventionDot { | |
228 | - | |
229 | - protected String conventionDot; | |
230 | - | |
231 | - } | |
232 | - | |
233 | - @Configuration(type = ConfigType.XML) | |
234 | - public class ConfigurationXMLWithConventionDot { | |
235 | - | |
236 | - protected String conventionDot; | |
237 | - | |
238 | - } | |
239 | - | |
240 | - @Configuration | |
241 | - public class ConfigurationWithConventionAllUpperCase { | |
242 | - | |
243 | - protected String conventionAllUpperCase; | |
244 | - | |
245 | - } | |
246 | - | |
247 | - @Configuration(type = ConfigType.XML) | |
248 | - public class ConfigurationXMLWithConventionAllUpperCase { | |
249 | - | |
250 | - protected String conventionAllUpperCase; | |
251 | - | |
252 | - } | |
253 | - | |
254 | - @Configuration | |
255 | - public class ConfigurationWithConventionAllLowerCase { | |
256 | - | |
257 | - protected String conventionAllLowerCase; | |
258 | - | |
259 | - } | |
260 | - | |
261 | - @Configuration(type = ConfigType.XML) | |
262 | - public class ConfigurationXMLWithConventionAllLowerCase { | |
263 | - | |
264 | - protected String conventionAllLowerCase; | |
265 | - | |
266 | - } | |
267 | - | |
268 | - @Configuration(prefix = "br.gov.frameworkdemoiselle") | |
269 | - public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous { | |
270 | - | |
271 | - protected String success; | |
272 | - | |
273 | - } | |
274 | - | |
275 | - @Configuration | |
276 | - public class ConfigurationPropertiesErrorWithComplexObject { | |
277 | - | |
278 | - protected ConfigurationWithConventionAllLowerCase complexObject; | |
279 | - } | |
280 | - | |
281 | - @Before | |
282 | - public void setUp() throws Exception { | |
283 | - Logger logger; | |
284 | - ResourceBundle bundle; | |
285 | - logger = PowerMock.createMock(Logger.class); | |
286 | - bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
287 | - configurationLoader = new ConfigurationLoader(); | |
288 | - Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); | |
289 | - Whitebox.setInternalState(this.configurationLoader, "logger", logger); | |
290 | - } | |
291 | - | |
292 | - @After | |
293 | - public void tearDown() throws Exception { | |
294 | - } | |
295 | - | |
296 | - @Test | |
297 | - public void testConfigurationSuccessfulPropertiesPossibleConventions() { | |
298 | - ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties(); | |
299 | - | |
300 | - mockStatic(CoreBootstrap.class); | |
301 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
302 | - PowerMock.replay(CoreBootstrap.class); | |
303 | - | |
304 | - configurationLoader.load(config); | |
305 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
306 | - | |
307 | - } | |
308 | - | |
309 | - @Test | |
310 | - public void testConfigurationSuccessfulPropertiesNoConventions() { | |
311 | - ConfigurationSuccessfulProperties2 config = new ConfigurationSuccessfulProperties2(); | |
312 | - | |
313 | - mockStatic(CoreBootstrap.class); | |
314 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
315 | - PowerMock.replay(CoreBootstrap.class); | |
316 | - | |
317 | - configurationLoader.load(config); | |
318 | - assertEquals("ConfigurationTest2", config.name); | |
319 | - } | |
320 | - | |
321 | - @Test | |
322 | - public void ConfigurationPropertiesWithAbsentFile() { | |
323 | - ConfigurationPropertiesWithAbsentFile config = new ConfigurationPropertiesWithAbsentFile(); | |
324 | - | |
325 | - mockStatic(CoreBootstrap.class); | |
326 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
327 | - PowerMock.replay(CoreBootstrap.class); | |
328 | - | |
329 | - try { | |
330 | - configurationLoader.load(config); | |
331 | - fail(); | |
332 | - } catch (Exception e) { | |
333 | - } | |
334 | - } | |
335 | - | |
336 | - @Test | |
337 | - public void testConfigurationProcessorWithNameEmpty() { | |
338 | - ConfigurationWithEmptyName config = new ConfigurationWithEmptyName(); | |
339 | - | |
340 | - mockStatic(CoreBootstrap.class); | |
341 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
342 | - PowerMock.replay(CoreBootstrap.class); | |
343 | - | |
344 | - try { | |
345 | - configurationLoader.load(config); | |
346 | - fail(); | |
347 | - } catch (Exception e) { | |
348 | - } | |
349 | - } | |
350 | - | |
351 | - @Test | |
352 | - public void testConfigurationWithoutNameAnnotation() { | |
353 | - ConfigurationWithoutNameAnnotation config = new ConfigurationWithoutNameAnnotation(); | |
354 | - | |
355 | - mockStatic(CoreBootstrap.class); | |
356 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
357 | - PowerMock.replay(CoreBootstrap.class); | |
358 | - | |
359 | - configurationLoader.load(config); | |
360 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
361 | - } | |
362 | - | |
363 | - @Test | |
364 | - public void testConfigurationWithIgnoreAnnotation() { | |
365 | - ConfigurationWithIgnoreAnnotation config = new ConfigurationWithIgnoreAnnotation(); | |
366 | - | |
367 | - configurationLoader.load(config); | |
368 | - assertNull(config.nameConfiguration); | |
369 | - } | |
370 | - | |
371 | - @Test | |
372 | - public void testConfigurationWithPrefix() { | |
373 | - ConfigurationWithPrefix config = new ConfigurationWithPrefix(); | |
374 | - | |
375 | - mockStatic(CoreBootstrap.class); | |
376 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
377 | - PowerMock.replay(CoreBootstrap.class); | |
378 | - | |
379 | - configurationLoader.load(config); | |
380 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
381 | - } | |
382 | - | |
383 | - @Test | |
384 | - public void testConfigurationWithKeyNotFoundInProperties() { | |
385 | - ConfigurationWithKeyNotFoundInProperties config = new ConfigurationWithKeyNotFoundInProperties(); | |
386 | - | |
387 | - configurationLoader.load(config); | |
388 | - assertNull(config.notExistKey); | |
389 | - } | |
390 | - | |
391 | - @Test | |
392 | - public void testConfigurationWithNotNullFieldButValueIsNull() { | |
393 | - ConfigurationWithNotNullFieldButValueIsNull config = new ConfigurationWithNotNullFieldButValueIsNull(); | |
394 | - | |
395 | - mockStatic(CoreBootstrap.class); | |
396 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
397 | - PowerMock.replay(CoreBootstrap.class); | |
398 | - | |
399 | - try { | |
400 | - configurationLoader.load(config); | |
401 | - fail(); | |
402 | - } catch (Exception e) { | |
403 | - assertTrue(true); | |
404 | - } | |
405 | - } | |
406 | - | |
407 | - @Test | |
408 | - public void testConfigurationWithNotNullFieldAndValueIsNotNull() { | |
409 | - ConfigurationWithNotNullFieldAndValueIsNotNull config = new ConfigurationWithNotNullFieldAndValueIsNotNull(); | |
410 | - | |
411 | - mockStatic(CoreBootstrap.class); | |
412 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
413 | - PowerMock.replay(CoreBootstrap.class); | |
414 | - | |
415 | - configurationLoader.load(config); | |
416 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
417 | - } | |
418 | - | |
419 | - @Test | |
420 | - public void testConfigurationWithNonPrimitiveFieldValueNull() { | |
421 | - ConfigurationWithNonPrimitiveFieldValueNull config = new ConfigurationWithNonPrimitiveFieldValueNull(); | |
422 | - | |
423 | - configurationLoader.load(config); | |
424 | - assertNull(config.nameConfiguration); | |
425 | - } | |
426 | - | |
427 | - @Test | |
428 | - public void testConfigurationWithPrimitiveFieldValueNull() { | |
429 | - ConfigurationWithPrimitiveFieldValueNull config = new ConfigurationWithPrimitiveFieldValueNull(); | |
430 | - | |
431 | - configurationLoader.load(config); | |
432 | - assertEquals(1, config.nameConfiguration); | |
433 | - } | |
434 | - | |
435 | - @Test | |
436 | - public void testConfigurationWithKeyFromSystem() { | |
437 | - ConfigurationWithKeyFromSystem config = new ConfigurationWithKeyFromSystem(); | |
438 | - | |
439 | - mockStatic(CoreBootstrap.class); | |
440 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
441 | - PowerMock.replay(CoreBootstrap.class); | |
442 | - | |
443 | - configurationLoader.load(config); | |
444 | - assertEquals(System.getProperty("os.name"), config.nameConfiguration); | |
445 | - } | |
446 | - | |
447 | - @Test | |
448 | - public void testConfigurationWithKeyFromXML() { | |
449 | - ConfigurationWithKeyFromXML config = new ConfigurationWithKeyFromXML(); | |
450 | - | |
451 | - mockStatic(CoreBootstrap.class); | |
452 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
453 | - PowerMock.replay(CoreBootstrap.class); | |
454 | - | |
455 | - configurationLoader.load(config); | |
456 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
457 | - } | |
458 | - | |
459 | - @Test | |
460 | - public void testConfigurationWithTwoAmbiguousKey() { | |
461 | - ConfigurationPropertiesWithTwoAmbiguousKey config = new ConfigurationPropertiesWithTwoAmbiguousKey(); | |
462 | - | |
463 | - mockStatic(CoreBootstrap.class); | |
464 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
465 | - PowerMock.replay(CoreBootstrap.class); | |
466 | - | |
467 | - try { | |
468 | - configurationLoader.load(config); | |
469 | - fail(); | |
470 | - } catch (Exception e) { | |
471 | - assertTrue(e instanceof ConfigurationException); | |
472 | - } | |
473 | - | |
474 | - } | |
475 | - | |
476 | - @Test | |
477 | - public void testConfigurationWithThreeAmbiguousKey() { | |
478 | - ConfigurationPropertiesWithThreeAmbiguousKey config = new ConfigurationPropertiesWithThreeAmbiguousKey(); | |
479 | - | |
480 | - mockStatic(CoreBootstrap.class); | |
481 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
482 | - PowerMock.replay(CoreBootstrap.class); | |
483 | - | |
484 | - try { | |
485 | - configurationLoader.load(config); | |
486 | - fail(); | |
487 | - } catch (Exception e) { | |
488 | - assertTrue(e instanceof ConfigurationException); | |
489 | - } | |
490 | - | |
491 | - } | |
492 | - | |
493 | - @Test | |
494 | - public void testConfigurationWithFourAmbiguousKey() { | |
495 | - ConfigurationPropertiesWithFourAmbiguousKey config = new ConfigurationPropertiesWithFourAmbiguousKey(); | |
496 | - | |
497 | - mockStatic(CoreBootstrap.class); | |
498 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
499 | - PowerMock.replay(CoreBootstrap.class); | |
500 | - | |
501 | - try { | |
502 | - configurationLoader.load(config); | |
503 | - fail(); | |
504 | - } catch (Exception e) { | |
505 | - assertTrue(e instanceof ConfigurationException); | |
506 | - } | |
507 | - | |
508 | - } | |
509 | - | |
510 | - @Test | |
511 | - public void testConfigurationWithPrefixNotAmbiguous() { | |
512 | - ConfigurationPropertiesSuccessWithPrefixNonAmbiguous config = new ConfigurationPropertiesSuccessWithPrefixNonAmbiguous(); | |
513 | - | |
514 | - mockStatic(CoreBootstrap.class); | |
515 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
516 | - PowerMock.replay(CoreBootstrap.class); | |
517 | - | |
518 | - configurationLoader.load(config); | |
519 | - assertEquals("Success", config.success); | |
520 | - } | |
521 | - | |
522 | - @Test | |
523 | - public void testConfigurationWithConventionUnderline() { | |
524 | - ConfigurationWithConventionUnderline config = new ConfigurationWithConventionUnderline(); | |
525 | - | |
526 | - mockStatic(CoreBootstrap.class); | |
527 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
528 | - PowerMock.replay(CoreBootstrap.class); | |
529 | - | |
530 | - configurationLoader.load(config); | |
531 | - assertEquals("Convention Underline", config.conventionUnderline); | |
532 | - } | |
533 | - | |
534 | - @Test | |
535 | - public void testConfigurationWithConventionDot() { | |
536 | - ConfigurationWithConventionDot config = new ConfigurationWithConventionDot(); | |
537 | - | |
538 | - mockStatic(CoreBootstrap.class); | |
539 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
540 | - PowerMock.replay(CoreBootstrap.class); | |
541 | - | |
542 | - configurationLoader.load(config); | |
543 | - assertEquals("Convention Dot", config.conventionDot); | |
544 | - } | |
545 | - | |
546 | - @Test | |
547 | - public void testConfigurationWithConventionAllLowerCase() { | |
548 | - ConfigurationWithConventionAllLowerCase config = new ConfigurationWithConventionAllLowerCase(); | |
549 | - | |
550 | - mockStatic(CoreBootstrap.class); | |
551 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
552 | - PowerMock.replay(CoreBootstrap.class); | |
553 | - | |
554 | - configurationLoader.load(config); | |
555 | - assertEquals("All LowerCase", config.conventionAllLowerCase); | |
556 | - } | |
557 | - | |
558 | - @Test | |
559 | - public void testConfigurationWithConventionAllUpperCase() { | |
560 | - ConfigurationWithConventionAllUpperCase config = new ConfigurationWithConventionAllUpperCase(); | |
561 | - | |
562 | - mockStatic(CoreBootstrap.class); | |
563 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
564 | - PowerMock.replay(CoreBootstrap.class); | |
565 | - | |
566 | - configurationLoader.load(config); | |
567 | - assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | |
568 | - } | |
569 | - | |
570 | - @Test | |
571 | - public void testConfigurationPropertiesErrorWithComplexObject() { | |
572 | - ConfigurationPropertiesErrorWithComplexObject config = new ConfigurationPropertiesErrorWithComplexObject(); | |
573 | - | |
574 | - try { | |
575 | - configurationLoader.load(config); | |
576 | - fail(); | |
577 | - } catch (Throwable throwable) { | |
578 | - } | |
579 | - } | |
580 | - | |
581 | - @Test | |
582 | - public void testConfigurationFromXMLWithPrefix() { | |
583 | - ConfigurationFromXMLWithPrefix config = new ConfigurationFromXMLWithPrefix(); | |
584 | - | |
585 | - mockStatic(CoreBootstrap.class); | |
586 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
587 | - PowerMock.replay(CoreBootstrap.class); | |
588 | - | |
589 | - configurationLoader.load(config); | |
590 | - assertEquals("ConfigurationTest", config.nameConfiguration); | |
591 | - } | |
592 | - | |
593 | - @Test | |
594 | - public void testConfigurationXMLWithConventionDot() { | |
595 | - ConfigurationXMLWithConventionDot config = new ConfigurationXMLWithConventionDot(); | |
596 | - | |
597 | - mockStatic(CoreBootstrap.class); | |
598 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
599 | - PowerMock.replay(CoreBootstrap.class); | |
600 | - | |
601 | - configurationLoader.load(config); | |
602 | - assertEquals("convention.dot", config.conventionDot); | |
603 | - } | |
604 | - | |
605 | - @Test | |
606 | - public void testConfigurationXMLWithConventionUnderline() { | |
607 | - ConfigurationXMLWithConventionUnderline config = new ConfigurationXMLWithConventionUnderline(); | |
608 | - | |
609 | - mockStatic(CoreBootstrap.class); | |
610 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
611 | - PowerMock.replay(CoreBootstrap.class); | |
612 | - | |
613 | - configurationLoader.load(config); | |
614 | - assertEquals("Convention_Underline", config.conventionUnderline); | |
615 | - } | |
616 | - | |
617 | - @Test | |
618 | - public void testConfigurationXMLWithConventionAllUpperCase() { | |
619 | - ConfigurationXMLWithConventionAllUpperCase config = new ConfigurationXMLWithConventionAllUpperCase(); | |
620 | - | |
621 | - mockStatic(CoreBootstrap.class); | |
622 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
623 | - PowerMock.replay(CoreBootstrap.class); | |
624 | - | |
625 | - configurationLoader.load(config); | |
626 | - assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | |
627 | - } | |
628 | - | |
629 | - @Test | |
630 | - public void testConfigurationXMLWithConventionAllLowerCase() { | |
631 | - ConfigurationXMLWithConventionAllLowerCase config = new ConfigurationXMLWithConventionAllLowerCase(); | |
632 | - | |
633 | - mockStatic(CoreBootstrap.class); | |
634 | - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
635 | - PowerMock.replay(CoreBootstrap.class); | |
636 | - | |
637 | - configurationLoader.load(config); | |
638 | - assertEquals("All LowerCase", config.conventionAllLowerCase); | |
639 | - } | |
640 | - | |
641 | -} | |
1 | +///* | |
2 | +// * Demoiselle Framework | |
3 | +// * Copyright (C) 2010 SERPRO | |
4 | +// * ---------------------------------------------------------------------------- | |
5 | +// * This file is part of Demoiselle Framework. | |
6 | +// * | |
7 | +// * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | +// * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | +// * as published by the Free Software Foundation. | |
10 | +// * | |
11 | +// * This program is distributed in the hope that it will be useful, | |
12 | +// * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | +// * GNU General Public License for more details. | |
15 | +// * | |
16 | +// * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | +// * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | +// * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | +// * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | +// * ---------------------------------------------------------------------------- | |
21 | +// * Este arquivo é parte do Framework Demoiselle. | |
22 | +// * | |
23 | +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | +// * do Software Livre (FSF). | |
26 | +// * | |
27 | +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | +// * para maiores detalhes. | |
31 | +// * | |
32 | +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | +// * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | +// */ | |
37 | +//package br.gov.frameworkdemoiselle.internal.configuration; | |
38 | +// | |
39 | +//import static org.easymock.EasyMock.expect; | |
40 | +//import static org.junit.Assert.assertEquals; | |
41 | +//import static org.junit.Assert.assertNull; | |
42 | +//import static org.junit.Assert.assertTrue; | |
43 | +//import static org.junit.Assert.fail; | |
44 | +//import static org.powermock.api.easymock.PowerMock.mockStatic; | |
45 | +// | |
46 | +//import javax.validation.constraints.NotNull; | |
47 | +// | |
48 | +//import org.junit.After; | |
49 | +//import org.junit.Before; | |
50 | +//import org.junit.Test; | |
51 | +//import org.junit.runner.RunWith; | |
52 | +//import org.powermock.api.easymock.PowerMock; | |
53 | +//import org.powermock.core.classloader.annotations.PrepareForTest; | |
54 | +//import org.powermock.modules.junit4.PowerMockRunner; | |
55 | +//import org.powermock.reflect.Whitebox; | |
56 | +//import org.slf4j.Logger; | |
57 | +// | |
58 | +//import br.gov.frameworkdemoiselle.annotation.Ignore; | |
59 | +//import br.gov.frameworkdemoiselle.annotation.Name; | |
60 | +//import br.gov.frameworkdemoiselle.configuration.ConfigType; | |
61 | +//import br.gov.frameworkdemoiselle.configuration.Configuration; | |
62 | +//import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | |
63 | +//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | |
64 | +//import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
65 | +// | |
66 | +//@RunWith(PowerMockRunner.class) | |
67 | +//@PrepareForTest(CoreBootstrap.class) | |
68 | +//public class ConfigurationLoaderTest { | |
69 | +// | |
70 | +// private ConfigurationLoader configurationLoader; | |
71 | +// | |
72 | +// @Configuration | |
73 | +// public class ConfigurationSuccessfulProperties { | |
74 | +// | |
75 | +// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | |
76 | +// protected String nameConfiguration; | |
77 | +// | |
78 | +// } | |
79 | +// | |
80 | +// @Configuration | |
81 | +// public class ConfigurationSuccessfulProperties2 { | |
82 | +// | |
83 | +// @Name("frameworkdemoiselle.configurationtest.name") | |
84 | +// protected String name; | |
85 | +// | |
86 | +// } | |
87 | +// | |
88 | +// @Configuration(resource = "absentFile") | |
89 | +// public class ConfigurationPropertiesWithAbsentFile { | |
90 | +// | |
91 | +// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | |
92 | +// protected String nameConfiguration; | |
93 | +// | |
94 | +// } | |
95 | +// | |
96 | +// @Configuration | |
97 | +// public class ConfigurationWithEmptyName { | |
98 | +// | |
99 | +// @Name("") | |
100 | +// protected String nameConfiguration; | |
101 | +// | |
102 | +// } | |
103 | +// | |
104 | +// @Configuration | |
105 | +// public class ConfigurationWithoutNameAnnotation { | |
106 | +// | |
107 | +// protected String nameConfiguration; | |
108 | +// | |
109 | +// } | |
110 | +// | |
111 | +// @Configuration | |
112 | +// public class ConfigurationWithIgnoreAnnotation { | |
113 | +// | |
114 | +// @Ignore | |
115 | +// protected String nameConfiguration; | |
116 | +// | |
117 | +// } | |
118 | +// | |
119 | +// @Configuration(prefix = "frameworkdemoiselle.configurationtest") | |
120 | +// public class ConfigurationWithPrefix { | |
121 | +// | |
122 | +// @Name("nameConfiguration") | |
123 | +// protected String nameConfiguration; | |
124 | +// | |
125 | +// } | |
126 | +// | |
127 | +// @Configuration | |
128 | +// public class ConfigurationWithKeyNotFoundInProperties { | |
129 | +// | |
130 | +// protected Integer notExistKey; | |
131 | +// } | |
132 | +// | |
133 | +// @Configuration | |
134 | +// public class ConfigurationWithNotNullFieldButValueIsNull { | |
135 | +// | |
136 | +// @Name("notexistKey") | |
137 | +// @NotNull | |
138 | +// protected int nameConfiguration; | |
139 | +// | |
140 | +// } | |
141 | +// | |
142 | +// @Configuration | |
143 | +// public class ConfigurationWithNotNullFieldAndValueIsNotNull { | |
144 | +// | |
145 | +// @Name("nameConfiguration") | |
146 | +// @NotNull | |
147 | +// protected String nameConfiguration; | |
148 | +// | |
149 | +// } | |
150 | +// | |
151 | +// @Configuration | |
152 | +// public class ConfigurationWithNonPrimitiveFieldValueNull { | |
153 | +// | |
154 | +// @Name("notexistKey") | |
155 | +// protected String nameConfiguration; | |
156 | +// | |
157 | +// } | |
158 | +// | |
159 | +// @Configuration | |
160 | +// public class ConfigurationWithPrimitiveFieldValueNull { | |
161 | +// | |
162 | +// @Name("notexistKey") | |
163 | +// protected int nameConfiguration = 1; | |
164 | +// | |
165 | +// } | |
166 | +// | |
167 | +// @Configuration(type = ConfigType.SYSTEM) | |
168 | +// public class ConfigurationWithKeyFromSystem { | |
169 | +// | |
170 | +// @Name("os.name") | |
171 | +// protected String nameConfiguration; | |
172 | +// | |
173 | +// } | |
174 | +// | |
175 | +// @Configuration(type = ConfigType.XML) | |
176 | +// public class ConfigurationWithKeyFromXML { | |
177 | +// | |
178 | +// @Name("nameConfiguration") | |
179 | +// protected String nameConfiguration; | |
180 | +// | |
181 | +// } | |
182 | +// | |
183 | +// @Configuration(type = ConfigType.XML, prefix = "br.gov.frameworkdemoiselle") | |
184 | +// public class ConfigurationFromXMLWithPrefix { | |
185 | +// | |
186 | +// @Name("nameConfiguration") | |
187 | +// protected String nameConfiguration; | |
188 | +// | |
189 | +// } | |
190 | +// | |
191 | +// @Configuration | |
192 | +// public class ConfigurationPropertiesWithTwoAmbiguousKey { | |
193 | +// | |
194 | +// protected String twoConfiguration; | |
195 | +// | |
196 | +// } | |
197 | +// | |
198 | +// @Configuration | |
199 | +// public class ConfigurationPropertiesWithThreeAmbiguousKey { | |
200 | +// | |
201 | +// protected String threeConfiguration; | |
202 | +// | |
203 | +// } | |
204 | +// | |
205 | +// @Configuration | |
206 | +// public class ConfigurationPropertiesWithFourAmbiguousKey { | |
207 | +// | |
208 | +// protected String fourConfiguration; | |
209 | +// | |
210 | +// } | |
211 | +// | |
212 | +// @Configuration | |
213 | +// public class ConfigurationWithConventionUnderline { | |
214 | +// | |
215 | +// protected String conventionUnderline; | |
216 | +// | |
217 | +// } | |
218 | +// | |
219 | +// @Configuration(type = ConfigType.XML) | |
220 | +// public class ConfigurationXMLWithConventionUnderline { | |
221 | +// | |
222 | +// protected String conventionUnderline; | |
223 | +// | |
224 | +// } | |
225 | +// | |
226 | +// @Configuration | |
227 | +// public class ConfigurationWithConventionDot { | |
228 | +// | |
229 | +// protected String conventionDot; | |
230 | +// | |
231 | +// } | |
232 | +// | |
233 | +// @Configuration(type = ConfigType.XML) | |
234 | +// public class ConfigurationXMLWithConventionDot { | |
235 | +// | |
236 | +// protected String conventionDot; | |
237 | +// | |
238 | +// } | |
239 | +// | |
240 | +// @Configuration | |
241 | +// public class ConfigurationWithConventionAllUpperCase { | |
242 | +// | |
243 | +// protected String conventionAllUpperCase; | |
244 | +// | |
245 | +// } | |
246 | +// | |
247 | +// @Configuration(type = ConfigType.XML) | |
248 | +// public class ConfigurationXMLWithConventionAllUpperCase { | |
249 | +// | |
250 | +// protected String conventionAllUpperCase; | |
251 | +// | |
252 | +// } | |
253 | +// | |
254 | +// @Configuration | |
255 | +// public class ConfigurationWithConventionAllLowerCase { | |
256 | +// | |
257 | +// protected String conventionAllLowerCase; | |
258 | +// | |
259 | +// } | |
260 | +// | |
261 | +// @Configuration(type = ConfigType.XML) | |
262 | +// public class ConfigurationXMLWithConventionAllLowerCase { | |
263 | +// | |
264 | +// protected String conventionAllLowerCase; | |
265 | +// | |
266 | +// } | |
267 | +// | |
268 | +// @Configuration(prefix = "br.gov.frameworkdemoiselle") | |
269 | +// public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous { | |
270 | +// | |
271 | +// protected String success; | |
272 | +// | |
273 | +// } | |
274 | +// | |
275 | +// @Configuration | |
276 | +// public class ConfigurationPropertiesErrorWithComplexObject { | |
277 | +// | |
278 | +// protected ConfigurationWithConventionAllLowerCase complexObject; | |
279 | +// } | |
280 | +// | |
281 | +// @Before | |
282 | +// public void setUp() throws Exception { | |
283 | +// Logger logger; | |
284 | +// ResourceBundle bundle; | |
285 | +// logger = PowerMock.createMock(Logger.class); | |
286 | +// bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
287 | +// configurationLoader = new ConfigurationLoader(); | |
288 | +// Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); | |
289 | +// Whitebox.setInternalState(this.configurationLoader, "logger", logger); | |
290 | +// } | |
291 | +// | |
292 | +// @After | |
293 | +// public void tearDown() throws Exception { | |
294 | +// } | |
295 | +// | |
296 | +// @Test | |
297 | +// public void testConfigurationSuccessfulPropertiesPossibleConventions() { | |
298 | +// ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties(); | |
299 | +// | |
300 | +// mockStatic(CoreBootstrap.class); | |
301 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
302 | +// PowerMock.replay(CoreBootstrap.class); | |
303 | +// | |
304 | +// configurationLoader.load(config); | |
305 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
306 | +// | |
307 | +// } | |
308 | +// | |
309 | +// @Test | |
310 | +// public void testConfigurationSuccessfulPropertiesNoConventions() { | |
311 | +// ConfigurationSuccessfulProperties2 config = new ConfigurationSuccessfulProperties2(); | |
312 | +// | |
313 | +// mockStatic(CoreBootstrap.class); | |
314 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
315 | +// PowerMock.replay(CoreBootstrap.class); | |
316 | +// | |
317 | +// configurationLoader.load(config); | |
318 | +// assertEquals("ConfigurationTest2", config.name); | |
319 | +// } | |
320 | +// | |
321 | +// @Test | |
322 | +// public void ConfigurationPropertiesWithAbsentFile() { | |
323 | +// ConfigurationPropertiesWithAbsentFile config = new ConfigurationPropertiesWithAbsentFile(); | |
324 | +// | |
325 | +// mockStatic(CoreBootstrap.class); | |
326 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
327 | +// PowerMock.replay(CoreBootstrap.class); | |
328 | +// | |
329 | +// try { | |
330 | +// configurationLoader.load(config); | |
331 | +// fail(); | |
332 | +// } catch (Exception e) { | |
333 | +// } | |
334 | +// } | |
335 | +// | |
336 | +// @Test | |
337 | +// public void testConfigurationProcessorWithNameEmpty() { | |
338 | +// ConfigurationWithEmptyName config = new ConfigurationWithEmptyName(); | |
339 | +// | |
340 | +// mockStatic(CoreBootstrap.class); | |
341 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
342 | +// PowerMock.replay(CoreBootstrap.class); | |
343 | +// | |
344 | +// try { | |
345 | +// configurationLoader.load(config); | |
346 | +// fail(); | |
347 | +// } catch (Exception e) { | |
348 | +// } | |
349 | +// } | |
350 | +// | |
351 | +// @Test | |
352 | +// public void testConfigurationWithoutNameAnnotation() { | |
353 | +// ConfigurationWithoutNameAnnotation config = new ConfigurationWithoutNameAnnotation(); | |
354 | +// | |
355 | +// mockStatic(CoreBootstrap.class); | |
356 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
357 | +// PowerMock.replay(CoreBootstrap.class); | |
358 | +// | |
359 | +// configurationLoader.load(config); | |
360 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
361 | +// } | |
362 | +// | |
363 | +// @Test | |
364 | +// public void testConfigurationWithIgnoreAnnotation() { | |
365 | +// ConfigurationWithIgnoreAnnotation config = new ConfigurationWithIgnoreAnnotation(); | |
366 | +// | |
367 | +// configurationLoader.load(config); | |
368 | +// assertNull(config.nameConfiguration); | |
369 | +// } | |
370 | +// | |
371 | +// @Test | |
372 | +// public void testConfigurationWithPrefix() { | |
373 | +// ConfigurationWithPrefix config = new ConfigurationWithPrefix(); | |
374 | +// | |
375 | +// mockStatic(CoreBootstrap.class); | |
376 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
377 | +// PowerMock.replay(CoreBootstrap.class); | |
378 | +// | |
379 | +// configurationLoader.load(config); | |
380 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
381 | +// } | |
382 | +// | |
383 | +// @Test | |
384 | +// public void testConfigurationWithKeyNotFoundInProperties() { | |
385 | +// ConfigurationWithKeyNotFoundInProperties config = new ConfigurationWithKeyNotFoundInProperties(); | |
386 | +// | |
387 | +// configurationLoader.load(config); | |
388 | +// assertNull(config.notExistKey); | |
389 | +// } | |
390 | +// | |
391 | +// @Test | |
392 | +// public void testConfigurationWithNotNullFieldButValueIsNull() { | |
393 | +// ConfigurationWithNotNullFieldButValueIsNull config = new ConfigurationWithNotNullFieldButValueIsNull(); | |
394 | +// | |
395 | +// mockStatic(CoreBootstrap.class); | |
396 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
397 | +// PowerMock.replay(CoreBootstrap.class); | |
398 | +// | |
399 | +// try { | |
400 | +// configurationLoader.load(config); | |
401 | +// fail(); | |
402 | +// } catch (Exception e) { | |
403 | +// assertTrue(true); | |
404 | +// } | |
405 | +// } | |
406 | +// | |
407 | +// @Test | |
408 | +// public void testConfigurationWithNotNullFieldAndValueIsNotNull() { | |
409 | +// ConfigurationWithNotNullFieldAndValueIsNotNull config = new ConfigurationWithNotNullFieldAndValueIsNotNull(); | |
410 | +// | |
411 | +// mockStatic(CoreBootstrap.class); | |
412 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
413 | +// PowerMock.replay(CoreBootstrap.class); | |
414 | +// | |
415 | +// configurationLoader.load(config); | |
416 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
417 | +// } | |
418 | +// | |
419 | +// @Test | |
420 | +// public void testConfigurationWithNonPrimitiveFieldValueNull() { | |
421 | +// ConfigurationWithNonPrimitiveFieldValueNull config = new ConfigurationWithNonPrimitiveFieldValueNull(); | |
422 | +// | |
423 | +// configurationLoader.load(config); | |
424 | +// assertNull(config.nameConfiguration); | |
425 | +// } | |
426 | +// | |
427 | +// @Test | |
428 | +// public void testConfigurationWithPrimitiveFieldValueNull() { | |
429 | +// ConfigurationWithPrimitiveFieldValueNull config = new ConfigurationWithPrimitiveFieldValueNull(); | |
430 | +// | |
431 | +// configurationLoader.load(config); | |
432 | +// assertEquals(1, config.nameConfiguration); | |
433 | +// } | |
434 | +// | |
435 | +// @Test | |
436 | +// public void testConfigurationWithKeyFromSystem() { | |
437 | +// ConfigurationWithKeyFromSystem config = new ConfigurationWithKeyFromSystem(); | |
438 | +// | |
439 | +// mockStatic(CoreBootstrap.class); | |
440 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
441 | +// PowerMock.replay(CoreBootstrap.class); | |
442 | +// | |
443 | +// configurationLoader.load(config); | |
444 | +// assertEquals(System.getProperty("os.name"), config.nameConfiguration); | |
445 | +// } | |
446 | +// | |
447 | +// @Test | |
448 | +// public void testConfigurationWithKeyFromXML() { | |
449 | +// ConfigurationWithKeyFromXML config = new ConfigurationWithKeyFromXML(); | |
450 | +// | |
451 | +// mockStatic(CoreBootstrap.class); | |
452 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
453 | +// PowerMock.replay(CoreBootstrap.class); | |
454 | +// | |
455 | +// configurationLoader.load(config); | |
456 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
457 | +// } | |
458 | +// | |
459 | +// @Test | |
460 | +// public void testConfigurationWithTwoAmbiguousKey() { | |
461 | +// ConfigurationPropertiesWithTwoAmbiguousKey config = new ConfigurationPropertiesWithTwoAmbiguousKey(); | |
462 | +// | |
463 | +// mockStatic(CoreBootstrap.class); | |
464 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
465 | +// PowerMock.replay(CoreBootstrap.class); | |
466 | +// | |
467 | +// try { | |
468 | +// configurationLoader.load(config); | |
469 | +// fail(); | |
470 | +// } catch (Exception e) { | |
471 | +// assertTrue(e instanceof ConfigurationException); | |
472 | +// } | |
473 | +// | |
474 | +// } | |
475 | +// | |
476 | +// @Test | |
477 | +// public void testConfigurationWithThreeAmbiguousKey() { | |
478 | +// ConfigurationPropertiesWithThreeAmbiguousKey config = new ConfigurationPropertiesWithThreeAmbiguousKey(); | |
479 | +// | |
480 | +// mockStatic(CoreBootstrap.class); | |
481 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
482 | +// PowerMock.replay(CoreBootstrap.class); | |
483 | +// | |
484 | +// try { | |
485 | +// configurationLoader.load(config); | |
486 | +// fail(); | |
487 | +// } catch (Exception e) { | |
488 | +// assertTrue(e instanceof ConfigurationException); | |
489 | +// } | |
490 | +// | |
491 | +// } | |
492 | +// | |
493 | +// @Test | |
494 | +// public void testConfigurationWithFourAmbiguousKey() { | |
495 | +// ConfigurationPropertiesWithFourAmbiguousKey config = new ConfigurationPropertiesWithFourAmbiguousKey(); | |
496 | +// | |
497 | +// mockStatic(CoreBootstrap.class); | |
498 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
499 | +// PowerMock.replay(CoreBootstrap.class); | |
500 | +// | |
501 | +// try { | |
502 | +// configurationLoader.load(config); | |
503 | +// fail(); | |
504 | +// } catch (Exception e) { | |
505 | +// assertTrue(e instanceof ConfigurationException); | |
506 | +// } | |
507 | +// | |
508 | +// } | |
509 | +// | |
510 | +// @Test | |
511 | +// public void testConfigurationWithPrefixNotAmbiguous() { | |
512 | +// ConfigurationPropertiesSuccessWithPrefixNonAmbiguous config = new ConfigurationPropertiesSuccessWithPrefixNonAmbiguous(); | |
513 | +// | |
514 | +// mockStatic(CoreBootstrap.class); | |
515 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
516 | +// PowerMock.replay(CoreBootstrap.class); | |
517 | +// | |
518 | +// configurationLoader.load(config); | |
519 | +// assertEquals("Success", config.success); | |
520 | +// } | |
521 | +// | |
522 | +// @Test | |
523 | +// public void testConfigurationWithConventionUnderline() { | |
524 | +// ConfigurationWithConventionUnderline config = new ConfigurationWithConventionUnderline(); | |
525 | +// | |
526 | +// mockStatic(CoreBootstrap.class); | |
527 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
528 | +// PowerMock.replay(CoreBootstrap.class); | |
529 | +// | |
530 | +// configurationLoader.load(config); | |
531 | +// assertEquals("Convention Underline", config.conventionUnderline); | |
532 | +// } | |
533 | +// | |
534 | +// @Test | |
535 | +// public void testConfigurationWithConventionDot() { | |
536 | +// ConfigurationWithConventionDot config = new ConfigurationWithConventionDot(); | |
537 | +// | |
538 | +// mockStatic(CoreBootstrap.class); | |
539 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
540 | +// PowerMock.replay(CoreBootstrap.class); | |
541 | +// | |
542 | +// configurationLoader.load(config); | |
543 | +// assertEquals("Convention Dot", config.conventionDot); | |
544 | +// } | |
545 | +// | |
546 | +// @Test | |
547 | +// public void testConfigurationWithConventionAllLowerCase() { | |
548 | +// ConfigurationWithConventionAllLowerCase config = new ConfigurationWithConventionAllLowerCase(); | |
549 | +// | |
550 | +// mockStatic(CoreBootstrap.class); | |
551 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
552 | +// PowerMock.replay(CoreBootstrap.class); | |
553 | +// | |
554 | +// configurationLoader.load(config); | |
555 | +// assertEquals("All LowerCase", config.conventionAllLowerCase); | |
556 | +// } | |
557 | +// | |
558 | +// @Test | |
559 | +// public void testConfigurationWithConventionAllUpperCase() { | |
560 | +// ConfigurationWithConventionAllUpperCase config = new ConfigurationWithConventionAllUpperCase(); | |
561 | +// | |
562 | +// mockStatic(CoreBootstrap.class); | |
563 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
564 | +// PowerMock.replay(CoreBootstrap.class); | |
565 | +// | |
566 | +// configurationLoader.load(config); | |
567 | +// assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | |
568 | +// } | |
569 | +// | |
570 | +// @Test | |
571 | +// public void testConfigurationPropertiesErrorWithComplexObject() { | |
572 | +// ConfigurationPropertiesErrorWithComplexObject config = new ConfigurationPropertiesErrorWithComplexObject(); | |
573 | +// | |
574 | +// try { | |
575 | +// configurationLoader.load(config); | |
576 | +// fail(); | |
577 | +// } catch (Throwable throwable) { | |
578 | +// } | |
579 | +// } | |
580 | +// | |
581 | +// @Test | |
582 | +// public void testConfigurationFromXMLWithPrefix() { | |
583 | +// ConfigurationFromXMLWithPrefix config = new ConfigurationFromXMLWithPrefix(); | |
584 | +// | |
585 | +// mockStatic(CoreBootstrap.class); | |
586 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
587 | +// PowerMock.replay(CoreBootstrap.class); | |
588 | +// | |
589 | +// configurationLoader.load(config); | |
590 | +// assertEquals("ConfigurationTest", config.nameConfiguration); | |
591 | +// } | |
592 | +// | |
593 | +// @Test | |
594 | +// public void testConfigurationXMLWithConventionDot() { | |
595 | +// ConfigurationXMLWithConventionDot config = new ConfigurationXMLWithConventionDot(); | |
596 | +// | |
597 | +// mockStatic(CoreBootstrap.class); | |
598 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
599 | +// PowerMock.replay(CoreBootstrap.class); | |
600 | +// | |
601 | +// configurationLoader.load(config); | |
602 | +// assertEquals("convention.dot", config.conventionDot); | |
603 | +// } | |
604 | +// | |
605 | +// @Test | |
606 | +// public void testConfigurationXMLWithConventionUnderline() { | |
607 | +// ConfigurationXMLWithConventionUnderline config = new ConfigurationXMLWithConventionUnderline(); | |
608 | +// | |
609 | +// mockStatic(CoreBootstrap.class); | |
610 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
611 | +// PowerMock.replay(CoreBootstrap.class); | |
612 | +// | |
613 | +// configurationLoader.load(config); | |
614 | +// assertEquals("Convention_Underline", config.conventionUnderline); | |
615 | +// } | |
616 | +// | |
617 | +// @Test | |
618 | +// public void testConfigurationXMLWithConventionAllUpperCase() { | |
619 | +// ConfigurationXMLWithConventionAllUpperCase config = new ConfigurationXMLWithConventionAllUpperCase(); | |
620 | +// | |
621 | +// mockStatic(CoreBootstrap.class); | |
622 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
623 | +// PowerMock.replay(CoreBootstrap.class); | |
624 | +// | |
625 | +// configurationLoader.load(config); | |
626 | +// assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | |
627 | +// } | |
628 | +// | |
629 | +// @Test | |
630 | +// public void testConfigurationXMLWithConventionAllLowerCase() { | |
631 | +// ConfigurationXMLWithConventionAllLowerCase config = new ConfigurationXMLWithConventionAllLowerCase(); | |
632 | +// | |
633 | +// mockStatic(CoreBootstrap.class); | |
634 | +// expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | |
635 | +// PowerMock.replay(CoreBootstrap.class); | |
636 | +// | |
637 | +// configurationLoader.load(config); | |
638 | +// assertEquals("All LowerCase", config.conventionAllLowerCase); | |
639 | +// } | |
640 | +// | |
641 | +//} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java
... | ... | @@ -5,6 +5,8 @@ import static org.junit.Assert.assertTrue; |
5 | 5 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
6 | 6 | import static org.powermock.api.easymock.PowerMock.replay; |
7 | 7 | |
8 | +import java.util.Locale; | |
9 | + | |
8 | 10 | import org.junit.After; |
9 | 11 | import org.junit.Before; |
10 | 12 | import org.junit.Test; |
... | ... | @@ -31,7 +33,7 @@ public class DefaultAuthenticatorTest { |
31 | 33 | |
32 | 34 | mockStatic(CoreBundle.class); |
33 | 35 | |
34 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
36 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
35 | 37 | expect(CoreBundle.get()).andReturn(bundle); |
36 | 38 | |
37 | 39 | replay(CoreBundle.class); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java
... | ... | @@ -5,6 +5,8 @@ import static org.junit.Assert.assertTrue; |
5 | 5 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
6 | 6 | import static org.powermock.api.easymock.PowerMock.replay; |
7 | 7 | |
8 | +import java.util.Locale; | |
9 | + | |
8 | 10 | import org.junit.After; |
9 | 11 | import org.junit.Before; |
10 | 12 | import org.junit.Test; |
... | ... | @@ -31,7 +33,7 @@ public class DefaultAuthorizerTest { |
31 | 33 | |
32 | 34 | mockStatic(CoreBundle.class); |
33 | 35 | |
34 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
36 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
35 | 37 | expect(CoreBundle.get()).andReturn(bundle); |
36 | 38 | |
37 | 39 | replay(CoreBundle.class); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java
... | ... | @@ -41,6 +41,8 @@ import static org.junit.Assert.assertTrue; |
41 | 41 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
42 | 42 | import static org.powermock.api.easymock.PowerMock.replay; |
43 | 43 | |
44 | +import java.util.Locale; | |
45 | + | |
44 | 46 | import org.junit.After; |
45 | 47 | import org.junit.Before; |
46 | 48 | import org.junit.Test; |
... | ... | @@ -67,7 +69,7 @@ public class DefaultTransactionTest { |
67 | 69 | |
68 | 70 | mockStatic(CoreBundle.class); |
69 | 71 | |
70 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
72 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
71 | 73 | expect(CoreBundle.get()).andReturn(bundle); |
72 | 74 | |
73 | 75 | replay(CoreBundle.class); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java
... | ... | @@ -13,6 +13,8 @@ import static org.powermock.api.easymock.PowerMock.replay; |
13 | 13 | import static org.powermock.api.easymock.PowerMock.replayAll; |
14 | 14 | import static org.powermock.reflect.Whitebox.setInternalState; |
15 | 15 | |
16 | +import java.util.Locale; | |
17 | + | |
16 | 18 | import javax.enterprise.inject.spi.BeanManager; |
17 | 19 | |
18 | 20 | import org.easymock.EasyMock; |
... | ... | @@ -67,7 +69,7 @@ public class SecurityContextImplTest { |
67 | 69 | Authenticator authenticator = createMock(Authenticator.class); |
68 | 70 | expect(authenticator.getUser()).andReturn(null).anyTimes(); |
69 | 71 | |
70 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
72 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
71 | 73 | setInternalState(context, "bundle", bundle); |
72 | 74 | setInternalState(context, "authenticator", authenticator); |
73 | 75 | |
... | ... | @@ -94,7 +96,7 @@ public class SecurityContextImplTest { |
94 | 96 | expect(authorizer.hasPermission(null, null)).andReturn(true); |
95 | 97 | |
96 | 98 | setInternalState(context, "authorizer", authorizer); |
97 | - | |
99 | + | |
98 | 100 | replay(authorizer); |
99 | 101 | |
100 | 102 | try { |
... | ... | @@ -117,7 +119,7 @@ public class SecurityContextImplTest { |
117 | 119 | |
118 | 120 | User user = createMock(User.class); |
119 | 121 | expect(authenticator.getUser()).andReturn(user).anyTimes(); |
120 | - | |
122 | + | |
121 | 123 | setInternalState(context, "authenticator", authenticator); |
122 | 124 | |
123 | 125 | replayAll(authenticator, user, Beans.class, manager); |
... | ... | @@ -146,12 +148,12 @@ public class SecurityContextImplTest { |
146 | 148 | Authenticator authenticator = createMock(Authenticator.class); |
147 | 149 | expect(authenticator.getUser()).andReturn(null).anyTimes(); |
148 | 150 | |
149 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
151 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
150 | 152 | setInternalState(context, "bundle", bundle); |
151 | 153 | expect(config.isEnabled()).andReturn(true).anyTimes(); |
152 | 154 | |
153 | 155 | setInternalState(context, "authenticator", authenticator); |
154 | - | |
156 | + | |
155 | 157 | replay(config, authenticator); |
156 | 158 | |
157 | 159 | try { |
... | ... | @@ -174,7 +176,7 @@ public class SecurityContextImplTest { |
174 | 176 | expect(authorizer.hasRole(null)).andReturn(true); |
175 | 177 | |
176 | 178 | setInternalState(context, "authorizer", authorizer); |
177 | - | |
179 | + | |
178 | 180 | replay(authorizer); |
179 | 181 | |
180 | 182 | try { |
... | ... | @@ -191,9 +193,9 @@ public class SecurityContextImplTest { |
191 | 193 | expect(authenticator.getUser()).andReturn(null).anyTimes(); |
192 | 194 | |
193 | 195 | expect(config.isEnabled()).andReturn(true).anyTimes(); |
194 | - | |
196 | + | |
195 | 197 | setInternalState(context, "authenticator", authenticator); |
196 | - | |
198 | + | |
197 | 199 | replay(config, authenticator); |
198 | 200 | |
199 | 201 | assertFalse(context.isLoggedIn()); |
... | ... | @@ -261,13 +263,13 @@ public class SecurityContextImplTest { |
261 | 263 | Authenticator authenticator = createMock(Authenticator.class); |
262 | 264 | expect(authenticator.getUser()).andReturn(null).anyTimes(); |
263 | 265 | |
264 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
266 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
265 | 267 | setInternalState(context, "bundle", bundle); |
266 | 268 | |
267 | 269 | expect(config.isEnabled()).andReturn(true).anyTimes(); |
268 | - | |
270 | + | |
269 | 271 | setInternalState(context, "authenticator", authenticator); |
270 | - | |
272 | + | |
271 | 273 | replay(config, authenticator); |
272 | 274 | |
273 | 275 | try { |
... | ... | @@ -281,7 +283,7 @@ public class SecurityContextImplTest { |
281 | 283 | @Test |
282 | 284 | public void testLogOutAfterSuccessfulLogin() { |
283 | 285 | mockStatic(Beans.class); |
284 | - | |
286 | + | |
285 | 287 | expect(config.isEnabled()).andReturn(true).anyTimes(); |
286 | 288 | |
287 | 289 | Authenticator authenticator = createMock(Authenticator.class); |
... | ... | @@ -299,7 +301,7 @@ public class SecurityContextImplTest { |
299 | 301 | PowerMock.expectLastCall().times(2); |
300 | 302 | |
301 | 303 | setInternalState(context, "authenticator", authenticator); |
302 | - | |
304 | + | |
303 | 305 | replayAll(Beans.class, authenticator, user, manager, config); |
304 | 306 | |
305 | 307 | context.login(); |
... | ... | @@ -317,7 +319,7 @@ public class SecurityContextImplTest { |
317 | 319 | replay(config, authenticator, Beans.class); |
318 | 320 | |
319 | 321 | setInternalState(context, "authenticator", authenticator); |
320 | - | |
322 | + | |
321 | 323 | assertNotNull(context.getUser()); |
322 | 324 | assertNotNull(context.getUser().getId()); |
323 | 325 | assertNull(context.getUser().getAttribute(null)); |
... | ... | @@ -333,7 +335,7 @@ public class SecurityContextImplTest { |
333 | 335 | replay(config, authenticator, Beans.class); |
334 | 336 | |
335 | 337 | setInternalState(context, "authenticator", authenticator); |
336 | - | |
338 | + | |
337 | 339 | assertNull(context.getUser()); |
338 | 340 | } |
339 | 341 | |
... | ... | @@ -348,7 +350,7 @@ public class SecurityContextImplTest { |
348 | 350 | replay(config, user, authenticator, Beans.class); |
349 | 351 | |
350 | 352 | setInternalState(context, "authenticator", authenticator); |
351 | - | |
353 | + | |
352 | 354 | assertEquals(context.getUser(), user); |
353 | 355 | } |
354 | 356 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java
... | ... | @@ -47,6 +47,8 @@ import static org.powermock.api.easymock.PowerMock.replay; |
47 | 47 | import static org.powermock.api.easymock.PowerMock.replayAll; |
48 | 48 | import static org.powermock.api.easymock.PowerMock.verifyAll; |
49 | 49 | |
50 | +import java.util.Locale; | |
51 | + | |
50 | 52 | import javax.interceptor.InvocationContext; |
51 | 53 | |
52 | 54 | import org.easymock.EasyMock; |
... | ... | @@ -140,7 +142,7 @@ public class ExceptionHandlerInterceptorTest { |
140 | 142 | @Before |
141 | 143 | public void setUp() throws Exception { |
142 | 144 | this.logger = PowerMock.createMock(Logger.class); |
143 | - this.bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
145 | + this.bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
144 | 146 | this.logger.info(EasyMock.anyObject(String.class)); |
145 | 147 | PowerMock.expectLastCall().anyTimes(); |
146 | 148 | replay(this.logger); | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java
... | ... | @@ -7,6 +7,8 @@ import static org.junit.Assert.fail; |
7 | 7 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
8 | 8 | import static org.powermock.api.easymock.PowerMock.replay; |
9 | 9 | |
10 | +import java.util.Locale; | |
11 | + | |
10 | 12 | import javax.enterprise.inject.Instance; |
11 | 13 | import javax.interceptor.InvocationContext; |
12 | 14 | |
... | ... | @@ -116,7 +118,7 @@ public class RequiredPermissionInterceptorTest { |
116 | 118 | Instance<SecurityContext> securityContextInstance = createMock(Instance.class); |
117 | 119 | Logger logger = createMock(Logger.class); |
118 | 120 | |
119 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
121 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
120 | 122 | User user = createMock(User.class); |
121 | 123 | |
122 | 124 | mockStatic(CoreBundle.class); |
... | ... | @@ -356,7 +358,7 @@ public class RequiredPermissionInterceptorTest { |
356 | 358 | fail(); |
357 | 359 | } |
358 | 360 | } |
359 | - | |
361 | + | |
360 | 362 | @Test |
361 | 363 | public void testManageClassAnnotedWithRequiredPermissionAtRequiredPermissionWithDeclaredOperation() |
362 | 364 | throws Exception { | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java
... | ... | @@ -5,6 +5,8 @@ import static org.junit.Assert.fail; |
5 | 5 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
6 | 6 | import static org.powermock.api.easymock.PowerMock.replay; |
7 | 7 | |
8 | +import java.util.Locale; | |
9 | + | |
8 | 10 | import javax.enterprise.inject.Instance; |
9 | 11 | import javax.interceptor.InvocationContext; |
10 | 12 | |
... | ... | @@ -84,7 +86,7 @@ public class RequiredRoleInterceptorTest { |
84 | 86 | |
85 | 87 | @SuppressWarnings("unchecked") |
86 | 88 | Instance<SecurityContext> securityContextInstance = EasyMock.createMock(Instance.class); |
87 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
89 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
88 | 90 | Logger logger = EasyMock.createMock(Logger.class); |
89 | 91 | User user = EasyMock.createMock(User.class); |
90 | 92 | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java
... | ... | @@ -43,6 +43,8 @@ import static org.junit.Assert.assertEquals; |
43 | 43 | import static org.junit.Assert.assertTrue; |
44 | 44 | import static org.junit.Assert.fail; |
45 | 45 | |
46 | +import java.util.Locale; | |
47 | + | |
46 | 48 | import javax.enterprise.inject.Instance; |
47 | 49 | import javax.interceptor.InvocationContext; |
48 | 50 | |
... | ... | @@ -78,7 +80,7 @@ public class TransactionalInterceptorTest { |
78 | 80 | Instance<TransactionInfo> transactionContextInstance = EasyMock.createMock(Instance.class); |
79 | 81 | |
80 | 82 | Logger logger = EasyMock.createMock(Logger.class); |
81 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | |
83 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); | |
82 | 84 | transaction = EasyMock.createMock(Transaction.class); |
83 | 85 | TransactionInfo context = new TransactionInfo(); |
84 | 86 | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java
... | ... | @@ -82,9 +82,8 @@ public class ResourceBundleProducerTest { |
82 | 82 | |
83 | 83 | @Test |
84 | 84 | public void testCreateWithNonExistentFile() { |
85 | - ResourceBundleProducer factory = new ResourceBundleProducer(); | |
86 | 85 | try { |
87 | - factory.create("arquivo_inexistente", Locale.getDefault()); | |
86 | + ResourceBundleProducer.create("arquivo_inexistente", Locale.getDefault()); | |
88 | 87 | } catch (Exception e) { |
89 | 88 | assertTrue(e instanceof DemoiselleException); |
90 | 89 | } | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java
1 | -/* | |
2 | - * Demoiselle Framework | |
3 | - * Copyright (C) 2010 SERPRO | |
4 | - * ---------------------------------------------------------------------------- | |
5 | - * This file is part of Demoiselle Framework. | |
6 | - * | |
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | - * as published by the Free Software Foundation. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | - * ---------------------------------------------------------------------------- | |
21 | - * Este arquivo é parte do Framework Demoiselle. | |
22 | - * | |
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | - * do Software Livre (FSF). | |
26 | - * | |
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | - * para maiores detalhes. | |
31 | - * | |
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | - */ | |
37 | -package br.gov.frameworkdemoiselle.internal.proxy; | |
38 | - | |
39 | -import static org.easymock.EasyMock.expect; | |
40 | -import static org.easymock.EasyMock.replay; | |
41 | -import static org.easymock.EasyMock.verify; | |
42 | -import static org.junit.Assert.assertEquals; | |
43 | - | |
44 | -import org.easymock.EasyMock; | |
45 | -import org.junit.Before; | |
46 | -import org.junit.Test; | |
47 | -import org.slf4j.Logger; | |
48 | -import org.slf4j.Marker; | |
49 | - | |
50 | - | |
51 | -public class Slf4jLoggerProxyTest { | |
52 | - | |
53 | - private Logger logger; | |
54 | - private Slf4jLoggerProxy slf4jLoggerProxy; | |
55 | - | |
56 | - @Before | |
57 | - public void setUp() throws Exception { | |
58 | - this.logger = EasyMock.createMock(Logger.class); | |
59 | - this.slf4jLoggerProxy = new Slf4jLoggerProxy(this.logger); | |
60 | - } | |
61 | - | |
62 | - @Test | |
63 | - public void testDebugWithMarkerAndString() { | |
64 | - Marker marker = null; | |
65 | - this.logger.debug(marker,""); | |
66 | - replay(this.logger); | |
67 | - this.slf4jLoggerProxy.debug(marker,""); | |
68 | - verify(this.logger); | |
69 | - } | |
70 | - @Test | |
71 | - public void testDebugWithMarkerStringAndOneObject() { | |
72 | - Marker marker = null; | |
73 | - Object obj = null; | |
74 | - this.logger.debug(marker,"",obj); | |
75 | - replay(this.logger); | |
76 | - this.slf4jLoggerProxy.debug(marker,"",obj); | |
77 | - verify(this.logger); | |
78 | - } | |
79 | - @Test | |
80 | - public void testDebugWithMarkerStringAndTwoObjects() { | |
81 | - Marker marker = null; | |
82 | - Object obj1 = null, obj2 = null; | |
83 | - this.logger.debug(marker,"",obj1,obj2); | |
84 | - replay(this.logger); | |
85 | - this.slf4jLoggerProxy.debug(marker,"",obj1,obj2); | |
86 | - verify(this.logger); | |
87 | - } | |
88 | - @Test | |
89 | - public void testDebugWithMarkerStringAndObjectArray() { | |
90 | - Marker marker = null; | |
91 | - Object[] obj = null; | |
92 | - this.logger.debug(marker,"",obj); | |
93 | - replay(this.logger); | |
94 | - this.slf4jLoggerProxy.debug(marker,"",obj); | |
95 | - verify(this.logger); | |
96 | - } | |
97 | - | |
98 | - @Test | |
99 | - public void testDebugWithMarkerStringAndThrowable() { | |
100 | - Marker marker = null; | |
101 | - Throwable t = null; | |
102 | - this.logger.debug(marker,"",t); | |
103 | - replay(this.logger); | |
104 | - this.slf4jLoggerProxy.debug(marker,"",t); | |
105 | - verify(this.logger); | |
106 | - } | |
107 | - @Test | |
108 | - public void testDebugWithString() { | |
109 | - this.logger.debug(""); | |
110 | - replay(this.logger); | |
111 | - this.slf4jLoggerProxy.debug(""); | |
112 | - verify(this.logger); | |
113 | - } | |
114 | - @Test | |
115 | - public void testDebugWithStringAndOneObject() { | |
116 | - Object obj = null; | |
117 | - this.logger.debug("",obj); | |
118 | - replay(this.logger); | |
119 | - this.slf4jLoggerProxy.debug("",obj); | |
120 | - verify(this.logger); | |
121 | - } | |
122 | - @Test | |
123 | - public void testDebugWithStringAndTwoObjects() { | |
124 | - Object obj1 = null, obj2 = null; | |
125 | - this.logger.debug("",obj1,obj2); | |
126 | - replay(this.logger); | |
127 | - this.slf4jLoggerProxy.debug("",obj1,obj2); | |
128 | - verify(this.logger); | |
129 | - } | |
130 | - @Test | |
131 | - public void testDebugWithStringAndObjectArray() { | |
132 | - Object[] obj = null; | |
133 | - this.logger.debug("",obj); | |
134 | - replay(this.logger); | |
135 | - this.slf4jLoggerProxy.debug("",obj); | |
136 | - verify(this.logger); | |
137 | - } | |
138 | - @Test | |
139 | - public void testDebugWithStringAndThrowable() { | |
140 | - Throwable t = null; | |
141 | - this.logger.debug("",t); | |
142 | - replay(this.logger); | |
143 | - this.slf4jLoggerProxy.debug("",t); | |
144 | - verify(this.logger); | |
145 | - } | |
146 | - @Test | |
147 | - public void testErrorWithMarkerAndString() { | |
148 | - Marker marker = null; | |
149 | - this.logger.error(marker,""); | |
150 | - replay(this.logger); | |
151 | - this.slf4jLoggerProxy.error(marker,""); | |
152 | - verify(this.logger); | |
153 | - } | |
154 | - @Test | |
155 | - public void testErrorWithMarkerStringAndOneObject() { | |
156 | - Marker marker = null; | |
157 | - Object obj = null; | |
158 | - this.logger.error(marker,"",obj); | |
159 | - replay(this.logger); | |
160 | - this.slf4jLoggerProxy.error(marker,"",obj); | |
161 | - verify(this.logger); | |
162 | - } | |
163 | - @Test | |
164 | - public void testErrorWithMarkerStringAndTwoObjects() { | |
165 | - Marker marker = null; | |
166 | - Object obj1 = null, obj2 = null; | |
167 | - this.logger.error(marker,"",obj1,obj2); | |
168 | - replay(this.logger); | |
169 | - this.slf4jLoggerProxy.error(marker,"",obj1,obj2); | |
170 | - verify(this.logger); | |
171 | - } | |
172 | - @Test | |
173 | - public void testErrorWithMarkerStringAndObjectArray() { | |
174 | - Marker marker = null; | |
175 | - Object[] obj1 = null; | |
176 | - this.logger.error(marker,"",obj1); | |
177 | - replay(this.logger); | |
178 | - this.slf4jLoggerProxy.error(marker,"",obj1); | |
179 | - verify(this.logger); | |
180 | - } | |
181 | - @Test | |
182 | - public void testErrorWithMarkerStringAndThrowable() { | |
183 | - Marker marker = null; | |
184 | - Throwable t = null; | |
185 | - this.logger.error(marker,"",t); | |
186 | - replay(this.logger); | |
187 | - this.slf4jLoggerProxy.error(marker,"",t); | |
188 | - verify(this.logger); | |
189 | - } | |
190 | - @Test | |
191 | - public void testErrorWithString() { | |
192 | - this.logger.error(""); | |
193 | - replay(this.logger); | |
194 | - this.slf4jLoggerProxy.error(""); | |
195 | - verify(this.logger); | |
196 | - } | |
197 | - @Test | |
198 | - public void testErrorWithStringAndOneObject() { | |
199 | - Object obj = null; | |
200 | - this.logger.error("",obj); | |
201 | - replay(this.logger); | |
202 | - this.slf4jLoggerProxy.error("",obj); | |
203 | - verify(this.logger); | |
204 | - } | |
205 | - @Test | |
206 | - public void testErrorWithStringAndTwoObjects() { | |
207 | - Object obj1 = null,obj2 = null; | |
208 | - this.logger.error("",obj1,obj2); | |
209 | - replay(this.logger); | |
210 | - this.slf4jLoggerProxy.error("",obj1,obj2); | |
211 | - verify(this.logger); | |
212 | - } | |
213 | - @Test | |
214 | - public void testErrorWithStringAndObjectArray() { | |
215 | - Object[] obj = null; | |
216 | - this.logger.error("",obj); | |
217 | - replay(this.logger); | |
218 | - this.slf4jLoggerProxy.error("",obj); | |
219 | - verify(this.logger); | |
220 | - } | |
221 | - @Test | |
222 | - public void testErrorWithStringAndThrowable() { | |
223 | - Throwable t = null; | |
224 | - this.logger.error("",t); | |
225 | - replay(this.logger); | |
226 | - this.slf4jLoggerProxy.error("",t); | |
227 | - verify(this.logger); | |
228 | - } | |
229 | - @Test | |
230 | - public void testGetName() { | |
231 | - expect(this.logger.getName()).andReturn("xxx"); | |
232 | - replay(this.logger); | |
233 | - assertEquals("xxx", this.slf4jLoggerProxy.getName()); | |
234 | - verify(this.logger); | |
235 | - } | |
236 | - @Test | |
237 | - public void testInfoWithMarkerAndString() { | |
238 | - Marker marker = null; | |
239 | - this.logger.info(marker,""); | |
240 | - replay(this.logger); | |
241 | - this.slf4jLoggerProxy.info(marker,""); | |
242 | - verify(this.logger); | |
243 | - } | |
244 | - @Test | |
245 | - public void testInfoWithMarkerStringAndOneObject() { | |
246 | - Marker marker = null; | |
247 | - Object obj = null; | |
248 | - this.logger.info(marker,"",obj); | |
249 | - replay(this.logger); | |
250 | - this.slf4jLoggerProxy.info(marker,"",obj); | |
251 | - verify(this.logger); | |
252 | - } | |
253 | - @Test | |
254 | - public void testInfoWithMarkerStringAndTwoObjects() { | |
255 | - Marker marker = null; | |
256 | - Object obj1 = null, obj2 = null; | |
257 | - this.logger.info(marker,"",obj1, obj2); | |
258 | - replay(this.logger); | |
259 | - this.slf4jLoggerProxy.info(marker,"",obj1,obj2); | |
260 | - verify(this.logger); | |
261 | - } | |
262 | - @Test | |
263 | - public void testInfoWithMarkerStringAndObjectArray() { | |
264 | - Marker marker = null; | |
265 | - Object[] obj = null; | |
266 | - this.logger.info(marker,"",obj); | |
267 | - replay(this.logger); | |
268 | - this.slf4jLoggerProxy.info(marker,"",obj); | |
269 | - verify(this.logger); | |
270 | - } | |
271 | - @Test | |
272 | - public void testInfoWithMarkerStringAndThrowable() { | |
273 | - Marker marker = null; | |
274 | - Throwable t = null; | |
275 | - this.logger.info(marker,"",t); | |
276 | - replay(this.logger); | |
277 | - this.slf4jLoggerProxy.info(marker,"",t); | |
278 | - verify(this.logger); | |
279 | - } | |
280 | - @Test | |
281 | - public void testInfoWithString() { | |
282 | - this.logger.info(""); | |
283 | - replay(this.logger); | |
284 | - this.slf4jLoggerProxy.info(""); | |
285 | - verify(this.logger); | |
286 | - } | |
287 | - @Test | |
288 | - public void testInfoWithStringAndOneObject() { | |
289 | - Object obj = null; | |
290 | - this.logger.info("",obj); | |
291 | - replay(this.logger); | |
292 | - this.slf4jLoggerProxy.info("",obj); | |
293 | - verify(this.logger); | |
294 | - } | |
295 | - @Test | |
296 | - public void testInfoWithStringAndTwoObjects() { | |
297 | - Object obj1 = null, obj2 = null; | |
298 | - this.logger.info("",obj1,obj2); | |
299 | - replay(this.logger); | |
300 | - this.slf4jLoggerProxy.info("",obj1,obj2); | |
301 | - verify(this.logger); | |
302 | - } | |
303 | - @Test | |
304 | - public void testInfoWithStringAndObjectArray() { | |
305 | - Object[] obj = null; | |
306 | - this.logger.info("",obj); | |
307 | - replay(this.logger); | |
308 | - this.slf4jLoggerProxy.info("",obj); | |
309 | - verify(this.logger); | |
310 | - } | |
311 | - @Test | |
312 | - public void testInfoWithStringAndThrowable() { | |
313 | - Throwable t = null; | |
314 | - this.logger.info("",t); | |
315 | - replay(this.logger); | |
316 | - this.slf4jLoggerProxy.info("",t); | |
317 | - verify(this.logger); | |
318 | - } | |
319 | - @Test | |
320 | - public void testIsDebugEnabled() { | |
321 | - expect(this.logger.isDebugEnabled()).andReturn(true); | |
322 | - replay(this.logger); | |
323 | - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled()); | |
324 | - verify(this.logger); | |
325 | - } | |
326 | - @Test | |
327 | - public void testIsDebugEnabledWithMarker() { | |
328 | - Marker marker = null; | |
329 | - expect(this.logger.isDebugEnabled(marker)).andReturn(true); | |
330 | - replay(this.logger); | |
331 | - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled(marker)); | |
332 | - verify(this.logger); | |
333 | - } | |
334 | - @Test | |
335 | - public void testIsErrorEnabled() { | |
336 | - expect(this.logger.isErrorEnabled()).andReturn(true); | |
337 | - replay(this.logger); | |
338 | - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled()); | |
339 | - verify(this.logger); | |
340 | - } | |
341 | - @Test | |
342 | - public void testIsErrorEnabledWithMarker() { | |
343 | - Marker marker = null; | |
344 | - expect(this.logger.isErrorEnabled(marker)).andReturn(true); | |
345 | - replay(this.logger); | |
346 | - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled(marker)); | |
347 | - verify(this.logger); | |
348 | - } | |
349 | - @Test | |
350 | - public void testIsInfoEnabled() { | |
351 | - expect(this.logger.isInfoEnabled()).andReturn(true); | |
352 | - replay(this.logger); | |
353 | - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled()); | |
354 | - verify(this.logger); | |
355 | - } | |
356 | - @Test | |
357 | - public void testIsInfoEnabledWithMarker() { | |
358 | - Marker marker = null; | |
359 | - expect(this.logger.isInfoEnabled(marker)).andReturn(true); | |
360 | - replay(this.logger); | |
361 | - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled(marker)); | |
362 | - verify(this.logger); | |
363 | - } | |
364 | - @Test | |
365 | - public void testIsTRaceEnabled() { | |
366 | - expect(this.logger.isTraceEnabled()).andReturn(true); | |
367 | - replay(this.logger); | |
368 | - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled()); | |
369 | - verify(this.logger); | |
370 | - } | |
371 | - @Test | |
372 | - public void testIsTraceEnabledWithMarker() { | |
373 | - Marker marker = null; | |
374 | - expect(this.logger.isTraceEnabled(marker)).andReturn(true); | |
375 | - replay(this.logger); | |
376 | - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled(marker)); | |
377 | - verify(this.logger); | |
378 | - } | |
379 | - @Test | |
380 | - public void testIsWarnEnabled() { | |
381 | - expect(this.logger.isWarnEnabled()).andReturn(true); | |
382 | - replay(this.logger); | |
383 | - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled()); | |
384 | - verify(this.logger); | |
385 | - } | |
386 | - @Test | |
387 | - public void testIsWarnEnabledWithMarker() { | |
388 | - Marker marker = null; | |
389 | - expect(this.logger.isWarnEnabled(marker)).andReturn(true); | |
390 | - replay(this.logger); | |
391 | - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled(marker)); | |
392 | - verify(this.logger); | |
393 | - } | |
394 | - @Test | |
395 | - public void testTraceWithMarkerAndString() { | |
396 | - Marker marker = null; | |
397 | - this.logger.trace(marker,""); | |
398 | - replay(this.logger); | |
399 | - this.slf4jLoggerProxy.trace(marker,""); | |
400 | - verify(this.logger); | |
401 | - } | |
402 | - @Test | |
403 | - public void testTraceWithMarkerStringAndOneObject() { | |
404 | - Marker marker = null; | |
405 | - Object obj = null; | |
406 | - this.logger.trace(marker,"",obj); | |
407 | - replay(this.logger); | |
408 | - this.slf4jLoggerProxy.trace(marker,"",obj); | |
409 | - verify(this.logger); | |
410 | - } | |
411 | - @Test | |
412 | - public void testTraceWithMarkerStringAndTwoObjects() { | |
413 | - Marker marker = null; | |
414 | - Object obj1 = null, obj2 = null; | |
415 | - this.logger.trace(marker,"",obj1, obj2); | |
416 | - replay(this.logger); | |
417 | - this.slf4jLoggerProxy.trace(marker,"",obj1,obj2); | |
418 | - verify(this.logger); | |
419 | - } | |
420 | - @Test | |
421 | - public void testTraceWithMarkerStringAndObjectArray() { | |
422 | - Marker marker = null; | |
423 | - Object[] obj = null; | |
424 | - this.logger.trace(marker,"",obj); | |
425 | - replay(this.logger); | |
426 | - this.slf4jLoggerProxy.trace(marker,"",obj); | |
427 | - verify(this.logger); | |
428 | - } | |
429 | - @Test | |
430 | - public void testTraceWithMarkerStringAndThrowable() { | |
431 | - Marker marker = null; | |
432 | - Throwable t = null; | |
433 | - this.logger.trace(marker,"",t); | |
434 | - replay(this.logger); | |
435 | - this.slf4jLoggerProxy.trace(marker,"",t); | |
436 | - verify(this.logger); | |
437 | - } | |
438 | - @Test | |
439 | - public void testTraceWithString() { | |
440 | - this.logger.trace(""); | |
441 | - replay(this.logger); | |
442 | - this.slf4jLoggerProxy.trace(""); | |
443 | - verify(this.logger); | |
444 | - } | |
445 | - @Test | |
446 | - public void testTraceWithStringAndOneObject() { | |
447 | - Object obj = null; | |
448 | - this.logger.trace("",obj); | |
449 | - replay(this.logger); | |
450 | - this.slf4jLoggerProxy.trace("",obj); | |
451 | - verify(this.logger); | |
452 | - } | |
453 | - @Test | |
454 | - public void testTraceWithStringAndTwoObjects() { | |
455 | - Object obj1 = null, obj2 = null; | |
456 | - this.logger.trace("",obj1,obj2); | |
457 | - replay(this.logger); | |
458 | - this.slf4jLoggerProxy.trace("",obj1,obj2); | |
459 | - verify(this.logger); | |
460 | - } | |
461 | - @Test | |
462 | - public void testTraceWithStringAndObjectArray() { | |
463 | - Object[] obj = null; | |
464 | - this.logger.trace("",obj); | |
465 | - replay(this.logger); | |
466 | - this.slf4jLoggerProxy.trace("",obj); | |
467 | - verify(this.logger); | |
468 | - } | |
469 | - @Test | |
470 | - public void testTraceWithStringAndThrowable() { | |
471 | - Throwable t = null; | |
472 | - this.logger.trace("",t); | |
473 | - replay(this.logger); | |
474 | - this.slf4jLoggerProxy.trace("",t); | |
475 | - verify(this.logger); | |
476 | - } | |
477 | - @Test | |
478 | - public void testWarnWithMarkerAndString() { | |
479 | - Marker marker = null; | |
480 | - this.logger.warn(marker,""); | |
481 | - replay(this.logger); | |
482 | - this.slf4jLoggerProxy.warn(marker,""); | |
483 | - verify(this.logger); | |
484 | - } | |
485 | - @Test | |
486 | - public void testWarnWithMarkerStringAndOneObject() { | |
487 | - Marker marker = null; | |
488 | - Object obj = null; | |
489 | - this.logger.warn(marker,"",obj); | |
490 | - replay(this.logger); | |
491 | - this.slf4jLoggerProxy.warn(marker,"",obj); | |
492 | - verify(this.logger); | |
493 | - } | |
494 | - @Test | |
495 | - public void testWarnWithMarkerStringAndTwoObjects() { | |
496 | - Marker marker = null; | |
497 | - Object obj1 = null, obj2 = null; | |
498 | - this.logger.warn(marker,"",obj1, obj2); | |
499 | - replay(this.logger); | |
500 | - this.slf4jLoggerProxy.warn(marker,"",obj1,obj2); | |
501 | - verify(this.logger); | |
502 | - } | |
503 | - @Test | |
504 | - public void testWarnWithMarkerStringAndObjectArray() { | |
505 | - Marker marker = null; | |
506 | - Object[] obj = null; | |
507 | - this.logger.warn(marker,"",obj); | |
508 | - replay(this.logger); | |
509 | - this.slf4jLoggerProxy.warn(marker,"",obj); | |
510 | - verify(this.logger); | |
511 | - } | |
512 | - @Test | |
513 | - public void testWarnWithMarkerStringAndThrowable() { | |
514 | - Marker marker = null; | |
515 | - Throwable t = null; | |
516 | - this.logger.warn(marker,"",t); | |
517 | - replay(this.logger); | |
518 | - this.slf4jLoggerProxy.warn(marker,"",t); | |
519 | - verify(this.logger); | |
520 | - } | |
521 | - @Test | |
522 | - public void testWarnWithString() { | |
523 | - this.logger.warn(""); | |
524 | - replay(this.logger); | |
525 | - this.slf4jLoggerProxy.warn(""); | |
526 | - verify(this.logger); | |
527 | - } | |
528 | - @Test | |
529 | - public void testWarnWithStringAndOneObject() { | |
530 | - Object obj = null; | |
531 | - this.logger.warn("",obj); | |
532 | - replay(this.logger); | |
533 | - this.slf4jLoggerProxy.warn("",obj); | |
534 | - verify(this.logger); | |
535 | - } | |
536 | - @Test | |
537 | - public void testWarnWithStringAndTwoObjects() { | |
538 | - Object obj1 = null, obj2 = null; | |
539 | - this.logger.warn("",obj1,obj2); | |
540 | - replay(this.logger); | |
541 | - this.slf4jLoggerProxy.warn("",obj1,obj2); | |
542 | - verify(this.logger); | |
543 | - } | |
544 | - @Test | |
545 | - public void testWarnWithStringAndObjectArray() { | |
546 | - Object[] obj = null; | |
547 | - this.logger.warn("",obj); | |
548 | - replay(this.logger); | |
549 | - this.slf4jLoggerProxy.warn("",obj); | |
550 | - verify(this.logger); | |
551 | - } | |
552 | - @Test | |
553 | - public void testWarnWithStringAndThrowable() { | |
554 | - Throwable t = null; | |
555 | - this.logger.warn("",t); | |
556 | - replay(this.logger); | |
557 | - this.slf4jLoggerProxy.warn("",t); | |
558 | - verify(this.logger); | |
559 | - } | |
560 | -} | |
1 | +///* | |
2 | +// * Demoiselle Framework | |
3 | +// * Copyright (C) 2010 SERPRO | |
4 | +// * ---------------------------------------------------------------------------- | |
5 | +// * This file is part of Demoiselle Framework. | |
6 | +// * | |
7 | +// * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | +// * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | +// * as published by the Free Software Foundation. | |
10 | +// * | |
11 | +// * This program is distributed in the hope that it will be useful, | |
12 | +// * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | +// * GNU General Public License for more details. | |
15 | +// * | |
16 | +// * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | +// * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | +// * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | +// * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | +// * ---------------------------------------------------------------------------- | |
21 | +// * Este arquivo é parte do Framework Demoiselle. | |
22 | +// * | |
23 | +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | +// * do Software Livre (FSF). | |
26 | +// * | |
27 | +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | +// * para maiores detalhes. | |
31 | +// * | |
32 | +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | +// * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | +// */ | |
37 | +//package br.gov.frameworkdemoiselle.internal.proxy; | |
38 | +// | |
39 | +//import static org.easymock.EasyMock.expect; | |
40 | +//import static org.easymock.EasyMock.replay; | |
41 | +//import static org.easymock.EasyMock.verify; | |
42 | +//import static org.junit.Assert.assertEquals; | |
43 | +// | |
44 | +//import org.easymock.EasyMock; | |
45 | +//import org.junit.Before; | |
46 | +//import org.junit.Test; | |
47 | +//import org.slf4j.Logger; | |
48 | +//import org.slf4j.Marker; | |
49 | +// | |
50 | +// | |
51 | +//public class Slf4jLoggerProxyTest { | |
52 | +// | |
53 | +// private Logger logger; | |
54 | +// private Slf4jLoggerProxy slf4jLoggerProxy; | |
55 | +// | |
56 | +// @Before | |
57 | +// public void setUp() throws Exception { | |
58 | +// this.logger = EasyMock.createMock(Logger.class); | |
59 | +// this.slf4jLoggerProxy = new Slf4jLoggerProxy(this.logger); | |
60 | +// } | |
61 | +// | |
62 | +// @Test | |
63 | +// public void testDebugWithMarkerAndString() { | |
64 | +// Marker marker = null; | |
65 | +// this.logger.debug(marker,""); | |
66 | +// replay(this.logger); | |
67 | +// this.slf4jLoggerProxy.debug(marker,""); | |
68 | +// verify(this.logger); | |
69 | +// } | |
70 | +// @Test | |
71 | +// public void testDebugWithMarkerStringAndOneObject() { | |
72 | +// Marker marker = null; | |
73 | +// Object obj = null; | |
74 | +// this.logger.debug(marker,"",obj); | |
75 | +// replay(this.logger); | |
76 | +// this.slf4jLoggerProxy.debug(marker,"",obj); | |
77 | +// verify(this.logger); | |
78 | +// } | |
79 | +// @Test | |
80 | +// public void testDebugWithMarkerStringAndTwoObjects() { | |
81 | +// Marker marker = null; | |
82 | +// Object obj1 = null, obj2 = null; | |
83 | +// this.logger.debug(marker,"",obj1,obj2); | |
84 | +// replay(this.logger); | |
85 | +// this.slf4jLoggerProxy.debug(marker,"",obj1,obj2); | |
86 | +// verify(this.logger); | |
87 | +// } | |
88 | +// @Test | |
89 | +// public void testDebugWithMarkerStringAndObjectArray() { | |
90 | +// Marker marker = null; | |
91 | +// Object[] obj = null; | |
92 | +// this.logger.debug(marker,"",obj); | |
93 | +// replay(this.logger); | |
94 | +// this.slf4jLoggerProxy.debug(marker,"",obj); | |
95 | +// verify(this.logger); | |
96 | +// } | |
97 | +// | |
98 | +// @Test | |
99 | +// public void testDebugWithMarkerStringAndThrowable() { | |
100 | +// Marker marker = null; | |
101 | +// Throwable t = null; | |
102 | +// this.logger.debug(marker,"",t); | |
103 | +// replay(this.logger); | |
104 | +// this.slf4jLoggerProxy.debug(marker,"",t); | |
105 | +// verify(this.logger); | |
106 | +// } | |
107 | +// @Test | |
108 | +// public void testDebugWithString() { | |
109 | +// this.logger.debug(""); | |
110 | +// replay(this.logger); | |
111 | +// this.slf4jLoggerProxy.debug(""); | |
112 | +// verify(this.logger); | |
113 | +// } | |
114 | +// @Test | |
115 | +// public void testDebugWithStringAndOneObject() { | |
116 | +// Object obj = null; | |
117 | +// this.logger.debug("",obj); | |
118 | +// replay(this.logger); | |
119 | +// this.slf4jLoggerProxy.debug("",obj); | |
120 | +// verify(this.logger); | |
121 | +// } | |
122 | +// @Test | |
123 | +// public void testDebugWithStringAndTwoObjects() { | |
124 | +// Object obj1 = null, obj2 = null; | |
125 | +// this.logger.debug("",obj1,obj2); | |
126 | +// replay(this.logger); | |
127 | +// this.slf4jLoggerProxy.debug("",obj1,obj2); | |
128 | +// verify(this.logger); | |
129 | +// } | |
130 | +// @Test | |
131 | +// public void testDebugWithStringAndObjectArray() { | |
132 | +// Object[] obj = null; | |
133 | +// this.logger.debug("",obj); | |
134 | +// replay(this.logger); | |
135 | +// this.slf4jLoggerProxy.debug("",obj); | |
136 | +// verify(this.logger); | |
137 | +// } | |
138 | +// @Test | |
139 | +// public void testDebugWithStringAndThrowable() { | |
140 | +// Throwable t = null; | |
141 | +// this.logger.debug("",t); | |
142 | +// replay(this.logger); | |
143 | +// this.slf4jLoggerProxy.debug("",t); | |
144 | +// verify(this.logger); | |
145 | +// } | |
146 | +// @Test | |
147 | +// public void testErrorWithMarkerAndString() { | |
148 | +// Marker marker = null; | |
149 | +// this.logger.error(marker,""); | |
150 | +// replay(this.logger); | |
151 | +// this.slf4jLoggerProxy.error(marker,""); | |
152 | +// verify(this.logger); | |
153 | +// } | |
154 | +// @Test | |
155 | +// public void testErrorWithMarkerStringAndOneObject() { | |
156 | +// Marker marker = null; | |
157 | +// Object obj = null; | |
158 | +// this.logger.error(marker,"",obj); | |
159 | +// replay(this.logger); | |
160 | +// this.slf4jLoggerProxy.error(marker,"",obj); | |
161 | +// verify(this.logger); | |
162 | +// } | |
163 | +// @Test | |
164 | +// public void testErrorWithMarkerStringAndTwoObjects() { | |
165 | +// Marker marker = null; | |
166 | +// Object obj1 = null, obj2 = null; | |
167 | +// this.logger.error(marker,"",obj1,obj2); | |
168 | +// replay(this.logger); | |
169 | +// this.slf4jLoggerProxy.error(marker,"",obj1,obj2); | |
170 | +// verify(this.logger); | |
171 | +// } | |
172 | +// @Test | |
173 | +// public void testErrorWithMarkerStringAndObjectArray() { | |
174 | +// Marker marker = null; | |
175 | +// Object[] obj1 = null; | |
176 | +// this.logger.error(marker,"",obj1); | |
177 | +// replay(this.logger); | |
178 | +// this.slf4jLoggerProxy.error(marker,"",obj1); | |
179 | +// verify(this.logger); | |
180 | +// } | |
181 | +// @Test | |
182 | +// public void testErrorWithMarkerStringAndThrowable() { | |
183 | +// Marker marker = null; | |
184 | +// Throwable t = null; | |
185 | +// this.logger.error(marker,"",t); | |
186 | +// replay(this.logger); | |
187 | +// this.slf4jLoggerProxy.error(marker,"",t); | |
188 | +// verify(this.logger); | |
189 | +// } | |
190 | +// @Test | |
191 | +// public void testErrorWithString() { | |
192 | +// this.logger.error(""); | |
193 | +// replay(this.logger); | |
194 | +// this.slf4jLoggerProxy.error(""); | |
195 | +// verify(this.logger); | |
196 | +// } | |
197 | +// @Test | |
198 | +// public void testErrorWithStringAndOneObject() { | |
199 | +// Object obj = null; | |
200 | +// this.logger.error("",obj); | |
201 | +// replay(this.logger); | |
202 | +// this.slf4jLoggerProxy.error("",obj); | |
203 | +// verify(this.logger); | |
204 | +// } | |
205 | +// @Test | |
206 | +// public void testErrorWithStringAndTwoObjects() { | |
207 | +// Object obj1 = null,obj2 = null; | |
208 | +// this.logger.error("",obj1,obj2); | |
209 | +// replay(this.logger); | |
210 | +// this.slf4jLoggerProxy.error("",obj1,obj2); | |
211 | +// verify(this.logger); | |
212 | +// } | |
213 | +// @Test | |
214 | +// public void testErrorWithStringAndObjectArray() { | |
215 | +// Object[] obj = null; | |
216 | +// this.logger.error("",obj); | |
217 | +// replay(this.logger); | |
218 | +// this.slf4jLoggerProxy.error("",obj); | |
219 | +// verify(this.logger); | |
220 | +// } | |
221 | +// @Test | |
222 | +// public void testErrorWithStringAndThrowable() { | |
223 | +// Throwable t = null; | |
224 | +// this.logger.error("",t); | |
225 | +// replay(this.logger); | |
226 | +// this.slf4jLoggerProxy.error("",t); | |
227 | +// verify(this.logger); | |
228 | +// } | |
229 | +// @Test | |
230 | +// public void testGetName() { | |
231 | +// expect(this.logger.getName()).andReturn("xxx"); | |
232 | +// replay(this.logger); | |
233 | +// assertEquals("xxx", this.slf4jLoggerProxy.getName()); | |
234 | +// verify(this.logger); | |
235 | +// } | |
236 | +// @Test | |
237 | +// public void testInfoWithMarkerAndString() { | |
238 | +// Marker marker = null; | |
239 | +// this.logger.info(marker,""); | |
240 | +// replay(this.logger); | |
241 | +// this.slf4jLoggerProxy.info(marker,""); | |
242 | +// verify(this.logger); | |
243 | +// } | |
244 | +// @Test | |
245 | +// public void testInfoWithMarkerStringAndOneObject() { | |
246 | +// Marker marker = null; | |
247 | +// Object obj = null; | |
248 | +// this.logger.info(marker,"",obj); | |
249 | +// replay(this.logger); | |
250 | +// this.slf4jLoggerProxy.info(marker,"",obj); | |
251 | +// verify(this.logger); | |
252 | +// } | |
253 | +// @Test | |
254 | +// public void testInfoWithMarkerStringAndTwoObjects() { | |
255 | +// Marker marker = null; | |
256 | +// Object obj1 = null, obj2 = null; | |
257 | +// this.logger.info(marker,"",obj1, obj2); | |
258 | +// replay(this.logger); | |
259 | +// this.slf4jLoggerProxy.info(marker,"",obj1,obj2); | |
260 | +// verify(this.logger); | |
261 | +// } | |
262 | +// @Test | |
263 | +// public void testInfoWithMarkerStringAndObjectArray() { | |
264 | +// Marker marker = null; | |
265 | +// Object[] obj = null; | |
266 | +// this.logger.info(marker,"",obj); | |
267 | +// replay(this.logger); | |
268 | +// this.slf4jLoggerProxy.info(marker,"",obj); | |
269 | +// verify(this.logger); | |
270 | +// } | |
271 | +// @Test | |
272 | +// public void testInfoWithMarkerStringAndThrowable() { | |
273 | +// Marker marker = null; | |
274 | +// Throwable t = null; | |
275 | +// this.logger.info(marker,"",t); | |
276 | +// replay(this.logger); | |
277 | +// this.slf4jLoggerProxy.info(marker,"",t); | |
278 | +// verify(this.logger); | |
279 | +// } | |
280 | +// @Test | |
281 | +// public void testInfoWithString() { | |
282 | +// this.logger.info(""); | |
283 | +// replay(this.logger); | |
284 | +// this.slf4jLoggerProxy.info(""); | |
285 | +// verify(this.logger); | |
286 | +// } | |
287 | +// @Test | |
288 | +// public void testInfoWithStringAndOneObject() { | |
289 | +// Object obj = null; | |
290 | +// this.logger.info("",obj); | |
291 | +// replay(this.logger); | |
292 | +// this.slf4jLoggerProxy.info("",obj); | |
293 | +// verify(this.logger); | |
294 | +// } | |
295 | +// @Test | |
296 | +// public void testInfoWithStringAndTwoObjects() { | |
297 | +// Object obj1 = null, obj2 = null; | |
298 | +// this.logger.info("",obj1,obj2); | |
299 | +// replay(this.logger); | |
300 | +// this.slf4jLoggerProxy.info("",obj1,obj2); | |
301 | +// verify(this.logger); | |
302 | +// } | |
303 | +// @Test | |
304 | +// public void testInfoWithStringAndObjectArray() { | |
305 | +// Object[] obj = null; | |
306 | +// this.logger.info("",obj); | |
307 | +// replay(this.logger); | |
308 | +// this.slf4jLoggerProxy.info("",obj); | |
309 | +// verify(this.logger); | |
310 | +// } | |
311 | +// @Test | |
312 | +// public void testInfoWithStringAndThrowable() { | |
313 | +// Throwable t = null; | |
314 | +// this.logger.info("",t); | |
315 | +// replay(this.logger); | |
316 | +// this.slf4jLoggerProxy.info("",t); | |
317 | +// verify(this.logger); | |
318 | +// } | |
319 | +// @Test | |
320 | +// public void testIsDebugEnabled() { | |
321 | +// expect(this.logger.isDebugEnabled()).andReturn(true); | |
322 | +// replay(this.logger); | |
323 | +// assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled()); | |
324 | +// verify(this.logger); | |
325 | +// } | |
326 | +// @Test | |
327 | +// public void testIsDebugEnabledWithMarker() { | |
328 | +// Marker marker = null; | |
329 | +// expect(this.logger.isDebugEnabled(marker)).andReturn(true); | |
330 | +// replay(this.logger); | |
331 | +// assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled(marker)); | |
332 | +// verify(this.logger); | |
333 | +// } | |
334 | +// @Test | |
335 | +// public void testIsErrorEnabled() { | |
336 | +// expect(this.logger.isErrorEnabled()).andReturn(true); | |
337 | +// replay(this.logger); | |
338 | +// assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled()); | |
339 | +// verify(this.logger); | |
340 | +// } | |
341 | +// @Test | |
342 | +// public void testIsErrorEnabledWithMarker() { | |
343 | +// Marker marker = null; | |
344 | +// expect(this.logger.isErrorEnabled(marker)).andReturn(true); | |
345 | +// replay(this.logger); | |
346 | +// assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled(marker)); | |
347 | +// verify(this.logger); | |
348 | +// } | |
349 | +// @Test | |
350 | +// public void testIsInfoEnabled() { | |
351 | +// expect(this.logger.isInfoEnabled()).andReturn(true); | |
352 | +// replay(this.logger); | |
353 | +// assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled()); | |
354 | +// verify(this.logger); | |
355 | +// } | |
356 | +// @Test | |
357 | +// public void testIsInfoEnabledWithMarker() { | |
358 | +// Marker marker = null; | |
359 | +// expect(this.logger.isInfoEnabled(marker)).andReturn(true); | |
360 | +// replay(this.logger); | |
361 | +// assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled(marker)); | |
362 | +// verify(this.logger); | |
363 | +// } | |
364 | +// @Test | |
365 | +// public void testIsTRaceEnabled() { | |
366 | +// expect(this.logger.isTraceEnabled()).andReturn(true); | |
367 | +// replay(this.logger); | |
368 | +// assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled()); | |
369 | +// verify(this.logger); | |
370 | +// } | |
371 | +// @Test | |
372 | +// public void testIsTraceEnabledWithMarker() { | |
373 | +// Marker marker = null; | |
374 | +// expect(this.logger.isTraceEnabled(marker)).andReturn(true); | |
375 | +// replay(this.logger); | |
376 | +// assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled(marker)); | |
377 | +// verify(this.logger); | |
378 | +// } | |
379 | +// @Test | |
380 | +// public void testIsWarnEnabled() { | |
381 | +// expect(this.logger.isWarnEnabled()).andReturn(true); | |
382 | +// replay(this.logger); | |
383 | +// assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled()); | |
384 | +// verify(this.logger); | |
385 | +// } | |
386 | +// @Test | |
387 | +// public void testIsWarnEnabledWithMarker() { | |
388 | +// Marker marker = null; | |
389 | +// expect(this.logger.isWarnEnabled(marker)).andReturn(true); | |
390 | +// replay(this.logger); | |
391 | +// assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled(marker)); | |
392 | +// verify(this.logger); | |
393 | +// } | |
394 | +// @Test | |
395 | +// public void testTraceWithMarkerAndString() { | |
396 | +// Marker marker = null; | |
397 | +// this.logger.trace(marker,""); | |
398 | +// replay(this.logger); | |
399 | +// this.slf4jLoggerProxy.trace(marker,""); | |
400 | +// verify(this.logger); | |
401 | +// } | |
402 | +// @Test | |
403 | +// public void testTraceWithMarkerStringAndOneObject() { | |
404 | +// Marker marker = null; | |
405 | +// Object obj = null; | |
406 | +// this.logger.trace(marker,"",obj); | |
407 | +// replay(this.logger); | |
408 | +// this.slf4jLoggerProxy.trace(marker,"",obj); | |
409 | +// verify(this.logger); | |
410 | +// } | |
411 | +// @Test | |
412 | +// public void testTraceWithMarkerStringAndTwoObjects() { | |
413 | +// Marker marker = null; | |
414 | +// Object obj1 = null, obj2 = null; | |
415 | +// this.logger.trace(marker,"",obj1, obj2); | |
416 | +// replay(this.logger); | |
417 | +// this.slf4jLoggerProxy.trace(marker,"",obj1,obj2); | |
418 | +// verify(this.logger); | |
419 | +// } | |
420 | +// @Test | |
421 | +// public void testTraceWithMarkerStringAndObjectArray() { | |
422 | +// Marker marker = null; | |
423 | +// Object[] obj = null; | |
424 | +// this.logger.trace(marker,"",obj); | |
425 | +// replay(this.logger); | |
426 | +// this.slf4jLoggerProxy.trace(marker,"",obj); | |
427 | +// verify(this.logger); | |
428 | +// } | |
429 | +// @Test | |
430 | +// public void testTraceWithMarkerStringAndThrowable() { | |
431 | +// Marker marker = null; | |
432 | +// Throwable t = null; | |
433 | +// this.logger.trace(marker,"",t); | |
434 | +// replay(this.logger); | |
435 | +// this.slf4jLoggerProxy.trace(marker,"",t); | |
436 | +// verify(this.logger); | |
437 | +// } | |
438 | +// @Test | |
439 | +// public void testTraceWithString() { | |
440 | +// this.logger.trace(""); | |
441 | +// replay(this.logger); | |
442 | +// this.slf4jLoggerProxy.trace(""); | |
443 | +// verify(this.logger); | |
444 | +// } | |
445 | +// @Test | |
446 | +// public void testTraceWithStringAndOneObject() { | |
447 | +// Object obj = null; | |
448 | +// this.logger.trace("",obj); | |
449 | +// replay(this.logger); | |
450 | +// this.slf4jLoggerProxy.trace("",obj); | |
451 | +// verify(this.logger); | |
452 | +// } | |
453 | +// @Test | |
454 | +// public void testTraceWithStringAndTwoObjects() { | |
455 | +// Object obj1 = null, obj2 = null; | |
456 | +// this.logger.trace("",obj1,obj2); | |
457 | +// replay(this.logger); | |
458 | +// this.slf4jLoggerProxy.trace("",obj1,obj2); | |
459 | +// verify(this.logger); | |
460 | +// } | |
461 | +// @Test | |
462 | +// public void testTraceWithStringAndObjectArray() { | |
463 | +// Object[] obj = null; | |
464 | +// this.logger.trace("",obj); | |
465 | +// replay(this.logger); | |
466 | +// this.slf4jLoggerProxy.trace("",obj); | |
467 | +// verify(this.logger); | |
468 | +// } | |
469 | +// @Test | |
470 | +// public void testTraceWithStringAndThrowable() { | |
471 | +// Throwable t = null; | |
472 | +// this.logger.trace("",t); | |
473 | +// replay(this.logger); | |
474 | +// this.slf4jLoggerProxy.trace("",t); | |
475 | +// verify(this.logger); | |
476 | +// } | |
477 | +// @Test | |
478 | +// public void testWarnWithMarkerAndString() { | |
479 | +// Marker marker = null; | |
480 | +// this.logger.warn(marker,""); | |
481 | +// replay(this.logger); | |
482 | +// this.slf4jLoggerProxy.warn(marker,""); | |
483 | +// verify(this.logger); | |
484 | +// } | |
485 | +// @Test | |
486 | +// public void testWarnWithMarkerStringAndOneObject() { | |
487 | +// Marker marker = null; | |
488 | +// Object obj = null; | |
489 | +// this.logger.warn(marker,"",obj); | |
490 | +// replay(this.logger); | |
491 | +// this.slf4jLoggerProxy.warn(marker,"",obj); | |
492 | +// verify(this.logger); | |
493 | +// } | |
494 | +// @Test | |
495 | +// public void testWarnWithMarkerStringAndTwoObjects() { | |
496 | +// Marker marker = null; | |
497 | +// Object obj1 = null, obj2 = null; | |
498 | +// this.logger.warn(marker,"",obj1, obj2); | |
499 | +// replay(this.logger); | |
500 | +// this.slf4jLoggerProxy.warn(marker,"",obj1,obj2); | |
501 | +// verify(this.logger); | |
502 | +// } | |
503 | +// @Test | |
504 | +// public void testWarnWithMarkerStringAndObjectArray() { | |
505 | +// Marker marker = null; | |
506 | +// Object[] obj = null; | |
507 | +// this.logger.warn(marker,"",obj); | |
508 | +// replay(this.logger); | |
509 | +// this.slf4jLoggerProxy.warn(marker,"",obj); | |
510 | +// verify(this.logger); | |
511 | +// } | |
512 | +// @Test | |
513 | +// public void testWarnWithMarkerStringAndThrowable() { | |
514 | +// Marker marker = null; | |
515 | +// Throwable t = null; | |
516 | +// this.logger.warn(marker,"",t); | |
517 | +// replay(this.logger); | |
518 | +// this.slf4jLoggerProxy.warn(marker,"",t); | |
519 | +// verify(this.logger); | |
520 | +// } | |
521 | +// @Test | |
522 | +// public void testWarnWithString() { | |
523 | +// this.logger.warn(""); | |
524 | +// replay(this.logger); | |
525 | +// this.slf4jLoggerProxy.warn(""); | |
526 | +// verify(this.logger); | |
527 | +// } | |
528 | +// @Test | |
529 | +// public void testWarnWithStringAndOneObject() { | |
530 | +// Object obj = null; | |
531 | +// this.logger.warn("",obj); | |
532 | +// replay(this.logger); | |
533 | +// this.slf4jLoggerProxy.warn("",obj); | |
534 | +// verify(this.logger); | |
535 | +// } | |
536 | +// @Test | |
537 | +// public void testWarnWithStringAndTwoObjects() { | |
538 | +// Object obj1 = null, obj2 = null; | |
539 | +// this.logger.warn("",obj1,obj2); | |
540 | +// replay(this.logger); | |
541 | +// this.slf4jLoggerProxy.warn("",obj1,obj2); | |
542 | +// verify(this.logger); | |
543 | +// } | |
544 | +// @Test | |
545 | +// public void testWarnWithStringAndObjectArray() { | |
546 | +// Object[] obj = null; | |
547 | +// this.logger.warn("",obj); | |
548 | +// replay(this.logger); | |
549 | +// this.slf4jLoggerProxy.warn("",obj); | |
550 | +// verify(this.logger); | |
551 | +// } | |
552 | +// @Test | |
553 | +// public void testWarnWithStringAndThrowable() { | |
554 | +// Throwable t = null; | |
555 | +// this.logger.warn("",t); | |
556 | +// replay(this.logger); | |
557 | +// this.slf4jLoggerProxy.warn("",t); | |
558 | +// verify(this.logger); | |
559 | +// } | |
560 | +//} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java
1 | -/* | |
2 | - * Demoiselle Framework | |
3 | - * Copyright (C) 2010 SERPRO | |
4 | - * ---------------------------------------------------------------------------- | |
5 | - * This file is part of Demoiselle Framework. | |
6 | - * | |
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | - * as published by the Free Software Foundation. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | - * ---------------------------------------------------------------------------- | |
21 | - * Este arquivo é parte do Framework Demoiselle. | |
22 | - * | |
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | - * do Software Livre (FSF). | |
26 | - * | |
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | - * para maiores detalhes. | |
31 | - * | |
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | - */ | |
37 | -package br.gov.frameworkdemoiselle.util; | |
38 | - | |
39 | -import static org.easymock.EasyMock.createMock; | |
40 | -import static org.easymock.EasyMock.replay; | |
41 | -import static org.easymock.EasyMock.verify; | |
42 | -import static org.junit.Assert.assertEquals; | |
43 | -import static org.junit.Assert.assertFalse; | |
44 | -import static org.junit.Assert.assertNull; | |
45 | -import static org.junit.Assert.assertTrue; | |
46 | - | |
47 | -import java.util.Enumeration; | |
48 | -import java.util.ListResourceBundle; | |
49 | - | |
50 | -import junit.framework.Assert; | |
51 | - | |
52 | -import org.junit.Before; | |
53 | -import org.junit.Test; | |
54 | - | |
55 | -public class ResourceBundleTest { | |
56 | - | |
57 | - /** | |
58 | - * This is a workaround to mock java.util.ResourceBundle. Since getString(key) method is defined as final, there is | |
59 | - * no way to extend and override it. For that reason, setting expectations (i.e. expect(...)) won't work. | |
60 | - */ | |
61 | - class MockResourceBundle extends ListResourceBundle { | |
62 | - | |
63 | - private Object[][] contents = new Object[][] { { "msgWithoutParams", "no params" }, | |
64 | - { "msgWithParams", "params: {0}, {1}" } }; | |
65 | - | |
66 | - protected Object[][] getContents() { | |
67 | - return contents; | |
68 | - } | |
69 | - | |
70 | - }; | |
71 | - | |
72 | - private ResourceBundle resourceBundle; | |
73 | - | |
74 | - private java.util.ResourceBundle mockResourceBundle; | |
75 | - | |
76 | - @Before | |
77 | - public void setUp() throws Exception { | |
78 | - mockResourceBundle = new MockResourceBundle(); | |
79 | - resourceBundle = new ResourceBundle(mockResourceBundle); | |
80 | - } | |
81 | - | |
82 | - @Test | |
83 | - public void containsKey() { | |
84 | - assertTrue(resourceBundle.containsKey("msgWithoutParams")); | |
85 | - | |
86 | - assertFalse(resourceBundle.containsKey("inexistentKey")); | |
87 | - } | |
88 | - | |
89 | - @Test | |
90 | - public void getKeys() { | |
91 | - int keyCount = 0; | |
92 | - | |
93 | - Enumeration<String> e = resourceBundle.getKeys(); | |
94 | - | |
95 | - while (e.hasMoreElements()) { | |
96 | - keyCount++; | |
97 | - e.nextElement(); | |
98 | - } | |
99 | - | |
100 | - assertEquals(resourceBundle.keySet().size(), keyCount); | |
101 | - } | |
102 | - | |
103 | - @Test | |
104 | - public void testGetLocale() { | |
105 | - assertNull(resourceBundle.getLocale()); | |
106 | - } | |
107 | - | |
108 | - @Test | |
109 | - public void testKeySet() { | |
110 | - assertEquals(2, resourceBundle.keySet().size()); | |
111 | - } | |
112 | - | |
113 | - @Test | |
114 | - public void getString() { | |
115 | - assertEquals("no params", resourceBundle.getString("msgWithoutParams")); | |
116 | - | |
117 | - assertEquals("params: a, b", resourceBundle.getString("msgWithParams", "a", "b")); | |
118 | - | |
119 | - assertEquals("params: {0}, {1}", resourceBundle.getString("msgWithParams")); | |
120 | - } | |
121 | - | |
122 | - /** | |
123 | - * For this test, java.util.ResourceBundle is mocked to force an exception. Since the getString method is called | |
124 | - * from the actual ResourceBundle, not from the mock, it tries to find a handleGetObject method that doesn't exist. | |
125 | - * | |
126 | - * @throws Exception | |
127 | - */ | |
128 | - @Test(expected = RuntimeException.class) | |
129 | - public void getStringWhenHandleGetObjectThrowsException() { | |
130 | - mockResourceBundle = createMock(java.util.ResourceBundle.class); | |
131 | - resourceBundle = new ResourceBundle(mockResourceBundle); | |
132 | - | |
133 | - replay(mockResourceBundle); | |
134 | - | |
135 | - resourceBundle.getString("msgWithParams"); | |
136 | - | |
137 | - verify(mockResourceBundle); | |
138 | - | |
139 | - Assert.fail(); | |
140 | - } | |
141 | - | |
142 | -} | |
1 | +///* | |
2 | +// * Demoiselle Framework | |
3 | +// * Copyright (C) 2010 SERPRO | |
4 | +// * ---------------------------------------------------------------------------- | |
5 | +// * This file is part of Demoiselle Framework. | |
6 | +// * | |
7 | +// * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | +// * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | +// * as published by the Free Software Foundation. | |
10 | +// * | |
11 | +// * This program is distributed in the hope that it will be useful, | |
12 | +// * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | +// * GNU General Public License for more details. | |
15 | +// * | |
16 | +// * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | +// * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | +// * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | +// * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | +// * ---------------------------------------------------------------------------- | |
21 | +// * Este arquivo é parte do Framework Demoiselle. | |
22 | +// * | |
23 | +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | +// * do Software Livre (FSF). | |
26 | +// * | |
27 | +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | +// * para maiores detalhes. | |
31 | +// * | |
32 | +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | +// * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | +// */ | |
37 | +//package br.gov.frameworkdemoiselle.util; | |
38 | +// | |
39 | +//import static org.easymock.EasyMock.createMock; | |
40 | +//import static org.easymock.EasyMock.replay; | |
41 | +//import static org.easymock.EasyMock.verify; | |
42 | +//import static org.junit.Assert.assertEquals; | |
43 | +//import static org.junit.Assert.assertFalse; | |
44 | +//import static org.junit.Assert.assertNull; | |
45 | +//import static org.junit.Assert.assertTrue; | |
46 | +// | |
47 | +//import java.util.Enumeration; | |
48 | +//import java.util.ListResourceBundle; | |
49 | +// | |
50 | +//import junit.framework.Assert; | |
51 | +// | |
52 | +//import org.junit.Before; | |
53 | +//import org.junit.Test; | |
54 | +// | |
55 | +//public class ResourceBundleTest { | |
56 | +// | |
57 | +// /** | |
58 | +// * This is a workaround to mock java.util.ResourceBundle. Since getString(key) method is defined as final, there is | |
59 | +// * no way to extend and override it. For that reason, setting expectations (i.e. expect(...)) won't work. | |
60 | +// */ | |
61 | +// class MockResourceBundle extends ListResourceBundle { | |
62 | +// | |
63 | +// private Object[][] contents = new Object[][] { { "msgWithoutParams", "no params" }, | |
64 | +// { "msgWithParams", "params: {0}, {1}" } }; | |
65 | +// | |
66 | +// protected Object[][] getContents() { | |
67 | +// return contents; | |
68 | +// } | |
69 | +// | |
70 | +// }; | |
71 | +// | |
72 | +// private ResourceBundle resourceBundle; | |
73 | +// | |
74 | +// private java.util.ResourceBundle mockResourceBundle; | |
75 | +// | |
76 | +// @Before | |
77 | +// public void setUp() throws Exception { | |
78 | +// mockResourceBundle = new MockResourceBundle(); | |
79 | +// resourceBundle = new ResourceBundle(mockResourceBundle); | |
80 | +// } | |
81 | +// | |
82 | +// @Test | |
83 | +// public void containsKey() { | |
84 | +// assertTrue(resourceBundle.containsKey("msgWithoutParams")); | |
85 | +// | |
86 | +// assertFalse(resourceBundle.containsKey("inexistentKey")); | |
87 | +// } | |
88 | +// | |
89 | +// @Test | |
90 | +// public void getKeys() { | |
91 | +// int keyCount = 0; | |
92 | +// | |
93 | +// Enumeration<String> e = resourceBundle.getKeys(); | |
94 | +// | |
95 | +// while (e.hasMoreElements()) { | |
96 | +// keyCount++; | |
97 | +// e.nextElement(); | |
98 | +// } | |
99 | +// | |
100 | +// assertEquals(resourceBundle.keySet().size(), keyCount); | |
101 | +// } | |
102 | +// | |
103 | +// @Test | |
104 | +// public void testGetLocale() { | |
105 | +// assertNull(resourceBundle.getLocale()); | |
106 | +// } | |
107 | +// | |
108 | +// @Test | |
109 | +// public void testKeySet() { | |
110 | +// assertEquals(2, resourceBundle.keySet().size()); | |
111 | +// } | |
112 | +// | |
113 | +// @Test | |
114 | +// public void getString() { | |
115 | +// assertEquals("no params", resourceBundle.getString("msgWithoutParams")); | |
116 | +// | |
117 | +// assertEquals("params: a, b", resourceBundle.getString("msgWithParams", "a", "b")); | |
118 | +// | |
119 | +// assertEquals("params: {0}, {1}", resourceBundle.getString("msgWithParams")); | |
120 | +// } | |
121 | +// | |
122 | +// /** | |
123 | +// * For this test, java.util.ResourceBundle is mocked to force an exception. Since the getString method is called | |
124 | +// * from the actual ResourceBundle, not from the mock, it tries to find a handleGetObject method that doesn't exist. | |
125 | +// * | |
126 | +// * @throws Exception | |
127 | +// */ | |
128 | +// @Test(expected = RuntimeException.class) | |
129 | +// public void getStringWhenHandleGetObjectThrowsException() { | |
130 | +// mockResourceBundle = createMock(java.util.ResourceBundle.class); | |
131 | +// resourceBundle = new ResourceBundle(mockResourceBundle); | |
132 | +// | |
133 | +// replay(mockResourceBundle); | |
134 | +// | |
135 | +// resourceBundle.getString("msgWithParams"); | |
136 | +// | |
137 | +// verify(mockResourceBundle); | |
138 | +// | |
139 | +// Assert.fail(); | |
140 | +// } | |
141 | +// | |
142 | +//} | ... | ... |
impl/extension/jpa/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/EntityManagerConfigTest.java
... | ... | @@ -40,6 +40,8 @@ import static org.easymock.EasyMock.expect; |
40 | 40 | import static org.junit.Assert.assertEquals; |
41 | 41 | import static org.powermock.api.easymock.PowerMock.mockStatic; |
42 | 42 | |
43 | +import java.util.Locale; | |
44 | + | |
43 | 45 | import org.junit.After; |
44 | 46 | import org.junit.Before; |
45 | 47 | import org.junit.Test; |
... | ... | @@ -68,17 +70,17 @@ public class EntityManagerConfigTest { |
68 | 70 | @Before |
69 | 71 | public void setUp() throws Exception { |
70 | 72 | Logger logger = PowerMock.createMock(Logger.class); |
71 | - ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));; | |
73 | + ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault());; | |
72 | 74 | |
73 | 75 | ConfigurationLoader configurationLoader = new ConfigurationLoader(); |
74 | - | |
76 | + | |
75 | 77 | Whitebox.setInternalState(configurationLoader, "bundle", bundle); |
76 | 78 | Whitebox.setInternalState(configurationLoader, "logger", logger); |
77 | - | |
79 | + | |
78 | 80 | mockStatic(CoreBootstrap.class); |
79 | 81 | expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); |
80 | 82 | PowerMock.replay(CoreBootstrap.class); |
81 | - | |
83 | + | |
82 | 84 | configurationLoader.load(config); |
83 | 85 | } |
84 | 86 | ... | ... |
impl/extension/jsf/pom.xml
... | ... | @@ -60,14 +60,17 @@ |
60 | 60 | <groupId>com.sun.faces</groupId> |
61 | 61 | <artifactId>jsf-api</artifactId> |
62 | 62 | </dependency> |
63 | - <dependency> | |
64 | - <groupId>com.sun.faces</groupId> | |
65 | - <artifactId>jsf-impl</artifactId> | |
66 | - </dependency> | |
63 | + <!-- | |
67 | 64 | <dependency> |
68 | 65 | <groupId>javax.el</groupId> |
69 | 66 | <artifactId>el-api</artifactId> |
70 | 67 | </dependency> |
68 | + --> | |
69 | + <dependency> | |
70 | + <groupId>com.sun.faces</groupId> | |
71 | + <artifactId>jsf-impl</artifactId> | |
72 | + <scope>test</scope> | |
73 | + </dependency> | |
71 | 74 | </dependencies> |
72 | 75 | |
73 | 76 | <repositories> | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ParameterImpl.java
... | ... | @@ -48,31 +48,49 @@ import javax.servlet.http.HttpServletRequest; |
48 | 48 | |
49 | 49 | import br.gov.frameworkdemoiselle.annotation.Name; |
50 | 50 | import br.gov.frameworkdemoiselle.annotation.ViewScoped; |
51 | +import br.gov.frameworkdemoiselle.util.Beans; | |
51 | 52 | import br.gov.frameworkdemoiselle.util.Faces; |
52 | 53 | import br.gov.frameworkdemoiselle.util.Parameter; |
53 | 54 | import br.gov.frameworkdemoiselle.util.Reflections; |
54 | 55 | |
55 | -public class ParameterImpl<T> implements Parameter<T>, Serializable { | |
56 | +public class ParameterImpl<T extends Serializable> implements Parameter<T>, Serializable { | |
56 | 57 | |
57 | 58 | private static final long serialVersionUID = 1L; |
58 | 59 | |
59 | 60 | private Class<Object> type; |
60 | 61 | |
61 | - private Converter converter; | |
62 | + private transient Converter converter; | |
62 | 63 | |
63 | - private final InjectionPoint ip; | |
64 | - | |
65 | - private final HttpServletRequest request; | |
64 | + private transient HttpServletRequest request; | |
66 | 65 | |
67 | 66 | private T value; |
68 | 67 | |
69 | 68 | private final String key; |
70 | 69 | |
71 | - @Inject | |
72 | - public ParameterImpl(InjectionPoint ip, HttpServletRequest request) { | |
73 | - this.ip = ip; | |
74 | - this.request = request; | |
70 | + private boolean viewScoped = false; | |
71 | + | |
72 | + private boolean requestScoped = false; | |
73 | + | |
74 | + private boolean sessionScoped = false; | |
75 | + | |
76 | + public Converter getConverter() { | |
77 | + if (converter == null) { | |
78 | + converter = Faces.getConverter(type); | |
79 | + } | |
80 | + | |
81 | + return converter; | |
82 | + } | |
75 | 83 | |
84 | + private HttpServletRequest getRequest() { | |
85 | + if (request == null) { | |
86 | + request = Beans.getReference(HttpServletRequest.class); | |
87 | + } | |
88 | + | |
89 | + return request; | |
90 | + } | |
91 | + | |
92 | + @Inject | |
93 | + public ParameterImpl(InjectionPoint ip) { | |
76 | 94 | if (ip.getAnnotated().isAnnotationPresent(Name.class)) { |
77 | 95 | this.key = ip.getAnnotated().getAnnotation(Name.class).value(); |
78 | 96 | } else { |
... | ... | @@ -80,7 +98,10 @@ public class ParameterImpl<T> implements Parameter<T>, Serializable { |
80 | 98 | } |
81 | 99 | |
82 | 100 | this.type = Reflections.getGenericTypeArgument(ip.getMember(), 0); |
83 | - this.converter = Faces.getConverter(type); | |
101 | + | |
102 | + this.viewScoped = ip.getAnnotated().isAnnotationPresent(ViewScoped.class); | |
103 | + this.requestScoped = ip.getAnnotated().isAnnotationPresent(RequestScoped.class); | |
104 | + this.sessionScoped = ip.getAnnotated().isAnnotationPresent(SessionScoped.class); | |
84 | 105 | } |
85 | 106 | |
86 | 107 | public String getKey() { |
... | ... | @@ -88,43 +109,43 @@ public class ParameterImpl<T> implements Parameter<T>, Serializable { |
88 | 109 | } |
89 | 110 | |
90 | 111 | private boolean isSessionScoped() { |
91 | - return ip.getAnnotated().isAnnotationPresent(SessionScoped.class); | |
112 | + return sessionScoped; | |
92 | 113 | } |
93 | 114 | |
94 | 115 | private boolean isViewScoped() { |
95 | - return ip.getAnnotated().isAnnotationPresent(ViewScoped.class); | |
116 | + return viewScoped; | |
96 | 117 | } |
97 | 118 | |
98 | 119 | private boolean isRequestScoped() { |
99 | - return ip.getAnnotated().isAnnotationPresent(RequestScoped.class); | |
120 | + return requestScoped; | |
100 | 121 | } |
101 | 122 | |
102 | 123 | @SuppressWarnings("unchecked") |
103 | 124 | public T getValue() { |
104 | 125 | T result = null; |
105 | - String parameterValue = request.getParameter(key); | |
126 | + String parameterValue = getRequest().getParameter(key); | |
106 | 127 | |
107 | 128 | if (isSessionScoped()) { |
108 | 129 | if (parameterValue != null) { |
109 | - request.getSession().setAttribute(key, Faces.convert(parameterValue, converter)); | |
130 | + getRequest().getSession().setAttribute(key, Faces.convert(parameterValue, getConverter())); | |
110 | 131 | } |
111 | 132 | |
112 | - result = (T) request.getSession().getAttribute(key); | |
133 | + result = (T) getRequest().getSession().getAttribute(key); | |
113 | 134 | |
114 | 135 | } else if (isRequestScoped()) { |
115 | - result = (T) Faces.convert(parameterValue, converter); | |
136 | + result = (T) Faces.convert(parameterValue, getConverter()); | |
116 | 137 | |
117 | 138 | } else if (isViewScoped()) { |
118 | 139 | Map<String, Object> viewMap = Faces.getViewMap(); |
119 | 140 | if (parameterValue != null) { |
120 | - viewMap.put(key, Faces.convert(parameterValue, converter)); | |
141 | + viewMap.put(key, Faces.convert(parameterValue, getConverter())); | |
121 | 142 | } |
122 | 143 | |
123 | 144 | result = (T) viewMap.get(key); |
124 | 145 | |
125 | 146 | } else { |
126 | 147 | if (value == null) { |
127 | - value = (T) Faces.convert(parameterValue, converter); | |
148 | + value = (T) Faces.convert(parameterValue, getConverter()); | |
128 | 149 | } |
129 | 150 | |
130 | 151 | result = value; |
... | ... | @@ -133,14 +154,10 @@ public class ParameterImpl<T> implements Parameter<T>, Serializable { |
133 | 154 | return result; |
134 | 155 | } |
135 | 156 | |
136 | - public Converter getConverter() { | |
137 | - return converter; | |
138 | - } | |
139 | - | |
140 | 157 | @Override |
141 | 158 | public void setValue(T value) { |
142 | 159 | if (isSessionScoped()) { |
143 | - this.request.getSession().setAttribute(key, value); | |
160 | + getRequest().getSession().setAttribute(key, value); | |
144 | 161 | |
145 | 162 | } else if (isRequestScoped()) { |
146 | 163 | // FIXME Lançar exceção informando que não é possível setar parâmetros no request. | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityObserver.java
... | ... | @@ -48,28 +48,22 @@ import javax.servlet.http.HttpSession; |
48 | 48 | |
49 | 49 | import org.slf4j.Logger; |
50 | 50 | |
51 | +import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | |
51 | 52 | import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig; |
52 | 53 | import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful; |
53 | 54 | import br.gov.frameworkdemoiselle.security.AfterLogoutSuccessful; |
55 | +import br.gov.frameworkdemoiselle.util.Beans; | |
54 | 56 | import br.gov.frameworkdemoiselle.util.PageNotFoundException; |
55 | 57 | import br.gov.frameworkdemoiselle.util.Redirector; |
56 | 58 | |
57 | -import com.sun.faces.config.ConfigurationException; | |
58 | - | |
59 | 59 | @SessionScoped |
60 | 60 | public class SecurityObserver implements Serializable { |
61 | 61 | |
62 | 62 | private static final long serialVersionUID = 1L; |
63 | 63 | |
64 | 64 | @Inject |
65 | - private FacesContext facesContext; | |
66 | - | |
67 | - @Inject | |
68 | 65 | private JsfSecurityConfig config; |
69 | 66 | |
70 | - @Inject | |
71 | - private HttpSession session; | |
72 | - | |
73 | 67 | private Map<String, Object> savedParams = new HashMap<String, Object>(); |
74 | 68 | |
75 | 69 | private String savedViewId; |
... | ... | @@ -83,6 +77,7 @@ public class SecurityObserver implements Serializable { |
83 | 77 | |
84 | 78 | private void saveCurrentState() { |
85 | 79 | clear(); |
80 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | |
86 | 81 | |
87 | 82 | if (!config.getLoginPage().equals(facesContext.getViewRoot().getViewId())) { |
88 | 83 | savedParams.putAll(facesContext.getExternalContext().getRequestParameterMap()); |
... | ... | @@ -151,7 +146,7 @@ public class SecurityObserver implements Serializable { |
151 | 146 | |
152 | 147 | } finally { |
153 | 148 | try { |
154 | - session.invalidate(); | |
149 | + Beans.getReference(HttpSession.class).invalidate(); | |
155 | 150 | } catch (IllegalStateException e) { |
156 | 151 | logger.debug("Esta sessão já foi invalidada."); |
157 | 152 | } | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/producer/JsfLocaleProducer.java
... | ... | @@ -48,13 +48,13 @@ public class JsfLocaleProducer implements Serializable { |
48 | 48 | |
49 | 49 | if (!loaded) { |
50 | 50 | if (facesContext != null) { |
51 | - HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); | |
52 | - locale = request.getLocale(); | |
51 | + locale = Beans.getReference(HttpServletRequest.class).getLocale(); | |
53 | 52 | facesContext.getApplication().setDefaultLocale(locale); |
54 | 53 | } |
55 | 54 | |
56 | 55 | loaded = true; |
57 | 56 | } |
57 | + | |
58 | 58 | locale = facesContext.getApplication().getDefaultLocale(); |
59 | 59 | |
60 | 60 | } catch (Exception cause) { | ... | ... |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Parameter.java
... | ... | @@ -36,9 +36,11 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.util; |
38 | 38 | |
39 | +import java.io.Serializable; | |
40 | + | |
39 | 41 | import javax.faces.convert.Converter; |
40 | 42 | |
41 | -public interface Parameter<T> { | |
43 | +public interface Parameter<T extends Serializable> { | |
42 | 44 | |
43 | 45 | void setValue(T value); |
44 | 46 | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ParameterImplTest.java
1 | -/* | |
2 | - * Demoiselle Framework | |
3 | - * Copyright (C) 2010 SERPRO | |
4 | - * ---------------------------------------------------------------------------- | |
5 | - * This file is part of Demoiselle Framework. | |
6 | - * | |
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | - * as published by the Free Software Foundation. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | - * ---------------------------------------------------------------------------- | |
21 | - * Este arquivo é parte do Framework Demoiselle. | |
22 | - * | |
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | - * do Software Livre (FSF). | |
26 | - * | |
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | - * para maiores detalhes. | |
31 | - * | |
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | - */ | |
37 | -package br.gov.frameworkdemoiselle.internal.implementation; | |
38 | - | |
39 | -import static org.easymock.EasyMock.expect; | |
40 | -import static org.junit.Assert.assertEquals; | |
41 | -import static org.powermock.api.easymock.PowerMock.createMock; | |
42 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | |
43 | -import static org.powermock.api.easymock.PowerMock.replayAll; | |
44 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | |
45 | - | |
46 | -import java.lang.reflect.Member; | |
47 | -import java.util.HashMap; | |
48 | -import java.util.Map; | |
49 | - | |
50 | -import javax.enterprise.context.RequestScoped; | |
51 | -import javax.enterprise.context.SessionScoped; | |
52 | -import javax.enterprise.inject.spi.Annotated; | |
53 | -import javax.enterprise.inject.spi.InjectionPoint; | |
54 | -import javax.faces.convert.Converter; | |
55 | -import javax.servlet.http.HttpServletRequest; | |
56 | -import javax.servlet.http.HttpSession; | |
57 | - | |
58 | -import org.easymock.EasyMock; | |
59 | -import org.junit.Before; | |
60 | -import org.junit.Test; | |
61 | -import org.junit.runner.RunWith; | |
62 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
63 | -import org.powermock.modules.junit4.PowerMockRunner; | |
64 | -import org.powermock.reflect.Whitebox; | |
65 | - | |
66 | -import br.gov.frameworkdemoiselle.annotation.Name; | |
67 | -import br.gov.frameworkdemoiselle.annotation.ViewScoped; | |
68 | -import br.gov.frameworkdemoiselle.util.Faces; | |
69 | -import br.gov.frameworkdemoiselle.util.Reflections; | |
70 | - | |
71 | -@RunWith(PowerMockRunner.class) | |
72 | -@PrepareForTest({ Reflections.class, Faces.class }) | |
73 | -public class ParameterImplTest { | |
74 | - | |
75 | - private ParameterImpl<Long> param; | |
76 | - | |
77 | - private HttpServletRequest request; | |
78 | - | |
79 | - private InjectionPoint ip; | |
80 | - | |
81 | - private Converter converter; | |
82 | - | |
83 | - private Annotated annotated; | |
84 | - | |
85 | - private Name name; | |
86 | - | |
87 | - private HttpSession session; | |
88 | - | |
89 | - private Member member; | |
90 | - | |
91 | - @Before | |
92 | - public void before() { | |
93 | - ip = createMock(InjectionPoint.class); | |
94 | - request = createMock(HttpServletRequest.class); | |
95 | - session = createMock(HttpSession.class); | |
96 | - annotated = createMock(Annotated.class); | |
97 | - name = createMock(Name.class); | |
98 | - converter = createMock(Converter.class); | |
99 | - member = createMock(Member.class); | |
100 | - | |
101 | - mockStatic(Reflections.class); | |
102 | - mockStatic(Faces.class); | |
103 | - } | |
104 | - | |
105 | - private void prepareForTestWithKeyFromNameAnnotation() { | |
106 | - expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | |
107 | - expect(ip.getMember()).andReturn(null); | |
108 | - expect(annotated.isAnnotationPresent(Name.class)).andReturn(true); | |
109 | - expect(annotated.getAnnotation(Name.class)).andReturn(name); | |
110 | - expect(name.value()).andReturn("name"); | |
111 | - expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | |
112 | - Object.class); | |
113 | - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | |
114 | - } | |
115 | - | |
116 | - @Test | |
117 | - public void testConstructorCase1() { | |
118 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
119 | - | |
120 | - replayAll(); | |
121 | - param = new ParameterImpl<Long>(ip, request); | |
122 | - assertEquals("name", param.getKey()); | |
123 | - assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | |
124 | - assertEquals(converter, param.getConverter()); | |
125 | - verifyAll(); | |
126 | - } | |
127 | - | |
128 | - @Test | |
129 | - public void testConstructorCase2() { | |
130 | - expect(member.getName()).andReturn("memberName"); | |
131 | - expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | |
132 | - expect(ip.getMember()).andReturn(member).anyTimes(); | |
133 | - expect(annotated.isAnnotationPresent(Name.class)).andReturn(false); | |
134 | - expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | |
135 | - Object.class); | |
136 | - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | |
137 | - | |
138 | - replayAll(); | |
139 | - param = new ParameterImpl<Long>(ip, request); | |
140 | - assertEquals("memberName", param.getKey()); | |
141 | - assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | |
142 | - assertEquals(converter, param.getConverter()); | |
143 | - verifyAll(); | |
144 | - } | |
145 | - | |
146 | - @Test | |
147 | - public void testGetValueWhenSessionScopedAndParameterValueNotNull() { | |
148 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
149 | - | |
150 | - expect(Faces.convert("1", converter)).andReturn("return"); | |
151 | - expect(request.getSession()).andReturn(session).anyTimes(); | |
152 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
153 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
154 | - expect(session.getAttribute("name")).andReturn("return"); | |
155 | - | |
156 | - session.setAttribute("name", "return"); | |
157 | - | |
158 | - replayAll(); | |
159 | - param = new ParameterImpl<Long>(ip, request); | |
160 | - assertEquals("return", param.getValue()); | |
161 | - verifyAll(); | |
162 | - } | |
163 | - | |
164 | - @Test | |
165 | - public void testGetValueWhenSessionScopedAndParameterValueNull() { | |
166 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
167 | - | |
168 | - expect(request.getSession()).andReturn(session).anyTimes(); | |
169 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | |
170 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
171 | - expect(session.getAttribute("name")).andReturn("return"); | |
172 | - | |
173 | - replayAll(); | |
174 | - param = new ParameterImpl<Long>(ip, request); | |
175 | - assertEquals("return", param.getValue()); | |
176 | - verifyAll(); | |
177 | - } | |
178 | - | |
179 | - @Test | |
180 | - public void testGetValueWhenRequestScoped() { | |
181 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
182 | - | |
183 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
184 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | |
185 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
186 | - expect(Faces.convert("1", converter)).andReturn("return"); | |
187 | - | |
188 | - replayAll(); | |
189 | - param = new ParameterImpl<Long>(ip, request); | |
190 | - assertEquals("return", param.getValue()); | |
191 | - verifyAll(); | |
192 | - } | |
193 | - | |
194 | - @Test | |
195 | - public void testGetValueWhenViewScopedWithParamValueNotNull() { | |
196 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
197 | - Map<String, Object> map = new HashMap<String,Object>(); | |
198 | - | |
199 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
200 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
201 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
202 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
203 | - expect(Faces.getViewMap()).andReturn(map); | |
204 | - expect(Faces.convert("1", converter)).andReturn("return"); | |
205 | - | |
206 | - replayAll(); | |
207 | - param = new ParameterImpl<Long>(ip, request); | |
208 | - assertEquals("return", param.getValue()); | |
209 | - assertEquals("return", map.get("name")); | |
210 | - verifyAll(); | |
211 | - } | |
212 | - | |
213 | - @Test | |
214 | - public void testGetValueWhenViewScopedWithParamValueNull() { | |
215 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
216 | - Map<String, Object> map = new HashMap<String,Object>(); | |
217 | - map.put("name", "ops"); | |
218 | - | |
219 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
220 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
221 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
222 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | |
223 | - expect(Faces.getViewMap()).andReturn(map); | |
224 | - | |
225 | - replayAll(); | |
226 | - param = new ParameterImpl<Long>(ip, request); | |
227 | - assertEquals("ops", param.getValue()); | |
228 | - assertEquals("ops", map.get("name")); | |
229 | - verifyAll(); | |
230 | - } | |
231 | - | |
232 | - @Test | |
233 | - public void testGetValueElseWithValueNull() { | |
234 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
235 | - | |
236 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
237 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
238 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
239 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
240 | - expect(Faces.convert("1", converter)).andReturn("return"); | |
241 | - | |
242 | - replayAll(); | |
243 | - param = new ParameterImpl<Long>(ip, request); | |
244 | - assertEquals("return", param.getValue()); | |
245 | - verifyAll(); | |
246 | - } | |
247 | - | |
248 | - @Test | |
249 | - public void testGetValueElseWithValueNotNull() { | |
250 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
251 | - | |
252 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
253 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
254 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
255 | - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
256 | - | |
257 | - replayAll(); | |
258 | - param = new ParameterImpl<Long>(ip, request); | |
259 | - Whitebox.setInternalState(param, "value", "myvalue"); | |
260 | - assertEquals("myvalue", param.getValue()); | |
261 | - verifyAll(); | |
262 | - } | |
263 | - | |
264 | - @Test | |
265 | - public void testSetValueIsSessionScoped() { | |
266 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
267 | - | |
268 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
269 | - expect(request.getSession()).andReturn(session); | |
270 | - | |
271 | - session.setAttribute("name", 1L); | |
272 | - | |
273 | - replayAll(); | |
274 | - param = new ParameterImpl<Long>(ip, request); | |
275 | - param.setValue(1L); | |
276 | - verifyAll(); | |
277 | - } | |
278 | - | |
279 | - @Test | |
280 | - public void testSetValueIsViewScoped() { | |
281 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
282 | - | |
283 | - Map<String, Object> map = new HashMap<String, Object>(); | |
284 | - | |
285 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
286 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
287 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
288 | - expect(Faces.getViewMap()).andReturn(map); | |
289 | - | |
290 | - replayAll(); | |
291 | - param = new ParameterImpl<Long>(ip, request); | |
292 | - param.setValue(1L); | |
293 | - assertEquals(1L, map.get("name")); | |
294 | - verifyAll(); | |
295 | - } | |
296 | - | |
297 | - @Test | |
298 | - public void testSetValueElse() { | |
299 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
300 | - | |
301 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
302 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
303 | - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
304 | - | |
305 | - replayAll(); | |
306 | - param = new ParameterImpl<Long>(ip, request); | |
307 | - param.setValue(1L); | |
308 | - assertEquals(1L, Whitebox.getInternalState(param, "value")); | |
309 | - verifyAll(); | |
310 | - } | |
311 | - | |
312 | - @Test | |
313 | - public void testOthers() { | |
314 | - this.prepareForTestWithKeyFromNameAnnotation(); | |
315 | - | |
316 | - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
317 | - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | |
318 | - | |
319 | - replayAll(); | |
320 | - param = new ParameterImpl<Long>(ip, request); | |
321 | - param.setValue(1L); | |
322 | - verifyAll(); | |
323 | - } | |
324 | - | |
325 | -} | |
1 | +///* | |
2 | +// * Demoiselle Framework | |
3 | +// * Copyright (C) 2010 SERPRO | |
4 | +// * ---------------------------------------------------------------------------- | |
5 | +// * This file is part of Demoiselle Framework. | |
6 | +// * | |
7 | +// * Demoiselle Framework is free software; you can redistribute it and/or | |
8 | +// * modify it under the terms of the GNU Lesser General Public License version 3 | |
9 | +// * as published by the Free Software Foundation. | |
10 | +// * | |
11 | +// * This program is distributed in the hope that it will be useful, | |
12 | +// * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | +// * GNU General Public License for more details. | |
15 | +// * | |
16 | +// * You should have received a copy of the GNU Lesser General Public License version 3 | |
17 | +// * along with this program; if not, see <http://www.gnu.org/licenses/> | |
18 | +// * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | +// * Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | +// * ---------------------------------------------------------------------------- | |
21 | +// * Este arquivo é parte do Framework Demoiselle. | |
22 | +// * | |
23 | +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
24 | +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
25 | +// * do Software Livre (FSF). | |
26 | +// * | |
27 | +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
28 | +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
29 | +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
30 | +// * para maiores detalhes. | |
31 | +// * | |
32 | +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
33 | +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
34 | +// * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
35 | +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
36 | +// */ | |
37 | +//package br.gov.frameworkdemoiselle.internal.implementation; | |
38 | +// | |
39 | +//import static org.easymock.EasyMock.expect; | |
40 | +//import static org.junit.Assert.assertEquals; | |
41 | +//import static org.powermock.api.easymock.PowerMock.createMock; | |
42 | +//import static org.powermock.api.easymock.PowerMock.mockStatic; | |
43 | +//import static org.powermock.api.easymock.PowerMock.replayAll; | |
44 | +//import static org.powermock.api.easymock.PowerMock.verifyAll; | |
45 | +// | |
46 | +//import java.lang.reflect.Member; | |
47 | +//import java.util.HashMap; | |
48 | +//import java.util.Map; | |
49 | +// | |
50 | +//import javax.enterprise.context.RequestScoped; | |
51 | +//import javax.enterprise.context.SessionScoped; | |
52 | +//import javax.enterprise.inject.spi.Annotated; | |
53 | +//import javax.enterprise.inject.spi.InjectionPoint; | |
54 | +//import javax.faces.convert.Converter; | |
55 | +//import javax.servlet.http.HttpServletRequest; | |
56 | +//import javax.servlet.http.HttpSession; | |
57 | +// | |
58 | +//import org.easymock.EasyMock; | |
59 | +//import org.junit.Before; | |
60 | +//import org.junit.Test; | |
61 | +//import org.junit.runner.RunWith; | |
62 | +//import org.powermock.core.classloader.annotations.PrepareForTest; | |
63 | +//import org.powermock.modules.junit4.PowerMockRunner; | |
64 | +//import org.powermock.reflect.Whitebox; | |
65 | +// | |
66 | +//import br.gov.frameworkdemoiselle.annotation.Name; | |
67 | +//import br.gov.frameworkdemoiselle.annotation.ViewScoped; | |
68 | +//import br.gov.frameworkdemoiselle.util.Faces; | |
69 | +//import br.gov.frameworkdemoiselle.util.Reflections; | |
70 | +// | |
71 | +//@RunWith(PowerMockRunner.class) | |
72 | +//@PrepareForTest({ Reflections.class, Faces.class }) | |
73 | +//public class ParameterImplTest { | |
74 | +// | |
75 | +// private ParameterImpl<Long> param; | |
76 | +// | |
77 | +// private HttpServletRequest request; | |
78 | +// | |
79 | +// private InjectionPoint ip; | |
80 | +// | |
81 | +// private Converter converter; | |
82 | +// | |
83 | +// private Annotated annotated; | |
84 | +// | |
85 | +// private Name name; | |
86 | +// | |
87 | +// private HttpSession session; | |
88 | +// | |
89 | +// private Member member; | |
90 | +// | |
91 | +// @Before | |
92 | +// public void before() { | |
93 | +// ip = createMock(InjectionPoint.class); | |
94 | +// request = createMock(HttpServletRequest.class); | |
95 | +// session = createMock(HttpSession.class); | |
96 | +// annotated = createMock(Annotated.class); | |
97 | +// name = createMock(Name.class); | |
98 | +// converter = createMock(Converter.class); | |
99 | +// member = createMock(Member.class); | |
100 | +// | |
101 | +// mockStatic(Reflections.class); | |
102 | +// mockStatic(Faces.class); | |
103 | +// } | |
104 | +// | |
105 | +// private void prepareForTestWithKeyFromNameAnnotation() { | |
106 | +// expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | |
107 | +// expect(ip.getMember()).andReturn(null); | |
108 | +// expect(annotated.isAnnotationPresent(Name.class)).andReturn(true); | |
109 | +// expect(annotated.getAnnotation(Name.class)).andReturn(name); | |
110 | +// expect(name.value()).andReturn("name"); | |
111 | +// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | |
112 | +// Object.class); | |
113 | +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | |
114 | +// } | |
115 | +// | |
116 | +// @Test | |
117 | +// public void testConstructorCase1() { | |
118 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
119 | +// | |
120 | +// replayAll(); | |
121 | +// param = new ParameterImpl<Long>(ip, request); | |
122 | +// assertEquals("name", param.getKey()); | |
123 | +// assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | |
124 | +// assertEquals(converter, param.getConverter()); | |
125 | +// verifyAll(); | |
126 | +// } | |
127 | +// | |
128 | +// @Test | |
129 | +// public void testConstructorCase2() { | |
130 | +// expect(member.getName()).andReturn("memberName"); | |
131 | +// expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | |
132 | +// expect(ip.getMember()).andReturn(member).anyTimes(); | |
133 | +// expect(annotated.isAnnotationPresent(Name.class)).andReturn(false); | |
134 | +// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | |
135 | +// Object.class); | |
136 | +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | |
137 | +// | |
138 | +// replayAll(); | |
139 | +// param = new ParameterImpl<Long>(ip, request); | |
140 | +// assertEquals("memberName", param.getKey()); | |
141 | +// assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | |
142 | +// assertEquals(converter, param.getConverter()); | |
143 | +// verifyAll(); | |
144 | +// } | |
145 | +// | |
146 | +// @Test | |
147 | +// public void testGetValueWhenSessionScopedAndParameterValueNotNull() { | |
148 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
149 | +// | |
150 | +// expect(Faces.convert("1", converter)).andReturn("return"); | |
151 | +// expect(request.getSession()).andReturn(session).anyTimes(); | |
152 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
153 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
154 | +// expect(session.getAttribute("name")).andReturn("return"); | |
155 | +// | |
156 | +// session.setAttribute("name", "return"); | |
157 | +// | |
158 | +// replayAll(); | |
159 | +// param = new ParameterImpl<Long>(ip, request); | |
160 | +// assertEquals("return", param.getValue()); | |
161 | +// verifyAll(); | |
162 | +// } | |
163 | +// | |
164 | +// @Test | |
165 | +// public void testGetValueWhenSessionScopedAndParameterValueNull() { | |
166 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
167 | +// | |
168 | +// expect(request.getSession()).andReturn(session).anyTimes(); | |
169 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | |
170 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
171 | +// expect(session.getAttribute("name")).andReturn("return"); | |
172 | +// | |
173 | +// replayAll(); | |
174 | +// param = new ParameterImpl<Long>(ip, request); | |
175 | +// assertEquals("return", param.getValue()); | |
176 | +// verifyAll(); | |
177 | +// } | |
178 | +// | |
179 | +// @Test | |
180 | +// public void testGetValueWhenRequestScoped() { | |
181 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
182 | +// | |
183 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
184 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | |
185 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
186 | +// expect(Faces.convert("1", converter)).andReturn("return"); | |
187 | +// | |
188 | +// replayAll(); | |
189 | +// param = new ParameterImpl<Long>(ip, request); | |
190 | +// assertEquals("return", param.getValue()); | |
191 | +// verifyAll(); | |
192 | +// } | |
193 | +// | |
194 | +// @Test | |
195 | +// public void testGetValueWhenViewScopedWithParamValueNotNull() { | |
196 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
197 | +// Map<String, Object> map = new HashMap<String,Object>(); | |
198 | +// | |
199 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
200 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
201 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
202 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
203 | +// expect(Faces.getViewMap()).andReturn(map); | |
204 | +// expect(Faces.convert("1", converter)).andReturn("return"); | |
205 | +// | |
206 | +// replayAll(); | |
207 | +// param = new ParameterImpl<Long>(ip, request); | |
208 | +// assertEquals("return", param.getValue()); | |
209 | +// assertEquals("return", map.get("name")); | |
210 | +// verifyAll(); | |
211 | +// } | |
212 | +// | |
213 | +// @Test | |
214 | +// public void testGetValueWhenViewScopedWithParamValueNull() { | |
215 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
216 | +// Map<String, Object> map = new HashMap<String,Object>(); | |
217 | +// map.put("name", "ops"); | |
218 | +// | |
219 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
220 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
221 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
222 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | |
223 | +// expect(Faces.getViewMap()).andReturn(map); | |
224 | +// | |
225 | +// replayAll(); | |
226 | +// param = new ParameterImpl<Long>(ip, request); | |
227 | +// assertEquals("ops", param.getValue()); | |
228 | +// assertEquals("ops", map.get("name")); | |
229 | +// verifyAll(); | |
230 | +// } | |
231 | +// | |
232 | +// @Test | |
233 | +// public void testGetValueElseWithValueNull() { | |
234 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
235 | +// | |
236 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
237 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
238 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
239 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
240 | +// expect(Faces.convert("1", converter)).andReturn("return"); | |
241 | +// | |
242 | +// replayAll(); | |
243 | +// param = new ParameterImpl<Long>(ip, request); | |
244 | +// assertEquals("return", param.getValue()); | |
245 | +// verifyAll(); | |
246 | +// } | |
247 | +// | |
248 | +// @Test | |
249 | +// public void testGetValueElseWithValueNotNull() { | |
250 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
251 | +// | |
252 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
253 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
254 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
255 | +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | |
256 | +// | |
257 | +// replayAll(); | |
258 | +// param = new ParameterImpl<Long>(ip, request); | |
259 | +// Whitebox.setInternalState(param, "value", "myvalue"); | |
260 | +// assertEquals("myvalue", param.getValue()); | |
261 | +// verifyAll(); | |
262 | +// } | |
263 | +// | |
264 | +// @Test | |
265 | +// public void testSetValueIsSessionScoped() { | |
266 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
267 | +// | |
268 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | |
269 | +// expect(request.getSession()).andReturn(session); | |
270 | +// | |
271 | +// session.setAttribute("name", 1L); | |
272 | +// | |
273 | +// replayAll(); | |
274 | +// param = new ParameterImpl<Long>(ip, request); | |
275 | +// param.setValue(1L); | |
276 | +// verifyAll(); | |
277 | +// } | |
278 | +// | |
279 | +// @Test | |
280 | +// public void testSetValueIsViewScoped() { | |
281 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
282 | +// | |
283 | +// Map<String, Object> map = new HashMap<String, Object>(); | |
284 | +// | |
285 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
286 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
287 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | |
288 | +// expect(Faces.getViewMap()).andReturn(map); | |
289 | +// | |
290 | +// replayAll(); | |
291 | +// param = new ParameterImpl<Long>(ip, request); | |
292 | +// param.setValue(1L); | |
293 | +// assertEquals(1L, map.get("name")); | |
294 | +// verifyAll(); | |
295 | +// } | |
296 | +// | |
297 | +// @Test | |
298 | +// public void testSetValueElse() { | |
299 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
300 | +// | |
301 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
302 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | |
303 | +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | |
304 | +// | |
305 | +// replayAll(); | |
306 | +// param = new ParameterImpl<Long>(ip, request); | |
307 | +// param.setValue(1L); | |
308 | +// assertEquals(1L, Whitebox.getInternalState(param, "value")); | |
309 | +// verifyAll(); | |
310 | +// } | |
311 | +// | |
312 | +// @Test | |
313 | +// public void testOthers() { | |
314 | +// this.prepareForTestWithKeyFromNameAnnotation(); | |
315 | +// | |
316 | +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | |
317 | +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | |
318 | +// | |
319 | +// replayAll(); | |
320 | +// param = new ParameterImpl<Long>(ip, request); | |
321 | +// param.setValue(1L); | |
322 | +// verifyAll(); | |
323 | +// } | |
324 | +// | |
325 | +//} | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBeanTest.java
... | ... | @@ -82,7 +82,7 @@ public class AbstractEditPageBeanTest { |
82 | 82 | |
83 | 83 | @Before |
84 | 84 | public void before() { |
85 | - bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle", Locale.getDefault()); | |
85 | + bundle = ResourceBundleProducer.create("demoiselle-jsf-bundle", Locale.getDefault()); | |
86 | 86 | |
87 | 87 | pageBean = new AbstractEditPageBean<Contact, Object>() { |
88 | 88 | ... | ... |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/Contact.java
... | ... | @@ -36,13 +36,17 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.template; |
38 | 38 | |
39 | +import java.io.Serializable; | |
40 | + | |
41 | +public class Contact implements Serializable { | |
42 | + | |
43 | + private static final long serialVersionUID = 1L; | |
39 | 44 | |
40 | -public class Contact { | |
41 | 45 | private Long id; |
42 | 46 | |
43 | 47 | public Contact() { |
44 | 48 | } |
45 | - | |
49 | + | |
46 | 50 | public Contact(Long id) { |
47 | 51 | this.id = id; |
48 | 52 | } |
... | ... | @@ -54,5 +58,5 @@ public class Contact { |
54 | 58 | public Long getId() { |
55 | 59 | return id; |
56 | 60 | } |
57 | - | |
61 | + | |
58 | 62 | } | ... | ... |
impl/extension/servlet/pom.xml
... | ... | @@ -52,10 +52,12 @@ |
52 | 52 | <description /> |
53 | 53 | |
54 | 54 | <dependencies> |
55 | + <!-- | |
55 | 56 | <dependency> |
56 | 57 | <groupId>javax.servlet</groupId> |
57 | 58 | <artifactId>jstl</artifactId> |
58 | 59 | </dependency> |
60 | + --> | |
59 | 61 | <dependency> |
60 | 62 | <groupId>javax.servlet</groupId> |
61 | 63 | <artifactId>servlet-api</artifactId> | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletRequestProducer.java
... | ... | @@ -36,23 +36,27 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
38 | 38 | |
39 | +import java.io.Serializable; | |
40 | + | |
39 | 41 | import javax.enterprise.context.RequestScoped; |
40 | 42 | import javax.enterprise.inject.Default; |
41 | 43 | import javax.enterprise.inject.Produces; |
42 | 44 | import javax.servlet.http.HttpServletRequest; |
43 | 45 | |
44 | 46 | @RequestScoped |
45 | -public class HttpServletRequestProducer { | |
47 | +public class HttpServletRequestProducer implements Serializable { | |
48 | + | |
49 | + private static final long serialVersionUID = 1L; | |
46 | 50 | |
47 | - private HttpServletRequest request; | |
51 | + private transient HttpServletRequest request; | |
48 | 52 | |
49 | 53 | @Default |
50 | 54 | @Produces |
51 | 55 | public HttpServletRequest create() { |
52 | - return request; | |
56 | + return this.request; | |
53 | 57 | } |
54 | 58 | |
55 | - public void setRequest(HttpServletRequest request) { | |
59 | + public void setDelegate(HttpServletRequest request) { | |
56 | 60 | this.request = request; |
57 | 61 | } |
58 | 62 | } | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletResponseProducer.java
... | ... | @@ -36,23 +36,27 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
38 | 38 | |
39 | +import java.io.Serializable; | |
40 | + | |
39 | 41 | import javax.enterprise.context.RequestScoped; |
40 | 42 | import javax.enterprise.inject.Default; |
41 | 43 | import javax.enterprise.inject.Produces; |
42 | 44 | import javax.servlet.http.HttpServletResponse; |
43 | 45 | |
44 | 46 | @RequestScoped |
45 | -public class HttpServletResponseProducer { | |
47 | +public class HttpServletResponseProducer implements Serializable { | |
48 | + | |
49 | + private static final long serialVersionUID = 1L; | |
46 | 50 | |
47 | - private HttpServletResponse response; | |
51 | + private transient HttpServletResponse response; | |
48 | 52 | |
49 | 53 | @Default |
50 | 54 | @Produces |
51 | 55 | public HttpServletResponse create() { |
52 | - return response; | |
56 | + return this.response; | |
53 | 57 | } |
54 | 58 | |
55 | - public void setResponse(HttpServletResponse response) { | |
59 | + public void setDelegate(HttpServletResponse response) { | |
56 | 60 | this.response = response; |
57 | 61 | } |
58 | 62 | } | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/producer/HttpSessionProducer.java
... | ... | @@ -36,18 +36,20 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
38 | 38 | |
39 | -import javax.enterprise.context.SessionScoped; | |
39 | +import java.io.Serializable; | |
40 | + | |
40 | 41 | import javax.enterprise.inject.Default; |
41 | 42 | import javax.enterprise.inject.Produces; |
42 | 43 | import javax.servlet.http.HttpServletRequest; |
43 | 44 | import javax.servlet.http.HttpSession; |
44 | 45 | |
45 | -public class HttpSessionProducer { | |
46 | +public class HttpSessionProducer implements Serializable { | |
47 | + | |
48 | + private static final long serialVersionUID = 1L; | |
46 | 49 | |
47 | - @Produces | |
48 | 50 | @Default |
49 | - @SessionScoped | |
50 | - public HttpSession create(final HttpServletRequest request) { | |
51 | - return request.getSession(); | |
51 | + @Produces | |
52 | + public HttpSession create(HttpServletRequest request) { | |
53 | + return request != null ? request.getSession() : null; | |
52 | 54 | } |
53 | 55 | } | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ServletLocaleProducer.java
... | ... | @@ -36,21 +36,20 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
38 | 38 | |
39 | +import java.io.Serializable; | |
39 | 40 | import java.util.Locale; |
40 | 41 | |
41 | 42 | import javax.enterprise.inject.Default; |
42 | 43 | import javax.enterprise.inject.Produces; |
43 | -import javax.inject.Inject; | |
44 | 44 | import javax.servlet.http.HttpServletRequest; |
45 | 45 | |
46 | -public class ServletLocaleProducer { | |
46 | +public class ServletLocaleProducer implements Serializable { | |
47 | 47 | |
48 | - @Inject | |
49 | - private HttpServletRequest request; | |
48 | + private static final long serialVersionUID = 1L; | |
50 | 49 | |
51 | - @Produces | |
52 | 50 | @Default |
53 | - public Locale create() { | |
51 | + @Produces | |
52 | + public Locale create(HttpServletRequest request) { | |
54 | 53 | Locale result; |
55 | 54 | |
56 | 55 | if (request == null) { | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/HttpServletRequestProxy.java
0 → 100644
... | ... | @@ -0,0 +1,307 @@ |
1 | +//package br.gov.frameworkdemoiselle.internal.proxy; | |
2 | +// | |
3 | +//import java.io.BufferedReader; | |
4 | +//import java.io.IOException; | |
5 | +//import java.io.Serializable; | |
6 | +//import java.io.UnsupportedEncodingException; | |
7 | +//import java.security.Principal; | |
8 | +//import java.util.Enumeration; | |
9 | +//import java.util.Locale; | |
10 | +//import java.util.Map; | |
11 | +// | |
12 | +//import javax.enterprise.context.RequestScoped; | |
13 | +//import javax.enterprise.inject.Default; | |
14 | +//import javax.servlet.RequestDispatcher; | |
15 | +//import javax.servlet.ServletInputStream; | |
16 | +//import javax.servlet.http.Cookie; | |
17 | +//import javax.servlet.http.HttpServletRequest; | |
18 | +//import javax.servlet.http.HttpSession; | |
19 | +// | |
20 | +//@Default | |
21 | +//@RequestScoped | |
22 | +//public class HttpServletRequestProxy implements HttpServletRequest, Serializable { | |
23 | +// | |
24 | +// private static final long serialVersionUID = 1L; | |
25 | +// | |
26 | +// private transient HttpServletRequest delegate; | |
27 | +// | |
28 | +// public HttpServletRequestProxy(HttpServletRequest delegate) { | |
29 | +// this.delegate = delegate; | |
30 | +// } | |
31 | +// | |
32 | +// private HttpServletRequest getDelegate() { | |
33 | +// return delegate; | |
34 | +// } | |
35 | +// | |
36 | +// @Override | |
37 | +// public Object getAttribute(String name) { | |
38 | +// return getDelegate().getAttribute(name); | |
39 | +// } | |
40 | +// | |
41 | +// @Override | |
42 | +// public Enumeration<?> getAttributeNames() { | |
43 | +// return getDelegate().getAttributeNames(); | |
44 | +// } | |
45 | +// | |
46 | +// @Override | |
47 | +// public String getCharacterEncoding() { | |
48 | +// return getDelegate().getCharacterEncoding(); | |
49 | +// } | |
50 | +// | |
51 | +// @Override | |
52 | +// public void setCharacterEncoding(String env) throws UnsupportedEncodingException { | |
53 | +// getDelegate().setCharacterEncoding(env); | |
54 | +// } | |
55 | +// | |
56 | +// @Override | |
57 | +// public int getContentLength() { | |
58 | +// return getDelegate().getContentLength(); | |
59 | +// } | |
60 | +// | |
61 | +// @Override | |
62 | +// public String getContentType() { | |
63 | +// return getDelegate().getContentType(); | |
64 | +// } | |
65 | +// | |
66 | +// @Override | |
67 | +// public ServletInputStream getInputStream() throws IOException { | |
68 | +// return getDelegate().getInputStream(); | |
69 | +// } | |
70 | +// | |
71 | +// @Override | |
72 | +// public String getParameter(String name) { | |
73 | +// return getDelegate().getParameter(name); | |
74 | +// } | |
75 | +// | |
76 | +// @Override | |
77 | +// public Enumeration<?> getParameterNames() { | |
78 | +// return getDelegate().getParameterNames(); | |
79 | +// } | |
80 | +// | |
81 | +// @Override | |
82 | +// public String[] getParameterValues(String name) { | |
83 | +// return getDelegate().getParameterValues(name); | |
84 | +// } | |
85 | +// | |
86 | +// @Override | |
87 | +// public Map<?, ?> getParameterMap() { | |
88 | +// return getDelegate().getParameterMap(); | |
89 | +// } | |
90 | +// | |
91 | +// @Override | |
92 | +// public String getProtocol() { | |
93 | +// return getDelegate().getProtocol(); | |
94 | +// } | |
95 | +// | |
96 | +// @Override | |
97 | +// public String getScheme() { | |
98 | +// return getDelegate().getScheme(); | |
99 | +// } | |
100 | +// | |
101 | +// @Override | |
102 | +// public String getServerName() { | |
103 | +// return getDelegate().getServerName(); | |
104 | +// } | |
105 | +// | |
106 | +// @Override | |
107 | +// public int getServerPort() { | |
108 | +// return getDelegate().getServerPort(); | |
109 | +// } | |
110 | +// | |
111 | +// @Override | |
112 | +// public BufferedReader getReader() throws IOException { | |
113 | +// return getDelegate().getReader(); | |
114 | +// } | |
115 | +// | |
116 | +// @Override | |
117 | +// public String getRemoteAddr() { | |
118 | +// return getDelegate().getRemoteAddr(); | |
119 | +// } | |
120 | +// | |
121 | +// @Override | |
122 | +// public String getRemoteHost() { | |
123 | +// return getDelegate().getRemoteHost(); | |
124 | +// } | |
125 | +// | |
126 | +// @Override | |
127 | +// public void setAttribute(String name, Object o) { | |
128 | +// getDelegate().setAttribute(name, o); | |
129 | +// } | |
130 | +// | |
131 | +// @Override | |
132 | +// public void removeAttribute(String name) { | |
133 | +// getDelegate().removeAttribute(name); | |
134 | +// } | |
135 | +// | |
136 | +// @Override | |
137 | +// public Locale getLocale() { | |
138 | +// return getDelegate().getLocale(); | |
139 | +// } | |
140 | +// | |
141 | +// @Override | |
142 | +// public Enumeration<?> getLocales() { | |
143 | +// return getDelegate().getLocales(); | |
144 | +// } | |
145 | +// | |
146 | +// @Override | |
147 | +// public boolean isSecure() { | |
148 | +// return getDelegate().isSecure(); | |
149 | +// } | |
150 | +// | |
151 | +// @Override | |
152 | +// public RequestDispatcher getRequestDispatcher(String path) { | |
153 | +// return getDelegate().getRequestDispatcher(path); | |
154 | +// } | |
155 | +// | |
156 | +// @Override | |
157 | +// @Deprecated | |
158 | +// public String getRealPath(String path) { | |
159 | +// return getDelegate().getRealPath(path); | |
160 | +// } | |
161 | +// | |
162 | +// @Override | |
163 | +// public int getRemotePort() { | |
164 | +// return getDelegate().getRemotePort(); | |
165 | +// } | |
166 | +// | |
167 | +// @Override | |
168 | +// public String getLocalName() { | |
169 | +// return getDelegate().getLocalName(); | |
170 | +// } | |
171 | +// | |
172 | +// @Override | |
173 | +// public String getLocalAddr() { | |
174 | +// return getDelegate().getLocalAddr(); | |
175 | +// } | |
176 | +// | |
177 | +// @Override | |
178 | +// public int getLocalPort() { | |
179 | +// return getDelegate().getLocalPort(); | |
180 | +// } | |
181 | +// | |
182 | +// @Override | |
183 | +// public String getAuthType() { | |
184 | +// return getDelegate().getAuthType(); | |
185 | +// } | |
186 | +// | |
187 | +// @Override | |
188 | +// public Cookie[] getCookies() { | |
189 | +// return getDelegate().getCookies(); | |
190 | +// } | |
191 | +// | |
192 | +// @Override | |
193 | +// public long getDateHeader(String name) { | |
194 | +// return getDelegate().getDateHeader(name); | |
195 | +// } | |
196 | +// | |
197 | +// @Override | |
198 | +// public String getHeader(String name) { | |
199 | +// return getDelegate().getHeader(name); | |
200 | +// } | |
201 | +// | |
202 | +// @Override | |
203 | +// public Enumeration<?> getHeaders(String name) { | |
204 | +// return getDelegate().getHeaders(name); | |
205 | +// } | |
206 | +// | |
207 | +// @Override | |
208 | +// public Enumeration<?> getHeaderNames() { | |
209 | +// return getDelegate().getHeaderNames(); | |
210 | +// } | |
211 | +// | |
212 | +// @Override | |
213 | +// public int getIntHeader(String name) { | |
214 | +// return getDelegate().getIntHeader(name); | |
215 | +// } | |
216 | +// | |
217 | +// @Override | |
218 | +// public String getMethod() { | |
219 | +// return getDelegate().getMethod(); | |
220 | +// } | |
221 | +// | |
222 | +// @Override | |
223 | +// public String getPathInfo() { | |
224 | +// return getDelegate().getPathInfo(); | |
225 | +// } | |
226 | +// | |
227 | +// @Override | |
228 | +// public String getPathTranslated() { | |
229 | +// return getDelegate().getPathTranslated(); | |
230 | +// } | |
231 | +// | |
232 | +// @Override | |
233 | +// public String getContextPath() { | |
234 | +// return getDelegate().getContextPath(); | |
235 | +// } | |
236 | +// | |
237 | +// @Override | |
238 | +// public String getQueryString() { | |
239 | +// return getDelegate().getQueryString(); | |
240 | +// } | |
241 | +// | |
242 | +// @Override | |
243 | +// public String getRemoteUser() { | |
244 | +// return getDelegate().getRemoteUser(); | |
245 | +// } | |
246 | +// | |
247 | +// @Override | |
248 | +// public boolean isUserInRole(String role) { | |
249 | +// return getDelegate().isUserInRole(role); | |
250 | +// } | |
251 | +// | |
252 | +// @Override | |
253 | +// public Principal getUserPrincipal() { | |
254 | +// return getDelegate().getUserPrincipal(); | |
255 | +// } | |
256 | +// | |
257 | +// @Override | |
258 | +// public String getRequestedSessionId() { | |
259 | +// return getDelegate().getRequestedSessionId(); | |
260 | +// } | |
261 | +// | |
262 | +// @Override | |
263 | +// public String getRequestURI() { | |
264 | +// return getDelegate().getRequestURI(); | |
265 | +// } | |
266 | +// | |
267 | +// @Override | |
268 | +// public StringBuffer getRequestURL() { | |
269 | +// return getDelegate().getRequestURL(); | |
270 | +// } | |
271 | +// | |
272 | +// @Override | |
273 | +// public String getServletPath() { | |
274 | +// return getDelegate().getServletPath(); | |
275 | +// } | |
276 | +// | |
277 | +// @Override | |
278 | +// public HttpSession getSession(boolean create) { | |
279 | +// return getDelegate().getSession(create); | |
280 | +// } | |
281 | +// | |
282 | +// @Override | |
283 | +// public HttpSession getSession() { | |
284 | +// return getDelegate().getSession(); | |
285 | +// } | |
286 | +// | |
287 | +// @Override | |
288 | +// public boolean isRequestedSessionIdValid() { | |
289 | +// return getDelegate().isRequestedSessionIdValid(); | |
290 | +// } | |
291 | +// | |
292 | +// @Override | |
293 | +// public boolean isRequestedSessionIdFromCookie() { | |
294 | +// return getDelegate().isRequestedSessionIdFromCookie(); | |
295 | +// } | |
296 | +// | |
297 | +// @Override | |
298 | +// public boolean isRequestedSessionIdFromURL() { | |
299 | +// return getDelegate().isRequestedSessionIdFromURL(); | |
300 | +// } | |
301 | +// | |
302 | +// @Override | |
303 | +// @Deprecated | |
304 | +// public boolean isRequestedSessionIdFromUrl() { | |
305 | +// return getDelegate().isRequestedSessionIdFromUrl(); | |
306 | +// } | |
307 | +//} | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/HttpServletResponseProxy.java
0 → 100644
... | ... | @@ -0,0 +1,192 @@ |
1 | +//package br.gov.frameworkdemoiselle.internal.proxy; | |
2 | +// | |
3 | +//import java.io.IOException; | |
4 | +//import java.io.PrintWriter; | |
5 | +//import java.io.Serializable; | |
6 | +//import java.util.Locale; | |
7 | +// | |
8 | +//import javax.enterprise.context.RequestScoped; | |
9 | +//import javax.enterprise.inject.Default; | |
10 | +//import javax.servlet.ServletOutputStream; | |
11 | +//import javax.servlet.http.Cookie; | |
12 | +//import javax.servlet.http.HttpServletResponse; | |
13 | +// | |
14 | +//@Default | |
15 | +//@RequestScoped | |
16 | +//public class HttpServletResponseProxy implements HttpServletResponse, Serializable { | |
17 | +// | |
18 | +// private static final long serialVersionUID = 1L; | |
19 | +// | |
20 | +// private transient HttpServletResponse delegate; | |
21 | +// | |
22 | +// public HttpServletResponseProxy(HttpServletResponse delegate) { | |
23 | +// this.delegate = delegate; | |
24 | +// } | |
25 | +// | |
26 | +// private HttpServletResponse getDelegate() { | |
27 | +// return delegate; | |
28 | +// } | |
29 | +// | |
30 | +// @Override | |
31 | +// public String getCharacterEncoding() { | |
32 | +// return getDelegate().getCharacterEncoding(); | |
33 | +// } | |
34 | +// | |
35 | +// @Override | |
36 | +// public String getContentType() { | |
37 | +// return getDelegate().getContentType(); | |
38 | +// } | |
39 | +// | |
40 | +// @Override | |
41 | +// public ServletOutputStream getOutputStream() throws IOException { | |
42 | +// return getDelegate().getOutputStream(); | |
43 | +// } | |
44 | +// | |
45 | +// @Override | |
46 | +// public PrintWriter getWriter() throws IOException { | |
47 | +// return getDelegate().getWriter(); | |
48 | +// } | |
49 | +// | |
50 | +// @Override | |
51 | +// public void setCharacterEncoding(String charset) { | |
52 | +// getDelegate().setCharacterEncoding(charset); | |
53 | +// } | |
54 | +// | |
55 | +// @Override | |
56 | +// public void setContentLength(int len) { | |
57 | +// getDelegate().setContentLength(len); | |
58 | +// } | |
59 | +// | |
60 | +// @Override | |
61 | +// public void setContentType(String type) { | |
62 | +// getDelegate().setContentType(type); | |
63 | +// } | |
64 | +// | |
65 | +// @Override | |
66 | +// public void setBufferSize(int size) { | |
67 | +// getDelegate().setBufferSize(size); | |
68 | +// } | |
69 | +// | |
70 | +// @Override | |
71 | +// public int getBufferSize() { | |
72 | +// return getDelegate().getBufferSize(); | |
73 | +// } | |
74 | +// | |
75 | +// @Override | |
76 | +// public void flushBuffer() throws IOException { | |
77 | +// getDelegate().flushBuffer(); | |
78 | +// } | |
79 | +// | |
80 | +// @Override | |
81 | +// public void resetBuffer() { | |
82 | +// getDelegate().resetBuffer(); | |
83 | +// } | |
84 | +// | |
85 | +// @Override | |
86 | +// public boolean isCommitted() { | |
87 | +// return getDelegate().isCommitted(); | |
88 | +// } | |
89 | +// | |
90 | +// @Override | |
91 | +// public void reset() { | |
92 | +// getDelegate().reset(); | |
93 | +// } | |
94 | +// | |
95 | +// @Override | |
96 | +// public void setLocale(Locale loc) { | |
97 | +// getDelegate().setLocale(loc); | |
98 | +// } | |
99 | +// | |
100 | +// @Override | |
101 | +// public Locale getLocale() { | |
102 | +// return getDelegate().getLocale(); | |
103 | +// } | |
104 | +// | |
105 | +// @Override | |
106 | +// public void addCookie(Cookie cookie) { | |
107 | +// getDelegate().addCookie(cookie); | |
108 | +// } | |
109 | +// | |
110 | +// @Override | |
111 | +// public boolean containsHeader(String name) { | |
112 | +// return getDelegate().containsHeader(name); | |
113 | +// } | |
114 | +// | |
115 | +// @Override | |
116 | +// public String encodeURL(String url) { | |
117 | +// return getDelegate().encodeURL(url); | |
118 | +// } | |
119 | +// | |
120 | +// @Override | |
121 | +// public String encodeRedirectURL(String url) { | |
122 | +// return getDelegate().encodeRedirectURL(url); | |
123 | +// } | |
124 | +// | |
125 | +// @Override | |
126 | +// @Deprecated | |
127 | +// public String encodeUrl(String url) { | |
128 | +// return getDelegate().encodeUrl(url); | |
129 | +// } | |
130 | +// | |
131 | +// @Override | |
132 | +// @Deprecated | |
133 | +// public String encodeRedirectUrl(String url) { | |
134 | +// return getDelegate().encodeRedirectUrl(url); | |
135 | +// } | |
136 | +// | |
137 | +// @Override | |
138 | +// public void sendError(int sc, String msg) throws IOException { | |
139 | +// getDelegate().sendError(sc, msg); | |
140 | +// } | |
141 | +// | |
142 | +// @Override | |
143 | +// public void sendError(int sc) throws IOException { | |
144 | +// getDelegate().sendError(sc); | |
145 | +// } | |
146 | +// | |
147 | +// @Override | |
148 | +// public void sendRedirect(String location) throws IOException { | |
149 | +// getDelegate().sendRedirect(location); | |
150 | +// } | |
151 | +// | |
152 | +// @Override | |
153 | +// public void setDateHeader(String name, long date) { | |
154 | +// getDelegate().setDateHeader(name, date); | |
155 | +// } | |
156 | +// | |
157 | +// @Override | |
158 | +// public void addDateHeader(String name, long date) { | |
159 | +// getDelegate().addDateHeader(name, date); | |
160 | +// } | |
161 | +// | |
162 | +// @Override | |
163 | +// public void setHeader(String name, String value) { | |
164 | +// getDelegate().setHeader(name, value); | |
165 | +// } | |
166 | +// | |
167 | +// @Override | |
168 | +// public void addHeader(String name, String value) { | |
169 | +// getDelegate().addHeader(name, value); | |
170 | +// } | |
171 | +// | |
172 | +// @Override | |
173 | +// public void setIntHeader(String name, int value) { | |
174 | +// getDelegate().setIntHeader(name, value); | |
175 | +// } | |
176 | +// | |
177 | +// @Override | |
178 | +// public void addIntHeader(String name, int value) { | |
179 | +// getDelegate().addIntHeader(name, value); | |
180 | +// } | |
181 | +// | |
182 | +// @Override | |
183 | +// public void setStatus(int sc) { | |
184 | +// getDelegate().setStatus(sc); | |
185 | +// } | |
186 | +// | |
187 | +// @Override | |
188 | +// @Deprecated | |
189 | +// public void setStatus(int sc, String sm) { | |
190 | +// getDelegate().setStatus(sc, sm); | |
191 | +// } | |
192 | +//} | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/HttpSessionProxy.java
0 → 100644
... | ... | @@ -0,0 +1,118 @@ |
1 | +//package br.gov.frameworkdemoiselle.internal.proxy; | |
2 | +// | |
3 | +//import java.io.Serializable; | |
4 | +//import java.util.Enumeration; | |
5 | +// | |
6 | +//import javax.enterprise.context.SessionScoped; | |
7 | +//import javax.enterprise.inject.Default; | |
8 | +//import javax.servlet.ServletContext; | |
9 | +//import javax.servlet.http.HttpSession; | |
10 | +//import javax.servlet.http.HttpSessionContext; | |
11 | +// | |
12 | +//@Default | |
13 | +//@SessionScoped | |
14 | +//@SuppressWarnings("deprecation") | |
15 | +//public class HttpSessionProxy implements HttpSession, Serializable { | |
16 | +// | |
17 | +// private static final long serialVersionUID = 1L; | |
18 | +// | |
19 | +// private transient HttpSession delegate; | |
20 | +// | |
21 | +// public HttpSessionProxy(HttpSession delegate) { | |
22 | +// this.delegate = delegate; | |
23 | +// } | |
24 | +// | |
25 | +// private HttpSession getDelegate() { | |
26 | +// return delegate; | |
27 | +// } | |
28 | +// | |
29 | +// @Override | |
30 | +// public long getCreationTime() { | |
31 | +// return getDelegate().getCreationTime(); | |
32 | +// } | |
33 | +// | |
34 | +// @Override | |
35 | +// public String getId() { | |
36 | +// return getDelegate().getId(); | |
37 | +// } | |
38 | +// | |
39 | +// @Override | |
40 | +// public long getLastAccessedTime() { | |
41 | +// return getDelegate().getLastAccessedTime(); | |
42 | +// } | |
43 | +// | |
44 | +// @Override | |
45 | +// public ServletContext getServletContext() { | |
46 | +// return getDelegate().getServletContext(); | |
47 | +// } | |
48 | +// | |
49 | +// @Override | |
50 | +// public void setMaxInactiveInterval(int interval) { | |
51 | +// getDelegate().setMaxInactiveInterval(interval); | |
52 | +// } | |
53 | +// | |
54 | +// @Override | |
55 | +// public int getMaxInactiveInterval() { | |
56 | +// return getDelegate().getMaxInactiveInterval(); | |
57 | +// } | |
58 | +// | |
59 | +// @Override | |
60 | +// @Deprecated | |
61 | +// public HttpSessionContext getSessionContext() { | |
62 | +// return getDelegate().getSessionContext(); | |
63 | +// } | |
64 | +// | |
65 | +// @Override | |
66 | +// public Object getAttribute(String name) { | |
67 | +// return getDelegate().getAttribute(name); | |
68 | +// } | |
69 | +// | |
70 | +// @Override | |
71 | +// @Deprecated | |
72 | +// public Object getValue(String name) { | |
73 | +// return getDelegate().getValue(name); | |
74 | +// } | |
75 | +// | |
76 | +// @Override | |
77 | +// public Enumeration<?> getAttributeNames() { | |
78 | +// return getDelegate().getAttributeNames(); | |
79 | +// } | |
80 | +// | |
81 | +// @Override | |
82 | +// @Deprecated | |
83 | +// public String[] getValueNames() { | |
84 | +// return getDelegate().getValueNames(); | |
85 | +// } | |
86 | +// | |
87 | +// @Override | |
88 | +// public void setAttribute(String name, Object value) { | |
89 | +// getDelegate().setAttribute(name, value); | |
90 | +// } | |
91 | +// | |
92 | +// @Override | |
93 | +// @Deprecated | |
94 | +// public void putValue(String name, Object value) { | |
95 | +// getDelegate().putValue(name, value); | |
96 | +// } | |
97 | +// | |
98 | +// @Override | |
99 | +// public void removeAttribute(String name) { | |
100 | +// getDelegate().removeAttribute(name); | |
101 | +// } | |
102 | +// | |
103 | +// @Override | |
104 | +// @Deprecated | |
105 | +// public void removeValue(String name) { | |
106 | +// getDelegate().removeValue(name); | |
107 | +// } | |
108 | +// | |
109 | +// @Override | |
110 | +// public void invalidate() { | |
111 | +// getDelegate().invalidate(); | |
112 | +// } | |
113 | +// | |
114 | +// @Override | |
115 | +// public boolean isNew() { | |
116 | +// return getDelegate().isNew(); | |
117 | +// } | |
118 | +//} | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/ServletFilter.java
... | ... | @@ -60,12 +60,9 @@ public class ServletFilter implements Filter { |
60 | 60 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, |
61 | 61 | ServletException { |
62 | 62 | |
63 | - HttpServletRequestProducer requestProducer = Beans.getReference(HttpServletRequestProducer.class); | |
64 | - requestProducer.setRequest((HttpServletRequest) request); | |
65 | - | |
66 | - HttpServletResponseProducer responseProducer = Beans.getReference(HttpServletResponseProducer.class); | |
67 | - responseProducer.setResponse((HttpServletResponse) response); | |
68 | - | |
63 | + Beans.getReference(HttpServletRequestProducer.class).setDelegate((HttpServletRequest) request); | |
64 | + Beans.getReference(HttpServletResponseProducer.class).setDelegate((HttpServletResponse) response); | |
65 | + | |
69 | 66 | chain.doFilter(request, response); |
70 | 67 | } |
71 | 68 | ... | ... |
parent/extension/pom.xml
parent/framework/pom.xml
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <parent> |
10 | 10 | <groupId>br.gov.frameworkdemoiselle</groupId> |
11 | 11 | <artifactId>demoiselle-parent</artifactId> |
12 | - <version>4</version> | |
12 | + <version>5-SNAPSHOT</version> | |
13 | 13 | <relativePath>../../../internal/parent/demoiselle/pom.xml</relativePath> |
14 | 14 | </parent> |
15 | 15 | ... | ... |
parent/jsf/pom.xml
... | ... | @@ -34,7 +34,8 @@ |
34 | 34 | ou escreva para a Fundação do Software Livre (FSF) Inc., |
35 | 35 | 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
36 | 36 | --> |
37 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
37 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
38 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
38 | 39 | |
39 | 40 | <modelVersion>4.0.0</modelVersion> |
40 | 41 | |
... | ... | @@ -54,17 +55,37 @@ |
54 | 55 | utilizam o framework. |
55 | 56 | </description> |
56 | 57 | |
58 | + <build> | |
59 | + <plugins> | |
60 | + <plugin> | |
61 | + <groupId>org.apache.maven.plugins</groupId> | |
62 | + <artifactId>maven-war-plugin</artifactId> | |
63 | + <configuration> | |
64 | + <webResources> | |
65 | + <resource> | |
66 | + <directory>src/main/webapp/WEB-INF</directory> | |
67 | + <targetPath>WEB-INF</targetPath> | |
68 | + <filtering>true</filtering> | |
69 | + </resource> | |
70 | + </webResources> | |
71 | + </configuration> | |
72 | + </plugin> | |
73 | + </plugins> | |
74 | + </build> | |
75 | + | |
57 | 76 | <dependencies> |
58 | 77 | <dependency> |
59 | 78 | <groupId>br.gov.frameworkdemoiselle</groupId> |
60 | 79 | <artifactId>demoiselle-jsf</artifactId> |
61 | 80 | <scope>compile</scope> |
62 | 81 | </dependency> |
82 | + <!-- | |
63 | 83 | <dependency> |
64 | 84 | <groupId>javax.el</groupId> |
65 | 85 | <artifactId>el-api</artifactId> |
66 | 86 | <scope>provided</scope> |
67 | 87 | </dependency> |
88 | + --> | |
68 | 89 | </dependencies> |
69 | 90 | |
70 | 91 | <dependencyManagement> |
... | ... | @@ -99,6 +120,11 @@ |
99 | 120 | <scope>runtime</scope> |
100 | 121 | </dependency> |
101 | 122 | <dependency> |
123 | + <groupId>com.sun.faces</groupId> | |
124 | + <artifactId>jsf-impl</artifactId> | |
125 | + <scope>runtime</scope> | |
126 | + </dependency> | |
127 | + <dependency> | |
102 | 128 | <groupId>org.eclipse.persistence</groupId> |
103 | 129 | <artifactId>eclipselink</artifactId> |
104 | 130 | <scope>runtime</scope> |
... | ... | @@ -150,6 +176,11 @@ |
150 | 176 | <scope>runtime</scope> |
151 | 177 | </dependency> |
152 | 178 | <dependency> |
179 | + <groupId>com.sun.faces</groupId> | |
180 | + <artifactId>jsf-impl</artifactId> | |
181 | + <scope>runtime</scope> | |
182 | + </dependency> | |
183 | + <dependency> | |
153 | 184 | <groupId>org.eclipse.persistence</groupId> |
154 | 185 | <artifactId>eclipselink</artifactId> |
155 | 186 | <scope>runtime</scope> |
... | ... | @@ -172,6 +203,62 @@ |
172 | 203 | </dependencies> |
173 | 204 | </profile> |
174 | 205 | <profile> |
206 | + <id>gae</id> | |
207 | + <build> | |
208 | + <plugins> | |
209 | + <plugin> | |
210 | + <groupId>net.kindleit</groupId> | |
211 | + <artifactId>maven-gae-plugin</artifactId> | |
212 | + <version>${kindleit.plugin.version}</version> | |
213 | + <configuration> | |
214 | + <serverId>appengine.google.com</serverId> | |
215 | + </configuration> | |
216 | + </plugin> | |
217 | + </plugins> | |
218 | + </build> | |
219 | + <dependencies> | |
220 | + <dependency> | |
221 | + <groupId>javax.servlet</groupId> | |
222 | + <artifactId>servlet-api</artifactId> | |
223 | + <scope>provided</scope> | |
224 | + </dependency> | |
225 | + <dependency> | |
226 | + <groupId>org.jboss.weld</groupId> | |
227 | + <artifactId>weld-core</artifactId> | |
228 | + <scope>runtime</scope> | |
229 | + </dependency> | |
230 | + <dependency> | |
231 | + <groupId>org.jboss.weld.servlet</groupId> | |
232 | + <artifactId>weld-servlet-core</artifactId> | |
233 | + <scope>runtime</scope> | |
234 | + </dependency> | |
235 | + <dependency> | |
236 | + <groupId>com.sun.faces</groupId> | |
237 | + <artifactId>jsf-impl</artifactId> | |
238 | + <scope>runtime</scope> | |
239 | + </dependency> | |
240 | + <dependency> | |
241 | + <groupId>org.hibernate</groupId> | |
242 | + <artifactId>hibernate-validator</artifactId> | |
243 | + <scope>runtime</scope> | |
244 | + </dependency> | |
245 | + <dependency> | |
246 | + <groupId>org.slf4j</groupId> | |
247 | + <artifactId>slf4j-log4j12</artifactId> | |
248 | + <scope>runtime</scope> | |
249 | + </dependency> | |
250 | + <dependency> | |
251 | + <groupId>com.google.appengine</groupId> | |
252 | + <artifactId>appengine-api-1.0-sdk</artifactId> | |
253 | + <version>${gae.version}</version> | |
254 | + </dependency> | |
255 | + </dependencies> | |
256 | + <properties> | |
257 | + <gae.version>1.7.0</gae.version> | |
258 | + <kindleit.plugin.version>0.9.4</kindleit.plugin.version> | |
259 | + </properties> | |
260 | + </profile> | |
261 | + <profile> | |
175 | 262 | <id>glassfish3</id> |
176 | 263 | <dependencies> |
177 | 264 | <dependency> |
... | ... | @@ -298,11 +385,6 @@ |
298 | 385 | <scope>provided</scope> |
299 | 386 | </dependency> |
300 | 387 | <dependency> |
301 | - <groupId>com.sun.faces</groupId> | |
302 | - <artifactId>jsf-impl</artifactId> | |
303 | - <scope>provided</scope> | |
304 | - </dependency> | |
305 | - <dependency> | |
306 | 388 | <groupId>hsqldb</groupId> |
307 | 389 | <artifactId>hsqldb</artifactId> |
308 | 390 | <scope>provided</scope> |
... | ... | @@ -373,11 +455,6 @@ |
373 | 455 | <scope>provided</scope> |
374 | 456 | </dependency> |
375 | 457 | <dependency> |
376 | - <groupId>com.sun.faces</groupId> | |
377 | - <artifactId>jsf-impl</artifactId> | |
378 | - <scope>provided</scope> | |
379 | - </dependency> | |
380 | - <dependency> | |
381 | 458 | <groupId>hsqldb</groupId> |
382 | 459 | <artifactId>hsqldb</artifactId> |
383 | 460 | <scope>provided</scope> | ... | ... |