Commit 750b7bea9c16a22eb1b933b865196d312cdc0fd1

Authored by Cleverson Sacramento
1 parent 6819fe58
Exists in master

Configurando os testes das extensões com JBoss AS7

Showing 60 changed files with 3481 additions and 4084 deletions   Show diff stats
impl/core/pom.xml
@@ -76,6 +76,13 @@ @@ -76,6 +76,13 @@
76 <scope>import</scope> 76 <scope>import</scope>
77 <type>pom</type> 77 <type>pom</type>
78 </dependency> 78 </dependency>
  79 + <dependency>
  80 + <groupId>org.jboss.arquillian</groupId>
  81 + <artifactId>arquillian-bom</artifactId>
  82 + <version>${arquillian.bom.version}</version>
  83 + <scope>import</scope>
  84 + <type>pom</type>
  85 + </dependency>
79 </dependencies> 86 </dependencies>
80 </dependencyManagement> 87 </dependencyManagement>
81 88
@@ -189,6 +196,7 @@ @@ -189,6 +196,7 @@
189 <dependency> 196 <dependency>
190 <groupId>org.jboss.arquillian.container</groupId> 197 <groupId>org.jboss.arquillian.container</groupId>
191 <artifactId>arquillian-weld-se-embedded-1.1</artifactId> 198 <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
  199 + <version>${arquillian.weld.version}</version>
192 <scope>test</scope> 200 <scope>test</scope>
193 </dependency> 201 </dependency>
194 <dependency> 202 <dependency>
@@ -268,6 +276,9 @@ @@ -268,6 +276,9 @@
268 </repositories> 276 </repositories>
269 277
270 <properties> 278 <properties>
  279 + <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
  280 + <arquillian.weld.version>1.0.0.CR7</arquillian.weld.version>
  281 +
271 <!-- <jacoco.version>0.6.0.201210061924</jacoco.version> --> 282 <!-- <jacoco.version>0.6.0.201210061924</jacoco.version> -->
272 <demoiselle.validation.version>2.4.0-BETA2-SNAPSHOT</demoiselle.validation.version> 283 <demoiselle.validation.version>2.4.0-BETA2-SNAPSHOT</demoiselle.validation.version>
273 </properties> 284 </properties>
impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java
@@ -59,22 +59,20 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; @@ -59,22 +59,20 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle;
59 59
60 /** 60 /**
61 * <p> 61 * <p>
62 - * Intercepts some thrown exceptions, and calls the appropriate method. These interceptor works only in  
63 - * classes annotated with <b>@Contoller</b>. Above we discribe which kind of exception is intercepted and  
64 - * what is an appropriate method. 62 + * Intercepts some thrown exceptions, and calls the appropriate method. These interceptor works only in classes
  63 + * annotated with <b>@Contoller</b>. Above we discribe which kind of exception is intercepted and what is an appropriate
  64 + * method.
65 * <p> 65 * <p>
66 - * To be interceptable, the thrown exception must be from a type which is annotated with  
67 - * <b>@ApplicationException</b>. 66 + * To be interceptable, the thrown exception must be from a type which is annotated with <b>@ApplicationException</b>.
68 * <p> 67 * <p>
69 - * An appropriate method must be annotated with <b>@ExceptionHandler</b>, and receive as parameter some  
70 - * exception that could be thrown for it's class (which have to be annotated with <b>@ApplicationException</b>).  
71 - * So, when this method is called, it's receive the thrown exception as parameter. In the same class shouldn't  
72 - * be more than one method annotated with <b>@ExceptionHandler</b> and receiving the same type of exception. 68 + * An appropriate method must be annotated with <b>@ExceptionHandler</b>, and receive as parameter some exception that
  69 + * could be thrown for it's class (which have to be annotated with <b>@ApplicationException</b>). So, when this method
  70 + * is called, it's receive the thrown exception as parameter. In the same class shouldn't be more than one method
  71 + * annotated with <b>@ExceptionHandler</b> and receiving the same type of exception.
73 * <p> 72 * <p>
74 * <p> 73 * <p>
75 * The examples below shows how these interceptor works: 74 * The examples below shows how these interceptor works:
76 * <p> 75 * <p>
77 - *  
78 * <blockquote> 76 * <blockquote>
79 * 77 *
80 * <pre> 78 * <pre>
@@ -86,24 +84,23 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; @@ -86,24 +84,23 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle;
86 * public class CustomExceptionHandler { 84 * public class CustomExceptionHandler {
87 * 85 *
88 * public void throwException() { 86 * public void throwException() {
89 - * throw new CustomException();  
90 - * }  
91 - *  
92 - * &#064;ExceptionHandler  
93 - * public void handler(CustomException exception) {  
94 - * ...  
95 - * }  
96 - * 87 + * throw new CustomException();
  88 + * }
  89 + *
  90 + * &#064;ExceptionHandler
  91 + * public void handler(CustomException exception) {
  92 + * ...
97 * } 93 * }
  94 + * }
  95 + *
98 * </pre> 96 * </pre>
99 - * </blockquote>  
100 * 97 *
  98 + * </blockquote>
101 * <p> 99 * <p>
102 - * When the method <b>throwException</b> throw a <b>CustomException</b>, once CustomException is annotated  
103 - * with @ApplicationException and CustomExceptionHandle is annotated with @Controller, the interceptor will  
104 - * looking for some method (in CustomExceptionHandle) annotated with @ExceptionHandle and that receive a  
105 - * CustomException as parameter to call. In the case shown, the method <b>handler</b> is called when a  
106 - * <b>CustomException</b> is thrown. 100 + * When the method <b>throwException</b> throw a <b>CustomException</b>, once CustomException is annotated with @ApplicationException
  101 + * and CustomExceptionHandle is annotated with @Controller, the interceptor will looking for some method (in
  102 + * CustomExceptionHandle) annotated with @ExceptionHandle and that receive a CustomException as parameter to call. In
  103 + * the case shown, the method <b>handler</b> is called when a <b>CustomException</b> is thrown.
107 * <p> 104 * <p>
108 * 105 *
109 * @author SERPRO 106 * @author SERPRO
@@ -114,12 +111,12 @@ public class ExceptionHandlerInterceptor implements Serializable { @@ -114,12 +111,12 @@ public class ExceptionHandlerInterceptor implements Serializable {
114 111
115 private static final long serialVersionUID = 1L; 112 private static final long serialVersionUID = 1L;
116 113
117 - private static transient ResourceBundle bundle; 114 + private transient ResourceBundle bundle;
118 115
119 - private static transient Logger logger; 116 + private transient Logger logger;
120 117
121 private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); 118 private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>();
122 - 119 +
123 private boolean handleException(final Exception cause, final Object target) throws Exception { 120 private boolean handleException(final Exception cause, final Object target) throws Exception {
124 getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName())); 121 getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName()));
125 122
@@ -248,7 +245,7 @@ public class ExceptionHandlerInterceptor implements Serializable { @@ -248,7 +245,7 @@ public class ExceptionHandlerInterceptor implements Serializable {
248 return result; 245 return result;
249 } 246 }
250 247
251 - private static ResourceBundle getBundle() { 248 + private ResourceBundle getBundle() {
252 if (bundle == null) { 249 if (bundle == null) {
253 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 250 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
254 } 251 }
@@ -256,7 +253,7 @@ public class ExceptionHandlerInterceptor implements Serializable { @@ -256,7 +253,7 @@ public class ExceptionHandlerInterceptor implements Serializable {
256 return bundle; 253 return bundle;
257 } 254 }
258 255
259 - private static Logger getLogger() { 256 + private Logger getLogger() {
260 if (logger == null) { 257 if (logger == null) {
261 logger = Beans.getReference(Logger.class, new NameQualifier(ExceptionHandlerInterceptor.class.getName())); 258 logger = Beans.getReference(Logger.class, new NameQualifier(ExceptionHandlerInterceptor.class.getName()));
262 } 259 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrap.java
@@ -59,7 +59,7 @@ public class CoreBootstrap implements Extension { @@ -59,7 +59,7 @@ public class CoreBootstrap implements Extension {
59 59
60 private Logger logger; 60 private Logger logger;
61 61
62 - private static transient ResourceBundle bundle; 62 + private transient ResourceBundle bundle;
63 63
64 private Logger getLogger() { 64 private Logger getLogger() {
65 if (this.logger == null) { 65 if (this.logger == null) {
@@ -69,7 +69,7 @@ public class CoreBootstrap implements Extension { @@ -69,7 +69,7 @@ public class CoreBootstrap implements Extension {
69 return this.logger; 69 return this.logger;
70 } 70 }
71 71
72 - private static ResourceBundle getBundle() { 72 + private ResourceBundle getBundle() {
73 if (bundle == null) { 73 if (bundle == null) {
74 bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); 74 bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault());
75 } 75 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
@@ -29,7 +29,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; @@ -29,7 +29,7 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle;
29 29
30 public class ManagementBootstrap implements Extension { 30 public class ManagementBootstrap implements Extension {
31 31
32 - protected static List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>()); 32 + protected List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>());
33 33
34 private List<Class<? extends ManagementExtension>> managementExtensionCache = Collections 34 private List<Class<? extends ManagementExtension>> managementExtensionCache = Collections
35 .synchronizedList(new ArrayList<Class<? extends ManagementExtension>>()); 35 .synchronizedList(new ArrayList<Class<? extends ManagementExtension>>());
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ContextManager.java
@@ -3,8 +3,10 @@ package br.gov.frameworkdemoiselle.internal.context; @@ -3,8 +3,10 @@ package br.gov.frameworkdemoiselle.internal.context;
3 import java.lang.annotation.Annotation; 3 import java.lang.annotation.Annotation;
4 import java.util.ArrayList; 4 import java.util.ArrayList;
5 import java.util.Collections; 5 import java.util.Collections;
  6 +import java.util.HashMap;
6 import java.util.List; 7 import java.util.List;
7 import java.util.Locale; 8 import java.util.Locale;
  9 +import java.util.Map;
8 10
9 import javax.enterprise.context.ContextNotActiveException; 11 import javax.enterprise.context.ContextNotActiveException;
10 import javax.enterprise.context.spi.Context; 12 import javax.enterprise.context.spi.Context;
@@ -41,16 +43,43 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle; @@ -41,16 +43,43 @@ import br.gov.frameworkdemoiselle.util.ResourceBundle;
41 */ 43 */
42 public final class ContextManager { 44 public final class ContextManager {
43 45
44 - private static List<CustomContextCounter> contexts = Collections  
45 - .synchronizedList(new ArrayList<CustomContextCounter>()); 46 + private static final Map<ClassLoader, List<CustomContextCounter>> contextsCache = Collections
  47 + .synchronizedMap(new HashMap<ClassLoader, List<CustomContextCounter>>());
46 48
47 - private static boolean initialized = false; 49 + private static final Map<ClassLoader, Boolean> initializedCache = Collections
  50 + .synchronizedMap(new HashMap<ClassLoader, Boolean>());
48 51
49 - private static transient ResourceBundle bundle; 52 + private ContextManager() {
  53 + }
50 54
51 - private static Logger logger; 55 + private synchronized static List<CustomContextCounter> getContexts() {
  56 + List<CustomContextCounter> contexts = contextsCache.get(getCurrentClassLoader());
52 57
53 - private ContextManager() { 58 + if (contexts == null) {
  59 + contexts = Collections.synchronizedList(new ArrayList<CustomContextCounter>());
  60 + contextsCache.put(getCurrentClassLoader(), contexts);
  61 + }
  62 +
  63 + return contexts;
  64 + }
  65 +
  66 + private synchronized static boolean isInitialized() {
  67 + Boolean initialized = initializedCache.get(getCurrentClassLoader());
  68 +
  69 + if (initialized == null) {
  70 + initialized = false;
  71 + initializedCache.put(getCurrentClassLoader(), initialized);
  72 + }
  73 +
  74 + return initialized;
  75 + }
  76 +
  77 + private static void setInitialized(boolean initialized) {
  78 + initializedCache.put(getCurrentClassLoader(), initialized);
  79 + }
  80 +
  81 + private static ClassLoader getCurrentClassLoader() {
  82 + return Thread.currentThread().getContextClassLoader();
54 } 83 }
55 84
56 /** 85 /**
@@ -66,12 +95,12 @@ public final class ContextManager { @@ -66,12 +95,12 @@ public final class ContextManager {
66 * The CDI event indicating all beans have been discovered. 95 * The CDI event indicating all beans have been discovered.
67 */ 96 */
68 public static void initialize(AfterBeanDiscovery event) { 97 public static void initialize(AfterBeanDiscovery event) {
69 - if (initialized) { 98 + if (isInitialized()) {
70 return; 99 return;
71 } 100 }
72 101
73 add(new StaticContext(), event); 102 add(new StaticContext(), event);
74 - initialized = true; 103 + setInitialized(true);
75 } 104 }
76 105
77 /** 106 /**
@@ -92,7 +121,7 @@ public final class ContextManager { @@ -92,7 +121,7 @@ public final class ContextManager {
92 * The CDI event indicating all beans have been discovered. 121 * The CDI event indicating all beans have been discovered.
93 */ 122 */
94 public static void add(CustomContext context, AfterBeanDiscovery event) { 123 public static void add(CustomContext context, AfterBeanDiscovery event) {
95 - for (CustomContextCounter contextCounter : contexts) { 124 + for (CustomContextCounter contextCounter : getContexts()) {
96 if (contextCounter.isSame(context.getClass(), context.getScope())) { 125 if (contextCounter.isSame(context.getClass(), context.getScope())) {
97 126
98 ContextManager.getLogger().trace( 127 ContextManager.getLogger().trace(
@@ -109,7 +138,7 @@ public final class ContextManager { @@ -109,7 +138,7 @@ public final class ContextManager {
109 138
110 context.setActive(false); 139 context.setActive(false);
111 event.addContext(context); 140 event.addContext(context);
112 - contexts.add(new CustomContextCounter(context)); 141 + getContexts().add(new CustomContextCounter(context));
113 } 142 }
114 143
115 /** 144 /**
@@ -137,11 +166,11 @@ public final class ContextManager { @@ -137,11 +166,11 @@ public final class ContextManager {
137 */ 166 */
138 public static synchronized void activate(Class<? extends CustomContext> customContextClass, 167 public static synchronized void activate(Class<? extends CustomContext> customContextClass,
139 Class<? extends Annotation> scope) { 168 Class<? extends Annotation> scope) {
140 - if (!initialized) { 169 + if (!isInitialized()) {
141 throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized")); 170 throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized"));
142 } 171 }
143 172
144 - for (CustomContextCounter context : contexts) { 173 + for (CustomContextCounter context : getContexts()) {
145 if (context.isSame(customContextClass, scope)) { 174 if (context.isSame(customContextClass, scope)) {
146 context.activate(); 175 context.activate();
147 return; 176 return;
@@ -177,11 +206,11 @@ public final class ContextManager { @@ -177,11 +206,11 @@ public final class ContextManager {
177 */ 206 */
178 public static synchronized void deactivate(Class<? extends CustomContext> customContextClass, 207 public static synchronized void deactivate(Class<? extends CustomContext> customContextClass,
179 Class<? extends Annotation> scope) { 208 Class<? extends Annotation> scope) {
180 - if (!initialized) { 209 + if (!isInitialized()) {
181 throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized")); 210 throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized"));
182 } 211 }
183 212
184 - for (CustomContextCounter context : contexts) { 213 + for (CustomContextCounter context : getContexts()) {
185 if (context.isSame(customContextClass, scope)) { 214 if (context.isSame(customContextClass, scope)) {
186 context.deactivate(); 215 context.deactivate();
187 return; 216 return;
@@ -198,28 +227,20 @@ public final class ContextManager { @@ -198,28 +227,20 @@ public final class ContextManager {
198 * </p> 227 * </p>
199 */ 228 */
200 public static synchronized void shutdown() { 229 public static synchronized void shutdown() {
201 - for (CustomContextCounter context : contexts) { 230 + for (CustomContextCounter context : getContexts()) {
202 context.shutdown(); 231 context.shutdown();
203 } 232 }
204 233
205 - contexts.clear();  
206 - initialized = false; 234 + getContexts().clear();
  235 + setInitialized(false);
207 } 236 }
208 237
209 static Logger getLogger() { 238 static Logger getLogger() {
210 - if (logger == null) {  
211 - logger = LoggerProducer.create(ContextManager.class);  
212 - }  
213 -  
214 - return logger; 239 + return LoggerProducer.create(ContextManager.class);
215 } 240 }
216 241
217 static ResourceBundle getBundle() { 242 static ResourceBundle getBundle() {
218 - if (bundle == null) {  
219 - bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault());  
220 - }  
221 -  
222 - return bundle; 243 + return new ResourceBundle("demoiselle-core-bundle", Locale.getDefault());
223 } 244 }
224 } 245 }
225 246
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AnnotatedMethodProcessor.java
@@ -60,7 +60,7 @@ public class AnnotatedMethodProcessor&lt;T&gt; implements Comparable&lt;AnnotatedMethodPr @@ -60,7 +60,7 @@ public class AnnotatedMethodProcessor&lt;T&gt; implements Comparable&lt;AnnotatedMethodPr
60 60
61 private AnnotatedMethod<T> annotatedMethod; 61 private AnnotatedMethod<T> annotatedMethod;
62 62
63 - private transient static ResourceBundle bundle; 63 + private transient ResourceBundle bundle;
64 64
65 public AnnotatedMethodProcessor(final AnnotatedMethod<T> annotatedMethod) { 65 public AnnotatedMethodProcessor(final AnnotatedMethod<T> annotatedMethod) {
66 this.annotatedMethod = annotatedMethod; 66 this.annotatedMethod = annotatedMethod;
@@ -131,7 +131,7 @@ public class AnnotatedMethodProcessor&lt;T&gt; implements Comparable&lt;AnnotatedMethodPr @@ -131,7 +131,7 @@ public class AnnotatedMethodProcessor&lt;T&gt; implements Comparable&lt;AnnotatedMethodPr
131 return priority; 131 return priority;
132 } 132 }
133 133
134 - protected static ResourceBundle getBundle() { 134 + protected ResourceBundle getBundle() {
135 if (bundle == null) { 135 if (bundle == null) {
136 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 136 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
137 } 137 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationLoader.java
@@ -83,9 +83,9 @@ public class ConfigurationLoader implements Serializable { @@ -83,9 +83,9 @@ public class ConfigurationLoader implements Serializable {
83 83
84 private static final long serialVersionUID = 1L; 84 private static final long serialVersionUID = 1L;
85 85
86 - private static ResourceBundle bundle; 86 + private ResourceBundle bundle;
87 87
88 - private static Logger logger; 88 + private Logger logger;
89 89
90 private Object object; 90 private Object object;
91 91
@@ -314,7 +314,7 @@ public class ConfigurationLoader implements Serializable { @@ -314,7 +314,7 @@ public class ConfigurationLoader implements Serializable {
314 } 314 }
315 } 315 }
316 316
317 - private static ResourceBundle getBundle() { 317 + private ResourceBundle getBundle() {
318 if (bundle == null) { 318 if (bundle == null) {
319 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 319 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
320 } 320 }
@@ -322,7 +322,7 @@ public class ConfigurationLoader implements Serializable { @@ -322,7 +322,7 @@ public class ConfigurationLoader implements Serializable {
322 return bundle; 322 return bundle;
323 } 323 }
324 324
325 - private static Logger getLogger() { 325 + private Logger getLogger() {
326 if (logger == null) { 326 if (logger == null) {
327 logger = Beans.getReference(Logger.class, new NameQualifier(ConfigurationLoader.class.getName())); 327 logger = Beans.getReference(Logger.class, new NameQualifier(ConfigurationLoader.class.getName()));
328 } 328 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java
@@ -60,7 +60,7 @@ public class DefaultAuthenticator implements Authenticator { @@ -60,7 +60,7 @@ public class DefaultAuthenticator implements Authenticator {
60 60
61 private static final long serialVersionUID = 1L; 61 private static final long serialVersionUID = 1L;
62 62
63 - private transient static ResourceBundle bundle; 63 + private transient ResourceBundle bundle;
64 64
65 /** 65 /**
66 * @see br.gov.frameworkdemoiselle.security.Authenticator#authenticate() 66 * @see br.gov.frameworkdemoiselle.security.Authenticator#authenticate()
@@ -91,7 +91,7 @@ public class DefaultAuthenticator implements Authenticator { @@ -91,7 +91,7 @@ public class DefaultAuthenticator implements Authenticator {
91 SecurityContext.class.getSimpleName()), new ClassNotFoundException()); 91 SecurityContext.class.getSimpleName()), new ClassNotFoundException());
92 } 92 }
93 93
94 - private static ResourceBundle getBundle() { 94 + private ResourceBundle getBundle() {
95 if (bundle == null) { 95 if (bundle == null) {
96 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 96 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
97 } 97 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizer.java
@@ -56,7 +56,7 @@ public class DefaultAuthorizer implements Authorizer { @@ -56,7 +56,7 @@ public class DefaultAuthorizer implements Authorizer {
56 56
57 private static final long serialVersionUID = 1L; 57 private static final long serialVersionUID = 1L;
58 58
59 - private transient static ResourceBundle bundle; 59 + private transient ResourceBundle bundle;
60 60
61 @Override 61 @Override
62 public boolean hasRole(String role) { 62 public boolean hasRole(String role) {
@@ -73,7 +73,7 @@ public class DefaultAuthorizer implements Authorizer { @@ -73,7 +73,7 @@ public class DefaultAuthorizer implements Authorizer {
73 SecurityContext.class.getSimpleName())); 73 SecurityContext.class.getSimpleName()));
74 } 74 }
75 75
76 - private static ResourceBundle getBundle() { 76 + private ResourceBundle getBundle() {
77 if (bundle == null) { 77 if (bundle == null) {
78 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 78 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
79 } 79 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransaction.java
@@ -56,7 +56,7 @@ public class DefaultTransaction implements Transaction { @@ -56,7 +56,7 @@ public class DefaultTransaction implements Transaction {
56 56
57 private static final long serialVersionUID = 1L; 57 private static final long serialVersionUID = 1L;
58 58
59 - private transient static ResourceBundle bundle; 59 + private transient ResourceBundle bundle;
60 60
61 @Override 61 @Override
62 public void begin() { 62 public void begin() {
@@ -93,7 +93,7 @@ public class DefaultTransaction implements Transaction { @@ -93,7 +93,7 @@ public class DefaultTransaction implements Transaction {
93 Transactional.class.getSimpleName())); 93 Transactional.class.getSimpleName()));
94 } 94 }
95 95
96 - private static ResourceBundle getBundle() { 96 + private ResourceBundle getBundle() {
97 if (bundle == null) { 97 if (bundle == null) {
98 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 98 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
99 } 99 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImpl.java
@@ -61,9 +61,9 @@ public class MessageContextImpl implements Serializable, MessageContext { @@ -61,9 +61,9 @@ public class MessageContextImpl implements Serializable, MessageContext {
61 61
62 private static final long serialVersionUID = 1L; 62 private static final long serialVersionUID = 1L;
63 63
64 - private transient static ResourceBundle bundle; 64 + private transient ResourceBundle bundle;
65 65
66 - private transient static Logger logger; 66 + private transient Logger logger;
67 67
68 @Override 68 @Override
69 public void add(final Message message, Object... params) { 69 public void add(final Message message, Object... params) {
@@ -111,7 +111,7 @@ public class MessageContextImpl implements Serializable, MessageContext { @@ -111,7 +111,7 @@ public class MessageContextImpl implements Serializable, MessageContext {
111 + MessageAppender.class.getCanonicalName() + "."); 111 + MessageAppender.class.getCanonicalName() + ".");
112 } 112 }
113 113
114 - private static ResourceBundle getBundle() { 114 + private ResourceBundle getBundle() {
115 if (bundle == null) { 115 if (bundle == null) {
116 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 116 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
117 } 117 }
@@ -119,7 +119,7 @@ public class MessageContextImpl implements Serializable, MessageContext { @@ -119,7 +119,7 @@ public class MessageContextImpl implements Serializable, MessageContext {
119 return bundle; 119 return bundle;
120 } 120 }
121 121
122 - private static Logger getLogger() { 122 + private Logger getLogger() {
123 if (logger == null) { 123 if (logger == null) {
124 logger = LoggerProducer.create(MessageContext.class); 124 logger = LoggerProducer.create(MessageContext.class);
125 } 125 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java
@@ -10,8 +10,8 @@ import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEven @@ -10,8 +10,8 @@ import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEven
10 import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; 10 import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
11 import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; 11 import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
12 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; 12 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
13 -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;  
14 import br.gov.frameworkdemoiselle.management.GenericNotification; 13 import br.gov.frameworkdemoiselle.management.GenericNotification;
  14 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
15 import br.gov.frameworkdemoiselle.management.NotificationManager; 15 import br.gov.frameworkdemoiselle.management.NotificationManager;
16 import br.gov.frameworkdemoiselle.util.Beans; 16 import br.gov.frameworkdemoiselle.util.Beans;
17 17
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
@@ -66,7 +66,7 @@ public class SecurityContextImpl implements SecurityContext { @@ -66,7 +66,7 @@ public class SecurityContextImpl implements SecurityContext {
66 66
67 private static final long serialVersionUID = 1L; 67 private static final long serialVersionUID = 1L;
68 68
69 - private transient static ResourceBundle bundle; 69 + private transient ResourceBundle bundle;
70 70
71 private Authenticator authenticator; 71 private Authenticator authenticator;
72 72
@@ -205,7 +205,7 @@ public class SecurityContextImpl implements SecurityContext { @@ -205,7 +205,7 @@ public class SecurityContextImpl implements SecurityContext {
205 } 205 }
206 } 206 }
207 207
208 - private static ResourceBundle getBundle() { 208 + private ResourceBundle getBundle() {
209 if (bundle == null) { 209 if (bundle == null) {
210 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 210 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
211 } 211 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
@@ -58,8 +58,6 @@ public final class StrategySelector implements Serializable { @@ -58,8 +58,6 @@ public final class StrategySelector implements Serializable {
58 58
59 private static final long serialVersionUID = 1L; 59 private static final long serialVersionUID = 1L;
60 60
61 - private transient static ResourceBundle bundle;  
62 -  
63 private StrategySelector() { 61 private StrategySelector() {
64 } 62 }
65 63
@@ -156,10 +154,6 @@ public final class StrategySelector implements Serializable { @@ -156,10 +154,6 @@ public final class StrategySelector implements Serializable {
156 } 154 }
157 155
158 private static ResourceBundle getBundle() { 156 private static ResourceBundle getBundle() {
159 - if (bundle == null) {  
160 - bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));  
161 - }  
162 -  
163 - return bundle; 157 + return Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
164 } 158 }
165 } 159 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionalInterceptor.java
@@ -62,9 +62,9 @@ public class TransactionalInterceptor implements Serializable { @@ -62,9 +62,9 @@ public class TransactionalInterceptor implements Serializable {
62 62
63 private TransactionInfo transactionInfo; 63 private TransactionInfo transactionInfo;
64 64
65 - private static transient ResourceBundle bundle; 65 + private transient ResourceBundle bundle;
66 66
67 - private static transient Logger logger; 67 + private transient Logger logger;
68 68
69 private TransactionContext getTransactionContext() { 69 private TransactionContext getTransactionContext() {
70 if (this.transactionContext == null) { 70 if (this.transactionContext == null) {
@@ -97,14 +97,16 @@ public class TransactionalInterceptor implements Serializable { @@ -97,14 +97,16 @@ public class TransactionalInterceptor implements Serializable {
97 } 97 }
98 98
99 /** 99 /**
100 - * <p>Manages methods annotated with {@link Transactional}. If there's no active transaction  
101 - * the moment a {@link Transactional} method is called, this interceptor will activate one. If a {@link Transactional} method  
102 - * that activated a transaction returns, this method will commit the active transaction. If the {@link Transactional} method  
103 - * throws an exception caught outside of the method (or uncaught), this interceptor will mark the transaction for rollback.</p>  
104 - *  
105 * <p> 100 * <p>
106 - * This method is not intended to be called directly, instead the CDI provider will call this method when a {@link Transactional} method  
107 - * is called. 101 + * Manages methods annotated with {@link Transactional}. If there's no active transaction the moment a
  102 + * {@link Transactional} method is called, this interceptor will activate one. If a {@link Transactional} method
  103 + * that activated a transaction returns, this method will commit the active transaction. If the
  104 + * {@link Transactional} method throws an exception caught outside of the method (or uncaught), this interceptor
  105 + * will mark the transaction for rollback.
  106 + * </p>
  107 + * <p>
  108 + * This method is not intended to be called directly, instead the CDI provider will call this method when a
  109 + * {@link Transactional} method is called.
108 * </p> 110 * </p>
109 */ 111 */
110 @AroundInvoke 112 @AroundInvoke
@@ -183,7 +185,7 @@ public class TransactionalInterceptor implements Serializable { @@ -183,7 +185,7 @@ public class TransactionalInterceptor implements Serializable {
183 } 185 }
184 } 186 }
185 187
186 - private static ResourceBundle getBundle() { 188 + private ResourceBundle getBundle() {
187 if (bundle == null) { 189 if (bundle == null) {
188 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); 190 bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
189 } 191 }
@@ -191,7 +193,7 @@ public class TransactionalInterceptor implements Serializable { @@ -191,7 +193,7 @@ public class TransactionalInterceptor implements Serializable {
191 return bundle; 193 return bundle;
192 } 194 }
193 195
194 - private static Logger getLogger() { 196 + private Logger getLogger() {
195 if (logger == null) { 197 if (logger == null) {
196 logger = Beans.getReference(Logger.class, new NameQualifier(TransactionalInterceptor.class.getName())); 198 logger = Beans.getReference(Logger.class, new NameQualifier(TransactionalInterceptor.class.getName()));
197 } 199 }
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
@@ -40,7 +40,10 @@ import java.lang.annotation.Annotation; @@ -40,7 +40,10 @@ import java.lang.annotation.Annotation;
40 import java.lang.reflect.Member; 40 import java.lang.reflect.Member;
41 import java.lang.reflect.Type; 41 import java.lang.reflect.Type;
42 import java.util.Arrays; 42 import java.util.Arrays;
  43 +import java.util.Collections;
  44 +import java.util.HashMap;
43 import java.util.HashSet; 45 import java.util.HashSet;
  46 +import java.util.Map;
44 import java.util.NoSuchElementException; 47 import java.util.NoSuchElementException;
45 import java.util.Set; 48 import java.util.Set;
46 49
@@ -54,7 +57,8 @@ import br.gov.frameworkdemoiselle.DemoiselleException; @@ -54,7 +57,8 @@ import br.gov.frameworkdemoiselle.DemoiselleException;
54 57
55 /** 58 /**
56 * <p> 59 * <p>
57 - * Utilizes a {@link BeanManager}, obtained in the bootstrap process, to provide custom operations for obtaining contextual references for beans. 60 + * Utilizes a {@link BeanManager}, obtained in the bootstrap process, to provide custom operations for obtaining
  61 + * contextual references for beans.
58 * <p> 62 * <p>
59 * All its public methods are static. 63 * All its public methods are static.
60 * 64 *
@@ -62,40 +66,41 @@ import br.gov.frameworkdemoiselle.DemoiselleException; @@ -62,40 +66,41 @@ import br.gov.frameworkdemoiselle.DemoiselleException;
62 */ 66 */
63 public final class Beans { 67 public final class Beans {
64 68
65 - private static transient ResourceBundle bundle;  
66 -  
67 - private static BeanManager manager; 69 + private static final Map<ClassLoader, BeanManager> beanManagerCache = Collections
  70 + .synchronizedMap(new HashMap<ClassLoader, BeanManager>());
68 71
69 private Beans() { 72 private Beans() {
70 } 73 }
71 74
72 public static void setBeanManager(BeanManager beanManager) { 75 public static void setBeanManager(BeanManager beanManager) {
73 - manager = beanManager; 76 + beanManagerCache.put(getCurrentClassLoader(), beanManager);
74 } 77 }
75 78
76 public static BeanManager getBeanManager() { 79 public static BeanManager getBeanManager() {
77 - return manager; 80 + return beanManagerCache.get(getCurrentClassLoader());
  81 + }
  82 +
  83 + private static ClassLoader getCurrentClassLoader() {
  84 + return Thread.currentThread().getContextClassLoader();
78 } 85 }
79 86
80 /** 87 /**
81 - * Obtains a injectble instance of a bean, which have the given required type and qualifiers,  
82 - * and are available for injection in the point where this method was call. 88 + * Obtains a injectble instance of a bean, which have the given required type and qualifiers, and are available for
  89 + * injection in the point where this method was call.
83 * 90 *
84 * @param beanClass 91 * @param beanClass
85 - * the beanClass which instace is requested to be obtained. 92 + * the beanClass which instace is requested to be obtained.
86 * @param qualifiers 93 * @param qualifiers
87 - * a set of qualifiers with any quantity of elements (zero including).  
88 - * @return Type  
89 - * a instace of the injected beanClass. 94 + * a set of qualifiers with any quantity of elements (zero including).
  95 + * @return Type a instace of the injected beanClass.
90 * @throws DemoiselleException 96 * @throws DemoiselleException
91 - * if no bean are avaliable to be injected for the given Class and qualifiers.  
92 - * 97 + * if no bean are avaliable to be injected for the given Class and qualifiers.
93 */ 98 */
94 public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) { 99 public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) {
95 T instance; 100 T instance;
96 101
97 try { 102 try {
98 - instance = (T) getReference(manager.getBeans(beanClass, qualifiers), beanClass, qualifiers); 103 + instance = (T) getReference(getBeanManager().getBeans(beanClass, qualifiers), beanClass, qualifiers);
99 104
100 } catch (NoSuchElementException cause) { 105 } catch (NoSuchElementException cause) {
101 StringBuffer buffer = new StringBuffer(); 106 StringBuffer buffer = new StringBuffer();
@@ -114,22 +119,20 @@ public final class Beans { @@ -114,22 +119,20 @@ public final class Beans {
114 } 119 }
115 120
116 /** 121 /**
117 - * Obtains a injectble instance of a bean, which have the given required type  
118 - * and are available for injection in the point where this method was call. 122 + * Obtains a injectble instance of a bean, which have the given required type and are available for injection in the
  123 + * point where this method was call.
119 * 124 *
120 * @param beanClass 125 * @param beanClass
121 - * the beanClass which instace is requested to be obtained.  
122 - * @return Type  
123 - * a instace of the injected beanClass. 126 + * the beanClass which instace is requested to be obtained.
  127 + * @return Type a instace of the injected beanClass.
124 * @throws DemoiselleException 128 * @throws DemoiselleException
125 - * if no bean are avaliable to be injected for the given Class.  
126 - * 129 + * if no bean are avaliable to be injected for the given Class.
127 */ 130 */
128 public static <T> T getReference(final Class<T> beanClass) { 131 public static <T> T getReference(final Class<T> beanClass) {
129 T instance; 132 T instance;
130 133
131 try { 134 try {
132 - instance = (T) getReference(manager.getBeans(beanClass), beanClass); 135 + instance = (T) getReference(getBeanManager().getBeans(beanClass), beanClass);
133 136
134 } catch (NoSuchElementException cause) { 137 } catch (NoSuchElementException cause) {
135 String message = getBundle().getString("bean-not-found", beanClass.getCanonicalName()); 138 String message = getBundle().getString("bean-not-found", beanClass.getCanonicalName());
@@ -140,23 +143,21 @@ public final class Beans { @@ -140,23 +143,21 @@ public final class Beans {
140 } 143 }
141 144
142 /** 145 /**
143 - * Obtains a injectble instance of a bean, which have the given EL name  
144 - * and are available for injection in the point where this method was call. 146 + * Obtains a injectble instance of a bean, which have the given EL name and are available for injection in the point
  147 + * where this method was call.
145 * 148 *
146 * @param beanName 149 * @param beanName
147 - * the EL name for the requested bean.  
148 - * @return Type  
149 - * a instace of the injected beanClass. 150 + * the EL name for the requested bean.
  151 + * @return Type a instace of the injected beanClass.
150 * @throws DemoiselleException 152 * @throws DemoiselleException
151 - * if no bean are avaliable to be injected for the given bean name.  
152 - * 153 + * if no bean are avaliable to be injected for the given bean name.
153 */ 154 */
154 @SuppressWarnings("unchecked") 155 @SuppressWarnings("unchecked")
155 public static <T> T getReference(String beanName) { 156 public static <T> T getReference(String beanName) {
156 T instance; 157 T instance;
157 158
158 try { 159 try {
159 - instance = (T) getReference(manager.getBeans(beanName)); 160 + instance = (T) getReference(getBeanManager().getBeans(beanName));
160 161
161 } catch (NoSuchElementException cause) { 162 } catch (NoSuchElementException cause) {
162 String message = getBundle().getString("bean-not-found", beanName); 163 String message = getBundle().getString("bean-not-found", beanName);
@@ -169,11 +170,11 @@ public final class Beans { @@ -169,11 +170,11 @@ public final class Beans {
169 @SuppressWarnings("unchecked") 170 @SuppressWarnings("unchecked")
170 private static <T> T getReference(Set<Bean<?>> beans, Class<T> beanClass, Annotation... qualifiers) { 171 private static <T> T getReference(Set<Bean<?>> beans, Class<T> beanClass, Annotation... qualifiers) {
171 Bean<?> bean = beans.iterator().next(); 172 Bean<?> bean = beans.iterator().next();
172 - CreationalContext<?> context = manager.createCreationalContext(bean); 173 + CreationalContext<?> context = getBeanManager().createCreationalContext(bean);
173 Type beanType = beanClass == null ? bean.getBeanClass() : beanClass; 174 Type beanType = beanClass == null ? bean.getBeanClass() : beanClass;
174 InjectionPoint injectionPoint = new CustomInjectionPoint(bean, beanType, qualifiers); 175 InjectionPoint injectionPoint = new CustomInjectionPoint(bean, beanType, qualifiers);
175 176
176 - return (T) manager.getInjectableReference(injectionPoint, context); 177 + return (T) getBeanManager().getInjectableReference(injectionPoint, context);
177 } 178 }
178 179
179 private static <T> T getReference(Set<Bean<?>> beans) { 180 private static <T> T getReference(Set<Bean<?>> beans) {
@@ -181,11 +182,7 @@ public final class Beans { @@ -181,11 +182,7 @@ public final class Beans {
181 } 182 }
182 183
183 private static ResourceBundle getBundle() { 184 private static ResourceBundle getBundle() {
184 - if (bundle == null) {  
185 - bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));  
186 - }  
187 -  
188 - return bundle; 185 + return Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle"));
189 } 186 }
190 187
191 static class CustomInjectionPoint implements InjectionPoint { 188 static class CustomInjectionPoint implements InjectionPoint {
impl/core/src/main/resources/META-INF/beans.xml
@@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
1 -<!--  
2 - Demoiselle Framework  
3 - Copyright (C) 2010 SERPRO  
4 - ============================================================================  
5 - This file is part of Demoiselle Framework.  
6 -  
7 - Demoiselle Framework is free software; you can redistribute it and/or  
8 - modify it under the terms of the GNU Lesser General Public License version 3  
9 - as published by the Free Software Foundation.  
10 -  
11 - This program is distributed in the hope that it will be useful,  
12 - but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - GNU General Public License for more details.  
15 -  
16 - You should have received a copy of the GNU Lesser General Public License version 3  
17 - along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - Fifth Floor, Boston, MA 02110-1301, USA.  
20 - ============================================================================  
21 - Este arquivo é parte do Framework Demoiselle.  
22 -  
23 - O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - do Software Livre (FSF).  
26 -  
27 - Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - para maiores detalhes.  
31 -  
32 - Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 --->  
37 -<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
38 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">  
39 -  
40 -</beans>  
41 \ No newline at end of file 0 \ No newline at end of file
impl/extension/jdbc/pom.xml
@@ -71,38 +71,6 @@ @@ -71,38 +71,6 @@
71 <groupId>commons-dbcp</groupId> 71 <groupId>commons-dbcp</groupId>
72 <artifactId>commons-dbcp</artifactId> 72 <artifactId>commons-dbcp</artifactId>
73 </dependency> 73 </dependency>
74 -  
75 - <!-- for tests -->  
76 - <dependency>  
77 - <groupId>junit</groupId>  
78 - <artifactId>junit</artifactId>  
79 - <scope>test</scope>  
80 - </dependency>  
81 - <dependency>  
82 - <groupId>org.jboss.arquillian.junit</groupId>  
83 - <artifactId>arquillian-junit-container</artifactId>  
84 - <scope>test</scope>  
85 - </dependency>  
86 - <dependency>  
87 - <groupId>org.jboss.shrinkwrap.resolver</groupId>  
88 - <artifactId>shrinkwrap-resolver-impl-maven</artifactId>  
89 - <scope>test</scope>  
90 - </dependency>  
91 - <dependency>  
92 - <groupId>org.jboss.arquillian.container</groupId>  
93 - <artifactId>arquillian-glassfish-embedded-3.1</artifactId>  
94 - <scope>test</scope>  
95 - </dependency>  
96 - <dependency>  
97 - <groupId>org.glassfish.main.extras</groupId>  
98 - <artifactId>glassfish-embedded-all</artifactId>  
99 - <scope>test</scope>  
100 - </dependency>  
101 - <dependency>  
102 - <groupId>hsqldb</groupId>  
103 - <artifactId>hsqldb</artifactId>  
104 - <scope>test</scope>  
105 - </dependency>  
106 </dependencies> 74 </dependencies>
107 75
108 <repositories> 76 <repositories>
@@ -135,26 +103,9 @@ @@ -135,26 +103,9 @@
135 <id>arquillian-test</id> 103 <id>arquillian-test</id>
136 <dependencies> 104 <dependencies>
137 <dependency> 105 <dependency>
138 - <groupId>br.gov.frameworkdemoiselle</groupId>  
139 - <artifactId>demoiselle-core</artifactId>  
140 - <exclusions>  
141 - <exclusion>  
142 - <groupId>javax.enterprise</groupId>  
143 - <artifactId>cdi-api</artifactId>  
144 - </exclusion>  
145 - <exclusion>  
146 - <artifactId>validation-api</artifactId>  
147 - <groupId>javax.validation</groupId>  
148 - </exclusion>  
149 - <exclusion>  
150 - <groupId>org.slf4j</groupId>  
151 - <artifactId>slf4j-api</artifactId>  
152 - </exclusion>  
153 - <exclusion>  
154 - <groupId>org.javassist</groupId>  
155 - <artifactId>javassist</artifactId>  
156 - </exclusion>  
157 - </exclusions> 106 + <groupId>hsqldb</groupId>
  107 + <artifactId>hsqldb</artifactId>
  108 + <scope>runtime</scope>
158 </dependency> 109 </dependency>
159 </dependencies> 110 </dependencies>
160 </profile> 111 </profile>
impl/extension/jdbc/src/main/resources/META-INF/beans.xml
@@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
1 -<!--  
2 - Demoiselle Framework  
3 - Copyright (C) 2010 SERPRO  
4 - ============================================================================  
5 - This file is part of Demoiselle Framework.  
6 -  
7 - Demoiselle Framework is free software; you can redistribute it and/or  
8 - modify it under the terms of the GNU Lesser General Public License version 3  
9 - as published by the Free Software Foundation.  
10 -  
11 - This program is distributed in the hope that it will be useful,  
12 - but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - GNU General Public License for more details.  
15 -  
16 - You should have received a copy of the GNU Lesser General Public License version 3  
17 - along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - Fifth Floor, Boston, MA 02110-1301, USA.  
20 - ============================================================================  
21 - Este arquivo é parte do Framework Demoiselle.  
22 -  
23 - O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - do Software Livre (FSF).  
26 -  
27 - Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - para maiores detalhes.  
31 -  
32 - Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 --->  
37 -<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
38 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">  
39 -  
40 -</beans>  
41 \ No newline at end of file 0 \ No newline at end of file
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerMultipleConnectionsTest.java
@@ -16,6 +16,7 @@ import org.junit.runner.RunWith; @@ -16,6 +16,7 @@ import org.junit.runner.RunWith;
16 import test.Tests; 16 import test.Tests;
17 import br.gov.frameworkdemoiselle.annotation.Name; 17 import br.gov.frameworkdemoiselle.annotation.Name;
18 18
  19 +//@Ignore
19 @RunWith(Arquillian.class) 20 @RunWith(Arquillian.class)
20 public class ConnectionProducerMultipleConnectionsTest { 21 public class ConnectionProducerMultipleConnectionsTest {
21 22
@@ -49,7 +50,7 @@ public class ConnectionProducerMultipleConnectionsTest { @@ -49,7 +50,7 @@ public class ConnectionProducerMultipleConnectionsTest {
49 assertEquals(conn1.getMetaData().getURL(), "jdbc:hsqldb:hsql1"); 50 assertEquals(conn1.getMetaData().getURL(), "jdbc:hsqldb:hsql1");
50 assertEquals(conn2.getMetaData().getURL(), "jdbc:hsqldb:hsql2"); 51 assertEquals(conn2.getMetaData().getURL(), "jdbc:hsqldb:hsql2");
51 assertEquals(conn3.getMetaData().getURL(), "jdbc:hsqldb:hsql3"); 52 assertEquals(conn3.getMetaData().getURL(), "jdbc:hsqldb:hsql3");
52 - assertEquals(conn4.getMetaData().getURL(), "jdbc:derby:target/databases/derby"); 53 + assertEquals(conn4.getMetaData().getURL(), "jdbc:h2:mem:test");
53 } 54 }
54 55
55 } 56 }
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerNoConnectionDriverTest.java
@@ -14,6 +14,7 @@ import org.junit.runner.RunWith; @@ -14,6 +14,7 @@ import org.junit.runner.RunWith;
14 import test.Tests; 14 import test.Tests;
15 import br.gov.frameworkdemoiselle.annotation.Name; 15 import br.gov.frameworkdemoiselle.annotation.Name;
16 16
  17 +//@Ignore
17 @RunWith(Arquillian.class) 18 @RunWith(Arquillian.class)
18 public class ConnectionProducerNoConnectionDriverTest { 19 public class ConnectionProducerNoConnectionDriverTest {
19 20
@@ -31,7 +32,7 @@ public class ConnectionProducerNoConnectionDriverTest { @@ -31,7 +32,7 @@ public class ConnectionProducerNoConnectionDriverTest {
31 } 32 }
32 33
33 /** 34 /**
34 - * TODO Refinar a exceção esperada 35 + * TODO Refinar a exceção esperada
35 */ 36 */
36 @Test(expected = Exception.class) 37 @Test(expected = Exception.class)
37 public void failOnCreateConnection() { 38 public void failOnCreateConnection() {
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerNoConnectionUrlTest.java
@@ -14,6 +14,7 @@ import org.junit.runner.RunWith; @@ -14,6 +14,7 @@ import org.junit.runner.RunWith;
14 import test.Tests; 14 import test.Tests;
15 import br.gov.frameworkdemoiselle.annotation.Name; 15 import br.gov.frameworkdemoiselle.annotation.Name;
16 16
  17 +//@Ignore
17 @RunWith(Arquillian.class) 18 @RunWith(Arquillian.class)
18 public class ConnectionProducerNoConnectionUrlTest { 19 public class ConnectionProducerNoConnectionUrlTest {
19 20
@@ -31,7 +32,7 @@ public class ConnectionProducerNoConnectionUrlTest { @@ -31,7 +32,7 @@ public class ConnectionProducerNoConnectionUrlTest {
31 } 32 }
32 33
33 /** 34 /**
34 - * TODO Refinar a exceção esperada 35 + * TODO Refinar a exceção esperada
35 */ 36 */
36 @Test(expected = Exception.class) 37 @Test(expected = Exception.class)
37 public void failOnCreateConnection() { 38 public void failOnCreateConnection() {
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithJndiTest.java
@@ -16,6 +16,7 @@ import org.junit.runner.RunWith; @@ -16,6 +16,7 @@ import org.junit.runner.RunWith;
16 import test.Tests; 16 import test.Tests;
17 import br.gov.frameworkdemoiselle.annotation.Name; 17 import br.gov.frameworkdemoiselle.annotation.Name;
18 18
  19 +//@Ignore
19 @RunWith(Arquillian.class) 20 @RunWith(Arquillian.class)
20 public class ConnectionProducerWithJndiTest { 21 public class ConnectionProducerWithJndiTest {
21 22
@@ -34,7 +35,6 @@ public class ConnectionProducerWithJndiTest { @@ -34,7 +35,6 @@ public class ConnectionProducerWithJndiTest {
34 35
35 @Test 36 @Test
36 public void createConnection() throws SQLException { 37 public void createConnection() throws SQLException {
37 - assertEquals(conn1.getMetaData().getURL(), "jdbc:derby:target/databases/derby"); 38 + assertEquals(conn1.getMetaData().getURL(), "jdbc:h2:mem:test");
38 } 39 }
39 -  
40 -}  
41 \ No newline at end of file 40 \ No newline at end of file
  41 +}
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithNameTest.java
@@ -15,6 +15,7 @@ import org.junit.runner.RunWith; @@ -15,6 +15,7 @@ import org.junit.runner.RunWith;
15 import test.Tests; 15 import test.Tests;
16 import br.gov.frameworkdemoiselle.annotation.Name; 16 import br.gov.frameworkdemoiselle.annotation.Name;
17 17
  18 +//@Ignore
18 @RunWith(Arquillian.class) 19 @RunWith(Arquillian.class)
19 public class ConnectionProducerWithNameTest { 20 public class ConnectionProducerWithNameTest {
20 21
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithoutJndiTest.java
1 package connection.producer; 1 package connection.producer;
2 2
3 -import static org.junit.Assert.assertEquals;  
4 -  
5 import java.sql.Connection; 3 import java.sql.Connection;
6 import java.sql.SQLException; 4 import java.sql.SQLException;
7 5
@@ -17,6 +15,7 @@ import org.junit.runner.RunWith; @@ -17,6 +15,7 @@ import org.junit.runner.RunWith;
17 import test.Tests; 15 import test.Tests;
18 import br.gov.frameworkdemoiselle.annotation.Name; 16 import br.gov.frameworkdemoiselle.annotation.Name;
19 17
  18 +//@Ignore
20 @RunWith(Arquillian.class) 19 @RunWith(Arquillian.class)
21 public class ConnectionProducerWithoutJndiTest { 20 public class ConnectionProducerWithoutJndiTest {
22 21
@@ -33,9 +32,9 @@ public class ConnectionProducerWithoutJndiTest { @@ -33,9 +32,9 @@ public class ConnectionProducerWithoutJndiTest {
33 return deployment; 32 return deployment;
34 } 33 }
35 34
36 - @Test(expected=Exception.class) 35 + @Test(expected = Exception.class)
37 public void createConnection() throws SQLException { 36 public void createConnection() throws SQLException {
38 conn1.get(); 37 conn1.get();
39 } 38 }
40 39
41 -}  
42 \ No newline at end of file 40 \ No newline at end of file
  41 +}
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithoutNameTest.java
@@ -9,30 +9,30 @@ import javax.inject.Inject; @@ -9,30 +9,30 @@ import javax.inject.Inject;
9 import org.jboss.arquillian.container.test.api.Deployment; 9 import org.jboss.arquillian.container.test.api.Deployment;
10 import org.jboss.arquillian.junit.Arquillian; 10 import org.jboss.arquillian.junit.Arquillian;
11 import org.jboss.shrinkwrap.api.spec.WebArchive; 11 import org.jboss.shrinkwrap.api.spec.WebArchive;
12 -import org.junit.Ignore;  
13 import org.junit.Test; 12 import org.junit.Test;
14 import org.junit.runner.RunWith; 13 import org.junit.runner.RunWith;
15 14
16 import test.Tests; 15 import test.Tests;
17 16
  17 +//@Ignore
18 @RunWith(Arquillian.class) 18 @RunWith(Arquillian.class)
19 public class ConnectionProducerWithoutNameTest { 19 public class ConnectionProducerWithoutNameTest {
20 20
21 private static String PATH = "src/test/resources/producer/without-name"; 21 private static String PATH = "src/test/resources/producer/without-name";
22 - 22 +
23 @Inject 23 @Inject
24 private Connection connection; 24 private Connection connection;
25 - 25 +
26 @Deployment 26 @Deployment
27 public static WebArchive createDeployment() { 27 public static WebArchive createDeployment() {
28 WebArchive deployment = Tests.createDeployment(ConnectionProducerWithoutNameTest.class); 28 WebArchive deployment = Tests.createDeployment(ConnectionProducerWithoutNameTest.class);
29 deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); 29 deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties");
30 return deployment; 30 return deployment;
31 } 31 }
32 - 32 +
33 @Test 33 @Test
34 - public void createConnection(){ 34 + public void createConnection() {
35 assertNotNull(connection); 35 assertNotNull(connection);
36 } 36 }
37 - 37 +
38 } 38 }
impl/extension/jdbc/src/test/resources/arquillian.xml
@@ -43,10 +43,10 @@ @@ -43,10 +43,10 @@
43 <property name="deploymentExportPath">target/deployments</property> 43 <property name="deploymentExportPath">target/deployments</property>
44 </engine> 44 </engine>
45 45
46 - <container qualifier="glassfish-embedded" default="true"> 46 + <container qualifier="jbossas-managed" default="true">
  47 + <protocol type="Servlet 3.0" />
47 <configuration> 48 <configuration>
48 - <property name="resourcesXml">src/test/resources/glassfish-resources.xml</property>  
49 -<!-- <property name="resourcesXml">${project.testResources}/glassfish-resources.xml</property> --> 49 + <property name="jbossHome">target/jboss-as-${jboss.as.version}</property>
50 </configuration> 50 </configuration>
51 </container> 51 </container>
52 52
impl/extension/jdbc/src/test/resources/glassfish-resources.xml
@@ -1,48 +0,0 @@ @@ -1,48 +0,0 @@
1 -<!--  
2 - Demoiselle Framework  
3 - Copyright (C) 2010 SERPRO  
4 - ============================================================================  
5 - This file is part of Demoiselle Framework.  
6 -  
7 - Demoiselle Framework is free software; you can redistribute it and/or  
8 - modify it under the terms of the GNU Lesser General Public License version 3  
9 - as published by the Free Software Foundation.  
10 -  
11 - This program is distributed in the hope that it will be useful,  
12 - but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - GNU General Public License for more details.  
15 -  
16 - You should have received a copy of the GNU Lesser General Public License version 3  
17 - along with this program; if not, see <http://www.gnu.org/licenses />  
18 - or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - Fifth Floor, Boston, MA 02110-1301, USA.  
20 - ============================================================================  
21 - Este arquivo é parte do Framework Demoiselle.  
22 -  
23 - O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - do Software Livre (FSF).  
26 -  
27 - Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - para maiores detalhes.  
31 -  
32 - Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses />  
34 - ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 --->  
37 -<!DOCTYPE resources PUBLIC  
38 - "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"  
39 - "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">  
40 -<resources>  
41 - <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool" jndi-name="jdbc/arquillian" />  
42 -  
43 - <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool" res-type="javax.sql.DataSource" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"  
44 - is-isolation-level-guaranteed="false">  
45 - <property name="databaseName" value="target/databases/derby" />  
46 - <property name="createDatabase" value="create" />  
47 - </jdbc-connection-pool>  
48 -</resources>  
49 \ No newline at end of file 0 \ No newline at end of file
impl/extension/jdbc/src/test/resources/producer/multiple-connections/demoiselle.properties
@@ -13,6 +13,6 @@ frameworkdemoiselle.persistence.conn3.url=jdbc:hsqldb:hsql3 @@ -13,6 +13,6 @@ frameworkdemoiselle.persistence.conn3.url=jdbc:hsqldb:hsql3
13 frameworkdemoiselle.persistence.conn3.username=sa 13 frameworkdemoiselle.persistence.conn3.username=sa
14 frameworkdemoiselle.persistence.conn3.password= 14 frameworkdemoiselle.persistence.conn3.password=
15 15
16 -frameworkdemoiselle.persistence.conn4.jndi.name=jdbc/arquillian 16 +frameworkdemoiselle.persistence.conn4.jndi.name=java:jboss/datasources/ExampleDS
17 17
18 frameworkdemoiselle.persistence.default.datasource.name=conn3 18 frameworkdemoiselle.persistence.default.datasource.name=conn3
19 \ No newline at end of file 19 \ No newline at end of file
impl/extension/jdbc/src/test/resources/producer/with-jndi/demoiselle.properties
1 -frameworkdemoiselle.persistence.conn1.jndi.name=jdbc/arquillian  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +frameworkdemoiselle.persistence.conn1.jndi.name=java:jboss/datasources/ExampleDS
3 \ No newline at end of file 3 \ No newline at end of file
impl/extension/jmx/pom.xml
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 <artifactId>demoiselle-jmx</artifactId> 40 <artifactId>demoiselle-jmx</artifactId>
41 <name>Demoiselle Framework JMX Extension</name> 41 <name>Demoiselle Framework JMX Extension</name>
42 <description>Demoiselle Framework JMX Extension</description> 42 <description>Demoiselle Framework JMX Extension</description>
43 - 43 +
44 <parent> 44 <parent>
45 <artifactId>demoiselle-extension-parent</artifactId> 45 <artifactId>demoiselle-extension-parent</artifactId>
46 <groupId>br.gov.frameworkdemoiselle</groupId> 46 <groupId>br.gov.frameworkdemoiselle</groupId>
@@ -76,11 +76,13 @@ @@ -76,11 +76,13 @@
76 <artifactId>weld-se-core</artifactId> 76 <artifactId>weld-se-core</artifactId>
77 <scope>test</scope> 77 <scope>test</scope>
78 </dependency> 78 </dependency>
  79 + <!--
79 <dependency> 80 <dependency>
80 <groupId>org.jboss.arquillian.container</groupId> 81 <groupId>org.jboss.arquillian.container</groupId>
81 <artifactId>arquillian-weld-se-embedded-1.1</artifactId> 82 <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
82 <scope>test</scope> 83 <scope>test</scope>
83 </dependency> 84 </dependency>
  85 + -->
84 <dependency> 86 <dependency>
85 <groupId>org.hibernate</groupId> 87 <groupId>org.hibernate</groupId>
86 <artifactId>hibernate-validator</artifactId> 88 <artifactId>hibernate-validator</artifactId>
@@ -92,7 +94,7 @@ @@ -92,7 +94,7 @@
92 <scope>test</scope> 94 <scope>test</scope>
93 </dependency> 95 </dependency>
94 </dependencies> 96 </dependencies>
95 - 97 +
96 <repositories> 98 <repositories>
97 <repository> 99 <repository>
98 <id>sonatype-nexus-snapshots</id> 100 <id>sonatype-nexus-snapshots</id>
@@ -117,14 +119,14 @@ @@ -117,14 +119,14 @@
117 </releases> 119 </releases>
118 </repository> 120 </repository>
119 </repositories> 121 </repositories>
120 - 122 +
121 <url>http://www.frameworkdemoiselle.gov.br</url> 123 <url>http://www.frameworkdemoiselle.gov.br</url>
122 - 124 +
123 <organization> 125 <organization>
124 <name>SERPRO - Serviço Federal de Processamento de Dados</name> 126 <name>SERPRO - Serviço Federal de Processamento de Dados</name>
125 <url>http://www.serpro.gov.br</url> 127 <url>http://www.serpro.gov.br</url>
126 </organization> 128 </organization>
127 - 129 +
128 <licenses> 130 <licenses>
129 <license> 131 <license>
130 <name>GNU Lesser General Public License, Version 3</name> 132 <name>GNU Lesser General Public License, Version 3</name>
impl/extension/jpa/pom.xml
@@ -66,335 +66,11 @@ @@ -66,335 +66,11 @@
66 <url>http://www.serpro.gov.br</url> 66 <url>http://www.serpro.gov.br</url>
67 </organization> 67 </organization>
68 68
69 - <build>  
70 - <testResources>  
71 - <testResource>  
72 - <directory>src/test/resources</directory>  
73 - <filtering>true</filtering>  
74 - </testResource>  
75 - </testResources>  
76 -  
77 - <plugins>  
78 - <plugin>  
79 - <artifactId>maven-dependency-plugin</artifactId>  
80 - <executions>  
81 - <execution>  
82 - <id>unpack</id>  
83 - <phase>process-test-classes</phase>  
84 - <goals>  
85 - <goal>unpack</goal>  
86 - </goals>  
87 - <configuration>  
88 - <artifactItems>  
89 - <artifactItem>  
90 - <groupId>org.jboss.as</groupId>  
91 - <artifactId>jboss-as-dist</artifactId>  
92 - <version>${jbossas.version}</version>  
93 - <type>zip</type>  
94 - <overWrite>false</overWrite>  
95 - <outputDirectory>target</outputDirectory>  
96 - </artifactItem>  
97 - </artifactItems>  
98 - </configuration>  
99 - </execution>  
100 - </executions>  
101 - </plugin>  
102 - <!--  
103 - <plugin>  
104 - <artifactId>maven-surefire-plugin</artifactId>  
105 - <version>2.12.4</version>  
106 - <configuration>  
107 - <environmentVariables>  
108 - <JBOSS_HOME>${project.build.directory}/jboss-as-${jbossas.version}</JBOSS_HOME>  
109 - </environmentVariables>  
110 - <systemProperties>  
111 - <jboss.version>${jbossas.version}</jboss.version>  
112 - </systemProperties>  
113 - </configuration>  
114 - </plugin>  
115 - <plugin>  
116 - <groupId>org.apache.maven.plugins</groupId>  
117 - <artifactId>maven-dependency-plugin</artifactId>  
118 - <executions>  
119 - <execution>  
120 - <id>unpack</id>  
121 - <phase>process-test-classes</phase>  
122 - <goals>  
123 - <goal>unpack</goal>  
124 - </goals>  
125 - <configuration>  
126 - <artifactItems>  
127 - <artifactItem>  
128 - <groupId>org.jboss.as</groupId>  
129 - <artifactId>jboss-as-dist</artifactId>  
130 - <version>${jbossas.version}</version>  
131 - <type>zip</type>  
132 - <overWrite>false</overWrite>  
133 - <outputDirectory>${project.build.directory}</outputDirectory>  
134 - </artifactItem>  
135 - </artifactItems>  
136 - </configuration>  
137 - </execution>  
138 - </executions>  
139 - </plugin>  
140 - -->  
141 - <!--  
142 - <plugin>  
143 -  
144 - <groupId>org.apache.maven.plugins</groupId>  
145 - <artifactId>maven-surefire-plugin</artifactId>  
146 - <configuration>  
147 - <systemPropertyVariables>  
148 - <tomee.httpPort>-1</tomee.httpPort>  
149 - <tomee.stopPort>-1</tomee.stopPort>  
150 - </systemPropertyVariables>  
151 - </configuration>  
152 - </plugin>  
153 - -->  
154 - <!--  
155 - <plugin>  
156 - <groupId>org.apache.maven.plugins</groupId>  
157 - <artifactId>maven-surefire-plugin</artifactId>  
158 - <version>2.12</version>  
159 - <configuration>  
160 - <systemPropertyVariables>  
161 - <java.util.logging.config.file>${project.build.testOutputDirectory}/logging.properties</java.util.logging.config.file>  
162 - <derby.stream.error.file>${project.build.directory}/derby.log</derby.stream.error.file>  
163 - </systemPropertyVariables>  
164 - </configuration>  
165 - </plugin>  
166 - -->  
167 - <plugin>  
168 - <groupId>org.apache.maven.plugins</groupId>  
169 - <artifactId>maven-surefire-plugin</artifactId>  
170 - <version>2.16</version>  
171 - </plugin>  
172 - </plugins>  
173 - <pluginManagement>  
174 - <plugins>  
175 - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->  
176 - <plugin>  
177 - <groupId>org.eclipse.m2e</groupId>  
178 - <artifactId>lifecycle-mapping</artifactId>  
179 - <version>1.0.0</version>  
180 - <configuration>  
181 - <lifecycleMappingMetadata>  
182 - <pluginExecutions>  
183 - <pluginExecution>  
184 - <pluginExecutionFilter>  
185 - <groupId>  
186 - org.apache.maven.plugins  
187 - </groupId>  
188 - <artifactId>  
189 - maven-dependency-plugin  
190 - </artifactId>  
191 - <versionRange>  
192 - [2.1,)  
193 - </versionRange>  
194 - <goals>  
195 - <goal>unpack</goal>  
196 - </goals>  
197 - </pluginExecutionFilter>  
198 - <action>  
199 - <ignore></ignore>  
200 - </action>  
201 - </pluginExecution>  
202 - </pluginExecutions>  
203 - </lifecycleMappingMetadata>  
204 - </configuration>  
205 - </plugin>  
206 - </plugins>  
207 - </pluginManagement>  
208 - </build>  
209 -  
210 <dependencies> 69 <dependencies>
211 <dependency> 70 <dependency>
212 <groupId>org.eclipse.persistence</groupId> 71 <groupId>org.eclipse.persistence</groupId>
213 <artifactId>javax.persistence</artifactId> 72 <artifactId>javax.persistence</artifactId>
214 </dependency> 73 </dependency>
215 -  
216 - <!-- for tests -->  
217 - <dependency>  
218 - <groupId>junit</groupId>  
219 - <artifactId>junit</artifactId>  
220 - <scope>test</scope>  
221 - </dependency>  
222 - <dependency>  
223 - <groupId>org.jboss.arquillian.junit</groupId>  
224 - <artifactId>arquillian-junit-container</artifactId>  
225 - <scope>test</scope>  
226 - </dependency>  
227 -  
228 - <!--  
229 - <dependency>  
230 - <groupId>org.jboss.as</groupId>  
231 - <artifactId>jboss-as-arquillian-container-embedded</artifactId>  
232 - <version>7.2.0.Final</version>  
233 - <scope>test</scope>  
234 - </dependency>  
235 - -->  
236 -  
237 - <!--  
238 - -->  
239 - <dependency>  
240 - <groupId>org.jboss.as</groupId>  
241 - <artifactId>jboss-as-arquillian-container-managed</artifactId>  
242 - <version>${jbossas.version}</version>  
243 - <scope>test</scope>  
244 - </dependency>  
245 - <dependency>  
246 - <groupId>org.jboss.arquillian.protocol</groupId>  
247 - <artifactId>arquillian-protocol-servlet</artifactId>  
248 - </dependency>  
249 -  
250 - <!--  
251 - <dependency>  
252 - <groupId>org.apache.openejb</groupId>  
253 - <artifactId>arquillian-tomee-embedded</artifactId>  
254 - <version>1.5.2</version>  
255 - </dependency>  
256 - -->  
257 -  
258 - <!--  
259 - <dependency>  
260 - <groupId>org.jboss.arquillian.container</groupId>  
261 - <artifactId>arquillian-glassfish-embedded-3.1</artifactId>  
262 - <scope>test</scope>  
263 - </dependency>  
264 - <dependency>  
265 - <groupId>org.glassfish.main.extras</groupId>  
266 - <artifactId>glassfish-embedded-all</artifactId>  
267 - <version>3.1.2.2</version>  
268 - <version>4.0</version>  
269 - <version>3.2-b06</version>  
270 - <version>3.1.2</version>  
271 - <scope>test</scope>  
272 - </dependency>  
273 - -->  
274 - <!--  
275 - <dependency>  
276 - <groupId>org.glassfish.main.extras</groupId>  
277 - <artifactId>glassfish-embedded-web</artifactId>  
278 - <scope>test</scope>  
279 - </dependency>  
280 - -->  
281 -  
282 - <!--  
283 - <dependency>  
284 - <groupId>org.jboss.as</groupId>  
285 - <artifactId>jboss-as-arquillian-container-managed</artifactId>  
286 - <version>7.1.1.Final</version>  
287 - <scope>test</scope>  
288 - </dependency>  
289 - <dependency>  
290 - <groupId>org.jboss.arquillian.protocol</groupId>  
291 - <artifactId>arquillian-protocol-servlet</artifactId>  
292 - <scope>test</scope>  
293 - </dependency>  
294 - -->  
295 -  
296 - <!--  
297 - <dependency>  
298 - <groupId>org.jboss.as</groupId>  
299 - <artifactId>jboss-as-arquillian-container-managed</artifactId>  
300 - <version>7.1.1.Final</version>  
301 - <scope>test</scope>  
302 - </dependency>  
303 - <dependency>  
304 - <groupId>org.jboss.arquillian.protocol</groupId>  
305 - <artifactId>arquillian-protocol-servlet</artifactId>  
306 - <scope>test</scope>  
307 - </dependency>  
308 - -->  
309 -  
310 - <dependency>  
311 - <groupId>org.jboss.shrinkwrap.resolver</groupId>  
312 - <artifactId>shrinkwrap-resolver-impl-maven</artifactId>  
313 - <scope>test</scope>  
314 - </dependency>  
315 - <!--  
316 - <dependency>  
317 - <groupId>org.jboss.shrinkwrap.resolver</groupId>  
318 - <artifactId>shrinkwrap-resolver-depchain</artifactId>  
319 - <type>pom</type>  
320 - <scope>test</scope>  
321 - </dependency>  
322 - -->  
323 -  
324 - <!--  
325 - <dependency>  
326 - <groupId>org.jboss.arquillian.protocol</groupId>  
327 - <artifactId>arquillian-protocol-servlet</artifactId>  
328 - <scope>test</scope>  
329 - </dependency>  
330 - <dependency>  
331 - <groupId>org.jboss.arquillian.extension</groupId>  
332 - <artifactId>arquillian-jacoco</artifactId>  
333 - <version>1.0.0.Alpha5</version>  
334 - <scope>test</scope>  
335 - </dependency>  
336 - <dependency>  
337 - <groupId>org.jacoco</groupId>  
338 - <artifactId>org.jacoco.core</artifactId>  
339 - <version>0.6.3.201306030806</version>  
340 - </dependency>  
341 - -->  
342 -  
343 - <!--  
344 - <dependency>  
345 - <groupId>org.apache.openejb</groupId>  
346 - <artifactId>arquillian-tomee-embedded</artifactId>  
347 - <version>1.5.2</version>  
348 - </dependency>  
349 - <dependency>  
350 - <groupId>org.apache.openejb</groupId>  
351 - <artifactId>tomee-embedded</artifactId>  
352 - <version>1.5.2</version>  
353 - </dependency>  
354 - -->  
355 -  
356 - <!--  
357 - <dependency>  
358 - <groupId>org.jboss.arquillian.extension</groupId>  
359 - <artifactId>arquillian-persistence-impl</artifactId>  
360 - <scope>test</scope>  
361 - <exclusions>  
362 - <exclusion>  
363 - <artifactId>log4j</artifactId>  
364 - <groupId>log4j</groupId>  
365 - </exclusion>  
366 - </exclusions>  
367 - </dependency>  
368 - -->  
369 -  
370 - <!--  
371 - <dependency>  
372 - <groupId>hsqldb</groupId>  
373 - <artifactId>hsqldb</artifactId>  
374 - <scope>test</scope>  
375 - </dependency>  
376 - -->  
377 -  
378 - <!--  
379 - <dependency>  
380 - <groupId>org.slf4j</groupId>  
381 - <artifactId>slf4j-log4j12</artifactId>  
382 - <scope>test</scope>  
383 - </dependency>  
384 - -->  
385 -  
386 - <!--  
387 - <dependency>  
388 - <groupId>org.hibernate</groupId>  
389 - <artifactId>hibernate-entitymanager</artifactId>  
390 - <scope>test</scope>  
391 - </dependency>  
392 - <dependency>  
393 - <groupId>org.hibernate</groupId>  
394 - <artifactId>hibernate-validator</artifactId>  
395 - <scope>test</scope>  
396 - </dependency>  
397 - -->  
398 </dependencies> 74 </dependencies>
399 75
400 <repositories> 76 <repositories>
@@ -425,57 +101,13 @@ @@ -425,57 +101,13 @@
425 <profiles> 101 <profiles>
426 <profile> 102 <profile>
427 <id>arquillian-test</id> 103 <id>arquillian-test</id>
428 -  
429 <dependencies> 104 <dependencies>
430 <dependency> 105 <dependency>
431 - <groupId>br.gov.frameworkdemoiselle</groupId>  
432 - <artifactId>demoiselle-core</artifactId>  
433 - <exclusions>  
434 - <exclusion>  
435 - <groupId>javax.enterprise</groupId>  
436 - <artifactId>cdi-api</artifactId>  
437 - </exclusion>  
438 - <exclusion>  
439 - <artifactId>validation-api</artifactId>  
440 - <groupId>javax.validation</groupId>  
441 - </exclusion>  
442 - <!--  
443 - -->  
444 - <exclusion>  
445 - <groupId>org.slf4j</groupId>  
446 - <artifactId>slf4j-api</artifactId>  
447 - </exclusion>  
448 - <exclusion>  
449 - <groupId>org.javassist</groupId>  
450 - <artifactId>javassist</artifactId>  
451 - </exclusion>  
452 - </exclusions>  
453 - </dependency>  
454 - <dependency>  
455 <groupId>org.eclipse.persistence</groupId> 106 <groupId>org.eclipse.persistence</groupId>
456 <artifactId>javax.persistence</artifactId> 107 <artifactId>javax.persistence</artifactId>
457 <scope>provided</scope> 108 <scope>provided</scope>
458 </dependency> 109 </dependency>
459 -  
460 - <!--  
461 - <dependency>  
462 - <groupId>org.slf4j</groupId>  
463 - <artifactId>jul-to-slf4j</artifactId>  
464 - <version>1.7.5</version>  
465 - <scope>runtime</scope>  
466 - </dependency>  
467 - <dependency>  
468 - <groupId>ch.qos.logback</groupId>  
469 - <artifactId>logback-classic</artifactId>  
470 - <version>1.0.13</version>  
471 - <scope>runtime</scope>  
472 - </dependency>  
473 - -->  
474 </dependencies> 110 </dependencies>
475 </profile> 111 </profile>
476 </profiles> 112 </profiles>
477 -  
478 - <properties>  
479 - <jbossas.version>7.1.1.Final</jbossas.version>  
480 - </properties>  
481 </project> 113 </project>
impl/extension/jpa/src/test/java/template/JPACrudTest.java
@@ -31,11 +31,6 @@ public class JPACrudTest { @@ -31,11 +31,6 @@ public class JPACrudTest {
31 } 31 }
32 32
33 @Test 33 @Test
34 - public void x() {  
35 -  
36 - }  
37 -  
38 - @Test  
39 public void successfullyInserted() { 34 public void successfullyInserted() {
40 populate(1, 0); 35 populate(1, 0);
41 36
impl/extension/jpa/src/test/java/transaction/manual/JPATransactionTest.java
@@ -4,13 +4,12 @@ import static junit.framework.Assert.assertEquals; @@ -4,13 +4,12 @@ import static junit.framework.Assert.assertEquals;
4 import static junit.framework.Assert.assertFalse; 4 import static junit.framework.Assert.assertFalse;
5 import static junit.framework.Assert.assertNull; 5 import static junit.framework.Assert.assertNull;
6 import static junit.framework.Assert.assertTrue; 6 import static junit.framework.Assert.assertTrue;
  7 +import static junit.framework.Assert.fail;
7 8
8 import javax.inject.Inject; 9 import javax.inject.Inject;
9 import javax.persistence.EntityManager; 10 import javax.persistence.EntityManager;
10 import javax.persistence.TransactionRequiredException; 11 import javax.persistence.TransactionRequiredException;
11 12
12 -import junit.framework.Assert;  
13 -  
14 import org.jboss.arquillian.container.test.api.Deployment; 13 import org.jboss.arquillian.container.test.api.Deployment;
15 import org.jboss.arquillian.junit.Arquillian; 14 import org.jboss.arquillian.junit.Arquillian;
16 import org.jboss.shrinkwrap.api.spec.WebArchive; 15 import org.jboss.shrinkwrap.api.spec.WebArchive;
@@ -124,32 +123,32 @@ public class JPATransactionTest { @@ -124,32 +123,32 @@ public class JPATransactionTest {
124 assertNull(persisted1); 123 assertNull(persisted1);
125 assertNull(persisted2); 124 assertNull(persisted2);
126 } 125 }
127 - 126 +
128 @Test 127 @Test
129 - public void checkEntityManagerCreatedAfterTransaction(){ 128 + public void checkEntityManagerCreatedAfterTransaction() {
130 Transaction transaction = transactionContext.getCurrentTransaction(); 129 Transaction transaction = transactionContext.getCurrentTransaction();
131 130
132 String id = createId("id-5"); 131 String id = createId("id-5");
133 MyEntity1 entity1 = new MyEntity1(); 132 MyEntity1 entity1 = new MyEntity1();
134 entity1.setId(id); 133 entity1.setId(id);
135 entity1.setDescription("Test description"); 134 entity1.setDescription("Test description");
136 -  
137 - Assert.assertFalse(transaction.isActive()); 135 +
  136 + assertFalse(transaction.isActive());
138 transaction.begin(); 137 transaction.begin();
139 - Assert.assertTrue(transaction.isActive());  
140 - 138 + assertTrue(transaction.isActive());
  139 +
141 EntityManager em1 = Beans.getReference(EntityManager.class, new NameQualifier("pu3")); 140 EntityManager em1 = Beans.getReference(EntityManager.class, new NameQualifier("pu3"));
142 -  
143 - try{ 141 +
  142 + try {
144 em1.persist(entity1); 143 em1.persist(entity1);
145 transaction.commit(); 144 transaction.commit();
  145 +
  146 + } catch (TransactionRequiredException te) {
  147 + fail("Entity Manager não ingressou em transação já em curso: " + te.getMessage());
146 } 148 }
147 - catch(TransactionRequiredException te){  
148 - Assert.fail("Entity Manager não ingressou em transação já em curso: "+te.getMessage());  
149 - }  
150 - 149 +
151 entity1 = em1.find(MyEntity1.class, id); 150 entity1 = em1.find(MyEntity1.class, id);
152 - Assert.assertEquals("Test description", entity1.getDescription()); 151 + assertEquals("Test description", entity1.getDescription());
153 } 152 }
154 153
155 private String createId(String id) { 154 private String createId(String id) {
impl/extension/jpa/src/test/resources/arquillian.xml
@@ -46,51 +46,8 @@ @@ -46,51 +46,8 @@
46 <container qualifier="jbossas-managed" default="true"> 46 <container qualifier="jbossas-managed" default="true">
47 <protocol type="Servlet 3.0" /> 47 <protocol type="Servlet 3.0" />
48 <configuration> 48 <configuration>
49 - <property name="jbossHome">target/jboss-as-${jbossas.version}</property> 49 + <property name="jbossHome">target/jboss-as-${jboss.as.version}</property>
50 </configuration> 50 </configuration>
51 </container> 51 </container>
52 - <!--  
53 - <container qualifier="jbossas-managed" default="true">  
54 - <configuration>  
55 - <property name="jbossHome">target/jboss-as-${jbossas.version}</property>  
56 - <property name="javaVmArguments">-Djboss.socket.binding.port-offset=10000 -Xmx512m -XX:MaxPermSize=128m</property>  
57 - </configuration>  
58 - </container>  
59 - -->  
60 - <!--  
61 - <container qualifier="jbossas-managed" default="true">  
62 - <configuration>  
63 - <property name="javaHome">/usr/lib/jvm/java-6-serpro/</property>  
64 - <property name="jbossHome">/opt/demoiselle/server/jboss-7.1/</property>  
65 - </configuration>  
66 - </container>  
67 - -->  
68 -  
69 - <!--  
70 - <container qualifier="glassfish-embedded" default="true">  
71 - <protocol type="Servlet 3.0" />  
72 - <configuration>  
73 - <property name="sunResourcesXml">src/test/resources/glassfish-resources.xml</property>  
74 - </configuration>  
75 - </container>  
76 - -->  
77 -  
78 - <!--  
79 - <container qualifier="tomee" default="true">  
80 - <configuration>  
81 - <property name="httpPort">-1</property>  
82 - <property name="stopPort">-1</property>  
83 - </configuration>  
84 - </container>  
85 - -->  
86 -  
87 - <!--  
88 - <container qualifier="jbossas-embedded" default="true">  
89 - <configuration>  
90 - <property name="bindaddress">127.0.0.1</property>  
91 - <property name="httpport">8081</property>  
92 - </configuration>  
93 - </container>  
94 - -->  
95 52
96 </arquillian> 53 </arquillian>
impl/extension/jpa/src/test/resources/glassfish-resources.xml
@@ -1,57 +0,0 @@ @@ -1,57 +0,0 @@
1 -<!--  
2 - Demoiselle Framework  
3 - Copyright (C) 2010 SERPRO  
4 - ============================================================================  
5 - This file is part of Demoiselle Framework.  
6 -  
7 - Demoiselle Framework is free software; you can redistribute it and/or  
8 - modify it under the terms of the GNU Lesser General Public License version 3  
9 - as published by the Free Software Foundation.  
10 -  
11 - This program is distributed in the hope that it will be useful,  
12 - but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - GNU General Public License for more details.  
15 -  
16 - You should have received a copy of the GNU Lesser General Public License version 3  
17 - along with this program; if not, see <http://www.gnu.org/licenses />  
18 - or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - Fifth Floor, Boston, MA 02110-1301, USA.  
20 - ============================================================================  
21 - Este arquivo é parte do Framework Demoiselle.  
22 -  
23 - O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - do Software Livre (FSF).  
26 -  
27 - Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - para maiores detalhes.  
31 -  
32 - Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses />  
34 - ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 --->  
37 -<!DOCTYPE resources PUBLIC  
38 - "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"  
39 - "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">  
40 -<resources>  
41 - <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool1" jndi-name="jdbc/arquillian1" />  
42 - <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool2" jndi-name="jdbc/arquillian2" />  
43 -  
44 - <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool1" res-type="javax.sql.DataSource" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"  
45 - is-isolation-level-guaranteed="false">  
46 -  
47 - <property name="databaseName" value="target/databases/derby1" />  
48 - <property name="createDatabase" value="create" />  
49 - </jdbc-connection-pool>  
50 -  
51 - <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool2" res-type="javax.sql.DataSource" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"  
52 - is-isolation-level-guaranteed="false">  
53 -  
54 - <property name="databaseName" value="target/databases/derby2" />  
55 - <property name="createDatabase" value="create" />  
56 - </jdbc-connection-pool>  
57 -</resources>  
58 \ No newline at end of file 0 \ No newline at end of file
impl/extension/jpa/src/test/resources/logging.properties
@@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
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 -handlers=java.util.logging.ConsoleHandler  
37 -java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter  
38 -java.util.logging.SimpleFormatter.format=%4$s: %5$s%n  
39 -java.util.logging.ConsoleHandler.level=FINEST  
40 \ No newline at end of file 0 \ No newline at end of file
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/JsfBootstrapTest.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.bootstrap;  
38 -  
39 -import static org.easymock.EasyMock.expect;  
40 -import static org.powermock.api.easymock.PowerMock.createMock;  
41 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
42 -import static org.powermock.api.easymock.PowerMock.replay;  
43 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
44 -  
45 -import java.util.ArrayList;  
46 -import java.util.List;  
47 -import java.util.Locale;  
48 -  
49 -import javax.enterprise.inject.spi.AfterBeanDiscovery;  
50 -import javax.enterprise.inject.spi.AfterDeploymentValidation;  
51 -  
52 -import junit.framework.Assert;  
53 -  
54 -import org.junit.Before;  
55 -import org.junit.Ignore;  
56 -import org.junit.Test;  
57 -import org.junit.runner.RunWith;  
58 -import org.powermock.core.classloader.annotations.PrepareForTest;  
59 -import org.powermock.modules.junit4.PowerMockRunner;  
60 -import org.powermock.reflect.Whitebox;  
61 -  
62 -import br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext;  
63 -import br.gov.frameworkdemoiselle.internal.context.ContextManager;  
64 -import br.gov.frameworkdemoiselle.internal.context.ViewContext;  
65 -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;  
66 -import br.gov.frameworkdemoiselle.util.Beans;  
67 -  
68 -@RunWith(PowerMockRunner.class)  
69 -@PrepareForTest({ Beans.class, ContextManager.class })  
70 -@Ignore  
71 -public class JsfBootstrapTest {  
72 -  
73 - private JsfBootstrap bootstrap;  
74 -  
75 - private AfterBeanDiscovery event;  
76 -  
77 - @Before  
78 - public void before() {  
79 - event = createMock(AfterBeanDiscovery.class);  
80 - mockStatic(Beans.class);  
81 - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes();  
82 - replay(Beans.class);  
83 - bootstrap = new JsfBootstrap();  
84 - }  
85 -  
86 - @Test  
87 - public void testStoreContexts() {  
88 - bootstrap.storeContexts(event);  
89 - replay(event);  
90 -  
91 - Assert.assertEquals(event, Whitebox.getInternalState(bootstrap, "afterBeanDiscoveryEvent"));  
92 - List<AbstractCustomContext> context = Whitebox.getInternalState(bootstrap, "tempContexts");  
93 - Assert.assertEquals(1, context.size());  
94 - verifyAll();  
95 - }  
96 -  
97 - @Test  
98 - public void testAddContexts() {  
99 - List<AbstractCustomContext> tempContexts = new ArrayList<AbstractCustomContext>();  
100 - AbstractCustomContext tempContext = new ViewContext();  
101 - tempContexts.add(tempContext);  
102 - Whitebox.setInternalState(bootstrap, "tempContexts", tempContexts);  
103 - Whitebox.setInternalState(bootstrap, "afterBeanDiscoveryEvent", event);  
104 -  
105 - AfterDeploymentValidation afterDeploymentValidation = createMock(AfterDeploymentValidation.class);  
106 -  
107 - event.addContext(tempContext);  
108 -  
109 - replay(event, afterDeploymentValidation);  
110 -  
111 - bootstrap.addContexts(afterDeploymentValidation);  
112 - verifyAll();  
113 - }  
114 -  
115 - @Test  
116 - public void testRemoveContexts() {  
117 - bootstrap.storeContexts(event);  
118 -  
119 - AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class);  
120 - replay(event, afterShutdownProccess);  
121 - bootstrap.removeContexts(afterShutdownProccess);  
122 -  
123 - verifyAll();  
124 - }  
125 -  
126 -} 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.bootstrap;
  38 +//
  39 +//import static org.easymock.EasyMock.expect;
  40 +//import static org.powermock.api.easymock.PowerMock.createMock;
  41 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  42 +//import static org.powermock.api.easymock.PowerMock.replay;
  43 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  44 +//
  45 +//import java.util.ArrayList;
  46 +//import java.util.List;
  47 +//import java.util.Locale;
  48 +//
  49 +//import javax.enterprise.inject.spi.AfterBeanDiscovery;
  50 +//import javax.enterprise.inject.spi.AfterDeploymentValidation;
  51 +//
  52 +//import junit.framework.Assert;
  53 +//
  54 +//import org.junit.Before;
  55 +//import org.junit.Ignore;
  56 +//import org.junit.Test;
  57 +//import org.junit.runner.RunWith;
  58 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  59 +//import org.powermock.modules.junit4.PowerMockRunner;
  60 +//import org.powermock.reflect.Whitebox;
  61 +//
  62 +//import br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext;
  63 +//import br.gov.frameworkdemoiselle.internal.context.ContextManager;
  64 +//import br.gov.frameworkdemoiselle.internal.context.ViewContext;
  65 +//import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
  66 +//import br.gov.frameworkdemoiselle.util.Beans;
  67 +//
  68 +//@RunWith(PowerMockRunner.class)
  69 +//@PrepareForTest({ Beans.class, ContextManager.class })
  70 +//@Ignore
  71 +//public class JsfBootstrapTest {
  72 +//
  73 +// private JsfBootstrap bootstrap;
  74 +//
  75 +// private AfterBeanDiscovery event;
  76 +//
  77 +// @Before
  78 +// public void before() {
  79 +// event = createMock(AfterBeanDiscovery.class);
  80 +// mockStatic(Beans.class);
  81 +// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes();
  82 +// replay(Beans.class);
  83 +// bootstrap = new JsfBootstrap();
  84 +// }
  85 +//
  86 +// @Test
  87 +// public void testStoreContexts() {
  88 +// bootstrap.storeContexts(event);
  89 +// replay(event);
  90 +//
  91 +// Assert.assertEquals(event, Whitebox.getInternalState(bootstrap, "afterBeanDiscoveryEvent"));
  92 +// List<AbstractCustomContext> context = Whitebox.getInternalState(bootstrap, "tempContexts");
  93 +// Assert.assertEquals(1, context.size());
  94 +// verifyAll();
  95 +// }
  96 +//
  97 +// @Test
  98 +// public void testAddContexts() {
  99 +// List<AbstractCustomContext> tempContexts = new ArrayList<AbstractCustomContext>();
  100 +// AbstractCustomContext tempContext = new ViewContext();
  101 +// tempContexts.add(tempContext);
  102 +// Whitebox.setInternalState(bootstrap, "tempContexts", tempContexts);
  103 +// Whitebox.setInternalState(bootstrap, "afterBeanDiscoveryEvent", event);
  104 +//
  105 +// AfterDeploymentValidation afterDeploymentValidation = createMock(AfterDeploymentValidation.class);
  106 +//
  107 +// event.addContext(tempContext);
  108 +//
  109 +// replay(event, afterDeploymentValidation);
  110 +//
  111 +// bootstrap.addContexts(afterDeploymentValidation);
  112 +// verifyAll();
  113 +// }
  114 +//
  115 +// @Test
  116 +// public void testRemoveContexts() {
  117 +// bootstrap.storeContexts(event);
  118 +//
  119 +// AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class);
  120 +// replay(event, afterShutdownProccess);
  121 +// bootstrap.removeContexts(afterShutdownProccess);
  122 +//
  123 +// verifyAll();
  124 +// }
  125 +//
  126 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandlerFactoryTest.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 junit.framework.Assert.assertEquals;  
40 -import static org.easymock.EasyMock.expect;  
41 -import static org.powermock.api.easymock.PowerMock.replayAll;  
42 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
43 -  
44 -import javax.faces.context.ExceptionHandler;  
45 -import javax.faces.context.ExceptionHandlerFactory;  
46 -  
47 -import org.junit.Test;  
48 -import org.junit.runner.RunWith;  
49 -import org.powermock.api.easymock.PowerMock;  
50 -import org.powermock.modules.junit4.PowerMockRunner;  
51 -  
52 -@RunWith(PowerMockRunner.class)  
53 -public class ApplicationExceptionHandlerFactoryTest {  
54 -  
55 - @Test  
56 - public void testGetExceptionHandler() {  
57 -  
58 - ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);  
59 -  
60 - ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);  
61 -  
62 - ApplicationExceptionHandlerFactory handlerFactory = new ApplicationExceptionHandlerFactory(jsfFactory);  
63 - expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);  
64 -  
65 - replayAll();  
66 -  
67 - ApplicationExceptionHandler handler = (ApplicationExceptionHandler) handlerFactory.getExceptionHandler();  
68 -  
69 - assertEquals(handler.getWrapped(), jsfExceptionHandler);  
70 -  
71 - verifyAll();  
72 -  
73 - }  
74 -  
75 -} 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 junit.framework.Assert.assertEquals;
  40 +//import static org.easymock.EasyMock.expect;
  41 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  43 +//
  44 +//import javax.faces.context.ExceptionHandler;
  45 +//import javax.faces.context.ExceptionHandlerFactory;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.junit.runner.RunWith;
  49 +//import org.powermock.api.easymock.PowerMock;
  50 +//import org.powermock.modules.junit4.PowerMockRunner;
  51 +//
  52 +//@RunWith(PowerMockRunner.class)
  53 +//public class ApplicationExceptionHandlerFactoryTest {
  54 +//
  55 +// @Test
  56 +// public void testGetExceptionHandler() {
  57 +//
  58 +// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);
  59 +//
  60 +// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);
  61 +//
  62 +// ApplicationExceptionHandlerFactory handlerFactory = new ApplicationExceptionHandlerFactory(jsfFactory);
  63 +// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);
  64 +//
  65 +// replayAll();
  66 +//
  67 +// ApplicationExceptionHandler handler = (ApplicationExceptionHandler) handlerFactory.getExceptionHandler();
  68 +//
  69 +// assertEquals(handler.getWrapped(), jsfExceptionHandler);
  70 +//
  71 +// verifyAll();
  72 +//
  73 +// }
  74 +//
  75 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandlerTest.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 junit.framework.Assert.assertFalse;  
40 -import static junit.framework.Assert.assertTrue;  
41 -import static org.easymock.EasyMock.expect;  
42 -import static org.powermock.api.easymock.PowerMock.createMock;  
43 -import static org.powermock.api.easymock.PowerMock.expectLastCall;  
44 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
45 -import static org.powermock.api.easymock.PowerMock.replayAll;  
46 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
47 -  
48 -import java.util.ArrayList;  
49 -import java.util.Collection;  
50 -  
51 -import javax.faces.context.ExceptionHandler;  
52 -import javax.faces.context.FacesContext;  
53 -import javax.faces.event.ExceptionQueuedEvent;  
54 -import javax.faces.event.ExceptionQueuedEventContext;  
55 -import javax.faces.event.PhaseId;  
56 -  
57 -import org.junit.Before;  
58 -import org.junit.Test;  
59 -import org.junit.runner.RunWith;  
60 -import org.powermock.api.easymock.PowerMock;  
61 -import org.powermock.core.classloader.annotations.PrepareForTest;  
62 -import org.powermock.modules.junit4.PowerMockRunner;  
63 -  
64 -import br.gov.frameworkdemoiselle.exception.ApplicationException;  
65 -import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig;  
66 -import br.gov.frameworkdemoiselle.util.Beans;  
67 -import br.gov.frameworkdemoiselle.util.Faces;  
68 -  
69 -@RunWith(PowerMockRunner.class)  
70 -@PrepareForTest({ Beans.class, FacesContext.class, Faces.class })  
71 -public class ApplicationExceptionHandlerTest {  
72 -  
73 - private ApplicationExceptionHandler handler;  
74 -  
75 - private ExceptionQueuedEventContext eventContext;  
76 -  
77 - private ExceptionHandlerConfig config;  
78 -  
79 - private FacesContext facesContext;  
80 -  
81 - private Collection<ExceptionQueuedEvent> events;  
82 -  
83 - @SuppressWarnings("serial")  
84 - @ApplicationException  
85 - class AnnotatedAppException extends RuntimeException {  
86 - }  
87 -  
88 - @SuppressWarnings("serial")  
89 - class SomeException extends RuntimeException {  
90 - }  
91 -  
92 - @Before  
93 - public void setUp() {  
94 -  
95 - mockStatic(Beans.class);  
96 - mockStatic(FacesContext.class);  
97 -  
98 - events = new ArrayList<ExceptionQueuedEvent>();  
99 - ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);  
100 - handler = new ApplicationExceptionHandler(jsfExceptionHandler);  
101 - eventContext = PowerMock.createMock(ExceptionQueuedEventContext.class);  
102 - ExceptionQueuedEvent event = PowerMock.createMock(ExceptionQueuedEvent.class);  
103 - config = PowerMock.createMock(ExceptionHandlerConfig.class);  
104 - facesContext = PowerMock.createMock(FacesContext.class);  
105 -  
106 - expect(event.getSource()).andReturn(eventContext);  
107 - expect(Beans.getReference(ExceptionHandlerConfig.class)).andReturn(config);  
108 - expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes();  
109 - expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);  
110 -  
111 - events.add(event);  
112 -  
113 - }  
114 -  
115 - @Test  
116 - public void testHandleAnApplicationExceptionNotOnRenderResponse() {  
117 -  
118 - mockStatic(Faces.class);  
119 -  
120 - AnnotatedAppException exception = new AnnotatedAppException();  
121 - PhaseId phaseId = PowerMock.createMock(PhaseId.class);  
122 -  
123 - expect(eventContext.getException()).andReturn(exception);  
124 - expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
125 - expect(config.isHandleApplicationException()).andReturn(true);  
126 -  
127 - Faces.addMessage(exception);  
128 - expectLastCall();  
129 -  
130 - replayAll();  
131 -  
132 - handler.handle();  
133 -  
134 - assertTrue(events.isEmpty());  
135 -  
136 - verifyAll();  
137 -  
138 - }  
139 -  
140 - @Test  
141 - public void testHandleAnApplicationExceptionOnRenderResponse() {  
142 -  
143 - AnnotatedAppException exception = new AnnotatedAppException();  
144 - // PhaseId phaseId = PhaseId.RENDER_RESPONSE;  
145 -  
146 - expect(eventContext.getException()).andReturn(exception);  
147 - // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
148 - expect(config.isHandleApplicationException()).andReturn(false);  
149 -  
150 - handler.getWrapped().handle();  
151 - expectLastCall();  
152 -  
153 - replayAll();  
154 -  
155 - handler.handle();  
156 -  
157 - assertFalse(events.isEmpty());  
158 -  
159 - verifyAll();  
160 -  
161 - }  
162 -  
163 - @Test  
164 - public void testHandleAnyException() {  
165 -  
166 - SomeException exception = new SomeException();  
167 - // PhaseId phaseId = PowerMock.createMock(PhaseId.class);  
168 -  
169 - expect(eventContext.getException()).andReturn(exception);  
170 - // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
171 - expect(config.isHandleApplicationException()).andReturn(true);  
172 -  
173 - handler.getWrapped().handle();  
174 - expectLastCall();  
175 -  
176 - replayAll();  
177 -  
178 - handler.handle();  
179 -  
180 - assertFalse(events.isEmpty());  
181 -  
182 - verifyAll();  
183 -  
184 - }  
185 -  
186 - @Test  
187 - public void testDoNotHandleApplicationExceptions() {  
188 -  
189 - AnnotatedAppException exception = new AnnotatedAppException();  
190 -  
191 - expect(eventContext.getException()).andReturn(exception);  
192 - expect(config.isHandleApplicationException()).andReturn(false);  
193 -  
194 - handler.getWrapped().handle();  
195 - expectLastCall();  
196 -  
197 - replayAll();  
198 -  
199 - handler.handle();  
200 -  
201 - assertFalse(events.isEmpty());  
202 -  
203 - verifyAll();  
204 -  
205 - }  
206 -} 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 junit.framework.Assert.assertFalse;
  40 +//import static junit.framework.Assert.assertTrue;
  41 +//import static org.easymock.EasyMock.expect;
  42 +//import static org.powermock.api.easymock.PowerMock.createMock;
  43 +//import static org.powermock.api.easymock.PowerMock.expectLastCall;
  44 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  45 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  46 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  47 +//
  48 +//import java.util.ArrayList;
  49 +//import java.util.Collection;
  50 +//
  51 +//import javax.faces.context.ExceptionHandler;
  52 +//import javax.faces.context.FacesContext;
  53 +//import javax.faces.event.ExceptionQueuedEvent;
  54 +//import javax.faces.event.ExceptionQueuedEventContext;
  55 +//import javax.faces.event.PhaseId;
  56 +//
  57 +//import org.junit.Before;
  58 +//import org.junit.Test;
  59 +//import org.junit.runner.RunWith;
  60 +//import org.powermock.api.easymock.PowerMock;
  61 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  62 +//import org.powermock.modules.junit4.PowerMockRunner;
  63 +//
  64 +//import br.gov.frameworkdemoiselle.exception.ApplicationException;
  65 +//import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig;
  66 +//import br.gov.frameworkdemoiselle.util.Beans;
  67 +//import br.gov.frameworkdemoiselle.util.Faces;
  68 +//
  69 +//@RunWith(PowerMockRunner.class)
  70 +//@PrepareForTest({ Beans.class, FacesContext.class, Faces.class })
  71 +//public class ApplicationExceptionHandlerTest {
  72 +//
  73 +// private ApplicationExceptionHandler handler;
  74 +//
  75 +// private ExceptionQueuedEventContext eventContext;
  76 +//
  77 +// private ExceptionHandlerConfig config;
  78 +//
  79 +// private FacesContext facesContext;
  80 +//
  81 +// private Collection<ExceptionQueuedEvent> events;
  82 +//
  83 +// @SuppressWarnings("serial")
  84 +// @ApplicationException
  85 +// class AnnotatedAppException extends RuntimeException {
  86 +// }
  87 +//
  88 +// @SuppressWarnings("serial")
  89 +// class SomeException extends RuntimeException {
  90 +// }
  91 +//
  92 +// @Before
  93 +// public void setUp() {
  94 +//
  95 +// mockStatic(Beans.class);
  96 +// mockStatic(FacesContext.class);
  97 +//
  98 +// events = new ArrayList<ExceptionQueuedEvent>();
  99 +// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);
  100 +// handler = new ApplicationExceptionHandler(jsfExceptionHandler);
  101 +// eventContext = PowerMock.createMock(ExceptionQueuedEventContext.class);
  102 +// ExceptionQueuedEvent event = PowerMock.createMock(ExceptionQueuedEvent.class);
  103 +// config = PowerMock.createMock(ExceptionHandlerConfig.class);
  104 +// facesContext = PowerMock.createMock(FacesContext.class);
  105 +//
  106 +// expect(event.getSource()).andReturn(eventContext);
  107 +// expect(Beans.getReference(ExceptionHandlerConfig.class)).andReturn(config);
  108 +// expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes();
  109 +// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);
  110 +//
  111 +// events.add(event);
  112 +//
  113 +// }
  114 +//
  115 +// @Test
  116 +// public void testHandleAnApplicationExceptionNotOnRenderResponse() {
  117 +//
  118 +// mockStatic(Faces.class);
  119 +//
  120 +// AnnotatedAppException exception = new AnnotatedAppException();
  121 +// PhaseId phaseId = PowerMock.createMock(PhaseId.class);
  122 +//
  123 +// expect(eventContext.getException()).andReturn(exception);
  124 +// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  125 +// expect(config.isHandleApplicationException()).andReturn(true);
  126 +//
  127 +// Faces.addMessage(exception);
  128 +// expectLastCall();
  129 +//
  130 +// replayAll();
  131 +//
  132 +// handler.handle();
  133 +//
  134 +// assertTrue(events.isEmpty());
  135 +//
  136 +// verifyAll();
  137 +//
  138 +// }
  139 +//
  140 +// @Test
  141 +// public void testHandleAnApplicationExceptionOnRenderResponse() {
  142 +//
  143 +// AnnotatedAppException exception = new AnnotatedAppException();
  144 +// // PhaseId phaseId = PhaseId.RENDER_RESPONSE;
  145 +//
  146 +// expect(eventContext.getException()).andReturn(exception);
  147 +// // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  148 +// expect(config.isHandleApplicationException()).andReturn(false);
  149 +//
  150 +// handler.getWrapped().handle();
  151 +// expectLastCall();
  152 +//
  153 +// replayAll();
  154 +//
  155 +// handler.handle();
  156 +//
  157 +// assertFalse(events.isEmpty());
  158 +//
  159 +// verifyAll();
  160 +//
  161 +// }
  162 +//
  163 +// @Test
  164 +// public void testHandleAnyException() {
  165 +//
  166 +// SomeException exception = new SomeException();
  167 +// // PhaseId phaseId = PowerMock.createMock(PhaseId.class);
  168 +//
  169 +// expect(eventContext.getException()).andReturn(exception);
  170 +// // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  171 +// expect(config.isHandleApplicationException()).andReturn(true);
  172 +//
  173 +// handler.getWrapped().handle();
  174 +// expectLastCall();
  175 +//
  176 +// replayAll();
  177 +//
  178 +// handler.handle();
  179 +//
  180 +// assertFalse(events.isEmpty());
  181 +//
  182 +// verifyAll();
  183 +//
  184 +// }
  185 +//
  186 +// @Test
  187 +// public void testDoNotHandleApplicationExceptions() {
  188 +//
  189 +// AnnotatedAppException exception = new AnnotatedAppException();
  190 +//
  191 +// expect(eventContext.getException()).andReturn(exception);
  192 +// expect(config.isHandleApplicationException()).andReturn(false);
  193 +//
  194 +// handler.getWrapped().handle();
  195 +// expectLastCall();
  196 +//
  197 +// replayAll();
  198 +//
  199 +// handler.handle();
  200 +//
  201 +// assertFalse(events.isEmpty());
  202 +//
  203 +// verifyAll();
  204 +//
  205 +// }
  206 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionHandlerFactoryTest.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 junit.framework.Assert.assertEquals;  
40 -import static org.easymock.EasyMock.expect;  
41 -import static org.powermock.api.easymock.PowerMock.replayAll;  
42 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
43 -  
44 -import javax.faces.context.ExceptionHandler;  
45 -import javax.faces.context.ExceptionHandlerFactory;  
46 -  
47 -import org.junit.Test;  
48 -import org.junit.runner.RunWith;  
49 -import org.powermock.api.easymock.PowerMock;  
50 -import org.powermock.modules.junit4.PowerMockRunner;  
51 -  
52 -@RunWith(PowerMockRunner.class)  
53 -public class AuthenticationExceptionHandlerFactoryTest {  
54 -  
55 - @Test  
56 - public void testGetExceptionHandler() {  
57 -  
58 - ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);  
59 -  
60 - ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);  
61 -  
62 - AuthenticationExceptionHandlerFactory handlerFactory = new AuthenticationExceptionHandlerFactory(jsfFactory);  
63 - expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);  
64 -  
65 - replayAll();  
66 -  
67 - AuthenticationExceptionHandler handler = (AuthenticationExceptionHandler) handlerFactory.getExceptionHandler();  
68 -  
69 - assertEquals(handler.getWrapped(), jsfExceptionHandler);  
70 -  
71 - verifyAll();  
72 -  
73 - }  
74 -  
75 -} 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 junit.framework.Assert.assertEquals;
  40 +//import static org.easymock.EasyMock.expect;
  41 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  43 +//
  44 +//import javax.faces.context.ExceptionHandler;
  45 +//import javax.faces.context.ExceptionHandlerFactory;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.junit.runner.RunWith;
  49 +//import org.powermock.api.easymock.PowerMock;
  50 +//import org.powermock.modules.junit4.PowerMockRunner;
  51 +//
  52 +//@RunWith(PowerMockRunner.class)
  53 +//public class AuthenticationExceptionHandlerFactoryTest {
  54 +//
  55 +// @Test
  56 +// public void testGetExceptionHandler() {
  57 +//
  58 +// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);
  59 +//
  60 +// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);
  61 +//
  62 +// AuthenticationExceptionHandlerFactory handlerFactory = new AuthenticationExceptionHandlerFactory(jsfFactory);
  63 +// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);
  64 +//
  65 +// replayAll();
  66 +//
  67 +// AuthenticationExceptionHandler handler = (AuthenticationExceptionHandler) handlerFactory.getExceptionHandler();
  68 +//
  69 +// assertEquals(handler.getWrapped(), jsfExceptionHandler);
  70 +//
  71 +// verifyAll();
  72 +//
  73 +// }
  74 +//
  75 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionHandlerTest.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 junit.framework.Assert.assertFalse;  
40 -import static junit.framework.Assert.assertTrue;  
41 -import static org.easymock.EasyMock.expect;  
42 -import static org.powermock.api.easymock.PowerMock.createMock;  
43 -import static org.powermock.api.easymock.PowerMock.expectLastCall;  
44 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
45 -import static org.powermock.api.easymock.PowerMock.replayAll;  
46 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
47 -  
48 -import java.util.ArrayList;  
49 -import java.util.Collection;  
50 -  
51 -import javax.faces.context.ExceptionHandler;  
52 -import javax.faces.event.ExceptionQueuedEvent;  
53 -import javax.faces.event.ExceptionQueuedEventContext;  
54 -  
55 -import org.junit.Before;  
56 -import org.junit.Test;  
57 -import org.junit.runner.RunWith;  
58 -import org.powermock.core.classloader.annotations.PrepareForTest;  
59 -import org.powermock.modules.junit4.PowerMockRunner;  
60 -  
61 -import br.gov.frameworkdemoiselle.security.NotLoggedInException;  
62 -import br.gov.frameworkdemoiselle.util.Beans;  
63 -  
64 -@RunWith(PowerMockRunner.class)  
65 -@PrepareForTest({ Beans.class})  
66 -public class AuthenticationExceptionHandlerTest {  
67 -  
68 - private AuthenticationExceptionHandler handler;  
69 -  
70 - private ExceptionQueuedEventContext eventContext;  
71 -  
72 - private Collection<ExceptionQueuedEvent> events;  
73 -  
74 - @Before  
75 - public void setUp() {  
76 -  
77 - mockStatic(Beans.class);  
78 -  
79 - events = new ArrayList<ExceptionQueuedEvent>();  
80 - ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);  
81 - handler = new AuthenticationExceptionHandler(jsfExceptionHandler);  
82 - eventContext = createMock(ExceptionQueuedEventContext.class);  
83 - ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);  
84 -  
85 - expect(event.getSource()).andReturn(eventContext);  
86 - expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);  
87 -  
88 - events.add(event);  
89 -  
90 - }  
91 -  
92 - @Test  
93 - public void testHandleNotLoggedInException() {  
94 -  
95 - NotLoggedInException exception = new NotLoggedInException("");  
96 -  
97 - SecurityObserver observer = createMock(SecurityObserver.class);  
98 - expect(Beans.getReference(SecurityObserver.class)).andReturn(observer);  
99 - expect(eventContext.getException()).andReturn(exception);  
100 -  
101 - observer.redirectToLoginPage();  
102 - expectLastCall();  
103 -  
104 - replayAll();  
105 -  
106 - handler.handle();  
107 -  
108 - assertTrue(events.isEmpty());  
109 -  
110 - verifyAll();  
111 -  
112 - }  
113 -  
114 - @Test  
115 - public void testHandleAnyException() {  
116 -  
117 - Exception exception = new Exception();  
118 -  
119 - expect(eventContext.getException()).andReturn(exception);  
120 -  
121 - handler.getWrapped().handle();  
122 - expectLastCall();  
123 -  
124 - replayAll();  
125 -  
126 - handler.handle();  
127 -  
128 - assertFalse(events.isEmpty());  
129 -  
130 - verifyAll();  
131 -  
132 - }  
133 -  
134 -} 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 junit.framework.Assert.assertFalse;
  40 +//import static junit.framework.Assert.assertTrue;
  41 +//import static org.easymock.EasyMock.expect;
  42 +//import static org.powermock.api.easymock.PowerMock.createMock;
  43 +//import static org.powermock.api.easymock.PowerMock.expectLastCall;
  44 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  45 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  46 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  47 +//
  48 +//import java.util.ArrayList;
  49 +//import java.util.Collection;
  50 +//
  51 +//import javax.faces.context.ExceptionHandler;
  52 +//import javax.faces.event.ExceptionQueuedEvent;
  53 +//import javax.faces.event.ExceptionQueuedEventContext;
  54 +//
  55 +//import org.junit.Before;
  56 +//import org.junit.Test;
  57 +//import org.junit.runner.RunWith;
  58 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  59 +//import org.powermock.modules.junit4.PowerMockRunner;
  60 +//
  61 +//import br.gov.frameworkdemoiselle.security.NotLoggedInException;
  62 +//import br.gov.frameworkdemoiselle.util.Beans;
  63 +//
  64 +//@RunWith(PowerMockRunner.class)
  65 +//@PrepareForTest({ Beans.class})
  66 +//public class AuthenticationExceptionHandlerTest {
  67 +//
  68 +// private AuthenticationExceptionHandler handler;
  69 +//
  70 +// private ExceptionQueuedEventContext eventContext;
  71 +//
  72 +// private Collection<ExceptionQueuedEvent> events;
  73 +//
  74 +// @Before
  75 +// public void setUp() {
  76 +//
  77 +// mockStatic(Beans.class);
  78 +//
  79 +// events = new ArrayList<ExceptionQueuedEvent>();
  80 +// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);
  81 +// handler = new AuthenticationExceptionHandler(jsfExceptionHandler);
  82 +// eventContext = createMock(ExceptionQueuedEventContext.class);
  83 +// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);
  84 +//
  85 +// expect(event.getSource()).andReturn(eventContext);
  86 +// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);
  87 +//
  88 +// events.add(event);
  89 +//
  90 +// }
  91 +//
  92 +// @Test
  93 +// public void testHandleNotLoggedInException() {
  94 +//
  95 +// NotLoggedInException exception = new NotLoggedInException("");
  96 +//
  97 +// SecurityObserver observer = createMock(SecurityObserver.class);
  98 +// expect(Beans.getReference(SecurityObserver.class)).andReturn(observer);
  99 +// expect(eventContext.getException()).andReturn(exception);
  100 +//
  101 +// observer.redirectToLoginPage();
  102 +// expectLastCall();
  103 +//
  104 +// replayAll();
  105 +//
  106 +// handler.handle();
  107 +//
  108 +// assertTrue(events.isEmpty());
  109 +//
  110 +// verifyAll();
  111 +//
  112 +// }
  113 +//
  114 +// @Test
  115 +// public void testHandleAnyException() {
  116 +//
  117 +// Exception exception = new Exception();
  118 +//
  119 +// expect(eventContext.getException()).andReturn(exception);
  120 +//
  121 +// handler.getWrapped().handle();
  122 +// expectLastCall();
  123 +//
  124 +// replayAll();
  125 +//
  126 +// handler.handle();
  127 +//
  128 +// assertFalse(events.isEmpty());
  129 +//
  130 +// verifyAll();
  131 +//
  132 +// }
  133 +//
  134 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandlerFactoryTest.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 junit.framework.Assert.assertEquals;  
40 -import static org.easymock.EasyMock.expect;  
41 -import static org.powermock.api.easymock.PowerMock.replayAll;  
42 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
43 -  
44 -import javax.faces.context.ExceptionHandler;  
45 -import javax.faces.context.ExceptionHandlerFactory;  
46 -  
47 -import org.junit.Test;  
48 -import org.junit.runner.RunWith;  
49 -import org.powermock.api.easymock.PowerMock;  
50 -import org.powermock.modules.junit4.PowerMockRunner;  
51 -  
52 -@RunWith(PowerMockRunner.class)  
53 -public class AuthorizationExceptionHandlerFactoryTest {  
54 -  
55 - @Test  
56 - public void testGetExceptionHandler() {  
57 -  
58 - ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);  
59 -  
60 - ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);  
61 -  
62 - AuthorizationExceptionHandlerFactory handlerFactory = new AuthorizationExceptionHandlerFactory(jsfFactory);  
63 - expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);  
64 -  
65 - replayAll();  
66 -  
67 - AuthorizationExceptionHandler handler = (AuthorizationExceptionHandler) handlerFactory.getExceptionHandler();  
68 -  
69 - assertEquals(handler.getWrapped(), jsfExceptionHandler);  
70 -  
71 - verifyAll();  
72 -  
73 - }  
74 -  
75 -} 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 junit.framework.Assert.assertEquals;
  40 +//import static org.easymock.EasyMock.expect;
  41 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  43 +//
  44 +//import javax.faces.context.ExceptionHandler;
  45 +//import javax.faces.context.ExceptionHandlerFactory;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.junit.runner.RunWith;
  49 +//import org.powermock.api.easymock.PowerMock;
  50 +//import org.powermock.modules.junit4.PowerMockRunner;
  51 +//
  52 +//@RunWith(PowerMockRunner.class)
  53 +//public class AuthorizationExceptionHandlerFactoryTest {
  54 +//
  55 +// @Test
  56 +// public void testGetExceptionHandler() {
  57 +//
  58 +// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);
  59 +//
  60 +// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);
  61 +//
  62 +// AuthorizationExceptionHandlerFactory handlerFactory = new AuthorizationExceptionHandlerFactory(jsfFactory);
  63 +// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);
  64 +//
  65 +// replayAll();
  66 +//
  67 +// AuthorizationExceptionHandler handler = (AuthorizationExceptionHandler) handlerFactory.getExceptionHandler();
  68 +//
  69 +// assertEquals(handler.getWrapped(), jsfExceptionHandler);
  70 +//
  71 +// verifyAll();
  72 +//
  73 +// }
  74 +//
  75 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandlerTest.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 junit.framework.Assert.assertFalse;  
40 -import static junit.framework.Assert.assertTrue;  
41 -import static org.easymock.EasyMock.expect;  
42 -import static org.powermock.api.easymock.PowerMock.createMock;  
43 -import static org.powermock.api.easymock.PowerMock.expectLastCall;  
44 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
45 -import static org.powermock.api.easymock.PowerMock.replayAll;  
46 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
47 -  
48 -import java.util.ArrayList;  
49 -import java.util.Collection;  
50 -  
51 -import javax.faces.context.ExceptionHandler;  
52 -import javax.faces.context.FacesContext;  
53 -import javax.faces.event.ExceptionQueuedEvent;  
54 -import javax.faces.event.ExceptionQueuedEventContext;  
55 -import javax.faces.event.PhaseId;  
56 -  
57 -import org.junit.Before;  
58 -import org.junit.Test;  
59 -import org.junit.runner.RunWith;  
60 -import org.powermock.api.easymock.PowerMock;  
61 -import org.powermock.core.classloader.annotations.PrepareForTest;  
62 -import org.powermock.modules.junit4.PowerMockRunner;  
63 -  
64 -import br.gov.frameworkdemoiselle.security.AuthorizationException;  
65 -import br.gov.frameworkdemoiselle.util.Faces;  
66 -  
67 -@RunWith(PowerMockRunner.class)  
68 -@PrepareForTest({ FacesContext.class, Faces.class })  
69 -public class AuthorizationExceptionHandlerTest {  
70 -  
71 - private AuthorizationExceptionHandler handler;  
72 -  
73 - private ExceptionQueuedEventContext eventContext;  
74 -  
75 - private Collection<ExceptionQueuedEvent> events;  
76 -  
77 - private FacesContext facesContext;  
78 -  
79 - @Before  
80 - public void setUp() {  
81 -  
82 - mockStatic(FacesContext.class);  
83 -  
84 - events = new ArrayList<ExceptionQueuedEvent>();  
85 - ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);  
86 - handler = new AuthorizationExceptionHandler(jsfExceptionHandler);  
87 - eventContext = createMock(ExceptionQueuedEventContext.class);  
88 - ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);  
89 - facesContext = PowerMock.createMock(FacesContext.class);  
90 -  
91 - expect(event.getSource()).andReturn(eventContext);  
92 - events.add(event);  
93 - expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);  
94 - expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes();  
95 -  
96 -  
97 - }  
98 -  
99 - @Test  
100 - public void testHandleAnAuthorizationExceptionNotOnRenderResponse() {  
101 -  
102 - mockStatic(Faces.class);  
103 -  
104 -// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));  
105 -  
106 - AuthorizationException exception = new AuthorizationException("");  
107 - PhaseId phaseId = PowerMock.createMock(PhaseId.class);  
108 -  
109 - expect(eventContext.getException()).andReturn(exception);  
110 - expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
111 -  
112 - Faces.addMessage(exception);  
113 - expectLastCall();  
114 -  
115 - replayAll();  
116 -  
117 - handler.handle();  
118 -  
119 - assertTrue(events.isEmpty());  
120 -  
121 - verifyAll();  
122 -  
123 - }  
124 -  
125 - @Test  
126 - public void testHandleAnAuthorizationExceptionOnRenderResponse() {  
127 -  
128 -// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));  
129 -  
130 - AuthorizationException exception = new AuthorizationException("");  
131 - PhaseId phaseId = PhaseId.RENDER_RESPONSE;  
132 -  
133 - expect(eventContext.getException()).andReturn(exception);  
134 - expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
135 -  
136 - handler.getWrapped().handle();  
137 - expectLastCall();  
138 -  
139 - replayAll();  
140 -  
141 - handler.handle();  
142 -  
143 - assertFalse(events.isEmpty());  
144 -  
145 - verifyAll();  
146 -  
147 - }  
148 -  
149 - @Test  
150 - public void testHandleAnyException() {  
151 -  
152 - Exception exception = new Exception();  
153 - PhaseId phaseId = PowerMock.createMock(PhaseId.class);  
154 -  
155 - expect(eventContext.getException()).andReturn(exception);  
156 - expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);  
157 -  
158 - handler.getWrapped().handle();  
159 - expectLastCall();  
160 -  
161 - replayAll();  
162 -  
163 - handler.handle();  
164 -  
165 - assertFalse(events.isEmpty());  
166 -  
167 - verifyAll();  
168 -  
169 - }  
170 -  
171 -} 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 junit.framework.Assert.assertFalse;
  40 +//import static junit.framework.Assert.assertTrue;
  41 +//import static org.easymock.EasyMock.expect;
  42 +//import static org.powermock.api.easymock.PowerMock.createMock;
  43 +//import static org.powermock.api.easymock.PowerMock.expectLastCall;
  44 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  45 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  46 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  47 +//
  48 +//import java.util.ArrayList;
  49 +//import java.util.Collection;
  50 +//
  51 +//import javax.faces.context.ExceptionHandler;
  52 +//import javax.faces.context.FacesContext;
  53 +//import javax.faces.event.ExceptionQueuedEvent;
  54 +//import javax.faces.event.ExceptionQueuedEventContext;
  55 +//import javax.faces.event.PhaseId;
  56 +//
  57 +//import org.junit.Before;
  58 +//import org.junit.Test;
  59 +//import org.junit.runner.RunWith;
  60 +//import org.powermock.api.easymock.PowerMock;
  61 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  62 +//import org.powermock.modules.junit4.PowerMockRunner;
  63 +//
  64 +//import br.gov.frameworkdemoiselle.security.AuthorizationException;
  65 +//import br.gov.frameworkdemoiselle.util.Faces;
  66 +//
  67 +//@RunWith(PowerMockRunner.class)
  68 +//@PrepareForTest({ FacesContext.class, Faces.class })
  69 +//public class AuthorizationExceptionHandlerTest {
  70 +//
  71 +// private AuthorizationExceptionHandler handler;
  72 +//
  73 +// private ExceptionQueuedEventContext eventContext;
  74 +//
  75 +// private Collection<ExceptionQueuedEvent> events;
  76 +//
  77 +// private FacesContext facesContext;
  78 +//
  79 +// @Before
  80 +// public void setUp() {
  81 +//
  82 +// mockStatic(FacesContext.class);
  83 +//
  84 +// events = new ArrayList<ExceptionQueuedEvent>();
  85 +// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);
  86 +// handler = new AuthorizationExceptionHandler(jsfExceptionHandler);
  87 +// eventContext = createMock(ExceptionQueuedEventContext.class);
  88 +// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);
  89 +// facesContext = PowerMock.createMock(FacesContext.class);
  90 +//
  91 +// expect(event.getSource()).andReturn(eventContext);
  92 +// events.add(event);
  93 +// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);
  94 +// expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes();
  95 +//
  96 +//
  97 +// }
  98 +//
  99 +// @Test
  100 +// public void testHandleAnAuthorizationExceptionNotOnRenderResponse() {
  101 +//
  102 +// mockStatic(Faces.class);
  103 +//
  104 +//// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));
  105 +//
  106 +// AuthorizationException exception = new AuthorizationException("");
  107 +// PhaseId phaseId = PowerMock.createMock(PhaseId.class);
  108 +//
  109 +// expect(eventContext.getException()).andReturn(exception);
  110 +// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  111 +//
  112 +// Faces.addMessage(exception);
  113 +// expectLastCall();
  114 +//
  115 +// replayAll();
  116 +//
  117 +// handler.handle();
  118 +//
  119 +// assertTrue(events.isEmpty());
  120 +//
  121 +// verifyAll();
  122 +//
  123 +// }
  124 +//
  125 +// @Test
  126 +// public void testHandleAnAuthorizationExceptionOnRenderResponse() {
  127 +//
  128 +//// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));
  129 +//
  130 +// AuthorizationException exception = new AuthorizationException("");
  131 +// PhaseId phaseId = PhaseId.RENDER_RESPONSE;
  132 +//
  133 +// expect(eventContext.getException()).andReturn(exception);
  134 +// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  135 +//
  136 +// handler.getWrapped().handle();
  137 +// expectLastCall();
  138 +//
  139 +// replayAll();
  140 +//
  141 +// handler.handle();
  142 +//
  143 +// assertFalse(events.isEmpty());
  144 +//
  145 +// verifyAll();
  146 +//
  147 +// }
  148 +//
  149 +// @Test
  150 +// public void testHandleAnyException() {
  151 +//
  152 +// Exception exception = new Exception();
  153 +// PhaseId phaseId = PowerMock.createMock(PhaseId.class);
  154 +//
  155 +// expect(eventContext.getException()).andReturn(exception);
  156 +// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId);
  157 +//
  158 +// handler.getWrapped().handle();
  159 +// expectLastCall();
  160 +//
  161 +// replayAll();
  162 +//
  163 +// handler.handle();
  164 +//
  165 +// assertFalse(events.isEmpty());
  166 +//
  167 +// verifyAll();
  168 +//
  169 +// }
  170 +//
  171 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/FileRendererImplTest.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 java.io.ByteArrayInputStream;  
40 -import java.io.File;  
41 -import java.io.IOException;  
42 -import java.io.InputStream;  
43 -  
44 -import javax.faces.context.FacesContext;  
45 -import javax.servlet.ServletOutputStream;  
46 -import javax.servlet.http.HttpServletResponse;  
47 -  
48 -import junit.framework.Assert;  
49 -  
50 -import org.easymock.EasyMock;  
51 -import org.junit.Before;  
52 -import org.junit.Test;  
53 -import org.junit.runner.RunWith;  
54 -import org.powermock.api.easymock.PowerMock;  
55 -import org.powermock.core.classloader.annotations.PrepareForTest;  
56 -import org.powermock.modules.junit4.PowerMockRunner;  
57 -import org.powermock.reflect.Whitebox;  
58 -import org.slf4j.Logger;  
59 -  
60 -import br.gov.frameworkdemoiselle.util.Faces;  
61 -import br.gov.frameworkdemoiselle.util.FileRenderer;  
62 -import br.gov.frameworkdemoiselle.util.FileRenderer.ContentType;  
63 -  
64 -@RunWith(PowerMockRunner.class)  
65 -@PrepareForTest({ Faces.class })  
66 -public class FileRendererImplTest {  
67 -  
68 - private Logger logger;  
69 -  
70 - private FileRenderer renderer;  
71 -  
72 - private FacesContext facesContext;  
73 -  
74 - private HttpServletResponse response;  
75 -  
76 - @Before  
77 - public void before() {  
78 - renderer = new FileRendererImpl();  
79 -  
80 - logger = PowerMock.createMock(Logger.class);  
81 - Whitebox.setInternalState(renderer, "logger", logger);  
82 -  
83 - facesContext = PowerMock.createMock(FacesContext.class);  
84 - Whitebox.setInternalState(renderer, "context", facesContext);  
85 -  
86 - response = PowerMock.createMock(HttpServletResponse.class);  
87 - Whitebox.setInternalState(renderer, "response", response);  
88 - }  
89 -  
90 - @Test  
91 - public void testRenderBytesFail() {  
92 - byte[] bytes = "Test".getBytes();  
93 - String fileName = "fileName.pdf";  
94 -  
95 - logger.debug(EasyMock.anyObject(String.class));  
96 - EasyMock.expectLastCall().anyTimes();  
97 -  
98 - IOException exception = new IOException();  
99 - logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);  
100 - EasyMock.expectLastCall().anyTimes();  
101 -  
102 - response.setContentType(ContentType.PDF.getContentType());  
103 - EasyMock.expectLastCall().times(1);  
104 -  
105 - response.setContentLength(bytes.length);  
106 - EasyMock.expectLastCall().times(1);  
107 -  
108 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
109 - EasyMock.expectLastCall().times(1);  
110 -  
111 - facesContext.responseComplete();  
112 - EasyMock.expectLastCall().times(1);  
113 -  
114 - try {  
115 - EasyMock.expect(response.getOutputStream()).andThrow(exception);  
116 - } catch (IOException e) {  
117 - Assert.fail();  
118 - }  
119 -  
120 - PowerMock.mockStatic(Faces.class);  
121 - Faces.addMessage(exception);  
122 -  
123 - PowerMock.replayAll();  
124 - renderer.render(bytes, ContentType.PDF, fileName);  
125 - PowerMock.verifyAll();  
126 - }  
127 -  
128 - @Test  
129 - public void testRenderBytesSuccess() throws IOException {  
130 - byte[] bytes = "Test".getBytes();  
131 - String fileName = "fileName.pdf";  
132 -  
133 - logger.debug(EasyMock.anyObject(String.class));  
134 - EasyMock.expectLastCall().anyTimes();  
135 -  
136 - facesContext.responseComplete();  
137 - EasyMock.expectLastCall().times(1);  
138 -  
139 - response.setContentType(ContentType.PDF.getContentType());  
140 - EasyMock.expectLastCall().times(1);  
141 -  
142 - response.setContentLength(bytes.length);  
143 - EasyMock.expectLastCall().times(1);  
144 -  
145 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
146 - EasyMock.expectLastCall().times(1);  
147 -  
148 - ServletOutputStream stream = PowerMock.createMock(ServletOutputStream.class);  
149 - stream.write(bytes, 0, bytes.length);  
150 - EasyMock.expectLastCall().times(1);  
151 -  
152 - stream.flush();  
153 - EasyMock.expectLastCall().times(1);  
154 -  
155 - stream.close();  
156 - EasyMock.expectLastCall().times(1);  
157 -  
158 - EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3);  
159 -  
160 - PowerMock.replayAll();  
161 - renderer.render(bytes, ContentType.PDF, fileName);  
162 - PowerMock.verifyAll();  
163 - }  
164 -  
165 - @Test  
166 - public void testRenderStreamFail() {  
167 - byte[] bytes = "Test".getBytes();  
168 - InputStream stream = new ByteArrayInputStream(bytes);  
169 - String fileName = "fileName.pdf";  
170 -  
171 - logger.debug(EasyMock.anyObject(String.class));  
172 - EasyMock.expectLastCall().anyTimes();  
173 -  
174 - IOException exception = new IOException();  
175 - logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);  
176 - EasyMock.expectLastCall().anyTimes();  
177 -  
178 - response.setContentType(ContentType.PDF.getContentType());  
179 - EasyMock.expectLastCall().times(1);  
180 -  
181 - response.setContentLength(bytes.length);  
182 - EasyMock.expectLastCall().times(1);  
183 -  
184 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
185 - EasyMock.expectLastCall().times(1);  
186 -  
187 - facesContext.responseComplete();  
188 - EasyMock.expectLastCall().times(1);  
189 -  
190 - try {  
191 - EasyMock.expect(response.getOutputStream()).andThrow(exception);  
192 - } catch (IOException e) {  
193 - Assert.fail();  
194 - }  
195 -  
196 - PowerMock.mockStatic(Faces.class);  
197 - Faces.addMessage(exception);  
198 -  
199 - PowerMock.replayAll();  
200 - renderer.render(stream, ContentType.PDF, fileName, false);  
201 - PowerMock.verifyAll();  
202 - }  
203 -  
204 - @Test  
205 - public void testRenderStreamSuccess() throws IOException {  
206 - byte[] bytes = "Test".getBytes();  
207 - InputStream inputStream = new ByteArrayInputStream(bytes);  
208 -  
209 - String fileName = "fileName.pdf";  
210 -  
211 - logger.debug(EasyMock.anyObject(String.class));  
212 - EasyMock.expectLastCall().anyTimes();  
213 -  
214 - facesContext.responseComplete();  
215 - EasyMock.expectLastCall().times(1);  
216 -  
217 - response.setContentType(ContentType.PDF.getContentType());  
218 - EasyMock.expectLastCall().times(1);  
219 -  
220 - response.setContentLength(bytes.length);  
221 - EasyMock.expectLastCall().times(1);  
222 -  
223 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
224 - EasyMock.expectLastCall().times(1);  
225 -  
226 - ServletOutputStream stream = new ServletOutputStream() {  
227 -  
228 - @Override  
229 - public void write(int b) throws IOException {  
230 - Assert.assertTrue(true);  
231 - }  
232 - };  
233 -  
234 - EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3);  
235 -  
236 - PowerMock.replayAll();  
237 - renderer.render(inputStream, ContentType.PDF, fileName);  
238 - PowerMock.verifyAll();  
239 - }  
240 -  
241 - @Test  
242 - public void testRenderFileFail() throws IOException {  
243 -  
244 - File file = new File("fileName");  
245 - file.createNewFile();  
246 -  
247 - String fileName = "fileName.pdf";  
248 -  
249 - logger.debug(EasyMock.anyObject(String.class));  
250 - EasyMock.expectLastCall().anyTimes();  
251 -  
252 - IOException exception = new IOException();  
253 - logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);  
254 - EasyMock.expectLastCall().anyTimes();  
255 -  
256 - response.setContentType(ContentType.PDF.getContentType());  
257 - EasyMock.expectLastCall().times(1);  
258 -  
259 - response.setContentLength((int) file.length());  
260 - EasyMock.expectLastCall().times(1);  
261 -  
262 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
263 - EasyMock.expectLastCall().times(1);  
264 -  
265 - facesContext.responseComplete();  
266 - EasyMock.expectLastCall().times(1);  
267 -  
268 - try {  
269 - EasyMock.expect(response.getOutputStream()).andThrow(exception);  
270 - } catch (IOException e) {  
271 - Assert.fail();  
272 - }  
273 -  
274 - PowerMock.mockStatic(Faces.class);  
275 - Faces.addMessage(exception);  
276 -  
277 - PowerMock.replayAll();  
278 - renderer.render(file, ContentType.PDF, fileName);  
279 - PowerMock.verifyAll();  
280 -  
281 - file.delete();  
282 - }  
283 -  
284 - @Test  
285 - public void testRenderFileNotFoundException() throws IOException {  
286 -  
287 - File file = new File("fileName");  
288 - file.createNewFile();  
289 -  
290 - String fileName = "fileName.pdf";  
291 -  
292 - logger.debug(EasyMock.anyObject(String.class));  
293 - EasyMock.expectLastCall().anyTimes();  
294 -  
295 - IOException exception = new IOException();  
296 - logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);  
297 - EasyMock.expectLastCall().anyTimes();  
298 -  
299 - response.setContentType(ContentType.PDF.getContentType());  
300 - EasyMock.expectLastCall().times(1);  
301 -  
302 - response.setContentLength((int) file.length());  
303 - EasyMock.expectLastCall().times(1);  
304 -  
305 - response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");  
306 - EasyMock.expectLastCall().times(1);  
307 -  
308 - facesContext.responseComplete();  
309 - EasyMock.expectLastCall().times(1);  
310 -  
311 - try {  
312 - EasyMock.expect(response.getOutputStream()).andThrow(exception);  
313 - } catch (IOException e) {  
314 - Assert.fail();  
315 - }  
316 -  
317 -  
318 -  
319 - PowerMock.mockStatic(Faces.class);  
320 - Faces.addMessage(exception);  
321 -  
322 - PowerMock.replayAll();  
323 - renderer.render(file, ContentType.PDF, fileName);  
324 - PowerMock.verifyAll();  
325 -  
326 - file.delete();  
327 - }  
328 -} 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 java.io.ByteArrayInputStream;
  40 +//import java.io.File;
  41 +//import java.io.IOException;
  42 +//import java.io.InputStream;
  43 +//
  44 +//import javax.faces.context.FacesContext;
  45 +//import javax.servlet.ServletOutputStream;
  46 +//import javax.servlet.http.HttpServletResponse;
  47 +//
  48 +//import junit.framework.Assert;
  49 +//
  50 +//import org.easymock.EasyMock;
  51 +//import org.junit.Before;
  52 +//import org.junit.Test;
  53 +//import org.junit.runner.RunWith;
  54 +//import org.powermock.api.easymock.PowerMock;
  55 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  56 +//import org.powermock.modules.junit4.PowerMockRunner;
  57 +//import org.powermock.reflect.Whitebox;
  58 +//import org.slf4j.Logger;
  59 +//
  60 +//import br.gov.frameworkdemoiselle.util.Faces;
  61 +//import br.gov.frameworkdemoiselle.util.FileRenderer;
  62 +//import br.gov.frameworkdemoiselle.util.FileRenderer.ContentType;
  63 +//
  64 +//@RunWith(PowerMockRunner.class)
  65 +//@PrepareForTest({ Faces.class })
  66 +//public class FileRendererImplTest {
  67 +//
  68 +// private Logger logger;
  69 +//
  70 +// private FileRenderer renderer;
  71 +//
  72 +// private FacesContext facesContext;
  73 +//
  74 +// private HttpServletResponse response;
  75 +//
  76 +// @Before
  77 +// public void before() {
  78 +// renderer = new FileRendererImpl();
  79 +//
  80 +// logger = PowerMock.createMock(Logger.class);
  81 +// Whitebox.setInternalState(renderer, "logger", logger);
  82 +//
  83 +// facesContext = PowerMock.createMock(FacesContext.class);
  84 +// Whitebox.setInternalState(renderer, "context", facesContext);
  85 +//
  86 +// response = PowerMock.createMock(HttpServletResponse.class);
  87 +// Whitebox.setInternalState(renderer, "response", response);
  88 +// }
  89 +//
  90 +// @Test
  91 +// public void testRenderBytesFail() {
  92 +// byte[] bytes = "Test".getBytes();
  93 +// String fileName = "fileName.pdf";
  94 +//
  95 +// logger.debug(EasyMock.anyObject(String.class));
  96 +// EasyMock.expectLastCall().anyTimes();
  97 +//
  98 +// IOException exception = new IOException();
  99 +// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);
  100 +// EasyMock.expectLastCall().anyTimes();
  101 +//
  102 +// response.setContentType(ContentType.PDF.getContentType());
  103 +// EasyMock.expectLastCall().times(1);
  104 +//
  105 +// response.setContentLength(bytes.length);
  106 +// EasyMock.expectLastCall().times(1);
  107 +//
  108 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  109 +// EasyMock.expectLastCall().times(1);
  110 +//
  111 +// facesContext.responseComplete();
  112 +// EasyMock.expectLastCall().times(1);
  113 +//
  114 +// try {
  115 +// EasyMock.expect(response.getOutputStream()).andThrow(exception);
  116 +// } catch (IOException e) {
  117 +// Assert.fail();
  118 +// }
  119 +//
  120 +// PowerMock.mockStatic(Faces.class);
  121 +// Faces.addMessage(exception);
  122 +//
  123 +// PowerMock.replayAll();
  124 +// renderer.render(bytes, ContentType.PDF, fileName);
  125 +// PowerMock.verifyAll();
  126 +// }
  127 +//
  128 +// @Test
  129 +// public void testRenderBytesSuccess() throws IOException {
  130 +// byte[] bytes = "Test".getBytes();
  131 +// String fileName = "fileName.pdf";
  132 +//
  133 +// logger.debug(EasyMock.anyObject(String.class));
  134 +// EasyMock.expectLastCall().anyTimes();
  135 +//
  136 +// facesContext.responseComplete();
  137 +// EasyMock.expectLastCall().times(1);
  138 +//
  139 +// response.setContentType(ContentType.PDF.getContentType());
  140 +// EasyMock.expectLastCall().times(1);
  141 +//
  142 +// response.setContentLength(bytes.length);
  143 +// EasyMock.expectLastCall().times(1);
  144 +//
  145 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  146 +// EasyMock.expectLastCall().times(1);
  147 +//
  148 +// ServletOutputStream stream = PowerMock.createMock(ServletOutputStream.class);
  149 +// stream.write(bytes, 0, bytes.length);
  150 +// EasyMock.expectLastCall().times(1);
  151 +//
  152 +// stream.flush();
  153 +// EasyMock.expectLastCall().times(1);
  154 +//
  155 +// stream.close();
  156 +// EasyMock.expectLastCall().times(1);
  157 +//
  158 +// EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3);
  159 +//
  160 +// PowerMock.replayAll();
  161 +// renderer.render(bytes, ContentType.PDF, fileName);
  162 +// PowerMock.verifyAll();
  163 +// }
  164 +//
  165 +// @Test
  166 +// public void testRenderStreamFail() {
  167 +// byte[] bytes = "Test".getBytes();
  168 +// InputStream stream = new ByteArrayInputStream(bytes);
  169 +// String fileName = "fileName.pdf";
  170 +//
  171 +// logger.debug(EasyMock.anyObject(String.class));
  172 +// EasyMock.expectLastCall().anyTimes();
  173 +//
  174 +// IOException exception = new IOException();
  175 +// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);
  176 +// EasyMock.expectLastCall().anyTimes();
  177 +//
  178 +// response.setContentType(ContentType.PDF.getContentType());
  179 +// EasyMock.expectLastCall().times(1);
  180 +//
  181 +// response.setContentLength(bytes.length);
  182 +// EasyMock.expectLastCall().times(1);
  183 +//
  184 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  185 +// EasyMock.expectLastCall().times(1);
  186 +//
  187 +// facesContext.responseComplete();
  188 +// EasyMock.expectLastCall().times(1);
  189 +//
  190 +// try {
  191 +// EasyMock.expect(response.getOutputStream()).andThrow(exception);
  192 +// } catch (IOException e) {
  193 +// Assert.fail();
  194 +// }
  195 +//
  196 +// PowerMock.mockStatic(Faces.class);
  197 +// Faces.addMessage(exception);
  198 +//
  199 +// PowerMock.replayAll();
  200 +// renderer.render(stream, ContentType.PDF, fileName, false);
  201 +// PowerMock.verifyAll();
  202 +// }
  203 +//
  204 +// @Test
  205 +// public void testRenderStreamSuccess() throws IOException {
  206 +// byte[] bytes = "Test".getBytes();
  207 +// InputStream inputStream = new ByteArrayInputStream(bytes);
  208 +//
  209 +// String fileName = "fileName.pdf";
  210 +//
  211 +// logger.debug(EasyMock.anyObject(String.class));
  212 +// EasyMock.expectLastCall().anyTimes();
  213 +//
  214 +// facesContext.responseComplete();
  215 +// EasyMock.expectLastCall().times(1);
  216 +//
  217 +// response.setContentType(ContentType.PDF.getContentType());
  218 +// EasyMock.expectLastCall().times(1);
  219 +//
  220 +// response.setContentLength(bytes.length);
  221 +// EasyMock.expectLastCall().times(1);
  222 +//
  223 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  224 +// EasyMock.expectLastCall().times(1);
  225 +//
  226 +// ServletOutputStream stream = new ServletOutputStream() {
  227 +//
  228 +// @Override
  229 +// public void write(int b) throws IOException {
  230 +// Assert.assertTrue(true);
  231 +// }
  232 +// };
  233 +//
  234 +// EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3);
  235 +//
  236 +// PowerMock.replayAll();
  237 +// renderer.render(inputStream, ContentType.PDF, fileName);
  238 +// PowerMock.verifyAll();
  239 +// }
  240 +//
  241 +// @Test
  242 +// public void testRenderFileFail() throws IOException {
  243 +//
  244 +// File file = new File("fileName");
  245 +// file.createNewFile();
  246 +//
  247 +// String fileName = "fileName.pdf";
  248 +//
  249 +// logger.debug(EasyMock.anyObject(String.class));
  250 +// EasyMock.expectLastCall().anyTimes();
  251 +//
  252 +// IOException exception = new IOException();
  253 +// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);
  254 +// EasyMock.expectLastCall().anyTimes();
  255 +//
  256 +// response.setContentType(ContentType.PDF.getContentType());
  257 +// EasyMock.expectLastCall().times(1);
  258 +//
  259 +// response.setContentLength((int) file.length());
  260 +// EasyMock.expectLastCall().times(1);
  261 +//
  262 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  263 +// EasyMock.expectLastCall().times(1);
  264 +//
  265 +// facesContext.responseComplete();
  266 +// EasyMock.expectLastCall().times(1);
  267 +//
  268 +// try {
  269 +// EasyMock.expect(response.getOutputStream()).andThrow(exception);
  270 +// } catch (IOException e) {
  271 +// Assert.fail();
  272 +// }
  273 +//
  274 +// PowerMock.mockStatic(Faces.class);
  275 +// Faces.addMessage(exception);
  276 +//
  277 +// PowerMock.replayAll();
  278 +// renderer.render(file, ContentType.PDF, fileName);
  279 +// PowerMock.verifyAll();
  280 +//
  281 +// file.delete();
  282 +// }
  283 +//
  284 +// @Test
  285 +// public void testRenderFileNotFoundException() throws IOException {
  286 +//
  287 +// File file = new File("fileName");
  288 +// file.createNewFile();
  289 +//
  290 +// String fileName = "fileName.pdf";
  291 +//
  292 +// logger.debug(EasyMock.anyObject(String.class));
  293 +// EasyMock.expectLastCall().anyTimes();
  294 +//
  295 +// IOException exception = new IOException();
  296 +// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception);
  297 +// EasyMock.expectLastCall().anyTimes();
  298 +//
  299 +// response.setContentType(ContentType.PDF.getContentType());
  300 +// EasyMock.expectLastCall().times(1);
  301 +//
  302 +// response.setContentLength((int) file.length());
  303 +// EasyMock.expectLastCall().times(1);
  304 +//
  305 +// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\"");
  306 +// EasyMock.expectLastCall().times(1);
  307 +//
  308 +// facesContext.responseComplete();
  309 +// EasyMock.expectLastCall().times(1);
  310 +//
  311 +// try {
  312 +// EasyMock.expect(response.getOutputStream()).andThrow(exception);
  313 +// } catch (IOException e) {
  314 +// Assert.fail();
  315 +// }
  316 +//
  317 +//
  318 +//
  319 +// PowerMock.mockStatic(Faces.class);
  320 +// Faces.addMessage(exception);
  321 +//
  322 +// PowerMock.replayAll();
  323 +// renderer.render(file, ContentType.PDF, fileName);
  324 +// PowerMock.verifyAll();
  325 +//
  326 +// file.delete();
  327 +// }
  328 +//}
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 PURPaOSE. 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.Ignore;  
61 -import org.junit.Test;  
62 -import org.junit.runner.RunWith;  
63 -import org.powermock.core.classloader.annotations.PrepareForTest;  
64 -import org.powermock.modules.junit4.PowerMockRunner;  
65 -import org.powermock.reflect.Whitebox;  
66 -  
67 -import br.gov.frameworkdemoiselle.annotation.Name;  
68 -import br.gov.frameworkdemoiselle.annotation.ViewScoped;  
69 -import br.gov.frameworkdemoiselle.util.Beans;  
70 -import br.gov.frameworkdemoiselle.util.Faces;  
71 -import br.gov.frameworkdemoiselle.util.Reflections;  
72 -  
73 -@Ignore  
74 -@RunWith(PowerMockRunner.class)  
75 -@PrepareForTest({ Reflections.class, Faces.class, Beans.class })  
76 -public class ParameterImplTest {  
77 -  
78 - private ParameterImpl<Long> param;  
79 -  
80 - private HttpServletRequest request;  
81 -  
82 - private InjectionPoint ip;  
83 -  
84 - private Converter converter;  
85 -  
86 - private Annotated annotated;  
87 -  
88 - private Name name;  
89 -  
90 - private HttpSession session;  
91 -  
92 - private Member member;  
93 -  
94 - @Before  
95 - public void before() {  
96 - ip = createMock(InjectionPoint.class);  
97 - request = createMock(HttpServletRequest.class);  
98 - session = createMock(HttpSession.class);  
99 - annotated = createMock(Annotated.class);  
100 - name = createMock(Name.class);  
101 - converter = createMock(Converter.class);  
102 - member = createMock(Member.class);  
103 -  
104 - mockStatic(Reflections.class);  
105 - mockStatic(Faces.class);  
106 - }  
107 -  
108 - private void prepareForTestWithKeyFromNameAnnotation() {  
109 - expect(ip.getAnnotated()).andReturn(annotated).anyTimes();  
110 - expect(ip.getMember()).andReturn(null);  
111 - expect(annotated.isAnnotationPresent(Name.class)).andReturn(true);  
112 - expect(annotated.getAnnotation(Name.class)).andReturn(name);  
113 - expect(name.value()).andReturn("name");  
114 - expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn(  
115 - Object.class);  
116 - }  
117 -  
118 - @Test  
119 - public void testConstructorCase1() {  
120 - this.prepareForTestWithKeyFromNameAnnotation();  
121 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
122 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);  
123 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);  
124 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);  
125 -  
126 - replayAll();  
127 - param = new ParameterImpl<Long>(ip);  
128 - assertEquals("name", param.getKey());  
129 - assertEquals(Object.class, Whitebox.getInternalState(param, "type"));  
130 - assertEquals(converter, param.getConverter());  
131 - verifyAll();  
132 - }  
133 -  
134 - @Test  
135 - public void testConstructorCase2() {  
136 - expect(member.getName()).andReturn("memberName");  
137 - expect(ip.getAnnotated()).andReturn(annotated).anyTimes();  
138 - expect(ip.getMember()).andReturn(member).anyTimes();  
139 - expect(annotated.isAnnotationPresent(Name.class)).andReturn(false);  
140 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);  
141 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);  
142 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);  
143 - expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn(  
144 - Object.class);  
145 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
146 -  
147 - replayAll();  
148 - param = new ParameterImpl<Long>(ip);  
149 - assertEquals("memberName", param.getKey());  
150 - assertEquals(Object.class, Whitebox.getInternalState(param, "type"));  
151 - assertEquals(converter, param.getConverter());  
152 - verifyAll();  
153 - }  
154 -  
155 - @Test  
156 - public void testGetValueWhenSessionScopedAndParameterValueNotNull() {  
157 - this.prepareForTestWithKeyFromNameAnnotation();  
158 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
159 -  
160 - mockStatic(Beans.class);  
161 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
162 -  
163 - expect(Faces.convert("1", converter)).andReturn("return");  
164 - expect(request.getSession()).andReturn(session).anyTimes();  
165 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");  
166 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);  
167 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
168 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
169 -  
170 - expect(session.getAttribute("name")).andReturn("return");  
171 -  
172 - session.setAttribute("name", "return");  
173 -  
174 - replayAll();  
175 - param = new ParameterImpl<Long>(ip);  
176 - assertEquals("return", param.getValue());  
177 - verifyAll();  
178 - }  
179 -  
180 - @Test  
181 - public void testGetValueWhenSessionScopedAndParameterValueNull() {  
182 - this.prepareForTestWithKeyFromNameAnnotation();  
183 -  
184 - mockStatic(Beans.class);  
185 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
186 -  
187 - expect(request.getSession()).andReturn(session).anyTimes();  
188 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null);  
189 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);  
190 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
191 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
192 - expect(session.getAttribute("name")).andReturn("return");  
193 -  
194 - replayAll();  
195 - param = new ParameterImpl<Long>(ip);  
196 - assertEquals("return", param.getValue());  
197 - verifyAll();  
198 - }  
199 -  
200 - @Test  
201 - public void testGetValueWhenRequestScoped() {  
202 - this.prepareForTestWithKeyFromNameAnnotation();  
203 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
204 -  
205 - mockStatic(Beans.class);  
206 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
207 -  
208 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
209 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);  
210 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
211 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");  
212 - expect(request.getSession()).andReturn(session).anyTimes();  
213 - expect(Faces.convert("1", converter)).andReturn("return");  
214 -  
215 - replayAll();  
216 - param = new ParameterImpl<Long>(ip);  
217 - assertEquals("return", param.getValue());  
218 - verifyAll();  
219 - }  
220 -  
221 - @Test  
222 - public void testGetValueWhenViewScopedWithParamValueNotNull() {  
223 - this.prepareForTestWithKeyFromNameAnnotation();  
224 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
225 - Map<String, Object> map = new HashMap<String, Object>();  
226 -  
227 - mockStatic(Beans.class);  
228 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
229 -  
230 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
231 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
232 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);  
233 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");  
234 - expect(Faces.getViewMap()).andReturn(map);  
235 - expect(Faces.convert("1", converter)).andReturn("return");  
236 -  
237 - replayAll();  
238 - param = new ParameterImpl<Long>(ip);  
239 - assertEquals("return", param.getValue());  
240 - assertEquals("return", map.get("name"));  
241 - verifyAll();  
242 - }  
243 -  
244 - @Test  
245 - public void testGetValueWhenViewScopedWithParamValueNull() {  
246 - this.prepareForTestWithKeyFromNameAnnotation();  
247 - Map<String, Object> map = new HashMap<String, Object>();  
248 - map.put("name", "ops");  
249 -  
250 - mockStatic(Beans.class);  
251 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
252 -  
253 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
254 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
255 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);  
256 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null);  
257 - expect(Faces.getViewMap()).andReturn(map);  
258 -  
259 - replayAll();  
260 - param = new ParameterImpl<Long>(ip);  
261 - assertEquals("ops", param.getValue());  
262 - assertEquals("ops", map.get("name"));  
263 - verifyAll();  
264 - }  
265 -  
266 - @Test  
267 - public void testGetValueElseWithValueNull() {  
268 - this.prepareForTestWithKeyFromNameAnnotation();  
269 - expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);  
270 -  
271 - mockStatic(Beans.class);  
272 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
273 -  
274 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
275 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
276 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
277 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");  
278 - expect(Faces.convert("1", converter)).andReturn("return");  
279 -  
280 - replayAll();  
281 - param = new ParameterImpl<Long>(ip);  
282 - assertEquals("return", param.getValue());  
283 - verifyAll();  
284 - }  
285 -  
286 - @Test  
287 - public void testGetValueElseWithValueNotNull() {  
288 - this.prepareForTestWithKeyFromNameAnnotation();  
289 -  
290 - mockStatic(Beans.class);  
291 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
292 -  
293 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
294 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
295 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
296 - expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");  
297 -  
298 - replayAll();  
299 - param = new ParameterImpl<Long>(ip);  
300 - Whitebox.setInternalState(param, "value", "myvalue");  
301 - assertEquals("myvalue", param.getValue());  
302 - verifyAll();  
303 - }  
304 -  
305 - @Test  
306 - public void testSetValueIsSessionScoped() {  
307 - this.prepareForTestWithKeyFromNameAnnotation();  
308 -  
309 - mockStatic(Beans.class);  
310 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();  
311 -  
312 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);  
313 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
314 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
315 - expect(request.getSession()).andReturn(session);  
316 -  
317 - session.setAttribute("name", 1L);  
318 -  
319 - replayAll();  
320 - param = new ParameterImpl<Long>(ip);  
321 - param.setValue(1L);  
322 - verifyAll();  
323 - }  
324 -  
325 - @Test  
326 - public void testSetValueIsViewScoped() {  
327 - this.prepareForTestWithKeyFromNameAnnotation();  
328 -  
329 - Map<String, Object> map = new HashMap<String, Object>();  
330 -  
331 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
332 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
333 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);  
334 - expect(Faces.getViewMap()).andReturn(map);  
335 -  
336 - replayAll();  
337 - param = new ParameterImpl<Long>(ip);  
338 - param.setValue(1L);  
339 - assertEquals(1L, map.get("name"));  
340 - verifyAll();  
341 - }  
342 -  
343 - @Test  
344 - public void testSetValueElse() {  
345 - this.prepareForTestWithKeyFromNameAnnotation();  
346 -  
347 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
348 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);  
349 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
350 -  
351 - replayAll();  
352 - param = new ParameterImpl<Long>(ip);  
353 - param.setValue(1L);  
354 - assertEquals(1L, Whitebox.getInternalState(param, "value"));  
355 - verifyAll();  
356 - }  
357 -  
358 - @Test  
359 - public void testOthers() {  
360 - this.prepareForTestWithKeyFromNameAnnotation();  
361 -  
362 - expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);  
363 - expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);  
364 - expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);  
365 -  
366 - replayAll();  
367 - param = new ParameterImpl<Long>(ip);  
368 - param.setValue(1L);  
369 - verifyAll();  
370 - }  
371 -  
372 -} 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 PURPaOSE. 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.Ignore;
  61 +//import org.junit.Test;
  62 +//import org.junit.runner.RunWith;
  63 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  64 +//import org.powermock.modules.junit4.PowerMockRunner;
  65 +//import org.powermock.reflect.Whitebox;
  66 +//
  67 +//import br.gov.frameworkdemoiselle.annotation.Name;
  68 +//import br.gov.frameworkdemoiselle.annotation.ViewScoped;
  69 +//import br.gov.frameworkdemoiselle.util.Beans;
  70 +//import br.gov.frameworkdemoiselle.util.Faces;
  71 +//import br.gov.frameworkdemoiselle.util.Reflections;
  72 +//
  73 +//@Ignore
  74 +//@RunWith(PowerMockRunner.class)
  75 +//@PrepareForTest({ Reflections.class, Faces.class, Beans.class })
  76 +//public class ParameterImplTest {
  77 +//
  78 +// private ParameterImpl<Long> param;
  79 +//
  80 +// private HttpServletRequest request;
  81 +//
  82 +// private InjectionPoint ip;
  83 +//
  84 +// private Converter converter;
  85 +//
  86 +// private Annotated annotated;
  87 +//
  88 +// private Name name;
  89 +//
  90 +// private HttpSession session;
  91 +//
  92 +// private Member member;
  93 +//
  94 +// @Before
  95 +// public void before() {
  96 +// ip = createMock(InjectionPoint.class);
  97 +// request = createMock(HttpServletRequest.class);
  98 +// session = createMock(HttpSession.class);
  99 +// annotated = createMock(Annotated.class);
  100 +// name = createMock(Name.class);
  101 +// converter = createMock(Converter.class);
  102 +// member = createMock(Member.class);
  103 +//
  104 +// mockStatic(Reflections.class);
  105 +// mockStatic(Faces.class);
  106 +// }
  107 +//
  108 +// private void prepareForTestWithKeyFromNameAnnotation() {
  109 +// expect(ip.getAnnotated()).andReturn(annotated).anyTimes();
  110 +// expect(ip.getMember()).andReturn(null);
  111 +// expect(annotated.isAnnotationPresent(Name.class)).andReturn(true);
  112 +// expect(annotated.getAnnotation(Name.class)).andReturn(name);
  113 +// expect(name.value()).andReturn("name");
  114 +// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn(
  115 +// Object.class);
  116 +// }
  117 +//
  118 +// @Test
  119 +// public void testConstructorCase1() {
  120 +// this.prepareForTestWithKeyFromNameAnnotation();
  121 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  122 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);
  123 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);
  124 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);
  125 +//
  126 +// replayAll();
  127 +// param = new ParameterImpl<Long>(ip);
  128 +// assertEquals("name", param.getKey());
  129 +// assertEquals(Object.class, Whitebox.getInternalState(param, "type"));
  130 +// assertEquals(converter, param.getConverter());
  131 +// verifyAll();
  132 +// }
  133 +//
  134 +// @Test
  135 +// public void testConstructorCase2() {
  136 +// expect(member.getName()).andReturn("memberName");
  137 +// expect(ip.getAnnotated()).andReturn(annotated).anyTimes();
  138 +// expect(ip.getMember()).andReturn(member).anyTimes();
  139 +// expect(annotated.isAnnotationPresent(Name.class)).andReturn(false);
  140 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);
  141 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);
  142 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);
  143 +// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn(
  144 +// Object.class);
  145 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  146 +//
  147 +// replayAll();
  148 +// param = new ParameterImpl<Long>(ip);
  149 +// assertEquals("memberName", param.getKey());
  150 +// assertEquals(Object.class, Whitebox.getInternalState(param, "type"));
  151 +// assertEquals(converter, param.getConverter());
  152 +// verifyAll();
  153 +// }
  154 +//
  155 +// @Test
  156 +// public void testGetValueWhenSessionScopedAndParameterValueNotNull() {
  157 +// this.prepareForTestWithKeyFromNameAnnotation();
  158 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  159 +//
  160 +// mockStatic(Beans.class);
  161 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  162 +//
  163 +// expect(Faces.convert("1", converter)).andReturn("return");
  164 +// expect(request.getSession()).andReturn(session).anyTimes();
  165 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");
  166 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);
  167 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  168 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  169 +//
  170 +// expect(session.getAttribute("name")).andReturn("return");
  171 +//
  172 +// session.setAttribute("name", "return");
  173 +//
  174 +// replayAll();
  175 +// param = new ParameterImpl<Long>(ip);
  176 +// assertEquals("return", param.getValue());
  177 +// verifyAll();
  178 +// }
  179 +//
  180 +// @Test
  181 +// public void testGetValueWhenSessionScopedAndParameterValueNull() {
  182 +// this.prepareForTestWithKeyFromNameAnnotation();
  183 +//
  184 +// mockStatic(Beans.class);
  185 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  186 +//
  187 +// expect(request.getSession()).andReturn(session).anyTimes();
  188 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null);
  189 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);
  190 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  191 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  192 +// expect(session.getAttribute("name")).andReturn("return");
  193 +//
  194 +// replayAll();
  195 +// param = new ParameterImpl<Long>(ip);
  196 +// assertEquals("return", param.getValue());
  197 +// verifyAll();
  198 +// }
  199 +//
  200 +// @Test
  201 +// public void testGetValueWhenRequestScoped() {
  202 +// this.prepareForTestWithKeyFromNameAnnotation();
  203 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  204 +//
  205 +// mockStatic(Beans.class);
  206 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  207 +//
  208 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  209 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);
  210 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  211 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");
  212 +// expect(request.getSession()).andReturn(session).anyTimes();
  213 +// expect(Faces.convert("1", converter)).andReturn("return");
  214 +//
  215 +// replayAll();
  216 +// param = new ParameterImpl<Long>(ip);
  217 +// assertEquals("return", param.getValue());
  218 +// verifyAll();
  219 +// }
  220 +//
  221 +// @Test
  222 +// public void testGetValueWhenViewScopedWithParamValueNotNull() {
  223 +// this.prepareForTestWithKeyFromNameAnnotation();
  224 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  225 +// Map<String, Object> map = new HashMap<String, Object>();
  226 +//
  227 +// mockStatic(Beans.class);
  228 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  229 +//
  230 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  231 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  232 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);
  233 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");
  234 +// expect(Faces.getViewMap()).andReturn(map);
  235 +// expect(Faces.convert("1", converter)).andReturn("return");
  236 +//
  237 +// replayAll();
  238 +// param = new ParameterImpl<Long>(ip);
  239 +// assertEquals("return", param.getValue());
  240 +// assertEquals("return", map.get("name"));
  241 +// verifyAll();
  242 +// }
  243 +//
  244 +// @Test
  245 +// public void testGetValueWhenViewScopedWithParamValueNull() {
  246 +// this.prepareForTestWithKeyFromNameAnnotation();
  247 +// Map<String, Object> map = new HashMap<String, Object>();
  248 +// map.put("name", "ops");
  249 +//
  250 +// mockStatic(Beans.class);
  251 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  252 +//
  253 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  254 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  255 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);
  256 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null);
  257 +// expect(Faces.getViewMap()).andReturn(map);
  258 +//
  259 +// replayAll();
  260 +// param = new ParameterImpl<Long>(ip);
  261 +// assertEquals("ops", param.getValue());
  262 +// assertEquals("ops", map.get("name"));
  263 +// verifyAll();
  264 +// }
  265 +//
  266 +// @Test
  267 +// public void testGetValueElseWithValueNull() {
  268 +// this.prepareForTestWithKeyFromNameAnnotation();
  269 +// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter);
  270 +//
  271 +// mockStatic(Beans.class);
  272 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  273 +//
  274 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  275 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  276 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  277 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");
  278 +// expect(Faces.convert("1", converter)).andReturn("return");
  279 +//
  280 +// replayAll();
  281 +// param = new ParameterImpl<Long>(ip);
  282 +// assertEquals("return", param.getValue());
  283 +// verifyAll();
  284 +// }
  285 +//
  286 +// @Test
  287 +// public void testGetValueElseWithValueNotNull() {
  288 +// this.prepareForTestWithKeyFromNameAnnotation();
  289 +//
  290 +// mockStatic(Beans.class);
  291 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  292 +//
  293 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  294 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  295 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  296 +// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1");
  297 +//
  298 +// replayAll();
  299 +// param = new ParameterImpl<Long>(ip);
  300 +// Whitebox.setInternalState(param, "value", "myvalue");
  301 +// assertEquals("myvalue", param.getValue());
  302 +// verifyAll();
  303 +// }
  304 +//
  305 +// @Test
  306 +// public void testSetValueIsSessionScoped() {
  307 +// this.prepareForTestWithKeyFromNameAnnotation();
  308 +//
  309 +// mockStatic(Beans.class);
  310 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes();
  311 +//
  312 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true);
  313 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  314 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  315 +// expect(request.getSession()).andReturn(session);
  316 +//
  317 +// session.setAttribute("name", 1L);
  318 +//
  319 +// replayAll();
  320 +// param = new ParameterImpl<Long>(ip);
  321 +// param.setValue(1L);
  322 +// verifyAll();
  323 +// }
  324 +//
  325 +// @Test
  326 +// public void testSetValueIsViewScoped() {
  327 +// this.prepareForTestWithKeyFromNameAnnotation();
  328 +//
  329 +// Map<String, Object> map = new HashMap<String, Object>();
  330 +//
  331 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  332 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  333 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true);
  334 +// expect(Faces.getViewMap()).andReturn(map);
  335 +//
  336 +// replayAll();
  337 +// param = new ParameterImpl<Long>(ip);
  338 +// param.setValue(1L);
  339 +// assertEquals(1L, map.get("name"));
  340 +// verifyAll();
  341 +// }
  342 +//
  343 +// @Test
  344 +// public void testSetValueElse() {
  345 +// this.prepareForTestWithKeyFromNameAnnotation();
  346 +//
  347 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  348 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false);
  349 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  350 +//
  351 +// replayAll();
  352 +// param = new ParameterImpl<Long>(ip);
  353 +// param.setValue(1L);
  354 +// assertEquals(1L, Whitebox.getInternalState(param, "value"));
  355 +// verifyAll();
  356 +// }
  357 +//
  358 +// @Test
  359 +// public void testOthers() {
  360 +// this.prepareForTestWithKeyFromNameAnnotation();
  361 +//
  362 +// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false);
  363 +// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true);
  364 +// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false);
  365 +//
  366 +// replayAll();
  367 +// param = new ParameterImpl<Long>(ip);
  368 +// param.setValue(1L);
  369 +// verifyAll();
  370 +// }
  371 +//
  372 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/RedirectExceptionHandlerFactoryTest.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 junit.framework.Assert.assertEquals;  
40 -import static org.easymock.EasyMock.expect;  
41 -import static org.powermock.api.easymock.PowerMock.replayAll;  
42 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
43 -  
44 -import javax.faces.context.ExceptionHandler;  
45 -import javax.faces.context.ExceptionHandlerFactory;  
46 -  
47 -import org.junit.Test;  
48 -import org.junit.runner.RunWith;  
49 -import org.powermock.api.easymock.PowerMock;  
50 -import org.powermock.modules.junit4.PowerMockRunner;  
51 -  
52 -@RunWith(PowerMockRunner.class)  
53 -public class RedirectExceptionHandlerFactoryTest {  
54 -  
55 - @Test  
56 - public void testGetExceptionHandler() {  
57 -  
58 - ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);  
59 -  
60 - ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);  
61 -  
62 - RedirectExceptionHandlerFactory handlerFactory = new RedirectExceptionHandlerFactory(jsfFactory);  
63 - expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);  
64 -  
65 - replayAll();  
66 -  
67 - RedirectExceptionHandler handler = (RedirectExceptionHandler) handlerFactory.getExceptionHandler();  
68 -  
69 - assertEquals(handler.getWrapped(), jsfExceptionHandler);  
70 -  
71 - verifyAll();  
72 -  
73 - }  
74 -  
75 -} 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 junit.framework.Assert.assertEquals;
  40 +//import static org.easymock.EasyMock.expect;
  41 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  43 +//
  44 +//import javax.faces.context.ExceptionHandler;
  45 +//import javax.faces.context.ExceptionHandlerFactory;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.junit.runner.RunWith;
  49 +//import org.powermock.api.easymock.PowerMock;
  50 +//import org.powermock.modules.junit4.PowerMockRunner;
  51 +//
  52 +//@RunWith(PowerMockRunner.class)
  53 +//public class RedirectExceptionHandlerFactoryTest {
  54 +//
  55 +// @Test
  56 +// public void testGetExceptionHandler() {
  57 +//
  58 +// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class);
  59 +//
  60 +// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class);
  61 +//
  62 +// RedirectExceptionHandlerFactory handlerFactory = new RedirectExceptionHandlerFactory(jsfFactory);
  63 +// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler);
  64 +//
  65 +// replayAll();
  66 +//
  67 +// RedirectExceptionHandler handler = (RedirectExceptionHandler) handlerFactory.getExceptionHandler();
  68 +//
  69 +// assertEquals(handler.getWrapped(), jsfExceptionHandler);
  70 +//
  71 +// verifyAll();
  72 +//
  73 +// }
  74 +//
  75 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/RedirectExceptionHandlerTest.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 junit.framework.Assert.assertFalse;  
40 -import static junit.framework.Assert.assertTrue;  
41 -import static org.easymock.EasyMock.expect;  
42 -import static org.powermock.api.easymock.PowerMock.createMock;  
43 -import static org.powermock.api.easymock.PowerMock.expectLastCall;  
44 -import static org.powermock.api.easymock.PowerMock.replayAll;  
45 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
46 -  
47 -import java.util.ArrayList;  
48 -import java.util.Collection;  
49 -  
50 -import javax.faces.context.ExceptionHandler;  
51 -import javax.faces.event.ExceptionQueuedEvent;  
52 -import javax.faces.event.ExceptionQueuedEventContext;  
53 -  
54 -import org.junit.Before;  
55 -import org.junit.Test;  
56 -import org.junit.runner.RunWith;  
57 -import org.powermock.modules.junit4.PowerMockRunner;  
58 -  
59 -import br.gov.frameworkdemoiselle.annotation.Redirect;  
60 -  
61 -@RunWith(PowerMockRunner.class)  
62 -public class RedirectExceptionHandlerTest {  
63 -  
64 - private RedirectExceptionHandler handler;  
65 -  
66 - private ExceptionQueuedEventContext eventContext;  
67 -  
68 - private Collection<ExceptionQueuedEvent> events;  
69 -  
70 - @SuppressWarnings("serial")  
71 - @Redirect  
72 - class AnnotatedException extends RuntimeException {  
73 - }  
74 -  
75 - @Before  
76 - public void setUp() {  
77 -  
78 - ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);  
79 - ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);  
80 - eventContext = createMock(ExceptionQueuedEventContext.class);  
81 - handler = new RedirectExceptionHandler(jsfExceptionHandler);  
82 - events = new ArrayList<ExceptionQueuedEvent>();  
83 -  
84 - expect(event.getSource()).andReturn(eventContext);  
85 - events.add(event);  
86 - expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);  
87 -  
88 - }  
89 -  
90 - @Test  
91 - public void testHandleAnAnnotatedException() {  
92 -  
93 - AnnotatedException exception = new AnnotatedException();  
94 -  
95 - expect(eventContext.getException()).andReturn(exception);  
96 -  
97 - replayAll();  
98 -  
99 - handler.handle();  
100 -  
101 - assertTrue(events.isEmpty());  
102 -  
103 - verifyAll();  
104 -  
105 - }  
106 -  
107 - @Test  
108 - public void testHandleAnyException() {  
109 -  
110 - Exception exception = new Exception();  
111 -  
112 - expect(eventContext.getException()).andReturn(exception);  
113 -  
114 - handler.getWrapped().handle();  
115 - expectLastCall();  
116 -  
117 - replayAll();  
118 -  
119 - handler.handle();  
120 -  
121 - assertFalse(events.isEmpty());  
122 -  
123 - verifyAll();  
124 -  
125 - }  
126 -  
127 -} 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 junit.framework.Assert.assertFalse;
  40 +//import static junit.framework.Assert.assertTrue;
  41 +//import static org.easymock.EasyMock.expect;
  42 +//import static org.powermock.api.easymock.PowerMock.createMock;
  43 +//import static org.powermock.api.easymock.PowerMock.expectLastCall;
  44 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  45 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  46 +//
  47 +//import java.util.ArrayList;
  48 +//import java.util.Collection;
  49 +//
  50 +//import javax.faces.context.ExceptionHandler;
  51 +//import javax.faces.event.ExceptionQueuedEvent;
  52 +//import javax.faces.event.ExceptionQueuedEventContext;
  53 +//
  54 +//import org.junit.Before;
  55 +//import org.junit.Test;
  56 +//import org.junit.runner.RunWith;
  57 +//import org.powermock.modules.junit4.PowerMockRunner;
  58 +//
  59 +//import br.gov.frameworkdemoiselle.annotation.Redirect;
  60 +//
  61 +//@RunWith(PowerMockRunner.class)
  62 +//public class RedirectExceptionHandlerTest {
  63 +//
  64 +// private RedirectExceptionHandler handler;
  65 +//
  66 +// private ExceptionQueuedEventContext eventContext;
  67 +//
  68 +// private Collection<ExceptionQueuedEvent> events;
  69 +//
  70 +// @SuppressWarnings("serial")
  71 +// @Redirect
  72 +// class AnnotatedException extends RuntimeException {
  73 +// }
  74 +//
  75 +// @Before
  76 +// public void setUp() {
  77 +//
  78 +// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class);
  79 +// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class);
  80 +// eventContext = createMock(ExceptionQueuedEventContext.class);
  81 +// handler = new RedirectExceptionHandler(jsfExceptionHandler);
  82 +// events = new ArrayList<ExceptionQueuedEvent>();
  83 +//
  84 +// expect(event.getSource()).andReturn(eventContext);
  85 +// events.add(event);
  86 +// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2);
  87 +//
  88 +// }
  89 +//
  90 +// @Test
  91 +// public void testHandleAnAnnotatedException() {
  92 +//
  93 +// AnnotatedException exception = new AnnotatedException();
  94 +//
  95 +// expect(eventContext.getException()).andReturn(exception);
  96 +//
  97 +// replayAll();
  98 +//
  99 +// handler.handle();
  100 +//
  101 +// assertTrue(events.isEmpty());
  102 +//
  103 +// verifyAll();
  104 +//
  105 +// }
  106 +//
  107 +// @Test
  108 +// public void testHandleAnyException() {
  109 +//
  110 +// Exception exception = new Exception();
  111 +//
  112 +// expect(eventContext.getException()).andReturn(exception);
  113 +//
  114 +// handler.getWrapped().handle();
  115 +// expectLastCall();
  116 +//
  117 +// replayAll();
  118 +//
  119 +// handler.handle();
  120 +//
  121 +// assertFalse(events.isEmpty());
  122 +//
  123 +// verifyAll();
  124 +//
  125 +// }
  126 +//
  127 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBeanTest.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.template;  
38 -  
39 -import static org.easymock.EasyMock.expect;  
40 -import static org.junit.Assert.assertEquals;  
41 -import static org.junit.Assert.assertFalse;  
42 -import static org.junit.Assert.assertNull;  
43 -import static org.junit.Assert.assertTrue;  
44 -import static org.powermock.api.easymock.PowerMock.createMock;  
45 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
46 -import static org.powermock.api.easymock.PowerMock.replayAll;  
47 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
48 -import static org.powermock.reflect.Whitebox.setInternalState;  
49 -  
50 -import java.util.Locale;  
51 -  
52 -import javax.faces.component.UIViewRoot;  
53 -import javax.faces.context.FacesContext;  
54 -import javax.faces.convert.Converter;  
55 -  
56 -import org.junit.Before;  
57 -import org.junit.Test;  
58 -import org.junit.runner.RunWith;  
59 -import org.powermock.api.easymock.PowerMock;  
60 -import org.powermock.core.classloader.annotations.PrepareForTest;  
61 -import org.powermock.modules.junit4.PowerMockRunner;  
62 -import org.powermock.reflect.Whitebox;  
63 -  
64 -import br.gov.frameworkdemoiselle.DemoiselleException;  
65 -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;  
66 -import br.gov.frameworkdemoiselle.util.Beans;  
67 -import br.gov.frameworkdemoiselle.util.Faces;  
68 -import br.gov.frameworkdemoiselle.util.Parameter;  
69 -import br.gov.frameworkdemoiselle.util.Reflections;  
70 -import br.gov.frameworkdemoiselle.util.ResourceBundle;  
71 -  
72 -import com.sun.faces.util.Util;  
73 -  
74 -@RunWith(PowerMockRunner.class)  
75 -@PrepareForTest({ Parameter.class, Beans.class, Reflections.class, Converter.class, FacesContext.class, Util.class,  
76 - Faces.class })  
77 -public class AbstractEditPageBeanTest {  
78 -  
79 - private AbstractEditPageBean<Contact, Object> pageBean;  
80 -  
81 - private ResourceBundle bundle;  
82 -  
83 - @Before  
84 - public void before() {  
85 - bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle", Locale.getDefault());  
86 -  
87 - pageBean = new AbstractEditPageBean<Contact, Object>() {  
88 -  
89 - private static final long serialVersionUID = 1L;  
90 -  
91 - @Override  
92 - public String update() {  
93 - return null;  
94 - }  
95 -  
96 - @Override  
97 - public String insert() {  
98 - return null;  
99 - }  
100 -  
101 - @Override  
102 - public String delete() {  
103 - return null;  
104 - }  
105 -  
106 - @Override  
107 - protected void handleLoad() {  
108 - }  
109 - };  
110 - }  
111 -  
112 - @Test  
113 - public void testClear() {  
114 - Parameter<?> param = PowerMock.createMock(Parameter.class);  
115 -  
116 - assertNull(Whitebox.getInternalState(pageBean, "bean"));  
117 - assertNull(Whitebox.getInternalState(pageBean, "id"));  
118 -  
119 - setInternalState(pageBean, "bean", new Contact());  
120 - setInternalState(pageBean, "id", param);  
121 -  
122 - pageBean.clear();  
123 -  
124 - assertNull(Whitebox.getInternalState(pageBean, "bean"));  
125 - assertNull(Whitebox.getInternalState(pageBean, "id"));  
126 - }  
127 -  
128 - @Test  
129 - public void testCreateBean() {  
130 - mockStatic(Beans.class);  
131 - Contact c = new Contact();  
132 - expect(Beans.getReference(Contact.class)).andReturn(c);  
133 -  
134 - replayAll();  
135 - assertEquals(c, pageBean.createBean());  
136 - verifyAll();  
137 - }  
138 -  
139 - @Test  
140 - public void testGetBean() {  
141 -  
142 - pageBean = new AbstractEditPageBean<Contact, Object>() {  
143 -  
144 - private static final long serialVersionUID = 1L;  
145 -  
146 - private boolean updateMode = false;  
147 -  
148 - @Override  
149 - public String update() {  
150 - return null;  
151 - }  
152 -  
153 - @Override  
154 - public String insert() {  
155 - return null;  
156 - }  
157 -  
158 - @Override  
159 - public String delete() {  
160 - return null;  
161 - }  
162 -  
163 - @Override  
164 - protected void handleLoad() {  
165 - this.setBean(new Contact(200L));  
166 - }  
167 -  
168 - public boolean isUpdateMode() {  
169 - return updateMode;  
170 - }  
171 -  
172 - };  
173 -  
174 - Contact c = new Contact();  
175 - assertNull(Whitebox.getInternalState(pageBean, "bean"));  
176 - setInternalState(pageBean, "bean", c);  
177 - assertEquals(c, pageBean.getBean());  
178 -  
179 - mockStatic(Beans.class);  
180 - expect(Beans.getReference(Contact.class)).andReturn(c);  
181 -  
182 - pageBean.clear();  
183 -  
184 - replayAll();  
185 - assertEquals(c, pageBean.getBean());  
186 - verifyAll();  
187 -  
188 - pageBean.clear();  
189 -  
190 - setInternalState(pageBean, "updateMode", true);  
191 - assertEquals(Long.valueOf(200), pageBean.getBean().getId());  
192 - }  
193 -  
194 - @Test  
195 - public void testGetBeanClass() {  
196 - mockStatic(Reflections.class);  
197 - expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class);  
198 -  
199 - assertNull(Whitebox.getInternalState(pageBean, "beanClass"));  
200 -  
201 - replayAll();  
202 - assertEquals(Object.class, pageBean.getBeanClass());  
203 - verifyAll();  
204 -  
205 - setInternalState(pageBean, "beanClass", Contact.class, AbstractEditPageBean.class);  
206 - assertEquals(Contact.class, pageBean.getBeanClass());  
207 - }  
208 -  
209 - @Test  
210 - public void testGetIdClass() {  
211 - mockStatic(Reflections.class);  
212 - expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 1)).andReturn(Object.class);  
213 -  
214 - assertNull(Whitebox.getInternalState(pageBean, "idClass"));  
215 -  
216 - replayAll();  
217 - assertEquals(Object.class, pageBean.getIdClass());  
218 - verifyAll();  
219 -  
220 - Whitebox.setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class);  
221 - assertEquals(Long.class, pageBean.getIdClass());  
222 - }  
223 -  
224 - @Test  
225 - @SuppressWarnings("unchecked")  
226 - public void testGetStringId() {  
227 - mockStatic(Util.class);  
228 -  
229 - FacesContext facesContext = createMock(FacesContext.class);  
230 - Parameter<String> parameter = createMock(Parameter.class);  
231 -  
232 - setInternalState(pageBean, "facesContext", facesContext);  
233 - setInternalState(pageBean, "id", parameter);  
234 - setInternalState(pageBean, "idClass", String.class, AbstractEditPageBean.class);  
235 -  
236 - String value = "1";  
237 - expect(parameter.getValue()).andReturn(value);  
238 -  
239 - replayAll();  
240 - assertEquals(value, pageBean.getId());  
241 - verifyAll();  
242 - }  
243 -  
244 - @Test  
245 - @SuppressWarnings("unchecked")  
246 - public void testGetLongId() {  
247 - mockStatic(Faces.class);  
248 -  
249 - FacesContext facesContext = createMock(FacesContext.class);  
250 - Converter converter = createMock(Converter.class);  
251 - UIViewRoot viewRoot = createMock(UIViewRoot.class);  
252 - Parameter<String> parameter = createMock(Parameter.class);  
253 -  
254 - setInternalState(pageBean, "facesContext", facesContext);  
255 - setInternalState(pageBean, "id", parameter);  
256 - setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class);  
257 -  
258 - String value = "1";  
259 -  
260 - expect(parameter.getValue()).andReturn(value);  
261 - expect(facesContext.getViewRoot()).andReturn(viewRoot);  
262 - expect(Faces.getConverter(Long.class)).andReturn(converter);  
263 - expect(converter.getAsObject(facesContext, viewRoot, value)).andReturn(Long.valueOf(value));  
264 -  
265 - replayAll();  
266 - assertEquals(Long.valueOf(value), pageBean.getId());  
267 - verifyAll();  
268 - }  
269 -  
270 - @Test  
271 - public void testGetNotStringIdWithNullConverter() {  
272 - FacesContext facesContext = createMock(FacesContext.class);  
273 -  
274 - setInternalState(pageBean, "facesContext", facesContext);  
275 - setInternalState(pageBean, "idClass", Contact.class, AbstractEditPageBean.class);  
276 - setInternalState(pageBean, "bundle", bundle);  
277 -  
278 - replayAll();  
279 - try {  
280 - pageBean.getId();  
281 - } catch (DemoiselleException cause) {  
282 - assertEquals(bundle.getString("id-converter-not-found", Contact.class.getCanonicalName()),  
283 - cause.getMessage());  
284 - }  
285 -  
286 - verifyAll();  
287 - }  
288 -  
289 - @SuppressWarnings("serial")  
290 - @Test  
291 - public void testUpdateMode() {  
292 -  
293 - pageBean = new AbstractEditPageBean<Contact, Object>() {  
294 -  
295 - private Long id = null;  
296 -  
297 - @Override  
298 - public String update() {  
299 - return null;  
300 - }  
301 -  
302 - @Override  
303 - public String insert() {  
304 - return null;  
305 - }  
306 -  
307 - @Override  
308 - public String delete() {  
309 - return null;  
310 - }  
311 -  
312 - @Override  
313 - protected void handleLoad() {  
314 - this.setBean(new Contact(200L));  
315 - }  
316 -  
317 - public Long getId() {  
318 - return id;  
319 - }  
320 -  
321 - };  
322 -  
323 - assertFalse(pageBean.isUpdateMode());  
324 - setInternalState(pageBean, "id", 1L);  
325 - assertTrue(pageBean.isUpdateMode());  
326 - }  
327 -} 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.template;
  38 +//
  39 +//import static org.easymock.EasyMock.expect;
  40 +//import static org.junit.Assert.assertEquals;
  41 +//import static org.junit.Assert.assertFalse;
  42 +//import static org.junit.Assert.assertNull;
  43 +//import static org.junit.Assert.assertTrue;
  44 +//import static org.powermock.api.easymock.PowerMock.createMock;
  45 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  46 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  47 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  48 +//import static org.powermock.reflect.Whitebox.setInternalState;
  49 +//
  50 +//import java.util.Locale;
  51 +//
  52 +//import javax.faces.component.UIViewRoot;
  53 +//import javax.faces.context.FacesContext;
  54 +//import javax.faces.convert.Converter;
  55 +//
  56 +//import org.junit.Before;
  57 +//import org.junit.Test;
  58 +//import org.junit.runner.RunWith;
  59 +//import org.powermock.api.easymock.PowerMock;
  60 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  61 +//import org.powermock.modules.junit4.PowerMockRunner;
  62 +//import org.powermock.reflect.Whitebox;
  63 +//
  64 +//import br.gov.frameworkdemoiselle.DemoiselleException;
  65 +//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
  66 +//import br.gov.frameworkdemoiselle.util.Beans;
  67 +//import br.gov.frameworkdemoiselle.util.Faces;
  68 +//import br.gov.frameworkdemoiselle.util.Parameter;
  69 +//import br.gov.frameworkdemoiselle.util.Reflections;
  70 +//import br.gov.frameworkdemoiselle.util.ResourceBundle;
  71 +//
  72 +//import com.sun.faces.util.Util;
  73 +//
  74 +//@RunWith(PowerMockRunner.class)
  75 +//@PrepareForTest({ Parameter.class, Beans.class, Reflections.class, Converter.class, FacesContext.class, Util.class,
  76 +// Faces.class })
  77 +//public class AbstractEditPageBeanTest {
  78 +//
  79 +// private AbstractEditPageBean<Contact, Object> pageBean;
  80 +//
  81 +// private ResourceBundle bundle;
  82 +//
  83 +// @Before
  84 +// public void before() {
  85 +// bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle", Locale.getDefault());
  86 +//
  87 +// pageBean = new AbstractEditPageBean<Contact, Object>() {
  88 +//
  89 +// private static final long serialVersionUID = 1L;
  90 +//
  91 +// @Override
  92 +// public String update() {
  93 +// return null;
  94 +// }
  95 +//
  96 +// @Override
  97 +// public String insert() {
  98 +// return null;
  99 +// }
  100 +//
  101 +// @Override
  102 +// public String delete() {
  103 +// return null;
  104 +// }
  105 +//
  106 +// @Override
  107 +// protected void handleLoad() {
  108 +// }
  109 +// };
  110 +// }
  111 +//
  112 +// @Test
  113 +// public void testClear() {
  114 +// Parameter<?> param = PowerMock.createMock(Parameter.class);
  115 +//
  116 +// assertNull(Whitebox.getInternalState(pageBean, "bean"));
  117 +// assertNull(Whitebox.getInternalState(pageBean, "id"));
  118 +//
  119 +// setInternalState(pageBean, "bean", new Contact());
  120 +// setInternalState(pageBean, "id", param);
  121 +//
  122 +// pageBean.clear();
  123 +//
  124 +// assertNull(Whitebox.getInternalState(pageBean, "bean"));
  125 +// assertNull(Whitebox.getInternalState(pageBean, "id"));
  126 +// }
  127 +//
  128 +// @Test
  129 +// public void testCreateBean() {
  130 +// mockStatic(Beans.class);
  131 +// Contact c = new Contact();
  132 +// expect(Beans.getReference(Contact.class)).andReturn(c);
  133 +//
  134 +// replayAll();
  135 +// assertEquals(c, pageBean.createBean());
  136 +// verifyAll();
  137 +// }
  138 +//
  139 +// @Test
  140 +// public void testGetBean() {
  141 +//
  142 +// pageBean = new AbstractEditPageBean<Contact, Object>() {
  143 +//
  144 +// private static final long serialVersionUID = 1L;
  145 +//
  146 +// private boolean updateMode = false;
  147 +//
  148 +// @Override
  149 +// public String update() {
  150 +// return null;
  151 +// }
  152 +//
  153 +// @Override
  154 +// public String insert() {
  155 +// return null;
  156 +// }
  157 +//
  158 +// @Override
  159 +// public String delete() {
  160 +// return null;
  161 +// }
  162 +//
  163 +// @Override
  164 +// protected void handleLoad() {
  165 +// this.setBean(new Contact(200L));
  166 +// }
  167 +//
  168 +// public boolean isUpdateMode() {
  169 +// return updateMode;
  170 +// }
  171 +//
  172 +// };
  173 +//
  174 +// Contact c = new Contact();
  175 +// assertNull(Whitebox.getInternalState(pageBean, "bean"));
  176 +// setInternalState(pageBean, "bean", c);
  177 +// assertEquals(c, pageBean.getBean());
  178 +//
  179 +// mockStatic(Beans.class);
  180 +// expect(Beans.getReference(Contact.class)).andReturn(c);
  181 +//
  182 +// pageBean.clear();
  183 +//
  184 +// replayAll();
  185 +// assertEquals(c, pageBean.getBean());
  186 +// verifyAll();
  187 +//
  188 +// pageBean.clear();
  189 +//
  190 +// setInternalState(pageBean, "updateMode", true);
  191 +// assertEquals(Long.valueOf(200), pageBean.getBean().getId());
  192 +// }
  193 +//
  194 +// @Test
  195 +// public void testGetBeanClass() {
  196 +// mockStatic(Reflections.class);
  197 +// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class);
  198 +//
  199 +// assertNull(Whitebox.getInternalState(pageBean, "beanClass"));
  200 +//
  201 +// replayAll();
  202 +// assertEquals(Object.class, pageBean.getBeanClass());
  203 +// verifyAll();
  204 +//
  205 +// setInternalState(pageBean, "beanClass", Contact.class, AbstractEditPageBean.class);
  206 +// assertEquals(Contact.class, pageBean.getBeanClass());
  207 +// }
  208 +//
  209 +// @Test
  210 +// public void testGetIdClass() {
  211 +// mockStatic(Reflections.class);
  212 +// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 1)).andReturn(Object.class);
  213 +//
  214 +// assertNull(Whitebox.getInternalState(pageBean, "idClass"));
  215 +//
  216 +// replayAll();
  217 +// assertEquals(Object.class, pageBean.getIdClass());
  218 +// verifyAll();
  219 +//
  220 +// Whitebox.setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class);
  221 +// assertEquals(Long.class, pageBean.getIdClass());
  222 +// }
  223 +//
  224 +// @Test
  225 +// @SuppressWarnings("unchecked")
  226 +// public void testGetStringId() {
  227 +// mockStatic(Util.class);
  228 +//
  229 +// FacesContext facesContext = createMock(FacesContext.class);
  230 +// Parameter<String> parameter = createMock(Parameter.class);
  231 +//
  232 +// setInternalState(pageBean, "facesContext", facesContext);
  233 +// setInternalState(pageBean, "id", parameter);
  234 +// setInternalState(pageBean, "idClass", String.class, AbstractEditPageBean.class);
  235 +//
  236 +// String value = "1";
  237 +// expect(parameter.getValue()).andReturn(value);
  238 +//
  239 +// replayAll();
  240 +// assertEquals(value, pageBean.getId());
  241 +// verifyAll();
  242 +// }
  243 +//
  244 +// @Test
  245 +// @SuppressWarnings("unchecked")
  246 +// public void testGetLongId() {
  247 +// mockStatic(Faces.class);
  248 +//
  249 +// FacesContext facesContext = createMock(FacesContext.class);
  250 +// Converter converter = createMock(Converter.class);
  251 +// UIViewRoot viewRoot = createMock(UIViewRoot.class);
  252 +// Parameter<String> parameter = createMock(Parameter.class);
  253 +//
  254 +// setInternalState(pageBean, "facesContext", facesContext);
  255 +// setInternalState(pageBean, "id", parameter);
  256 +// setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class);
  257 +//
  258 +// String value = "1";
  259 +//
  260 +// expect(parameter.getValue()).andReturn(value);
  261 +// expect(facesContext.getViewRoot()).andReturn(viewRoot);
  262 +// expect(Faces.getConverter(Long.class)).andReturn(converter);
  263 +// expect(converter.getAsObject(facesContext, viewRoot, value)).andReturn(Long.valueOf(value));
  264 +//
  265 +// replayAll();
  266 +// assertEquals(Long.valueOf(value), pageBean.getId());
  267 +// verifyAll();
  268 +// }
  269 +//
  270 +// @Test
  271 +// public void testGetNotStringIdWithNullConverter() {
  272 +// FacesContext facesContext = createMock(FacesContext.class);
  273 +//
  274 +// setInternalState(pageBean, "facesContext", facesContext);
  275 +// setInternalState(pageBean, "idClass", Contact.class, AbstractEditPageBean.class);
  276 +// setInternalState(pageBean, "bundle", bundle);
  277 +//
  278 +// replayAll();
  279 +// try {
  280 +// pageBean.getId();
  281 +// } catch (DemoiselleException cause) {
  282 +// assertEquals(bundle.getString("id-converter-not-found", Contact.class.getCanonicalName()),
  283 +// cause.getMessage());
  284 +// }
  285 +//
  286 +// verifyAll();
  287 +// }
  288 +//
  289 +// @SuppressWarnings("serial")
  290 +// @Test
  291 +// public void testUpdateMode() {
  292 +//
  293 +// pageBean = new AbstractEditPageBean<Contact, Object>() {
  294 +//
  295 +// private Long id = null;
  296 +//
  297 +// @Override
  298 +// public String update() {
  299 +// return null;
  300 +// }
  301 +//
  302 +// @Override
  303 +// public String insert() {
  304 +// return null;
  305 +// }
  306 +//
  307 +// @Override
  308 +// public String delete() {
  309 +// return null;
  310 +// }
  311 +//
  312 +// @Override
  313 +// protected void handleLoad() {
  314 +// this.setBean(new Contact(200L));
  315 +// }
  316 +//
  317 +// public Long getId() {
  318 +// return id;
  319 +// }
  320 +//
  321 +// };
  322 +//
  323 +// assertFalse(pageBean.isUpdateMode());
  324 +// setInternalState(pageBean, "id", 1L);
  325 +// assertTrue(pageBean.isUpdateMode());
  326 +// }
  327 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractListPageBeanTest.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.template;  
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.powermock.api.easymock.PowerMock.replayAll;  
44 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
45 -  
46 -import java.util.ArrayList;  
47 -import java.util.HashMap;  
48 -import java.util.List;  
49 -import java.util.Map;  
50 -  
51 -import javax.faces.model.ListDataModel;  
52 -  
53 -import org.junit.Before;  
54 -import org.junit.Test;  
55 -import org.junit.runner.RunWith;  
56 -import org.powermock.api.easymock.PowerMock;  
57 -import org.powermock.core.classloader.annotations.PrepareForTest;  
58 -import org.powermock.modules.junit4.PowerMockRunner;  
59 -import org.powermock.reflect.Whitebox;  
60 -  
61 -import br.gov.frameworkdemoiselle.internal.implementation.PaginationImpl;  
62 -import br.gov.frameworkdemoiselle.pagination.Pagination;  
63 -import br.gov.frameworkdemoiselle.pagination.PaginationContext;  
64 -import br.gov.frameworkdemoiselle.util.Reflections;  
65 -  
66 -@RunWith(PowerMockRunner.class)  
67 -@PrepareForTest({ Reflections.class, PaginationContext.class, Pagination.class })  
68 -public class AbstractListPageBeanTest {  
69 -  
70 - private MySimplePageBean pageBean;  
71 -  
72 - @Before  
73 - public void before() {  
74 - pageBean = new MySimplePageBean();  
75 - }  
76 -  
77 - @SuppressWarnings("rawtypes")  
78 - @Test  
79 - public void testClear() {  
80 - assertNull(Whitebox.getInternalState(pageBean, "dataModel"));  
81 - assertNull(Whitebox.getInternalState(pageBean, "resultList"));  
82 -  
83 - Whitebox.setInternalState(pageBean, "resultList", new ArrayList());  
84 - Whitebox.setInternalState(pageBean, "dataModel", new ListDataModel());  
85 -  
86 - pageBean.clear();  
87 -  
88 - assertNull(Whitebox.getInternalState(pageBean, "dataModel"));  
89 - assertNull(Whitebox.getInternalState(pageBean, "resultList"));  
90 - }  
91 -  
92 - @Test  
93 - public void testGetBeanClass() {  
94 - assertNull(Whitebox.getInternalState(pageBean, "beanClass"));  
95 -  
96 - PowerMock.mockStatic(Reflections.class);  
97 - expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class);  
98 -  
99 - PowerMock.replayAll();  
100 - assertEquals(Object.class, pageBean.getBeanClass());  
101 - PowerMock.verifyAll();  
102 -  
103 - Whitebox.setInternalState(pageBean, "beanClass", Contact.class, AbstractListPageBean.class);  
104 -  
105 - assertEquals(Contact.class, pageBean.getBeanClass());  
106 - }  
107 -  
108 - @Test  
109 - public void testGetDataModel() {  
110 - assertNull(Whitebox.getInternalState(pageBean, "dataModel"));  
111 - assertEquals(ListDataModel.class, pageBean.getDataModel().getClass());  
112 -  
113 - ListDataModel<Contact> ldm = new ListDataModel<Contact>();  
114 - Whitebox.setInternalState(pageBean, "dataModel", ldm);  
115 -  
116 - assertEquals(ldm, pageBean.getDataModel());  
117 - }  
118 -  
119 - @Test  
120 - public void testGetResultList() {  
121 - assertNull(Whitebox.getInternalState(pageBean, "resultList"));  
122 -  
123 - List<Contact> list = pageBean.getResultList();  
124 - assertTrue(list.size() == 2);  
125 -  
126 - list = new ArrayList<Contact>();  
127 - Whitebox.setInternalState(pageBean, "resultList", list);  
128 - assertTrue(list.size() == 0);  
129 - assertEquals(list, pageBean.getResultList());  
130 - }  
131 -  
132 - @Test  
133 - public void testList() {  
134 - this.testClear();  
135 - assertEquals(pageBean.getCurrentView(), pageBean.list());  
136 - }  
137 -  
138 - @Test  
139 - public void testSelection() {  
140 - Map<Long, Boolean> map = new HashMap<Long, Boolean>();  
141 - map.put(1L, true);  
142 - Whitebox.setInternalState(pageBean, "selection", map);  
143 - assertEquals(map, pageBean.getSelection());  
144 - assertEquals(true, pageBean.getSelection().get(1L));  
145 -  
146 - pageBean.setSelection(null);  
147 - assertNull(Whitebox.getInternalState(pageBean, "selection"));  
148 - pageBean.setSelection(map);  
149 - assertEquals(map, pageBean.getSelection());  
150 - assertEquals(true, pageBean.getSelection().get(1L));  
151 - }  
152 -  
153 - @Test  
154 - public void testPagination() {  
155 - Pagination pagination = new PaginationImpl();  
156 - PaginationContext pc = PowerMock.createMock(PaginationContext.class);  
157 - expect(pc.getPagination(Contact.class, true)).andReturn(pagination);  
158 -  
159 - replayAll();  
160 - Whitebox.setInternalState(pageBean, "paginationContext", pc);  
161 - assertEquals(pageBean.getPagination(), pagination);  
162 - verifyAll();  
163 - }  
164 -  
165 - @Test  
166 - public void testClearSelection() {  
167 - pageBean.clearSelection();  
168 - assertEquals(true, pageBean.getSelectedList().isEmpty());  
169 - }  
170 -  
171 - @Test  
172 - public void testGetSelectedList() {  
173 - Map<Long, Boolean> map = new HashMap<Long, Boolean>();  
174 - map.put(1L, true);  
175 - map.put(2L, true);  
176 - pageBean.setSelection(map);  
177 - assertEquals(2, pageBean.getSelectedList().size());  
178 - }  
179 -  
180 -}  
181 -  
182 -@SuppressWarnings("serial")  
183 -class MySimplePageBean extends AbstractListPageBean<Contact, Long> {  
184 -  
185 - @Override  
186 - protected List<Contact> handleResultList() {  
187 - List<Contact> list = new ArrayList<Contact>();  
188 - list.add(new Contact());  
189 - list.add(new Contact());  
190 - return list;  
191 - }  
192 -  
193 - @Override  
194 - public String getCurrentView() {  
195 - return "currentView";  
196 - }  
197 -  
198 -} 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.template;
  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.powermock.api.easymock.PowerMock.replayAll;
  44 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  45 +//
  46 +//import java.util.ArrayList;
  47 +//import java.util.HashMap;
  48 +//import java.util.List;
  49 +//import java.util.Map;
  50 +//
  51 +//import javax.faces.model.ListDataModel;
  52 +//
  53 +//import org.junit.Before;
  54 +//import org.junit.Test;
  55 +//import org.junit.runner.RunWith;
  56 +//import org.powermock.api.easymock.PowerMock;
  57 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  58 +//import org.powermock.modules.junit4.PowerMockRunner;
  59 +//import org.powermock.reflect.Whitebox;
  60 +//
  61 +//import br.gov.frameworkdemoiselle.internal.implementation.PaginationImpl;
  62 +//import br.gov.frameworkdemoiselle.pagination.Pagination;
  63 +//import br.gov.frameworkdemoiselle.pagination.PaginationContext;
  64 +//import br.gov.frameworkdemoiselle.util.Reflections;
  65 +//
  66 +//@RunWith(PowerMockRunner.class)
  67 +//@PrepareForTest({ Reflections.class, PaginationContext.class, Pagination.class })
  68 +//public class AbstractListPageBeanTest {
  69 +//
  70 +// private MySimplePageBean pageBean;
  71 +//
  72 +// @Before
  73 +// public void before() {
  74 +// pageBean = new MySimplePageBean();
  75 +// }
  76 +//
  77 +// @SuppressWarnings("rawtypes")
  78 +// @Test
  79 +// public void testClear() {
  80 +// assertNull(Whitebox.getInternalState(pageBean, "dataModel"));
  81 +// assertNull(Whitebox.getInternalState(pageBean, "resultList"));
  82 +//
  83 +// Whitebox.setInternalState(pageBean, "resultList", new ArrayList());
  84 +// Whitebox.setInternalState(pageBean, "dataModel", new ListDataModel());
  85 +//
  86 +// pageBean.clear();
  87 +//
  88 +// assertNull(Whitebox.getInternalState(pageBean, "dataModel"));
  89 +// assertNull(Whitebox.getInternalState(pageBean, "resultList"));
  90 +// }
  91 +//
  92 +// @Test
  93 +// public void testGetBeanClass() {
  94 +// assertNull(Whitebox.getInternalState(pageBean, "beanClass"));
  95 +//
  96 +// PowerMock.mockStatic(Reflections.class);
  97 +// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class);
  98 +//
  99 +// PowerMock.replayAll();
  100 +// assertEquals(Object.class, pageBean.getBeanClass());
  101 +// PowerMock.verifyAll();
  102 +//
  103 +// Whitebox.setInternalState(pageBean, "beanClass", Contact.class, AbstractListPageBean.class);
  104 +//
  105 +// assertEquals(Contact.class, pageBean.getBeanClass());
  106 +// }
  107 +//
  108 +// @Test
  109 +// public void testGetDataModel() {
  110 +// assertNull(Whitebox.getInternalState(pageBean, "dataModel"));
  111 +// assertEquals(ListDataModel.class, pageBean.getDataModel().getClass());
  112 +//
  113 +// ListDataModel<Contact> ldm = new ListDataModel<Contact>();
  114 +// Whitebox.setInternalState(pageBean, "dataModel", ldm);
  115 +//
  116 +// assertEquals(ldm, pageBean.getDataModel());
  117 +// }
  118 +//
  119 +// @Test
  120 +// public void testGetResultList() {
  121 +// assertNull(Whitebox.getInternalState(pageBean, "resultList"));
  122 +//
  123 +// List<Contact> list = pageBean.getResultList();
  124 +// assertTrue(list.size() == 2);
  125 +//
  126 +// list = new ArrayList<Contact>();
  127 +// Whitebox.setInternalState(pageBean, "resultList", list);
  128 +// assertTrue(list.size() == 0);
  129 +// assertEquals(list, pageBean.getResultList());
  130 +// }
  131 +//
  132 +// @Test
  133 +// public void testList() {
  134 +// this.testClear();
  135 +// assertEquals(pageBean.getCurrentView(), pageBean.list());
  136 +// }
  137 +//
  138 +// @Test
  139 +// public void testSelection() {
  140 +// Map<Long, Boolean> map = new HashMap<Long, Boolean>();
  141 +// map.put(1L, true);
  142 +// Whitebox.setInternalState(pageBean, "selection", map);
  143 +// assertEquals(map, pageBean.getSelection());
  144 +// assertEquals(true, pageBean.getSelection().get(1L));
  145 +//
  146 +// pageBean.setSelection(null);
  147 +// assertNull(Whitebox.getInternalState(pageBean, "selection"));
  148 +// pageBean.setSelection(map);
  149 +// assertEquals(map, pageBean.getSelection());
  150 +// assertEquals(true, pageBean.getSelection().get(1L));
  151 +// }
  152 +//
  153 +// @Test
  154 +// public void testPagination() {
  155 +// Pagination pagination = new PaginationImpl();
  156 +// PaginationContext pc = PowerMock.createMock(PaginationContext.class);
  157 +// expect(pc.getPagination(Contact.class, true)).andReturn(pagination);
  158 +//
  159 +// replayAll();
  160 +// Whitebox.setInternalState(pageBean, "paginationContext", pc);
  161 +// assertEquals(pageBean.getPagination(), pagination);
  162 +// verifyAll();
  163 +// }
  164 +//
  165 +// @Test
  166 +// public void testClearSelection() {
  167 +// pageBean.clearSelection();
  168 +// assertEquals(true, pageBean.getSelectedList().isEmpty());
  169 +// }
  170 +//
  171 +// @Test
  172 +// public void testGetSelectedList() {
  173 +// Map<Long, Boolean> map = new HashMap<Long, Boolean>();
  174 +// map.put(1L, true);
  175 +// map.put(2L, true);
  176 +// pageBean.setSelection(map);
  177 +// assertEquals(2, pageBean.getSelectedList().size());
  178 +// }
  179 +//
  180 +//}
  181 +//
  182 +//@SuppressWarnings("serial")
  183 +//class MySimplePageBean extends AbstractListPageBean<Contact, Long> {
  184 +//
  185 +// @Override
  186 +// protected List<Contact> handleResultList() {
  187 +// List<Contact> list = new ArrayList<Contact>();
  188 +// list.add(new Contact());
  189 +// list.add(new Contact());
  190 +// return list;
  191 +// }
  192 +//
  193 +// @Override
  194 +// public String getCurrentView() {
  195 +// return "currentView";
  196 +// }
  197 +//
  198 +//}
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractPageTest.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.template;  
38 -  
39 -import static org.easymock.EasyMock.expect;  
40 -import static org.junit.Assert.assertEquals;  
41 -import static org.powermock.api.easymock.PowerMock.replayAll;  
42 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
43 -  
44 -import javax.faces.component.UIViewRoot;  
45 -import javax.faces.context.FacesContext;  
46 -  
47 -import org.junit.Before;  
48 -import org.junit.Test;  
49 -import org.junit.runner.RunWith;  
50 -import org.powermock.api.easymock.PowerMock;  
51 -import org.powermock.core.classloader.annotations.PrepareForTest;  
52 -import org.powermock.modules.junit4.PowerMockRunner;  
53 -import org.powermock.reflect.Whitebox;  
54 -  
55 -import br.gov.frameworkdemoiselle.annotation.NextView;  
56 -import br.gov.frameworkdemoiselle.annotation.PreviousView;  
57 -import br.gov.frameworkdemoiselle.message.MessageContext;  
58 -  
59 -@RunWith(PowerMockRunner.class)  
60 -@PrepareForTest({ MessageContext.class })  
61 -public class AbstractPageTest {  
62 -  
63 - private AbstractPageBean abstractPage;  
64 -  
65 - private FacesContext facesContext;  
66 -  
67 - private UIViewRoot viewRoot;  
68 -  
69 - @Before  
70 - public void before() {  
71 - facesContext = PowerMock.createMock(FacesContext.class);  
72 - viewRoot = PowerMock.createMock(UIViewRoot.class);  
73 - expect(facesContext.getViewRoot()).andReturn(viewRoot).anyTimes();  
74 - expect(viewRoot.getViewId()).andReturn("viewId").anyTimes();  
75 - }  
76 -  
77 - @Test  
78 - public void testGetCurrentView() {  
79 - abstractPage = new MyAbstractPage();  
80 - Whitebox.setInternalState(abstractPage, "facesContext", facesContext);  
81 -  
82 - replayAll();  
83 - assertEquals(abstractPage.getCurrentView(), "viewId");  
84 - verifyAll();  
85 - }  
86 -  
87 - @Test  
88 - public void testGetNextViewOK() {  
89 - abstractPage = new MyAbstractPage();  
90 -  
91 - replayAll();  
92 - assertEquals(abstractPage.getNextView(), "next_view");  
93 - verifyAll();  
94 - }  
95 -  
96 - @Test  
97 - public void testGetNextViewWhenNoAnnotation() {  
98 - abstractPage = new MyAbstractPageNoAnnotations();  
99 -  
100 - replayAll();  
101 - assertEquals(abstractPage.getNextView(), null);  
102 - verifyAll();  
103 - }  
104 -  
105 - @Test  
106 - public void testGetNextViewAlreadySet() {  
107 - abstractPage = new MyAbstractPageNoAnnotations();  
108 - Whitebox.setInternalState(abstractPage, "nextView", "next");  
109 -  
110 - replayAll();  
111 - assertEquals(abstractPage.getNextView(), "next");  
112 - verifyAll();  
113 - }  
114 -  
115 - @Test  
116 - public void testGetPreviousViewOK() {  
117 - abstractPage = new MyAbstractPage();  
118 -  
119 - replayAll();  
120 - assertEquals(abstractPage.getPreviousView(), "prevs");  
121 - verifyAll();  
122 - }  
123 -  
124 - @Test  
125 - public void testGetPreviousViewAlreadySet() {  
126 - abstractPage = new MyAbstractPageNoAnnotations();  
127 - Whitebox.setInternalState(abstractPage, "previousView", "previous");  
128 -  
129 - replayAll();  
130 - assertEquals(abstractPage.getPreviousView(), "previous");  
131 - verifyAll();  
132 - }  
133 -  
134 - @Test  
135 - public void testGetPreviousViewWhenNoAnnotation() {  
136 - abstractPage = new MyAbstractPageNoAnnotations();  
137 -  
138 - replayAll();  
139 - assertEquals(abstractPage.getPreviousView(), null);  
140 - verifyAll();  
141 - }  
142 -  
143 - @Test  
144 - public void testOtherTests() {  
145 - abstractPage = new MyAbstractPageNoAnnotations();  
146 - assertEquals(null, abstractPage.getTitle());  
147 - }  
148 -}  
149 -  
150 -@SuppressWarnings("serial")  
151 -@NextView("next_view")  
152 -@PreviousView("prevs")  
153 -class MyAbstractPage extends AbstractPageBean {  
154 -  
155 -}  
156 -  
157 -@SuppressWarnings("serial")  
158 -class MyAbstractPageNoAnnotations extends AbstractPageBean {  
159 -  
160 -} 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.template;
  38 +//
  39 +//import static org.easymock.EasyMock.expect;
  40 +//import static org.junit.Assert.assertEquals;
  41 +//import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  43 +//
  44 +//import javax.faces.component.UIViewRoot;
  45 +//import javax.faces.context.FacesContext;
  46 +//
  47 +//import org.junit.Before;
  48 +//import org.junit.Test;
  49 +//import org.junit.runner.RunWith;
  50 +//import org.powermock.api.easymock.PowerMock;
  51 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  52 +//import org.powermock.modules.junit4.PowerMockRunner;
  53 +//import org.powermock.reflect.Whitebox;
  54 +//
  55 +//import br.gov.frameworkdemoiselle.annotation.NextView;
  56 +//import br.gov.frameworkdemoiselle.annotation.PreviousView;
  57 +//import br.gov.frameworkdemoiselle.message.MessageContext;
  58 +//
  59 +//@RunWith(PowerMockRunner.class)
  60 +//@PrepareForTest({ MessageContext.class })
  61 +//public class AbstractPageTest {
  62 +//
  63 +// private AbstractPageBean abstractPage;
  64 +//
  65 +// private FacesContext facesContext;
  66 +//
  67 +// private UIViewRoot viewRoot;
  68 +//
  69 +// @Before
  70 +// public void before() {
  71 +// facesContext = PowerMock.createMock(FacesContext.class);
  72 +// viewRoot = PowerMock.createMock(UIViewRoot.class);
  73 +// expect(facesContext.getViewRoot()).andReturn(viewRoot).anyTimes();
  74 +// expect(viewRoot.getViewId()).andReturn("viewId").anyTimes();
  75 +// }
  76 +//
  77 +// @Test
  78 +// public void testGetCurrentView() {
  79 +// abstractPage = new MyAbstractPage();
  80 +// Whitebox.setInternalState(abstractPage, "facesContext", facesContext);
  81 +//
  82 +// replayAll();
  83 +// assertEquals(abstractPage.getCurrentView(), "viewId");
  84 +// verifyAll();
  85 +// }
  86 +//
  87 +// @Test
  88 +// public void testGetNextViewOK() {
  89 +// abstractPage = new MyAbstractPage();
  90 +//
  91 +// replayAll();
  92 +// assertEquals(abstractPage.getNextView(), "next_view");
  93 +// verifyAll();
  94 +// }
  95 +//
  96 +// @Test
  97 +// public void testGetNextViewWhenNoAnnotation() {
  98 +// abstractPage = new MyAbstractPageNoAnnotations();
  99 +//
  100 +// replayAll();
  101 +// assertEquals(abstractPage.getNextView(), null);
  102 +// verifyAll();
  103 +// }
  104 +//
  105 +// @Test
  106 +// public void testGetNextViewAlreadySet() {
  107 +// abstractPage = new MyAbstractPageNoAnnotations();
  108 +// Whitebox.setInternalState(abstractPage, "nextView", "next");
  109 +//
  110 +// replayAll();
  111 +// assertEquals(abstractPage.getNextView(), "next");
  112 +// verifyAll();
  113 +// }
  114 +//
  115 +// @Test
  116 +// public void testGetPreviousViewOK() {
  117 +// abstractPage = new MyAbstractPage();
  118 +//
  119 +// replayAll();
  120 +// assertEquals(abstractPage.getPreviousView(), "prevs");
  121 +// verifyAll();
  122 +// }
  123 +//
  124 +// @Test
  125 +// public void testGetPreviousViewAlreadySet() {
  126 +// abstractPage = new MyAbstractPageNoAnnotations();
  127 +// Whitebox.setInternalState(abstractPage, "previousView", "previous");
  128 +//
  129 +// replayAll();
  130 +// assertEquals(abstractPage.getPreviousView(), "previous");
  131 +// verifyAll();
  132 +// }
  133 +//
  134 +// @Test
  135 +// public void testGetPreviousViewWhenNoAnnotation() {
  136 +// abstractPage = new MyAbstractPageNoAnnotations();
  137 +//
  138 +// replayAll();
  139 +// assertEquals(abstractPage.getPreviousView(), null);
  140 +// verifyAll();
  141 +// }
  142 +//
  143 +// @Test
  144 +// public void testOtherTests() {
  145 +// abstractPage = new MyAbstractPageNoAnnotations();
  146 +// assertEquals(null, abstractPage.getTitle());
  147 +// }
  148 +//}
  149 +//
  150 +//@SuppressWarnings("serial")
  151 +//@NextView("next_view")
  152 +//@PreviousView("prevs")
  153 +//class MyAbstractPage extends AbstractPageBean {
  154 +//
  155 +//}
  156 +//
  157 +//@SuppressWarnings("serial")
  158 +//class MyAbstractPageNoAnnotations extends AbstractPageBean {
  159 +//
  160 +//}
impl/extension/jta/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.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 -  
38 -package br.gov.frameworkdemoiselle.transaction;  
39 -  
40 -import static org.easymock.EasyMock.createMock;  
41 -import static org.easymock.EasyMock.expect;  
42 -import static org.easymock.EasyMock.expectLastCall;  
43 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
44 -import static org.powermock.api.easymock.PowerMock.replay;  
45 -import static org.powermock.api.easymock.PowerMock.replayAll;  
46 -import static org.powermock.api.easymock.PowerMock.verify;  
47 -import static org.powermock.reflect.Whitebox.setInternalState;  
48 -  
49 -import javax.transaction.HeuristicMixedException;  
50 -import javax.transaction.HeuristicRollbackException;  
51 -import javax.transaction.NotSupportedException;  
52 -import javax.transaction.RollbackException;  
53 -import javax.transaction.SystemException;  
54 -import javax.transaction.UserTransaction;  
55 -  
56 -import junit.framework.Assert;  
57 -  
58 -import org.junit.Before;  
59 -import org.junit.Test;  
60 -import org.junit.runner.RunWith;  
61 -import org.powermock.core.classloader.annotations.PrepareForTest;  
62 -import org.powermock.modules.junit4.PowerMockRunner;  
63 -  
64 -import br.gov.frameworkdemoiselle.DemoiselleException;  
65 -import br.gov.frameworkdemoiselle.util.Beans;  
66 -  
67 -@RunWith(PowerMockRunner.class)  
68 -@PrepareForTest({ Beans.class })  
69 -public class JTATransactionTest {  
70 -  
71 - private UserTransaction userTransaction;  
72 -  
73 - private JTATransaction jtaTransaction;  
74 -  
75 - @Before  
76 - public void setUp() {  
77 - userTransaction = createMock(UserTransaction.class);  
78 - jtaTransaction = new JTATransaction();  
79 -  
80 - setInternalState(jtaTransaction, UserTransaction.class, userTransaction);  
81 - }  
82 -  
83 - @Test  
84 - public void testGetDElegateWithUserTransactionNull() throws SystemException {  
85 - mockStatic(Beans.class);  
86 - userTransaction = null;  
87 - setInternalState(jtaTransaction, UserTransaction.class, userTransaction);  
88 - userTransaction = createMock(UserTransaction.class);  
89 - expect(Beans.getReference(UserTransaction.class)).andReturn(userTransaction);  
90 - replayAll();  
91 -  
92 - // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());  
93 - }  
94 -  
95 - @Test  
96 - public void testGetDElegateWithUserTransactionIsNotNull() throws SystemException {  
97 - // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());  
98 - }  
99 -  
100 - @Test  
101 - public void testIsActiveWithStatusEqualsActive() throws SystemException {  
102 - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(0));  
103 - replay(userTransaction);  
104 - Assert.assertTrue(this.jtaTransaction.isActive());  
105 - }  
106 -  
107 - @Test  
108 - public void testIsActiveWithStatusEqualsMarkedRollback() throws SystemException {  
109 - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1)).times(2);  
110 - replay(userTransaction);  
111 - Assert.assertTrue(this.jtaTransaction.isActive());  
112 - }  
113 -  
114 - @Test  
115 - public void testIsMarkedRollback() throws SystemException {  
116 - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1));  
117 - replay(userTransaction);  
118 - Assert.assertTrue(this.jtaTransaction.isMarkedRollback());  
119 - }  
120 -  
121 - @Test  
122 - public void testBegin() throws SystemException, NotSupportedException {  
123 - userTransaction.begin();  
124 - replay(userTransaction);  
125 - this.jtaTransaction.begin();  
126 - verify();  
127 - }  
128 -  
129 - @Test  
130 - public void testCommit() throws SystemException, NotSupportedException, SecurityException, IllegalStateException,  
131 - RollbackException, HeuristicMixedException, HeuristicRollbackException {  
132 - userTransaction.commit();  
133 - replay(userTransaction);  
134 - this.jtaTransaction.commit();  
135 - verify();  
136 - }  
137 -  
138 - @Test  
139 - public void testRollback() throws SystemException, NotSupportedException {  
140 - userTransaction.rollback();  
141 - replay(userTransaction);  
142 - this.jtaTransaction.rollback();  
143 - verify();  
144 - }  
145 -  
146 - @Test  
147 - public void testSetRollbackOnly() throws SystemException, NotSupportedException {  
148 - userTransaction.setRollbackOnly();  
149 - replay(userTransaction);  
150 - this.jtaTransaction.setRollbackOnly();  
151 - verify();  
152 - }  
153 -  
154 - @Test  
155 - public void testIsActiveThrowsSystemException() throws SystemException {  
156 - expect(userTransaction.getStatus()).andThrow(new SystemException());  
157 - replay(userTransaction);  
158 - try {  
159 - this.jtaTransaction.isActive();  
160 - Assert.fail();  
161 - } catch (DemoiselleException cause) {  
162 - Assert.assertTrue(true);  
163 - }  
164 - }  
165 -  
166 - @Test  
167 - public void testIsMarkedRollbackThrowsSystemException() throws SystemException {  
168 - expect(userTransaction.getStatus()).andThrow(new SystemException());  
169 - replay(userTransaction);  
170 - try {  
171 - this.jtaTransaction.isMarkedRollback();  
172 - Assert.fail();  
173 - } catch (DemoiselleException cause) {  
174 - Assert.assertTrue(true);  
175 - }  
176 - }  
177 -  
178 - @Test  
179 - public void testBeginThrowsException() throws SystemException, NotSupportedException {  
180 - userTransaction.begin();  
181 - expectLastCall().andThrow(new SystemException());  
182 - replay(userTransaction);  
183 - try {  
184 - this.jtaTransaction.begin();  
185 - Assert.fail();  
186 - } catch (DemoiselleException cause) {  
187 - Assert.assertTrue(true);  
188 - }  
189 - }  
190 -  
191 - @Test  
192 - public void testCommitThrowsException() throws SystemException, SecurityException, IllegalStateException,  
193 - RollbackException, HeuristicMixedException, HeuristicRollbackException {  
194 - userTransaction.commit();  
195 - expectLastCall().andThrow(new SystemException());  
196 - replay(userTransaction);  
197 - try {  
198 - this.jtaTransaction.commit();  
199 - Assert.fail();  
200 - } catch (DemoiselleException cause) {  
201 - Assert.assertTrue(true);  
202 - }  
203 - }  
204 -  
205 - @Test  
206 - public void testRollbackThrowsSystemException() throws SystemException {  
207 - userTransaction.rollback();  
208 - expectLastCall().andThrow(new SystemException());  
209 - replay(userTransaction);  
210 - try {  
211 - this.jtaTransaction.rollback();  
212 - Assert.fail();  
213 - } catch (DemoiselleException cause) {  
214 - Assert.assertTrue(true);  
215 - }  
216 - }  
217 -  
218 - @Test  
219 - public void testSetRollbackOnlyThrowsSystemException() throws SystemException {  
220 - userTransaction.setRollbackOnly();  
221 - expectLastCall().andThrow(new SystemException());  
222 - replay(userTransaction);  
223 - try {  
224 - this.jtaTransaction.setRollbackOnly();  
225 - Assert.fail();  
226 - } catch (DemoiselleException cause) {  
227 - Assert.assertTrue(true);  
228 - }  
229 - }  
230 -  
231 -} 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 +//
  38 +//package br.gov.frameworkdemoiselle.transaction;
  39 +//
  40 +//import javax.transaction.HeuristicMixedException;
  41 +//import javax.transaction.HeuristicRollbackException;
  42 +//import javax.transaction.NotSupportedException;
  43 +//import javax.transaction.RollbackException;
  44 +//import javax.transaction.SystemException;
  45 +//import javax.transaction.UserTransaction;
  46 +//
  47 +//import junit.framework.Assert;
  48 +//
  49 +//import org.junit.Before;
  50 +//import org.junit.Test;
  51 +//import org.junit.runner.RunWith;
  52 +//
  53 +//import br.gov.frameworkdemoiselle.DemoiselleException;
  54 +//import br.gov.frameworkdemoiselle.util.Beans;
  55 +//
  56 +//@RunWith(PowerMockRunner.class)
  57 +//@PrepareForTest({ Beans.class })
  58 +//public class JTATransactionTest {
  59 +//
  60 +// private UserTransaction userTransaction;
  61 +//
  62 +// private JTATransaction jtaTransaction;
  63 +//
  64 +// @Before
  65 +// public void setUp() {
  66 +// userTransaction = createMock(UserTransaction.class);
  67 +// jtaTransaction = new JTATransaction();
  68 +//
  69 +// setInternalState(jtaTransaction, UserTransaction.class, userTransaction);
  70 +// }
  71 +//
  72 +// @Test
  73 +// public void testGetDElegateWithUserTransactionNull() throws SystemException {
  74 +// mockStatic(Beans.class);
  75 +// userTransaction = null;
  76 +// setInternalState(jtaTransaction, UserTransaction.class, userTransaction);
  77 +// userTransaction = createMock(UserTransaction.class);
  78 +// expect(Beans.getReference(UserTransaction.class)).andReturn(userTransaction);
  79 +// replayAll();
  80 +//
  81 +// // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());
  82 +// }
  83 +//
  84 +// @Test
  85 +// public void testGetDElegateWithUserTransactionIsNotNull() throws SystemException {
  86 +// // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());
  87 +// }
  88 +//
  89 +// @Test
  90 +// public void testIsActiveWithStatusEqualsActive() throws SystemException {
  91 +// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(0));
  92 +// replay(userTransaction);
  93 +// Assert.assertTrue(this.jtaTransaction.isActive());
  94 +// }
  95 +//
  96 +// @Test
  97 +// public void testIsActiveWithStatusEqualsMarkedRollback() throws SystemException {
  98 +// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1)).times(2);
  99 +// replay(userTransaction);
  100 +// Assert.assertTrue(this.jtaTransaction.isActive());
  101 +// }
  102 +//
  103 +// @Test
  104 +// public void testIsMarkedRollback() throws SystemException {
  105 +// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1));
  106 +// replay(userTransaction);
  107 +// Assert.assertTrue(this.jtaTransaction.isMarkedRollback());
  108 +// }
  109 +//
  110 +// @Test
  111 +// public void testBegin() throws SystemException, NotSupportedException {
  112 +// userTransaction.begin();
  113 +// replay(userTransaction);
  114 +// this.jtaTransaction.begin();
  115 +// verify();
  116 +// }
  117 +//
  118 +// @Test
  119 +// public void testCommit() throws SystemException, NotSupportedException, SecurityException, IllegalStateException,
  120 +// RollbackException, HeuristicMixedException, HeuristicRollbackException {
  121 +// userTransaction.commit();
  122 +// replay(userTransaction);
  123 +// this.jtaTransaction.commit();
  124 +// verify();
  125 +// }
  126 +//
  127 +// @Test
  128 +// public void testRollback() throws SystemException, NotSupportedException {
  129 +// userTransaction.rollback();
  130 +// replay(userTransaction);
  131 +// this.jtaTransaction.rollback();
  132 +// verify();
  133 +// }
  134 +//
  135 +// @Test
  136 +// public void testSetRollbackOnly() throws SystemException, NotSupportedException {
  137 +// userTransaction.setRollbackOnly();
  138 +// replay(userTransaction);
  139 +// this.jtaTransaction.setRollbackOnly();
  140 +// verify();
  141 +// }
  142 +//
  143 +// @Test
  144 +// public void testIsActiveThrowsSystemException() throws SystemException {
  145 +// expect(userTransaction.getStatus()).andThrow(new SystemException());
  146 +// replay(userTransaction);
  147 +// try {
  148 +// this.jtaTransaction.isActive();
  149 +// Assert.fail();
  150 +// } catch (DemoiselleException cause) {
  151 +// Assert.assertTrue(true);
  152 +// }
  153 +// }
  154 +//
  155 +// @Test
  156 +// public void testIsMarkedRollbackThrowsSystemException() throws SystemException {
  157 +// expect(userTransaction.getStatus()).andThrow(new SystemException());
  158 +// replay(userTransaction);
  159 +// try {
  160 +// this.jtaTransaction.isMarkedRollback();
  161 +// Assert.fail();
  162 +// } catch (DemoiselleException cause) {
  163 +// Assert.assertTrue(true);
  164 +// }
  165 +// }
  166 +//
  167 +// @Test
  168 +// public void testBeginThrowsException() throws SystemException, NotSupportedException {
  169 +// userTransaction.begin();
  170 +// expectLastCall().andThrow(new SystemException());
  171 +// replay(userTransaction);
  172 +// try {
  173 +// this.jtaTransaction.begin();
  174 +// Assert.fail();
  175 +// } catch (DemoiselleException cause) {
  176 +// Assert.assertTrue(true);
  177 +// }
  178 +// }
  179 +//
  180 +// @Test
  181 +// public void testCommitThrowsException() throws SystemException, SecurityException, IllegalStateException,
  182 +// RollbackException, HeuristicMixedException, HeuristicRollbackException {
  183 +// userTransaction.commit();
  184 +// expectLastCall().andThrow(new SystemException());
  185 +// replay(userTransaction);
  186 +// try {
  187 +// this.jtaTransaction.commit();
  188 +// Assert.fail();
  189 +// } catch (DemoiselleException cause) {
  190 +// Assert.assertTrue(true);
  191 +// }
  192 +// }
  193 +//
  194 +// @Test
  195 +// public void testRollbackThrowsSystemException() throws SystemException {
  196 +// userTransaction.rollback();
  197 +// expectLastCall().andThrow(new SystemException());
  198 +// replay(userTransaction);
  199 +// try {
  200 +// this.jtaTransaction.rollback();
  201 +// Assert.fail();
  202 +// } catch (DemoiselleException cause) {
  203 +// Assert.assertTrue(true);
  204 +// }
  205 +// }
  206 +//
  207 +// @Test
  208 +// public void testSetRollbackOnlyThrowsSystemException() throws SystemException {
  209 +// userTransaction.setRollbackOnly();
  210 +// expectLastCall().andThrow(new SystemException());
  211 +// replay(userTransaction);
  212 +// try {
  213 +// this.jtaTransaction.setRollbackOnly();
  214 +// Assert.fail();
  215 +// } catch (DemoiselleException cause) {
  216 +// Assert.assertTrue(true);
  217 +// }
  218 +// }
  219 +//
  220 +//}
impl/extension/se/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrapTest.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.bootstrap;  
38 -  
39 -import static org.easymock.EasyMock.expect;  
40 -import static org.powermock.api.easymock.PowerMock.createMock;  
41 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
42 -import static org.powermock.api.easymock.PowerMock.replay;  
43 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
44 -  
45 -import java.util.List;  
46 -import java.util.Locale;  
47 -  
48 -import javax.enterprise.inject.spi.AfterBeanDiscovery;  
49 -  
50 -import junit.framework.Assert;  
51 -  
52 -import org.junit.Before;  
53 -import org.junit.Ignore;  
54 -import org.junit.Test;  
55 -import org.junit.runner.RunWith;  
56 -import org.powermock.core.classloader.annotations.PrepareForTest;  
57 -import org.powermock.modules.junit4.PowerMockRunner;  
58 -import org.powermock.reflect.Whitebox;  
59 -  
60 -import br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext;  
61 -import br.gov.frameworkdemoiselle.internal.context.ContextManager;  
62 -import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;  
63 -import br.gov.frameworkdemoiselle.util.Beans;  
64 -  
65 -@RunWith(PowerMockRunner.class)  
66 -@PrepareForTest({ Beans.class, ContextManager.class })  
67 -@Ignore  
68 -public class SeBootstrapTest {  
69 -  
70 - private SeBootstrap seBootstrap;  
71 -  
72 - private AfterBeanDiscovery event;  
73 -  
74 - @Before  
75 - public void before() {  
76 - event = createMock(AfterBeanDiscovery.class);  
77 - mockStatic(Beans.class);  
78 - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes();  
79 - replay(Beans.class);  
80 - seBootstrap = new SeBootstrap();  
81 - }  
82 -  
83 - @Test  
84 - public void testStoreContext() {  
85 - seBootstrap.storeContexts(event);  
86 - replay(event);  
87 -  
88 - Assert.assertEquals(event, Whitebox.getInternalState(seBootstrap, "afterBeanDiscoveryEvent"));  
89 - List<AbstractCustomContext> context = Whitebox.getInternalState(seBootstrap, "tempContexts");  
90 - Assert.assertEquals(4, context.size());  
91 - verifyAll();  
92 - }  
93 -  
94 - @Test  
95 - public void testRemoveContexts() {  
96 - seBootstrap.storeContexts(event);  
97 -  
98 - AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class);  
99 - replay(event, afterShutdownProccess);  
100 - seBootstrap.removeContexts(afterShutdownProccess);  
101 -  
102 - verifyAll();  
103 - }  
104 -} 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.bootstrap;
  38 +//
  39 +//import static org.easymock.EasyMock.expect;
  40 +//import static org.powermock.api.easymock.PowerMock.createMock;
  41 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  42 +//import static org.powermock.api.easymock.PowerMock.replay;
  43 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  44 +//
  45 +//import java.util.List;
  46 +//import java.util.Locale;
  47 +//
  48 +//import javax.enterprise.inject.spi.AfterBeanDiscovery;
  49 +//
  50 +//import junit.framework.Assert;
  51 +//
  52 +//import org.junit.Before;
  53 +//import org.junit.Ignore;
  54 +//import org.junit.Test;
  55 +//import org.junit.runner.RunWith;
  56 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  57 +//import org.powermock.modules.junit4.PowerMockRunner;
  58 +//import org.powermock.reflect.Whitebox;
  59 +//
  60 +//import br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext;
  61 +//import br.gov.frameworkdemoiselle.internal.context.ContextManager;
  62 +//import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
  63 +//import br.gov.frameworkdemoiselle.util.Beans;
  64 +//
  65 +//@RunWith(PowerMockRunner.class)
  66 +//@PrepareForTest({ Beans.class, ContextManager.class })
  67 +//@Ignore
  68 +//public class SeBootstrapTest {
  69 +//
  70 +// private SeBootstrap seBootstrap;
  71 +//
  72 +// private AfterBeanDiscovery event;
  73 +//
  74 +// @Before
  75 +// public void before() {
  76 +// event = createMock(AfterBeanDiscovery.class);
  77 +// mockStatic(Beans.class);
  78 +// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes();
  79 +// replay(Beans.class);
  80 +// seBootstrap = new SeBootstrap();
  81 +// }
  82 +//
  83 +// @Test
  84 +// public void testStoreContext() {
  85 +// seBootstrap.storeContexts(event);
  86 +// replay(event);
  87 +//
  88 +// Assert.assertEquals(event, Whitebox.getInternalState(seBootstrap, "afterBeanDiscoveryEvent"));
  89 +// List<AbstractCustomContext> context = Whitebox.getInternalState(seBootstrap, "tempContexts");
  90 +// Assert.assertEquals(4, context.size());
  91 +// verifyAll();
  92 +// }
  93 +//
  94 +// @Test
  95 +// public void testRemoveContexts() {
  96 +// seBootstrap.storeContexts(event);
  97 +//
  98 +// AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class);
  99 +// replay(event, afterShutdownProccess);
  100 +// seBootstrap.removeContexts(afterShutdownProccess);
  101 +//
  102 +// verifyAll();
  103 +// }
  104 +// }
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletRequestProducerTest.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.producer;  
38 -  
39 -import static org.easymock.EasyMock.replay;  
40 -import static org.powermock.api.easymock.PowerMock.createMock;  
41 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
42 -  
43 -import javax.servlet.http.HttpServletRequest;  
44 -  
45 -import junit.framework.Assert;  
46 -  
47 -import org.junit.Test;  
48 -import org.powermock.reflect.Whitebox;  
49 -  
50 -public class HttpServletRequestProducerTest {  
51 -  
52 - private HttpServletRequestProducer httpServletRequestProducer;  
53 -  
54 - private HttpServletRequest request;  
55 -  
56 - @Test  
57 - public void testCreate() {  
58 - request = createMock(HttpServletRequest.class);  
59 - replay(request);  
60 -  
61 - httpServletRequestProducer = new HttpServletRequestProducer();  
62 - Whitebox.setInternalState(httpServletRequestProducer, "request", request);  
63 -  
64 - Assert.assertEquals(httpServletRequestProducer.create(), request);  
65 -  
66 - verifyAll();  
67 - }  
68 -  
69 - @Test  
70 - public void testSetDelegate() {  
71 - request = createMock(HttpServletRequest.class);  
72 - replay(request);  
73 -  
74 - httpServletRequestProducer = new HttpServletRequestProducer();  
75 -  
76 - httpServletRequestProducer.setDelegate(request);  
77 - Assert.assertEquals(Whitebox.getInternalState(httpServletRequestProducer, "request"), request);  
78 -  
79 - verifyAll();  
80 - }  
81 -  
82 -} 1 +///*
  2 +// * Demoiselle Framework
  3 +// * Copyright (C) 2010 SERPRO
  4 +// * ----------------------------------------------------------------------------
  5 +// * This file is part of Demoiselle Framework.
  6 +// *
  7 +// * Demoiselle Framework is free software; you can redistribute it and/or
  8 +// * modify it under the terms of the GNU Lesser General Public License version 3
  9 +// * as published by the Free Software Foundation.
  10 +// *
  11 +// * This program is distributed in the hope that it will be useful,
  12 +// * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 +// * GNU General Public License for more details.
  15 +// *
  16 +// * You should have received a copy of the GNU Lesser General Public License version 3
  17 +// * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 +// * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 +// * Fifth Floor, Boston, MA 02110-1301, USA.
  20 +// * ----------------------------------------------------------------------------
  21 +// * Este arquivo é parte do Framework Demoiselle.
  22 +// *
  23 +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 +// * do Software Livre (FSF).
  26 +// *
  27 +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 +// * para maiores detalhes.
  31 +// *
  32 +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 +// * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +// */
  37 +//package br.gov.frameworkdemoiselle.internal.producer;
  38 +//
  39 +//import static org.easymock.EasyMock.replay;
  40 +//import static org.powermock.api.easymock.PowerMock.createMock;
  41 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  42 +//
  43 +//import javax.servlet.http.HttpServletRequest;
  44 +//
  45 +//import junit.framework.Assert;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.powermock.reflect.Whitebox;
  49 +//
  50 +//public class HttpServletRequestProducerTest {
  51 +//
  52 +// private HttpServletRequestProducer httpServletRequestProducer;
  53 +//
  54 +// private HttpServletRequest request;
  55 +//
  56 +// @Test
  57 +// public void testCreate() {
  58 +// request = createMock(HttpServletRequest.class);
  59 +// replay(request);
  60 +//
  61 +// httpServletRequestProducer = new HttpServletRequestProducer();
  62 +// Whitebox.setInternalState(httpServletRequestProducer, "request", request);
  63 +//
  64 +// Assert.assertEquals(httpServletRequestProducer.create(), request);
  65 +//
  66 +// verifyAll();
  67 +// }
  68 +//
  69 +// @Test
  70 +// public void testSetDelegate() {
  71 +// request = createMock(HttpServletRequest.class);
  72 +// replay(request);
  73 +//
  74 +// httpServletRequestProducer = new HttpServletRequestProducer();
  75 +//
  76 +// httpServletRequestProducer.setDelegate(request);
  77 +// Assert.assertEquals(Whitebox.getInternalState(httpServletRequestProducer, "request"), request);
  78 +//
  79 +// verifyAll();
  80 +// }
  81 +//
  82 +//}
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletResponseProducerTest.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.producer;  
38 -  
39 -import static org.easymock.EasyMock.replay;  
40 -import static org.powermock.api.easymock.PowerMock.createMock;  
41 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
42 -  
43 -import javax.servlet.http.HttpServletResponse;  
44 -  
45 -import junit.framework.Assert;  
46 -  
47 -import org.junit.Test;  
48 -import org.powermock.reflect.Whitebox;  
49 -  
50 -public class HttpServletResponseProducerTest {  
51 -  
52 - private HttpServletResponseProducer httpServletResponseProducer;  
53 -  
54 - private HttpServletResponse response;  
55 -  
56 - @Test  
57 - public void testCreate() {  
58 - response = createMock(HttpServletResponse.class);  
59 - replay(response);  
60 -  
61 - httpServletResponseProducer = new HttpServletResponseProducer();  
62 - Whitebox.setInternalState(httpServletResponseProducer, "response", response);  
63 -  
64 - Assert.assertEquals(httpServletResponseProducer.create(), response);  
65 -  
66 - verifyAll();  
67 - }  
68 -  
69 - @Test  
70 - public void testSetDelegate() {  
71 - response = createMock(HttpServletResponse.class);  
72 - replay(response);  
73 -  
74 - httpServletResponseProducer = new HttpServletResponseProducer();  
75 -  
76 - httpServletResponseProducer.setDelegate(response);  
77 - Assert.assertEquals(Whitebox.getInternalState(httpServletResponseProducer, "response"), response);  
78 -  
79 - verifyAll();  
80 - }  
81 -  
82 -} 1 +///*
  2 +// * Demoiselle Framework
  3 +// * Copyright (C) 2010 SERPRO
  4 +// * ----------------------------------------------------------------------------
  5 +// * This file is part of Demoiselle Framework.
  6 +// *
  7 +// * Demoiselle Framework is free software; you can redistribute it and/or
  8 +// * modify it under the terms of the GNU Lesser General Public License version 3
  9 +// * as published by the Free Software Foundation.
  10 +// *
  11 +// * This program is distributed in the hope that it will be useful,
  12 +// * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 +// * GNU General Public License for more details.
  15 +// *
  16 +// * You should have received a copy of the GNU Lesser General Public License version 3
  17 +// * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 +// * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 +// * Fifth Floor, Boston, MA 02110-1301, USA.
  20 +// * ----------------------------------------------------------------------------
  21 +// * Este arquivo é parte do Framework Demoiselle.
  22 +// *
  23 +// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 +// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 +// * do Software Livre (FSF).
  26 +// *
  27 +// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 +// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 +// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 +// * para maiores detalhes.
  31 +// *
  32 +// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 +// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 +// * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 +// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +// */
  37 +//package br.gov.frameworkdemoiselle.internal.producer;
  38 +//
  39 +//import static org.easymock.EasyMock.replay;
  40 +//import static org.powermock.api.easymock.PowerMock.createMock;
  41 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  42 +//
  43 +//import javax.servlet.http.HttpServletResponse;
  44 +//
  45 +//import junit.framework.Assert;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.powermock.reflect.Whitebox;
  49 +//
  50 +//public class HttpServletResponseProducerTest {
  51 +//
  52 +// private HttpServletResponseProducer httpServletResponseProducer;
  53 +//
  54 +// private HttpServletResponse response;
  55 +//
  56 +// @Test
  57 +// public void testCreate() {
  58 +// response = createMock(HttpServletResponse.class);
  59 +// replay(response);
  60 +//
  61 +// httpServletResponseProducer = new HttpServletResponseProducer();
  62 +// Whitebox.setInternalState(httpServletResponseProducer, "response", response);
  63 +//
  64 +// Assert.assertEquals(httpServletResponseProducer.create(), response);
  65 +//
  66 +// verifyAll();
  67 +// }
  68 +//
  69 +// @Test
  70 +// public void testSetDelegate() {
  71 +// response = createMock(HttpServletResponse.class);
  72 +// replay(response);
  73 +//
  74 +// httpServletResponseProducer = new HttpServletResponseProducer();
  75 +//
  76 +// httpServletResponseProducer.setDelegate(response);
  77 +// Assert.assertEquals(Whitebox.getInternalState(httpServletResponseProducer, "response"), response);
  78 +//
  79 +// verifyAll();
  80 +// }
  81 +//
  82 +//}
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpSessionProducerTest.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.producer;  
38 -  
39 -import static org.easymock.EasyMock.createMock;  
40 -import static org.easymock.EasyMock.replay;  
41 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
42 -  
43 -import javax.servlet.http.HttpServletRequest;  
44 -import javax.servlet.http.HttpSession;  
45 -  
46 -import junit.framework.Assert;  
47 -  
48 -import org.easymock.EasyMock;  
49 -import org.junit.Test;  
50 -  
51 -public class HttpSessionProducerTest {  
52 -  
53 - private HttpSessionProducer httpSessionProducer;  
54 -  
55 - private HttpServletRequest request;  
56 -  
57 - @Test  
58 - public void testCreateWithRequestNull() {  
59 - httpSessionProducer = new HttpSessionProducer();  
60 - Assert.assertNull(httpSessionProducer.create(null));  
61 -  
62 - verifyAll();  
63 - }  
64 -  
65 - @Test  
66 - public void testCreateWithRequest() {  
67 - request = createMock(HttpServletRequest.class);  
68 - HttpSession session = createMock(HttpSession.class);  
69 - EasyMock.expect(request.getSession()).andReturn(session);  
70 - replay(request, session);  
71 -  
72 - httpSessionProducer = new HttpSessionProducer();  
73 - Assert.assertNotNull(httpSessionProducer.create(request));  
74 -  
75 - verifyAll();  
76 -  
77 - }  
78 -  
79 -} 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.producer;
  38 +//
  39 +//import static org.easymock.EasyMock.createMock;
  40 +//import static org.easymock.EasyMock.replay;
  41 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  42 +//
  43 +//import javax.servlet.http.HttpServletRequest;
  44 +//import javax.servlet.http.HttpSession;
  45 +//
  46 +//import junit.framework.Assert;
  47 +//
  48 +//import org.easymock.EasyMock;
  49 +//import org.junit.Test;
  50 +//
  51 +//public class HttpSessionProducerTest {
  52 +//
  53 +// private HttpSessionProducer httpSessionProducer;
  54 +//
  55 +// private HttpServletRequest request;
  56 +//
  57 +// @Test
  58 +// public void testCreateWithRequestNull() {
  59 +// httpSessionProducer = new HttpSessionProducer();
  60 +// Assert.assertNull(httpSessionProducer.create(null));
  61 +//
  62 +// verifyAll();
  63 +// }
  64 +//
  65 +// @Test
  66 +// public void testCreateWithRequest() {
  67 +// request = createMock(HttpServletRequest.class);
  68 +// HttpSession session = createMock(HttpSession.class);
  69 +// EasyMock.expect(request.getSession()).andReturn(session);
  70 +// replay(request, session);
  71 +//
  72 +// httpSessionProducer = new HttpSessionProducer();
  73 +// Assert.assertNotNull(httpSessionProducer.create(request));
  74 +//
  75 +// verifyAll();
  76 +//
  77 +// }
  78 +//
  79 +//}
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ServletLocaleProducerTest.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.producer;  
38 -  
39 -import static org.easymock.EasyMock.createMock;  
40 -import static org.easymock.EasyMock.expect;  
41 -import static org.powermock.api.easymock.PowerMock.mockStatic;  
42 -import static org.powermock.api.easymock.PowerMock.replay;  
43 -import static org.powermock.api.easymock.PowerMock.verifyAll;  
44 -  
45 -import javax.servlet.http.HttpServletRequest;  
46 -  
47 -import org.junit.Test;  
48 -import org.junit.runner.RunWith;  
49 -import org.powermock.core.classloader.annotations.PrepareForTest;  
50 -import org.powermock.modules.junit4.PowerMockRunner;  
51 -  
52 -import br.gov.frameworkdemoiselle.util.Beans;  
53 -  
54 -@RunWith(PowerMockRunner.class)  
55 -@PrepareForTest(Beans.class)  
56 -public class ServletLocaleProducerTest {  
57 -  
58 - private ServletLocaleProducer servletLocaleProducer;  
59 -  
60 - private HttpServletRequest request;  
61 -  
62 - @Test  
63 - public void testCreate() {  
64 - request = createMock(HttpServletRequest.class);  
65 -  
66 - mockStatic(Beans.class);  
67 - expect(Beans.getReference(HttpServletRequest.class)).andReturn(request);  
68 - replay(Beans.class);  
69 -  
70 - servletLocaleProducer = new ServletLocaleProducer();  
71 - servletLocaleProducer.create();  
72 -  
73 - verifyAll();  
74 - }  
75 -  
76 - @Test  
77 - public void testCreate2() {  
78 - servletLocaleProducer = new ServletLocaleProducer();  
79 - servletLocaleProducer.create();  
80 -  
81 - verifyAll();  
82 - }  
83 -  
84 -} 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.producer;
  38 +//
  39 +//import static org.easymock.EasyMock.createMock;
  40 +//import static org.easymock.EasyMock.expect;
  41 +//import static org.powermock.api.easymock.PowerMock.mockStatic;
  42 +//import static org.powermock.api.easymock.PowerMock.replay;
  43 +//import static org.powermock.api.easymock.PowerMock.verifyAll;
  44 +//
  45 +//import javax.servlet.http.HttpServletRequest;
  46 +//
  47 +//import org.junit.Test;
  48 +//import org.junit.runner.RunWith;
  49 +//import org.powermock.core.classloader.annotations.PrepareForTest;
  50 +//import org.powermock.modules.junit4.PowerMockRunner;
  51 +//
  52 +//import br.gov.frameworkdemoiselle.util.Beans;
  53 +//
  54 +//@RunWith(PowerMockRunner.class)
  55 +//@PrepareForTest(Beans.class)
  56 +//public class ServletLocaleProducerTest {
  57 +//
  58 +// private ServletLocaleProducer servletLocaleProducer;
  59 +//
  60 +// private HttpServletRequest request;
  61 +//
  62 +// @Test
  63 +// public void testCreate() {
  64 +// request = createMock(HttpServletRequest.class);
  65 +//
  66 +// mockStatic(Beans.class);
  67 +// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request);
  68 +// replay(Beans.class);
  69 +//
  70 +// servletLocaleProducer = new ServletLocaleProducer();
  71 +// servletLocaleProducer.create();
  72 +//
  73 +// verifyAll();
  74 +// }
  75 +//
  76 +// @Test
  77 +// public void testCreate2() {
  78 +// servletLocaleProducer = new ServletLocaleProducer();
  79 +// servletLocaleProducer.create();
  80 +//
  81 +// verifyAll();
  82 +// }
  83 +//
  84 +//}
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/HttpServletRequestProxyTest.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 org.junit.runner.RunWith;  
40 -import org.powermock.modules.junit4.PowerMockRunner;  
41 -  
42 -@RunWith(PowerMockRunner.class)  
43 -public class HttpServletRequestProxyTest {  
44 -  
45 -} 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 org.junit.runner.RunWith;
  40 +//import org.powermock.modules.junit4.PowerMockRunner;
  41 +//
  42 +//@RunWith(PowerMockRunner.class)
  43 +//public class HttpServletRequestProxyTest {
  44 +//
  45 +//}
parent/bom/pom.xml
@@ -109,13 +109,13 @@ @@ -109,13 +109,13 @@
109 <artifactId>demoiselle-jmx</artifactId> 109 <artifactId>demoiselle-jmx</artifactId>
110 <version>2.4.0-BETA2-SNAPSHOT</version> 110 <version>2.4.0-BETA2-SNAPSHOT</version>
111 </dependency> 111 </dependency>
112 -<!-- 112 + <!--
113 <dependency> 113 <dependency>
114 <groupId>br.gov.frameworkdemoiselle</groupId> 114 <groupId>br.gov.frameworkdemoiselle</groupId>
115 <artifactId>demoiselle-jaas</artifactId> 115 <artifactId>demoiselle-jaas</artifactId>
116 <version>2.4.0-BETA1-SNAPSHOT</version> 116 <version>2.4.0-BETA1-SNAPSHOT</version>
117 </dependency> 117 </dependency>
118 ---> 118 + -->
119 119
120 <!-- jsr-299 api --> 120 <!-- jsr-299 api -->
121 <dependency> 121 <dependency>
@@ -308,13 +308,6 @@ @@ -308,13 +308,6 @@
308 <version>${commons.dbcp.version}</version> 308 <version>${commons.dbcp.version}</version>
309 </dependency> 309 </dependency>
310 310
311 - <!-- embedded containners -->  
312 - <dependency>  
313 - <groupId>org.glassfish.main.extras</groupId>  
314 - <artifactId>glassfish-embedded-all</artifactId>  
315 - <version>${glassfish.embedded.version}</version>  
316 - </dependency>  
317 -  
318 <!-- embedded database --> 311 <!-- embedded database -->
319 <dependency> 312 <dependency>
320 <groupId>hsqldb</groupId> 313 <groupId>hsqldb</groupId>
@@ -335,31 +328,6 @@ @@ -335,31 +328,6 @@
335 <version>${junit.version}</version> 328 <version>${junit.version}</version>
336 </dependency> 329 </dependency>
337 <dependency> 330 <dependency>
338 - <groupId>org.jboss.arquillian</groupId>  
339 - <artifactId>arquillian-bom</artifactId>  
340 - <version>${arquillian.version}</version>  
341 - <scope>import</scope>  
342 - <type>pom</type>  
343 - </dependency>  
344 - <dependency>  
345 - <groupId>org.jboss.arquillian.container</groupId>  
346 - <artifactId>arquillian-weld-se-embedded-1.1</artifactId>  
347 - <version>${arquillian.weld.se.embedded.version}</version>  
348 - </dependency>  
349 - <dependency>  
350 - <groupId>org.jboss.arquillian.container</groupId>  
351 - <artifactId>arquillian-glassfish-embedded-3.1</artifactId>  
352 - <version>${arquillian.glassfish.embedded.version}</version>  
353 - </dependency>  
354 - <!--  
355 - <dependency>  
356 - <groupId>org.jboss.arquillian.extension</groupId>  
357 - <artifactId>arquillian-persistence-impl</artifactId>  
358 - <version>${arquillian.persistence.version}</version>  
359 - <scope>test</scope>  
360 - </dependency>  
361 - -->  
362 - <dependency>  
363 <groupId>org.jboss.weld.se</groupId> 331 <groupId>org.jboss.weld.se</groupId>
364 <artifactId>weld-se-core</artifactId> 332 <artifactId>weld-se-core</artifactId>
365 <version>${weld.version}</version> 333 <version>${weld.version}</version>
@@ -430,16 +398,6 @@ @@ -430,16 +398,6 @@
430 <junit.version>4.8.1</junit.version> 398 <junit.version>4.8.1</junit.version>
431 <easymock.version>3.0</easymock.version> 399 <easymock.version>3.0</easymock.version>
432 400
433 - <arquillian.version>1.1.1.Final</arquillian.version>  
434 - <!--  
435 - <arquillian.version>1.0.4.Final</arquillian.version>  
436 - -->  
437 - <arquillian.weld.se.embedded.version>1.0.0.CR7</arquillian.weld.se.embedded.version>  
438 - <arquillian.persistence.version>1.0.0.Alpha6</arquillian.persistence.version>  
439 - <arquillian.glassfish.embedded.version>1.0.0.CR4</arquillian.glassfish.embedded.version>  
440 -  
441 - <glassfish.embedded.version>3.1.2.2</glassfish.embedded.version>  
442 -  
443 <maven.surefire.plugin.version>2.16</maven.surefire.plugin.version> 401 <maven.surefire.plugin.version>2.16</maven.surefire.plugin.version>
444 402
445 <powermock.version>1.4.6</powermock.version> 403 <powermock.version>1.4.6</powermock.version>
parent/extension/pom.xml
@@ -75,16 +75,17 @@ @@ -75,16 +75,17 @@
75 <scope>import</scope> 75 <scope>import</scope>
76 <type>pom</type> 76 <type>pom</type>
77 </dependency> 77 </dependency>
  78 + <dependency>
  79 + <groupId>org.jboss.arquillian</groupId>
  80 + <artifactId>arquillian-bom</artifactId>
  81 + <version>${arquillian.bom.version}</version>
  82 + <scope>import</scope>
  83 + <type>pom</type>
  84 + </dependency>
78 </dependencies> 85 </dependencies>
79 </dependencyManagement> 86 </dependencyManagement>
80 87
81 <build> 88 <build>
82 - <testResources>  
83 - <testResource>  
84 - <directory>src/test/resources</directory>  
85 - <filtering>true</filtering>  
86 - </testResource>  
87 - </testResources>  
88 <plugins> 89 <plugins>
89 <plugin> 90 <plugin>
90 <groupId>org.apache.maven.plugins</groupId> 91 <groupId>org.apache.maven.plugins</groupId>
@@ -106,6 +107,25 @@ @@ -106,6 +107,25 @@
106 <groupId>org.apache.maven.plugins</groupId> 107 <groupId>org.apache.maven.plugins</groupId>
107 <artifactId>maven-surefire-plugin</artifactId> 108 <artifactId>maven-surefire-plugin</artifactId>
108 </plugin> 109 </plugin>
  110 + <plugin>
  111 + <groupId>org.jacoco</groupId>
  112 + <artifactId>jacoco-maven-plugin</artifactId>
  113 + <version>${jacoco.version}</version>
  114 + <executions>
  115 + <execution>
  116 + <goals>
  117 + <goal>prepare-agent</goal>
  118 + </goals>
  119 + </execution>
  120 + <execution>
  121 + <id>report</id>
  122 + <phase>prepare-package</phase>
  123 + <goals>
  124 + <goal>report</goal>
  125 + </goals>
  126 + </execution>
  127 + </executions>
  128 + </plugin>
109 </plugins> 129 </plugins>
110 </build> 130 </build>
111 131
@@ -122,27 +142,27 @@ @@ -122,27 +142,27 @@
122 <scope>test</scope> 142 <scope>test</scope>
123 </dependency> 143 </dependency>
124 <dependency> 144 <dependency>
125 - <groupId>org.easymock</groupId>  
126 - <artifactId>easymock</artifactId> 145 + <groupId>org.jboss.arquillian.junit</groupId>
  146 + <artifactId>arquillian-junit-container</artifactId>
127 <scope>test</scope> 147 <scope>test</scope>
128 </dependency> 148 </dependency>
129 <dependency> 149 <dependency>
130 - <groupId>org.powermock</groupId>  
131 - <artifactId>powermock-module-junit4</artifactId> 150 + <groupId>org.jboss.shrinkwrap.resolver</groupId>
  151 + <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
132 <scope>test</scope> 152 <scope>test</scope>
133 </dependency> 153 </dependency>
134 <dependency> 154 <dependency>
135 - <groupId>org.powermock</groupId>  
136 - <artifactId>powermock-api-easymock</artifactId> 155 + <groupId>org.jboss.arquillian.extension</groupId>
  156 + <artifactId>arquillian-jacoco</artifactId>
  157 + <version>${arquillian.jacoco.version}</version>
137 <scope>test</scope> 158 <scope>test</scope>
138 </dependency> 159 </dependency>
139 - <!--  
140 <dependency> 160 <dependency>
141 - <groupId>org.slf4j</groupId>  
142 - <artifactId>slf4j-log4j12</artifactId> 161 + <groupId>org.jacoco</groupId>
  162 + <artifactId>org.jacoco.core</artifactId>
  163 + <version>${jacoco.version}</version>
143 <scope>test</scope> 164 <scope>test</scope>
144 </dependency> 165 </dependency>
145 - -->  
146 </dependencies> 166 </dependencies>
147 167
148 <repositories> 168 <repositories>
@@ -169,4 +189,97 @@ @@ -169,4 +189,97 @@
169 </releases> 189 </releases>
170 </repository> 190 </repository>
171 </repositories> 191 </repositories>
  192 +
  193 + <profiles>
  194 + <profile>
  195 + <id>arquillian-test</id>
  196 + <dependencies>
  197 + <dependency>
  198 + <groupId>br.gov.frameworkdemoiselle</groupId>
  199 + <artifactId>demoiselle-core</artifactId>
  200 + <exclusions>
  201 + <exclusion>
  202 + <groupId>javax.enterprise</groupId>
  203 + <artifactId>cdi-api</artifactId>
  204 + </exclusion>
  205 + <exclusion>
  206 + <artifactId>validation-api</artifactId>
  207 + <groupId>javax.validation</groupId>
  208 + </exclusion>
  209 + <exclusion>
  210 + <groupId>org.slf4j</groupId>
  211 + <artifactId>slf4j-api</artifactId>
  212 + </exclusion>
  213 + <exclusion>
  214 + <groupId>org.javassist</groupId>
  215 + <artifactId>javassist</artifactId>
  216 + </exclusion>
  217 + </exclusions>
  218 + </dependency>
  219 + </dependencies>
  220 + </profile>
  221 + <profile>
  222 + <id>arquillian-jbossas7-managed</id>
  223 + <activation>
  224 + <activeByDefault>true</activeByDefault>
  225 + </activation>
  226 + <build>
  227 + <testResources>
  228 + <testResource>
  229 + <directory>src/test/resources</directory>
  230 + <filtering>true</filtering>
  231 + </testResource>
  232 + </testResources>
  233 + <plugins>
  234 + <plugin>
  235 + <artifactId>maven-dependency-plugin</artifactId>
  236 + <executions>
  237 + <execution>
  238 + <id>unpack</id>
  239 + <phase>process-test-classes</phase>
  240 + <goals>
  241 + <goal>unpack</goal>
  242 + </goals>
  243 + <configuration>
  244 + <artifactItems>
  245 + <artifactItem>
  246 + <groupId>org.jboss.as</groupId>
  247 + <artifactId>jboss-as-dist</artifactId>
  248 + <version>${jboss.as.version}</version>
  249 + <type>zip</type>
  250 + <overWrite>false</overWrite>
  251 + <outputDirectory>target</outputDirectory>
  252 + </artifactItem>
  253 + </artifactItems>
  254 + </configuration>
  255 + </execution>
  256 + </executions>
  257 + </plugin>
  258 + </plugins>
  259 + </build>
  260 + <dependencies>
  261 + <dependency>
  262 + <groupId>org.jboss.as</groupId>
  263 + <artifactId>jboss-as-arquillian-container-managed</artifactId>
  264 + <version>${jboss.as.version}</version>
  265 + <scope>test</scope>
  266 + </dependency>
  267 + <dependency>
  268 + <groupId>org.jboss.arquillian.protocol</groupId>
  269 + <artifactId>arquillian-protocol-servlet</artifactId>
  270 + <scope>test</scope>
  271 + </dependency>
  272 + </dependencies>
  273 +
  274 + <properties>
  275 + <jboss.as.version>7.1.1.Final</jboss.as.version>
  276 + </properties>
  277 + </profile>
  278 + </profiles>
  279 +
  280 + <properties>
  281 + <arquillian.bom.version>1.1.1.Final</arquillian.bom.version>
  282 + <arquillian.jacoco.version>1.0.0.Alpha5</arquillian.jacoco.version>
  283 + <jacoco.version>0.6.0.201210061924</jacoco.version>
  284 + </properties>
172 </project> 285 </project>