Author: sergeyhalipov
Date: 2008-05-15 10:57:51 -0400 (Thu, 15 May 2008)
New Revision: 8596
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
Log:
Ordering list integrated tests.
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java 2008-05-15
14:57:51 UTC (rev 8596)
@@ -0,0 +1,134 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+public class OrderingListTestBean {
+ private Converter converter;
+ private List<Item> items;
+ private Collection<Item> selection;
+ private Object activeItem;
+
+ public OrderingListTestBean() {
+ converter = new ItemConverter();
+ items = new ArrayList<Item>();
+ for (int i = 0; i < 4; i++) {
+ items.add(new Item("item" + i));
+ }
+ }
+
+ public Object getActionResult() {
+ return
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("actionResult");
+ }
+
+ public Collection<Item> getSelection() {
+ return selection;
+ }
+
+ public void setSelection(Collection<Item> selection) {
+ this.selection = selection;
+ }
+
+ public Object getActiveItem() {
+ return activeItem;
+ }
+
+ public void setActiveItem(Object activeItem) {
+ this.activeItem = activeItem;
+ }
+
+ public Converter getConverter() {
+ return converter;
+ }
+
+ public void setConverter(Converter converter) {
+ this.converter = converter;
+ }
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void setItems(List<Item> items) {
+ this.items = items;
+ }
+
+
+ private class ItemConverter implements Converter {
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
+ */
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ return new Item(value);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
+ */
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ Item optionItem = (Item) value;
+ return optionItem.getName();
+ }
+
+ }
+
+ public class Item implements Serializable {
+
+ private static final long serialVersionUID = 1083694594537030790L;
+
+ private String name;
+
+ public String action() {
+ FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("actionResult",
name);
+ return null;
+ }
+
+ public Item(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ }
+
+}
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-05-15
14:56:03 UTC (rev 8595)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-05-15
14:57:51 UTC (rev 8596)
@@ -92,4 +92,9 @@
<managed-bean-class>org.ajax4jsf.PickListTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>orderingListBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.OrderingListTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListDescription.xhtml 2008-05-15
14:57:51 UTC (rev 8596)
@@ -0,0 +1,17 @@
+<html>
+<table border="1" style="border-color: #F1EEE9"
cellpadding="5"
+ cellspacing="0">
+ <tr>
+ <th></th>
+ <th>Action</th>
+ <th colspan="3">Result</th>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ </tr>
+</table>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml 2008-05-15
14:57:51 UTC (rev 8596)
@@ -0,0 +1,50 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="style">
+ .link {margin: 0px 5px}
+ </ui:define>
+ <ui:define name="component">
+ <h:form id="_form">
+ <rich:orderingList id="orderingList"
+ converter="#{orderingListBean.converter}"
+ value="#{orderingListBean.items}" var="item"
+ captionLabel="Caption Label"
+
+ selection="#{orderingListBean.selection}"
+ activeItem="#{orderingListBean.activeItem}" >
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Name" />
+ </f:facet>
+ <h:outputText value="#{item.name}" id="output" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Ajax Action" />
+ </f:facet>
+ <a4j:commandButton value="Ajax Action"
reRender="actionResult"
+ action="#{orderingListBean.action}" id="#{item.name}_ajax"
/>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Server Action" />
+ </f:facet>
+ <h:commandLink value="Server Action"
action="#{orderingListBean.action}" id="#{item.name}_server" />
+ </h:column>
+ </rich:orderingList>
+
+ <br/>
+ <h:outputText value="#{orderingListBean.actionResult}"
id="actionResult" />
+ <br/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java 2008-05-15
14:57:51 UTC (rev 8596)
@@ -0,0 +1,129 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+public class OrderingListTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public OrderingListTest() {
+ super("http", "localhost", "8080");
+ }
+
+ public OrderingListTest(String protocol, String host, String port) {
+ super(protocol, host, port);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testOrderingListComponent() throws Exception {
+ _testOrderingListComponent(Templates.SIMPLE);
+ _testOrderingListComponent(Templates.DATATABLE);
+ }
+
+ private void _testOrderingListComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+
+ String firstRowPrefix = getParentId() + "_form:orderingList:0:";
+ String textId = firstRowPrefix + "output";
+
+ checkButtons(true, true, true, true);
+ clickById(textId);
+ checkButtons(true, true, false, false);
+
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/orderingList/orderingListTest.xhtml";
+ }
+
+ private void checkButtons(boolean firstDisabled, boolean upDisabled, boolean
downDisabled, boolean lastDisabled) {
+ String parentId = getParentId() + "_form:orderingList";
+ String firstButton = parentId + "first";
+ String firstButtonDisabled = parentId + "disfirst";
+
+ String upButton = parentId + "up";
+ String upButtonDisabled = parentId + "disup";
+
+ String downButton = parentId + "down";
+ String downButtonDisabled = parentId + "disdown";
+
+ String lastButton = parentId + "last";
+ String lastButtonDisabled = parentId + "dislast";
+
+ if (firstDisabled) {
+ Assert.assertTrue(isVisibleById(firstButtonDisabled));
+ Assert.assertFalse(isVisibleById(firstButton));
+ } else {
+ Assert.assertFalse(isVisibleById(firstButtonDisabled));
+ Assert.assertTrue(isVisibleById(firstButton));
+ }
+
+ if (upDisabled) {
+ Assert.assertTrue(isVisibleById(upButtonDisabled));
+ Assert.assertFalse(isVisibleById(upButton));
+ } else {
+ Assert.assertFalse(isVisibleById(upButtonDisabled));
+ Assert.assertTrue(isVisibleById(upButton));
+ }
+
+ if (downDisabled) {
+ Assert.assertTrue(isVisibleById(downButtonDisabled));
+ Assert.assertFalse(isVisibleById(downButton));
+ } else {
+ Assert.assertFalse(isVisibleById(downButtonDisabled));
+ Assert.assertTrue(isVisibleById(downButton));
+ }
+
+ if (lastDisabled) {
+ Assert.assertTrue(isVisibleById(lastButtonDisabled));
+ Assert.assertFalse(isVisibleById(lastButton));
+ } else {
+ Assert.assertFalse(isVisibleById(lastButtonDisabled));
+ Assert.assertTrue(isVisibleById(lastButton));
+ }
+ }
+}