Author: nbelaevski
Date: 2010-05-24 17:26:47 -0400 (Mon, 24 May 2010)
New Revision: 17221
Modified:
root/ui/core/trunk/api/src/test/java/org/richfaces/component/QueueRendererTest.java
Log:
Support for "org.richfaces.queue.enabled" parameter
Modified:
root/ui/core/trunk/api/src/test/java/org/richfaces/component/QueueRendererTest.java
===================================================================
---
root/ui/core/trunk/api/src/test/java/org/richfaces/component/QueueRendererTest.java 2010-05-24
19:41:51 UTC (rev 17220)
+++
root/ui/core/trunk/api/src/test/java/org/richfaces/component/QueueRendererTest.java 2010-05-24
21:26:47 UTC (rev 17221)
@@ -27,11 +27,20 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
import org.jboss.test.faces.ApplicationServer;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
@@ -43,6 +52,10 @@
*/
public class QueueRendererTest{
+ @Target(value = {ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ private @interface DisableQueue {}
+
private static final String EXPECTED_QUEUE_SCRIPT =
"RichFaces.queue.setQueueOptions({" +
"'first': {'requestDelay': 400, 'timeout': 100,
'ignoreDupResponses': true}," +
"'form': {'requestDelay': 400}," +
@@ -56,7 +69,23 @@
protected HtmlUnitEnvironment facesEnvironment;
+ private boolean queueEnabled = true;
+ @Rule
+ public final MethodRule rule = new MethodRule() {
+
+ public Statement apply(Statement base, FrameworkMethod method, Object target) {
+ QueueRendererTest test = (QueueRendererTest) target;
+
+ DisableQueue annotation =
method.getMethod().getAnnotation(DisableQueue.class);
+ if (annotation != null) {
+ test.queueEnabled = false;
+ }
+
+ return base;
+ }
+ };
+
@Before
public void setUp() throws Exception {
facesEnvironment = new HtmlUnitEnvironment();
@@ -64,9 +93,12 @@
ApplicationServer facesServer = facesEnvironment.getServer();
facesServer.addResource("/queue.xhtml",
"org/richfaces/component/queue.xhtml");
facesServer.addResource("/nonQueue.xhtml",
"org/richfaces/component/nonQueue.xhtml");
-
+
+
facesEnvironment.getServer().addInitParameter("org.richfaces.queue.enabled",
Boolean.toString(queueEnabled));
facesEnvironment.start();
}
+
+
@After
public void tearDown() throws Exception {
@@ -96,13 +128,20 @@
}*/
}
+
+ @Test
+ @DisableQueue
+ public void testQueuingDisabled() throws Exception {
+ page = facesEnvironment.getPage("/queue.jsf");
+ String queueScript = extractQueueScript(page);
+ assertNull(queueScript);
+ }
@Test
public void testPageWithoutQueue() throws Exception {
page = facesEnvironment.getPage("/nonQueue.jsf");
String queueScript = extractQueueScript(page);
assertNull("Queue script must be null", queueScript);
-
}
private String dehydrate(String s) {
Show replies by date