Author: dsvyatobatsko
Date: 2008-06-27 13:23:07 -0400 (Fri, 27 Jun 2008)
New Revision: 9280
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/AjaxPushTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxPush/
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxPush/ajaxPushTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxPushTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
Log:
http://jira.jboss.com/jira/browse/RF-3778
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/AjaxPushTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/AjaxPushTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/AjaxPushTestBean.java 2008-06-27
17:23:07 UTC (rev 9280)
@@ -0,0 +1,88 @@
+package org.ajax4jsf.bean;
+
+import java.util.Date;
+import java.util.EventListener;
+import java.util.EventObject;
+
+import org.ajax4jsf.event.PushEventListener;
+
+public class AjaxPushTestBean implements Runnable {
+
+ private boolean enabled = false;
+
+ private Date startDate;
+
+ private PushEventListener listener;
+
+ private Thread thread;
+
+ private int eventsSent = 0;
+
+ /**
+ * Gets value of eventsSent field.
+ * @return value of eventsSent field
+ */
+ public int getEventsSent() {
+ return eventsSent;
+ }
+
+ /**
+ * Set a new value for eventsSent field.
+ * @param eventsSent a new value for eventsSent field
+ */
+ public void setEventsSent(int eventsSent) {
+ this.eventsSent = eventsSent;
+ }
+
+ public void addListener(EventListener listener) {
+ synchronized (listener) {
+ if (this.listener != listener) {
+ this.listener = (PushEventListener) listener;
+ }
+ }
+ }
+
+ public void run() {
+ while (thread != null) {
+ try {
+ long left = System.currentTimeMillis() - startDate.getTime();
+ if (left >= 60000) {
+ stop();
+ }
+ listener.onEvent(new EventObject(this));
+ eventsSent++;
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void start() {
+ if (thread == null) {
+ thread = new Thread(this);
+ thread.setDaemon(true);
+ thread.start();
+ startDate = new Date();
+ setEnabled(true);
+ }
+ }
+
+ public void stop() {
+ if (thread != null) {
+ startDate = null;
+ eventsSent = 0;
+ setEnabled(false);
+ thread = null;
+ }
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/AjaxPushTestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-27
14:53:23 UTC (rev 9279)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-27
17:23:07 UTC (rev 9280)
@@ -165,7 +165,11 @@
<managed-bean-class>org.ajax4jsf.bean.A4JSupport</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
-
+ <managed-bean>
+ <managed-bean-name>ajaxPushBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.AjaxPushTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
<navigation-case>
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxPush/ajaxPushTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxPush/ajaxPushTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxPushTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxPushTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxPushTest.java 2008-06-27
17:23:07 UTC (rev 9280)
@@ -0,0 +1,83 @@
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class AjaxPushTest extends SeleniumTestBase {
+
+ @Test(dataProvider = "templates")
+ public void testAjaxPushComponent(Template template) throws Exception {
+ renderPage(template);
+
+ String parentId = getParentId() + "_form:";
+
+ String startBtnID = parentId + "startButton";
+ String stopBtnID = parentId + "stopButton";
+
+ String startPanelID = parentId + "startPanel";
+ String progressPanelID = parentId + "progressPanel";
+
+ writeStatus("Check layout before start pushing");
+
+ AssertRendered(startBtnID);
+ AssertRendered(startPanelID);
+
+ AssertNotRendered(stopBtnID);
+ AssertNotRendered(progressPanelID);
+
+ writeStatus("Start push component. Test bean has to start sending events to
registered PushEventListener");
+
+ clickAjaxCommandAndWait(startBtnID);
+
+ writeStatus("Check layout after pushing started");
+
+ AssertNotRendered(startBtnID);
+ AssertNotRendered(startPanelID);
+
+ AssertRendered(stopBtnID);
+ AssertRendered(progressPanelID);
+
+ writeStatus("check whether push events are being fired");
+
+ int eventBefore = getEventsCount();
+
+ delay(3000);
+
+ int eventAfter = getEventsCount();
+
+ if(eventBefore >= eventAfter) {
+ Assert.fail("PushEvents are not fired");
+ }
+
+ writeStatus("stop pushing");
+
+ clickAjaxCommandAndWait(stopBtnID);
+
+ writeStatus("Check layout after pushing stopped");
+
+ AssertRendered(startBtnID);
+ AssertRendered(startPanelID);
+
+ AssertNotRendered(stopBtnID);
+ AssertNotRendered(progressPanelID);
+
+ }
+
+ private int getEventsCount() throws Exception {
+ String events = getTextById(getParentId() + "_form:events");
+ try {
+ return Integer.parseInt(events);
+ } catch (Exception e) {
+ Assert.fail("Quantity of sent events is not numeric :" +
e.getMessage());
+ throw new Exception(e);
+ }
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/ajaxPush/ajaxPushTest.xhtml";
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxPushTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native