Author: alexsmirnov
Date: 2009-02-06 20:43:53 -0500 (Fri, 06 Feb 2009)
New Revision: 12599
Added:
branches/jsf2.0/tests/ajax/src/main/java/org/
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataBean.java
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataItem.java
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/UIDataTest.java
branches/jsf2.0/tests/ajax/src/test/resources/test.xhtml
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties
Log:
Fix default UIViewRoot render kit and locale values in the base test class.
Wrote UIData performance test.
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-02-06
17:44:26 UTC (rev 12598)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-02-07
01:43:53 UTC (rev 12599)
@@ -7,6 +7,7 @@
import java.io.InputStream;
import java.net.URL;
import java.util.EventListener;
+import java.util.Locale;
import java.util.logging.LogManager;
import javax.faces.FactoryFinder;
@@ -19,6 +20,7 @@
import javax.faces.context.FacesContextFactory;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKitFactory;
import javax.faces.webapp.FacesServlet;
import javax.servlet.Filter;
@@ -252,6 +254,8 @@
protected UIViewRoot setupView() {
UIViewRoot viewRoot = (UIViewRoot)
application.createComponent(UIViewRoot.COMPONENT_TYPE);
viewRoot.setViewId("/test.xhtml");
+ viewRoot.setLocale(Locale.getDefault());
+ viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
return viewRoot;
}
Added: branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataBean.java
===================================================================
--- branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataBean.java
(rev 0)
+++ branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataBean.java 2009-02-07
01:43:53 UTC (rev 12599)
@@ -0,0 +1,42 @@
+/**
+ *
+ */
+package org.richfaces.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class DataBean {
+
+ private final List<DataItem> data;
+
+ public DataBean() {
+ data = new ArrayList<DataItem>(10);
+ for(int i=0;i<10;i++){
+ DataItem item = new DataItem();
+ item.setPrice(i);
+ item.setName("Name"+i);
+ ArrayList<DataItem> items = new ArrayList<DataItem>(10);
+ for(int j=0;j<10;j++){
+ String name = "Item "+j+" of "+i;
+ DataItem childItem = new DataItem();
+ childItem.setName(name);
+ items.add(childItem);
+ }
+ item.setItems(items);
+ data.add(item);
+ }
+ }
+
+ /**
+ * @return the data
+ */
+ public List<DataItem> getData() {
+ return data;
+ }
+
+}
Property changes on:
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataItem.java
===================================================================
--- branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataItem.java
(rev 0)
+++ branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataItem.java 2009-02-07
01:43:53 UTC (rev 12599)
@@ -0,0 +1,62 @@
+/**
+ *
+ */
+package org.richfaces.test;
+
+import java.util.List;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class DataItem {
+
+ private String name;
+
+ private int price;
+
+ private List<DataItem> items;
+
+ /**
+ * @return the items
+ */
+ public List<DataItem> getItems() {
+ return items;
+ }
+
+ /**
+ * @param items the items to set
+ */
+ public void setItems(List<DataItem> items) {
+ this.items = items;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the price
+ */
+ public int getPrice() {
+ return price;
+ }
+
+ /**
+ * @param price the price to set
+ */
+ public void setPrice(int price) {
+ this.price = price;
+ }
+
+}
Property changes on:
branches/jsf2.0/tests/ajax/src/main/java/org/richfaces/test/DataItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml 2009-02-06
17:44:26 UTC (rev 12598)
+++ branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml 2009-02-07
01:43:53 UTC (rev 12599)
@@ -9,4 +9,9 @@
<managed-bean-class>declarativeajax.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+<managed-bean>
+ <managed-bean-name>dataBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.test.DataBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+</managed-bean>
</faces-config>
Added: branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/UIDataTest.java
===================================================================
--- branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/UIDataTest.java
(rev 0)
+++
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/UIDataTest.java 2009-02-07
01:43:53 UTC (rev 12599)
@@ -0,0 +1,116 @@
+/**
+ *
+ */
+package org.richfaces.test.ajax;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.event.PhaseId;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.ResponseStateManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.test.AbstractFacesTest;
+import org.richfaces.test.DataBean;
+import org.richfaces.test.staging.HttpMethod;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UIDataTest extends AbstractFacesTest {
+
+ @Before
+ public void setUpData(){
+
+ }
+
+ @Override
+ protected void setupWebContent() {
+ facesServer.addResource("/WEB-INF/faces-config.xml",
"WEB-INF/faces-config.xml");
+ facesServer.addResource("/test.xhtml", "test.xhtml");
+ }
+
+ @Override
+ protected UIViewRoot setupView() {
+ facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW);
+ ELContext elContext = facesContext.getELContext();
+ ExpressionFactory expressionFactory = application.getExpressionFactory();
+ UIViewRoot root = super.setupView();
+ UIComponent output = application.createComponent(UIOutput.COMPONENT_TYPE);
+ output.setId(root.createUniqueId());
+ root.getChildren().add(output);
+ UIData data = (UIData) application.createComponent(UIData.COMPONENT_TYPE);
+ data.setId("data");
+ data.setVar("var");
+ data.setValueExpression("value",
expressionFactory.createValueExpression(elContext, "#{dataBean.data}",
List.class));
+ output.getChildren().add(data);
+ UIComponent column = application.createComponent(UIColumn.COMPONENT_TYPE);
+ data.getChildren().add(column);
+ UIData enclosedData = (UIData) application.createComponent(UIData.COMPONENT_TYPE);
+ enclosedData.setId("data1");
+ enclosedData.setVar("var1");
+ enclosedData.setValueExpression("value",
expressionFactory.createValueExpression(elContext, "#{var.items}",
List.class));
+ column.getChildren().add(enclosedData);
+ UIComponent enclosedColumn = application.createComponent(UIColumn.COMPONENT_TYPE);
+ enclosedData.getChildren().add(enclosedColumn);
+ UIForm form = (UIForm) application.createComponent(UIForm.COMPONENT_TYPE);
+ form.setId("form");
+ enclosedColumn.getChildren().add(form);
+ UIInput input = (UIInput) application.createComponent(UIInput.COMPONENT_TYPE);
+ input.setId("input");
+ input.setValueExpression("value",
expressionFactory.createValueExpression(elContext, "#{var1.name}",
String.class));
+ form.getChildren().add(input);
+ ///
+ input = (UIInput) application.createComponent(UIInput.COMPONENT_TYPE);
+ input.setId("priceinput");
+ input.setValueExpression("value",
expressionFactory.createValueExpression(elContext, "#{var1.price}",
Integer.class));
+ enclosedColumn.getChildren().add(input);
+ input = (UIInput) application.createComponent(UIInput.COMPONENT_TYPE);
+ input.setId("nameinput");
+ input.setValueExpression("value",
expressionFactory.createValueExpression(elContext, "#{var.name}",
String.class));
+ column.getChildren().add(input);
+ return root;
+ }
+
+ @Override
+ protected void setupConnection() {
+ this.connection.addRequestParameter(ResponseStateManager.VIEW_STATE_PARAM,
"id1");
+ this.connection.addRequestParameter("data:3:nameinput", "foo");
+ this.connection.addRequestParameter("data:5:data1:4:priceinput",
"333");
+ this.connection.addRequestParameter("data:6:data1:5:form",
"data:6:data1:5:form");
+ this.connection.addRequestParameter("data:6:data1:5:form:input",
"bar");
+ connection.setRequestMethod(HttpMethod.POST);
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+ setupFacesRequest();
+ long startTime = System.currentTimeMillis();
+ lifecycle.execute(facesContext);
+ System.err.println("Execute time
"+(System.currentTimeMillis()-startTime)+"ms");
+ lifecycle.render(facesContext);
+ DataBean dataBean = (DataBean)
this.facesServer.getSession().getAttribute("dataBean");
+ assertNotNull(dataBean);
+ assertEquals("foo", dataBean.getData().get(3).getName());
+ assertEquals(333, dataBean.getData().get(5).getItems().get(4).getPrice());
+ assertEquals("bar", dataBean.getData().get(6).getItems().get(5).getName());
+ }
+
+}
Property changes on:
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/UIDataTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties
===================================================================
---
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties 2009-02-06
17:44:26 UTC (rev 12598)
+++
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties 2009-02-07
01:43:53 UTC (rev 12599)
@@ -16,7 +16,7 @@
org.ajax4jsf.webapp.level=ALL
org.ajax4jsf.application.level=ALL
org.ajax4jsf.context.level=ALL
-javax.enterprise.resource.webcontainer.jsf.level=ALL
+javax.enterprise.resource.webcontainer.jsf.level=SEVERE
org.richfaces.level=ALL
-com.gargoylesoftware.htmlunit.level=ALL
+com.gargoylesoftware.htmlunit.level=SEVERE
\ No newline at end of file
Added: branches/jsf2.0/tests/ajax/src/test/resources/test.xhtml
===================================================================
--- branches/jsf2.0/tests/ajax/src/test/resources/test.xhtml (rev
0)
+++ branches/jsf2.0/tests/ajax/src/test/resources/test.xhtml 2009-02-07 01:43:53 UTC (rev
12599)
@@ -0,0 +1,5 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<f:view contentType="text/html"
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"/>
Property changes on: branches/jsf2.0/tests/ajax/src/test/resources/test.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain