JBoss Rich Faces SVN: r11310 - trunk/ui.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-23 16:41:04 -0500 (Sun, 23 Nov 2008)
New Revision: 11310
Modified:
trunk/ui/pom.xml
Log:
Editor moved to main build area
Modified: trunk/ui/pom.xml
===================================================================
--- trunk/ui/pom.xml 2008-11-23 21:39:36 UTC (rev 11309)
+++ trunk/ui/pom.xml 2008-11-23 21:41:04 UTC (rev 11310)
@@ -130,6 +130,7 @@
<module>beanValidator</module>
<module>state</module>
<module>extendedDataTable</module>
+ <module>editor</module>
</modules>
<dependencies>
<dependency>
17 years, 5 months
JBoss Rich Faces SVN: r11309 - trunk/sandbox/ui.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-23 16:39:36 -0500 (Sun, 23 Nov 2008)
New Revision: 11309
Removed:
trunk/sandbox/ui/editor/
Log:
Editor moved to main build area
17 years, 5 months
JBoss Rich Faces SVN: r11308 - in trunk/ui: editor and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-23 16:38:18 -0500 (Sun, 23 Nov 2008)
New Revision: 11308
Added:
trunk/ui/editor/
Modified:
trunk/ui/editor/pom.xml
Log:
Editor moved to main build area
Copied: trunk/ui/editor (from rev 11304, trunk/sandbox/ui/editor)
Property changes on: trunk/ui/editor
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.classpath
.project
Name: svn:mergeinfo
+
Modified: trunk/ui/editor/pom.xml
===================================================================
--- trunk/sandbox/ui/editor/pom.xml 2008-11-22 14:49:50 UTC (rev 11304)
+++ trunk/ui/editor/pom.xml 2008-11-23 21:38:18 UTC (rev 11308)
@@ -1,11 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ui</artifactId>
- <groupId>org.richfaces.sandbox</groupId>
+ <groupId>org.richfaces</groupId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.sandbox.ui</groupId>
+ <groupId>org.richfaces.ui</groupId>
<artifactId>editor</artifactId>
<name>Editor</name>
<build>
17 years, 5 months
JBoss Rich Faces SVN: r11307 - trunk/ui/core/src/test/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-23 16:21:10 -0500 (Sun, 23 Nov 2008)
New Revision: 11307
Modified:
trunk/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java
trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java
Log:
Javadoc comments added to AbstractQueueComponentTest
Modified: trunk/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java 2008-11-23 20:30:33 UTC (rev 11306)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java 2008-11-23 21:21:10 UTC (rev 11307)
@@ -173,24 +173,65 @@
return parameters;
}
+ /**
+ * Sets value of requestDelay parameter
+ * @param value
+ * @return
+ */
public ParametersBuilder requestDelay(double value) {
return new ParametersBuilder(this.parameters).put("requestDelay", value);
}
+
+ /**
+ * Sets value of similarityGroupingId parameter
+ * @param id
+ * @return
+ */
public ParametersBuilder similarityGroupingId(Object id) {
return new ParametersBuilder(this.parameters).put("similarityGroupingId", id);
}
+
+ /**
+ * Defines how long this request will be executed on server
+ * @param value
+ * @return
+ */
public ParametersBuilder requestTime(double value) {
return new ParametersBuilder(this.parameters).put("requestTime", value);
}
+
+ /**
+ * Sets value of timeout parameter
+ * @param value
+ * @return
+ */
public ParametersBuilder timeout(double value) {
return new ParametersBuilder(this.parameters).put("timeout", value);
}
+
+ /**
+ * Sets value of eventsQueue parameter
+ * @param name
+ * @return
+ */
public ParametersBuilder eventsQueue(String name) {
return new ParametersBuilder(this.parameters).put("eventsQueue", name);
}
+
+ /**
+ * Sets value of implicitEventsQueue parameter
+ * @param name
+ * @return
+ */
public ParametersBuilder implicitEventsQueue(String name) {
return new ParametersBuilder(this.parameters).put("implicitEventsQueue", name);
}
+
+ /**
+ * Sets value of ignoreDupResponses parameter
+ * @param value
+ * @return
+ */
public ParametersBuilder ignoreDupResponses(boolean value) {
return new ParametersBuilder(this.parameters).put("ignoreDupResponses", value);
}
@@ -306,6 +347,15 @@
}
+ /**
+ * Execute simulated ajax request starting on given time and having data and paramaters passed as arguments.
+ * For simulated requests defaut value of data is id of the element firing request and default request time
+ * is 1000
+ *
+ * @param time
+ * @param data
+ * @param builder
+ */
protected void ajax(int time, String data, ParametersBuilder builder) {
JSFunction function = new JSFunction("simulationContext.ajax", time, data, builder.getParameters());
page.executeJavaScript(function.toScript());
Modified: trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java 2008-11-23 20:30:33 UTC (rev 11306)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java 2008-11-23 21:21:10 UTC (rev 11307)
@@ -49,7 +49,8 @@
ajax(0, "a", parametersBuilder);
ajax(25, "b", parametersBuilder);
ajax(50, "c", parametersBuilder.requestDelay(30));
- ajax(90, "d", parametersBuilder.requestDelay(0));
+ ajax(90, "d", parametersBuilder.requestDelay(10));
+ ajax(95, "d", parametersBuilder.requestDelay(50));
TestsResult result = getTestsResult();
List<RequestData> dataList = result.getDataList();
@@ -59,7 +60,7 @@
checkRequestData(dataList.get(0), "a", 15, 20, false);
checkRequestData(dataList.get(1), "b", 40, 45, false);
checkRequestData(dataList.get(2), "c", 80, 85, false);
- checkRequestData(dataList.get(3), "d", 90, 95, false);
+ checkRequestData(dataList.get(3), "d", 145, 150, false);
}
public void testRequestDelayDefault() throws Exception {
17 years, 5 months
JBoss Rich Faces SVN: r11306 - in trunk/ui/core/src: main/java/org/ajax4jsf/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2008-11-23 15:30:33 -0500 (Sun, 23 Nov 2008)
New Revision: 11306
Added:
trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java
Modified:
trunk/ui/core/src/main/config/component/queue.xml
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-4662
Modified: trunk/ui/core/src/main/config/component/queue.xml
===================================================================
--- trunk/ui/core/src/main/config/component/queue.xml 2008-11-23 20:28:15 UTC (rev 11305)
+++ trunk/ui/core/src/main/config/component/queue.xml 2008-11-23 20:30:33 UTC (rev 11306)
@@ -6,6 +6,7 @@
<family>org.ajax4jsf.Queue</family>
<classname>org.ajax4jsf.component.html.HtmlQueue</classname>
<superclass>org.ajax4jsf.component.UIQueue</superclass>
+ <test />
<description>
<![CDATA[The <a4j:queue> tag.]]>
</description>
@@ -26,7 +27,7 @@
-->
<property>
<name>size</name>
- <classname>java.lang.Integer</classname>
+ <classname>int</classname>
</property>
<property>
<name>name</name>
@@ -36,15 +37,15 @@
<property >
<name>requestDelay</name>
- <classname>java.lang.Integer</classname>
+ <classname>int</classname>
</property>
<property>
<name>ignoreDupResponses</name>
- <classname>java.lang.Boolean</classname>
+ <classname>boolean</classname>
</property>
<property>
<name>timeout</name>
- <classname>java.lang.Integer</classname>
+ <classname>int</classname>
</property>
<property>
<name>disabled</name>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java 2008-11-23 20:28:15 UTC (rev 11305)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java 2008-11-23 20:30:33 UTC (rev 11306)
@@ -32,6 +32,7 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.html.scripts.QueueScript;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.util.MessageUtil;
@@ -63,10 +64,9 @@
public static final String BEHAVIOR_FIRE_NEW = "fireNew";
private static final String[] REQUEST_ATTRIBUTES = new String[] {
- "requestDelay",
- "timeout",
"ignoreDupResponses",
- "limitToList"
+ "requestDelay",
+ "timeout"
};
private volatile InternetResource[] scripts;
@@ -92,20 +92,7 @@
return UIQueue.class;
}
- private boolean isNotEmpty(Object object) {
- if (object == null) {
- return false;
- }
-
- if (object instanceof String) {
- String s = (String) object;
- if (s.length() == 0) {
- return false;
- }
- }
-
- return true;
- }
+ private static final RendererUtils utils = RendererUtils.getInstance();
private boolean isValidBehaviorValue(String value) {
return BEHAVIOR_DROP_NEW.equals(value) || BEHAVIOR_DROP_NEXT.equals(value) ||
@@ -117,13 +104,13 @@
QueueRendererData data = new QueueRendererData();
- Integer size = (Integer) attributes.get(SIZE);
- if (size != null) {
+ int size = queue.getSize();
+ if (utils.shouldRenderAttribute(size)) {
data.addQueueAttribute(SIZE, size);
}
String sizeExceededBehavior = (String) attributes.get(SIZE_EXCEEDED_BEHAVIOR);
- if (isNotEmpty(sizeExceededBehavior)) {
+ if (utils.shouldRenderAttribute(sizeExceededBehavior)) {
if (!isValidBehaviorValue(sizeExceededBehavior)) {
throw new IllegalArgumentException(sizeExceededBehavior + " value of " +
SIZE_EXCEEDED_BEHAVIOR + " attribute is not a legal one for component: " +
@@ -133,30 +120,30 @@
data.addQueueAttribute(SIZE_EXCEEDED_BEHAVIOR, sizeExceededBehavior);
}
+ String onsizeexceeded = queue.getOnsizeexceeded();
+ if (utils.shouldRenderAttribute(onsizeexceeded)) {
+ data.addQueueAttribute("onsizeexceeded", new JSFunctionDefinition("query", "options", "event").addToBody(onsizeexceeded));
+ }
+
for (String attributeName : REQUEST_ATTRIBUTES) {
Object value = attributes.get(attributeName);
- if (isNotEmpty(value)) {
+ if (utils.shouldRenderAttribute(value)) {
data.addRequestAttribute(attributeName, value);
}
}
- String onsizeexceeded = queue.getOnsizeexceeded();
- if (isNotEmpty(onsizeexceeded)) {
- data.addQueueAttribute("onsizeexceeded", new JSFunctionDefinition("query", "options", "event").addToBody(onsizeexceeded));
+ String onBeforeDomUpdate = queue.getOnbeforedomupdate();
+ if (utils.shouldRenderAttribute(onBeforeDomUpdate)) {
+ data.addRequestAttribute(QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE, AjaxRendererUtils.buildAjaxOnBeforeDomUpdate(onBeforeDomUpdate));
}
String oncomplete = queue.getOncomplete();
- if (isNotEmpty(oncomplete)) {
+ if (utils.shouldRenderAttribute(oncomplete)) {
data.addRequestAttribute(QUEUE_ONCOMPLETE_ATTRIBUTE, AjaxRendererUtils.buildAjaxOncomplete(oncomplete));
}
- String onBeforeDomUpdate = queue.getOnbeforedomupdate();
- if (isNotEmpty(onBeforeDomUpdate)) {
- data.addRequestAttribute(QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE, AjaxRendererUtils.buildAjaxOnBeforeDomUpdate(onBeforeDomUpdate));
- }
-
String onsubmit = queue.getOnsubmit();
- if (isNotEmpty(onsubmit)) {
+ if (utils.shouldRenderAttribute(onsubmit)) {
JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition("request");
onsubmitFunction.addToBody(onsubmit);
@@ -164,7 +151,7 @@
}
String onerror = queue.getOnerror();
- if (isNotEmpty(onerror)) {
+ if (utils.shouldRenderAttribute(onerror)) {
JSFunctionDefinition onerrorFunction = new JSFunctionDefinition("request", "status", "message");
onerrorFunction.addToBody(onerror);
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java 2008-11-23 20:28:15 UTC (rev 11305)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java 2008-11-23 20:30:33 UTC (rev 11306)
@@ -22,7 +22,7 @@
package org.ajax4jsf.renderkit.html;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -37,7 +37,7 @@
public void addQueueAttribute(String key, Object value) {
if (queueAttributes == null) {
- queueAttributes = new HashMap<String, Object>();
+ queueAttributes = new LinkedHashMap<String, Object>();
}
queueAttributes.put(key, value);
@@ -45,7 +45,7 @@
public void addRequestAttribute(String key, Object value) {
if (requestAttributes == null) {
- requestAttributes = new HashMap<String, Object>();
+ requestAttributes = new LinkedHashMap<String, Object>();
}
requestAttributes.put(key, value);
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-23 20:28:15 UTC (rev 11305)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-23 20:30:33 UTC (rev 11306)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -46,6 +47,9 @@
*/
public class QueueScriptResourceRenderer extends BaseResourceRenderer {
+ //TODO rename?
+ public static final String QUEUE_SCRIPT_ID = "richfaces:ajaxqueues";
+
private void encodeQueue(ResponseWriter writer, String queueName, QueueRendererData queueData)
throws IOException {
@@ -107,6 +111,8 @@
super.encode(resource, context, data, attributes);
}
+ } else {
+ context.getExternalContext().log("");
}
}
@@ -114,14 +120,19 @@
public void encode(InternetResource resource, FacesContext context,
Object data, Map<String, Object> attributes) throws IOException {
- doEncode(resource, context, data, attributes);
+ Map<String,Object> newAttributes = new LinkedHashMap<String, Object>(attributes);
+ newAttributes.put(HTML.id_ATTRIBUTE, context.getExternalContext().encodeNamespace(QUEUE_SCRIPT_ID));
+
+ doEncode(resource, context, data, newAttributes);
}
@Override
public void encode(InternetResource resource, FacesContext context,
Object data) throws IOException {
- doEncode(resource, context, data, Collections.EMPTY_MAP);
+ doEncode(resource, context, data,
+ Collections.singletonMap(HTML.id_ATTRIBUTE,
+ (Object) context.getExternalContext().encodeNamespace(QUEUE_SCRIPT_ID)));
}
@Override
Added: trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java (rev 0)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java 2008-11-23 20:30:33 UTC (rev 11306)
@@ -0,0 +1,224 @@
+/**
+ * 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.component;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+
+import org.ajax4jsf.renderkit.html.scripts.QueueScriptResourceRenderer;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.jaxen.JaxenException;
+
+import com.gargoylesoftware.htmlunit.html.DomText;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueueRendererTest extends AbstractAjax4JsfTestCase {
+
+ private UIForm form;
+
+ private static final String dry(String s) {
+ return s.replace(" ", "");
+ }
+
+ private static final String QUEUE_INIT_PROLOG = "A4J.AJAX.EventQueue.addQueue(new A4J.AJAX.EventQueue(";
+
+ private static final String QUEUE_INIT_PROLOG_DRIED = dry(QUEUE_INIT_PROLOG);
+
+ /**
+ * @param name
+ */
+ public QueueRendererTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ UIViewRoot root = facesContext.getViewRoot();
+ List<UIComponent> children = root.getChildren();
+
+ form = (UIForm) application.createComponent(UIForm.COMPONENT_TYPE);
+ form.setId("theform");
+ form.getChildren().add(application.createComponent(UIInput.COMPONENT_TYPE));
+ children.add(form);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ form = null;
+ }
+
+ private String getQueueScript(HtmlPage page) throws JaxenException {
+ List<?> list = page.getByXPath("//head/script[@id='" + QueueScriptResourceRenderer.QUEUE_SCRIPT_ID + "']/text()");
+ DomText text = (DomText) list.get(0);
+ return text.getData();
+ }
+
+ public void testViewQueueName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setName("test_view_queue");
+ facesContext.getViewRoot().getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertTrue(queueScript.startsWith(QUEUE_INIT_PROLOG + "'test_view_queue'"));
+ }
+
+ public void testViewQueueDefaultName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ facesContext.getViewRoot().getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertTrue(queueScript.startsWith(QUEUE_INIT_PROLOG + "'" + UIQueue.GLOBAL_QUEUE_NAME + "'"));
+ }
+
+ public void testFormQueueName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setName("test_view_queue");
+ form.getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertTrue(queueScript.startsWith(QUEUE_INIT_PROLOG + "'theform:test_view_queue'"));
+ }
+
+ public void testFormQueueDefaultName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ form.getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertTrue(queueScript.startsWith(QUEUE_INIT_PROLOG + "'theform'"));
+ }
+
+ public void testRenderQueueAttributes() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue1.setSize(10);
+ queue1.setOnsizeexceeded("sizeexceeded_handler()");
+ queue1.setSizeExceededBehavior("dropNext");
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue2.setSize(-1);
+ queue2.setName("unsizedQueue");
+ form.getChildren().add(queue2);
+
+ UIQueue queue3 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue3.setName("defaultSizeQueue");
+ form.getChildren().add(queue3);
+
+ HtmlPage page = renderView();
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = queueScript.split(";");
+ assertEquals(3, scripts.length);
+
+ assertEquals(QUEUE_INIT_PROLOG_DRIED +
+ "'theform',{'size':10,'sizeExceededBehavior':'dropNext','onsizeexceeded':function(query,options,event){sizeexceeded_handler()}},null))",
+ scripts[0]);
+
+ assertEquals(QUEUE_INIT_PROLOG_DRIED +
+ "'theform:unsizedQueue',{'size':-1},null))", scripts[1]);
+
+ assertEquals(QUEUE_INIT_PROLOG_DRIED +
+ "'theform:defaultSizeQueue',null,null))", scripts[2]);
+ }
+
+ public void testRenderRequestAttributes() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue1.setName("queue1");
+ queue1.setTimeout(50021);
+ queue1.setOnerror("error_queue_handler()");
+ queue1.setOnsubmit("submit_queue_handler()");
+ queue1.setIgnoreDupResponses(false);
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue2.setName("queue2");
+ queue2.setRequestDelay(600);
+ queue2.setIgnoreDupResponses(true);
+ queue2.setOnbeforedomupdate("beforedomupdate_handler()");
+ queue2.setOncomplete("complete_handler()");
+ form.getChildren().add(queue2);
+
+ HtmlPage page = renderView();
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = queueScript.split(";");
+ assertEquals(2, scripts.length);
+
+ assertEquals(QUEUE_INIT_PROLOG_DRIED + "'theform:queue1',null,{'timeout':50021,'queueonsubmit':function(request){submit_queue_handler()},'queueonerror':function(request,status,message){error_queue_handler()}}))", scripts[0]);
+ assertEquals(QUEUE_INIT_PROLOG_DRIED + "'theform:queue2',null,{'ignoreDupResponses':true,'requestDelay':600,'queueonbeforedomupdate':function(request,event,data){beforedomupdate_handler()},'queueoncomplete':function(request,event,data){complete_handler()}}))", scripts[1]);
+ }
+
+ public void testInvalidSizeExceededBehavior() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setSizeExceededBehavior("unknownBehavior");
+ form.getChildren().add(queue);
+
+ try {
+ renderView();
+ fail();
+ } catch (IllegalArgumentException e) {
+ //ok
+ }
+ }
+
+ public void testDuplicateQueues() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue1.setName("testQueue");
+ queue1.setSize(2);
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue2.setName("testQueue");
+ queue2.setSize(5);
+ form.getChildren().add(queue2);
+
+ HtmlPage page = renderView();
+
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = queueScript.split(";");
+ assertEquals(1, scripts.length);
+
+ assertEquals(QUEUE_INIT_PROLOG_DRIED + "'theform:testQueue',{'size':2},null))", scripts[0]);
+ }
+
+}
17 years, 5 months
JBoss Rich Faces SVN: r11305 - trunk/framework/impl/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2008-11-23 15:28:15 -0500 (Sun, 23 Nov 2008)
New Revision: 11305
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIQueue.java
Log:
https://jira.jboss.org/jira/browse/RF-4662
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIQueue.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIQueue.java 2008-11-22 14:49:50 UTC (rev 11304)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIQueue.java 2008-11-23 20:28:15 UTC (rev 11305)
@@ -61,6 +61,23 @@
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
+ public abstract int getSize();
+ public abstract void setSize(int size);
+
+ public abstract String getSizeExceededBehavior();
+ public abstract void setSizeExceededBehavior(String behavior);
+
+ public abstract int getTimeout();
+ public abstract void setTimeout(int timeout);
+
+ public abstract int getRequestDelay();
+ public abstract void setRequestDelay(int requestDelay);
+
+ public abstract boolean isIgnoreDupResponses();
+ public abstract void setIgnoreDupResponses(boolean ignoreDupResponses);
+
+
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
17 years, 5 months
JBoss Rich Faces SVN: r11304 - in trunk/sandbox/ui/editor/src: main/java/org/richfaces/renderkit/html/images and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-22 09:49:50 -0500 (Sat, 22 Nov 2008)
New Revision: 11304
Added:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/
trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/EditorRendererTest.java
trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/
trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/EditorIconTest.java
trunk/sandbox/ui/editor/src/test/resources/editorFull.properties
trunk/sandbox/ui/editor/src/test/resources/myplugins.properties
Removed:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/rendekit/
Modified:
trunk/sandbox/ui/editor/src/main/config/component/editor.xml
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
Log:
Editor: Add JUnits with javadocs
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-22 13:11:17 UTC (rev 11303)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-22 14:49:50 UTC (rev 11304)
@@ -7,7 +7,7 @@
<classname>org.richfaces.component.html.HtmlEditor</classname>
<superclass>org.richfaces.component.UIEditor</superclass>
<test>
- <classname>org.richfaces.component.EditorComponentTest</classname>
+ <classname>org.richfaces.component.html.HtmlEditorComponentTest</classname>
<superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
</test>
<description>
@@ -22,8 +22,8 @@
<superclass>
org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
- <test>
- </test>
+ <test>
+ </test>
</tag>
&ui_component_attributes;
&ui_input_attributes;
Modified: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java 2008-11-22 13:11:17 UTC (rev 11303)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java 2008-11-22 14:49:50 UTC (rev 11304)
@@ -50,13 +50,13 @@
public abstract class EditorIcons extends Java2Dresource {
/** Additional background color parameter name in skin */
- private final String ADDITIONAL_BACKGROUND_COLOR = "additionalBackgroundColor";
+ public final static String ADDITIONAL_BACKGROUND_COLOR = "additionalBackgroundColor";
/** SelectControl color parameter name in skin */
- private final String SELECT_CONTROL_COLOR = "selectControlColor";
+ public final static String SELECT_CONTROL_COLOR = "selectControlColor";
/** Panel border color parameter name in skin */
- private final String PANEL_BORDER_COLOR = "panelBorderColor";
+ public final static String PANEL_BORDER_COLOR = "panelBorderColor";
/** General text color parameter name in skin */
- private final String GENERAL_TEXT_COLOR = "generalTextColor";
+ public final static String GENERAL_TEXT_COLOR = "generalTextColor";
/** Icon sub border transparency value */
private final int SUB_BORDER_TRANSPARENCY = 150;
@@ -76,13 +76,18 @@
* @see org.ajax4jsf.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext, java.lang.Object)
*/
protected Object getDataToStore(FacesContext context, Object data) {
- String additionalBackgroundColor = getSkinParameter(context,
- ADDITIONAL_BACKGROUND_COLOR);
- String selectControlColor = getSkinParameter(context,
- SELECT_CONTROL_COLOR);
- String panelBorderColor = getSkinParameter(context, PANEL_BORDER_COLOR);
- String generalTextColor = getSkinParameter(context, GENERAL_TEXT_COLOR);
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+ String additionalBackgroundColor = getSkinParameter(skin, defaultSkin,
+ context, ADDITIONAL_BACKGROUND_COLOR);
+ String selectControlColor = getSkinParameter(skin, defaultSkin,
+ context, SELECT_CONTROL_COLOR);
+ String panelBorderColor = getSkinParameter(skin, defaultSkin, context,
+ PANEL_BORDER_COLOR);
+ String generalTextColor = getSkinParameter(skin, defaultSkin, context,
+ GENERAL_TEXT_COLOR);
+
byte[] ret = new byte[12];
Zipper2 zipper2 = new Zipper2(ret);
zipper2.addColor(HtmlColor.decode(additionalBackgroundColor).getRGB());
@@ -113,13 +118,13 @@
/**
* Method to get skin parameter value by parameter name
*
+ * @param skin - current component skin
+ * @param defaultSkin - default richfaces skin
* @param context - faces context instance
* @param parameterName - name of the skin parameter
* @return string value of parameter
*/
- private String getSkinParameter(FacesContext context, String parameterName) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+ private String getSkinParameter(Skin skin, Skin defaultSkin, FacesContext context, String parameterName) {
String value = (String) skin.getParameter(context, parameterName);
if (null == value || "".equals(value)) {
value = (String) defaultSkin.getParameter(context, parameterName);
Modified: trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
===================================================================
--- trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java 2008-11-22 13:11:17 UTC (rev 11303)
+++ trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java 2008-11-22 14:49:50 UTC (rev 11304)
@@ -20,13 +20,20 @@
*/
package org.richfaces.component;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlForm;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
/**
* Editor component Junit Test
@@ -34,43 +41,33 @@
*
*/
public class EditorComponentTest extends AbstractAjax4JsfTestCase {
-
+
+ /** UIForm instance */
UIForm form;
+ /** UIEditor instance */
UIEditor editor;
+
+ /** Set with required javascripts for Editor */
+ private static Set<String> javaScripts = new HashSet<String>();
- private final static String SEAM_TEXT_EXPRESSION_1 = "It's easy to make *emphasis*, |monospace|,\n"
- + "~deleted text~, super^scripts^ or _underlines_.";
+ static {
+ javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("scripts/tiny_mce/tiny_mce_src.js");
+ javaScripts.add("scripts/editor.js");
+ }
- private final static String SEAM_TEXT_EXPRESSION_2 = "+This is a big heading\n"
- + "You /must/ have some text following a heading!\n"
- + "++This is a smaller heading\n"
- + "This is the first paragraph. We can split it across multiple\n"
- + "lines, but we must end it with a blank line.\n"
- + "This is the second paragraph.";
-
- private final static String SEAM_TEXT_EXPRESSION_3 = "An ordered list:\n"
- + "\\#first item\n" + "\\#second item\n"
- + "\\#and even the /third/ item\n" + "An unordered list:\n"
- + "\\=an item\n" + "\\=another item\n";
-
- private final static String SEAM_TEXT_EXPRESSION_4 = "The other guy said:\n"
- + "\"Nyeah nyeah-nee\n"
- + "/nyeah/ nyeah!\"\n"
- + "But what do you think he means by \"nyeah-nee\"?";
-
- private final static String SEAM_TEXT_EXPRESSION_5 = "You can write down equations like 2*3=6 and HTML tags\n"
- + "like <body> using the escape character: \\.";
-
- private final static String SEAM_TEXT_EXPRESSION_6 = "My code doesn't work:\n"
- + "`for (int i=0; i<100; i--)\n"
- + "{\n"
- + "doSomething();\n"
- + "}`\n" + "Any ideas?";
-
+ /**
+ * Constructor with test name parameter
+ * @param name
+ */
public EditorComponentTest(String name) {
super(name);
}
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
public void setUp() throws Exception {
super.setUp();
form = new HtmlForm();
@@ -78,63 +75,89 @@
facesContext.getViewRoot().getChildren().add(form);
editor = (UIEditor) application.createComponent("org.richfaces.Editor");
+ editor.setId("editor");
+ editor.setValue("Some value");
form.getChildren().add(editor);
}
-
- public void testRenderer() throws Exception {
+
+ /**
+ * Method to test if required style is present on page
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testEditorStyles() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
+ List links = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "link");
+ if (links.size() == 0) {
+ fail();
+ }
+ for (int i = 0; i < links.size(); i++) {
+ HtmlElement link = (HtmlElement) links.get(i);
+ assertTrue(link.getAttributeValue("href").contains(
+ "css/editor.xcss"));
+ }
}
+
+ /**
+ * Method to test if required scripts is present on page
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testEditorScripts() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
- public void testSeamTextConverting1() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_1);
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ String srcAttr = item.getSrcAttribute();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
+ assertTrue(scriptBodyString.contains("RichEditor"));
+ }
+ if (StringUtils.isNotBlank(srcAttr)) {
+ boolean found = false;
+ for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ String src = (String) srcIt.next();
+ found = srcAttr.contains(src);
+ if (found) {
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+ }
}
-
- public void testSeamTextConverting2() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_2);
- }
-
- public void testSeamTextConverting3() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_3);
- }
-
- public void testSeamTextConverting4() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_4);
- }
-
- public void testSeamTextConverting5() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_5);
- }
-
- public void testSeamTextConverting6() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_6);
- }
-
+
/**
- * Method to assert converting from Seam Text to html and back
- * @param seamTextExpression
+ * Method to test Editor rendering
* @throws Exception
*/
- private void assertSeamConverting(String seamTextExpression)
- throws Exception {
- editor.setUseSeamText(true);
- editor.setValue(seamTextExpression);
-
+ public void testEditorRendering() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
-
- String convertedValue = null;
- HtmlElement component = page.getHtmlElementById(editor
+ HtmlElement htmlDiv = page.getHtmlElementById(editor
.getClientId(facesContext));
- convertedValue = component.getFirstDomChild().asText();
-
- editor.setSubmittedValue(convertedValue);
- editor.validate(facesContext);
-
- // TODO: Must be uncomented when html convertion to Seam Text will be implemented in SeamTextConverter
- //assertEquals(seamTextExpression, editor.getValue().toString());
+ assertNotNull(htmlDiv);
+ assertEquals(htmlDiv.getTagName(), "div");
+ HtmlElement htmlTextArea = page.getHtmlElementById(editor
+ .getClientId(facesContext)
+ + UIEditor.EDITOR_TEXT_AREA_ID_SUFFIX);
+ assertNotNull(htmlTextArea);
+ assertEquals(htmlTextArea.getTagName(), "textarea");
+ String style = htmlTextArea.getAttribute("style");
+ assertNotNull(style);
+ assertTrue(style.contains("visibility: hidden"));
+ String value = htmlTextArea.getFirstDomChild().asText();
+ assertEquals("Some value", value);
}
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
public void tearDown() throws Exception {
super.tearDown();
}
Added: trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/EditorRendererTest.java
===================================================================
--- trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/EditorRendererTest.java (rev 0)
+++ trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/EditorRendererTest.java 2008-11-22 14:49:50 UTC (rev 11304)
@@ -0,0 +1,259 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.renderkit;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.faces.component.UIParameter;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIEditor;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+public class EditorRendererTest extends AbstractAjax4JsfTestCase {
+
+ /** Name of test property file with configuration parameters */
+ private final static String PARAMETERS_PROPERTY_FILE_NAME = "editorFull";
+ /** Name of test property file with custom plugins parameters */
+ private final static String CUSTOM_PLUGINS_PROPERTY_FILE_NAME = "myplugins";
+
+ /** Test f:param name */
+ private final static String FPARAM_NAME = "fparam_name";
+ /** Test f:param value */
+ private final static String FPARAM_VALUE = "fparam_value";
+
+ /** UIEditor instance */
+ private UIEditor editor;
+
+ /**
+ * Constructor with test name parameter
+ * @param name
+ */
+ public EditorRendererTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ editor = (UIEditor) application.createComponent("org.richfaces.Editor");
+ editor.setValue("Some value");
+
+ UIParameter param1 = (UIParameter) application
+ .createComponent("javax.faces.Parameter");
+ param1.setName(FPARAM_NAME);
+ param1.setValue(FPARAM_VALUE);
+ editor.getChildren().add(param1);
+
+ facesContext.getViewRoot().getChildren().add(editor);
+ }
+
+
+ /**
+ * Method to test EditorRenderer writing configuration script parameters
+ * from properties file.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testWritingScriptParametersFromProperties() throws Exception {
+
+ editor.setConfiguration(PARAMETERS_PROPERTY_FILE_NAME);
+ Properties parameters = loadProperties(PARAMETERS_PROPERTY_FILE_NAME);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
+
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
+ for (Object key : parameters.keySet()) {
+ String keyString = key.toString();
+ String valueString = (parameters.get(key)).toString();
+ if (valueString.indexOf("\"") != -1) {
+ valueString = valueString.replaceAll("\"", "");
+ }
+ assertTrue("writed script parameters not contains '"
+ + keyString + "'", scriptBodyString
+ .contains(keyString));
+ assertTrue("writed script parameters not contains '"
+ + valueString + "'", scriptBodyString
+ .contains(valueString));
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Method to test EditorRenderer writing configuration script parameters
+ * from f:params children.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testWritingScriptParametersFromFParams() throws Exception {
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
+
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
+ assertTrue(
+ "writed script parameters not contains defined in Editor f:param",
+ scriptBodyString.contains(FPARAM_NAME));
+ assertTrue(
+ "writed script parameters not contains defined in Editor f:param",
+ scriptBodyString.contains(FPARAM_VALUE));
+ }
+
+ }
+
+ }
+
+ /**
+ * Method to test EditorRenderer writing configuration script parameters
+ * from UIEditor attributes.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testWritingScriptParametersFromAttributes() throws Exception {
+ editor.setAutoResize(true);
+ editor.setDialogType("window");
+ editor.setHeight(300);
+ editor.setWidth(300);
+ editor.setLanguage("ru");
+ editor.setPlugins("safari,spellchecker,pagebreak");
+ editor.setReadonly(true);
+ editor.setSkin("o2k7");
+ editor.setTheme("advanced");
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
+
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.auto_resize = true"));
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.dialog_type ="));
+ assertTrue(scriptBodyString.contains(editor.getDialogType()));
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.width = 300"));
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.height = 300"));
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.language ="));
+ assertTrue(scriptBodyString.contains(editor.getLanguage()));
+ assertTrue(scriptBodyString.contains("tinyMceParams.plugins ="));
+ assertTrue(scriptBodyString.contains(editor.getPlugins()));
+ assertTrue(scriptBodyString.contains("tinyMceParams.theme ="));
+ assertTrue(scriptBodyString.contains(editor.getTheme()));
+ assertTrue(scriptBodyString.contains("tinyMceParams.skin ="));
+ assertTrue(scriptBodyString.contains(editor.getSkin()));
+ assertTrue(scriptBodyString
+ .contains("tinyMceParams.readonly = true"));
+ }
+
+ }
+
+ }
+
+ /**
+ * Method to test EditorRenderer writing custom plugins loading calls from
+ * properties file.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testWritingScriptParametersForCustomPlugins() throws Exception {
+
+ editor.setCustomPlugins(CUSTOM_PLUGINS_PROPERTY_FILE_NAME);
+ Properties parameters = loadProperties(CUSTOM_PLUGINS_PROPERTY_FILE_NAME);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
+
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ if (item.getFirstDomChild() != null) {
+ String scriptBodyString = item.getFirstDomChild().toString();
+ for (Object key : parameters.keySet()) {
+ String keyString = key.toString();
+ String valueString = (parameters.get(key)).toString();
+ if (valueString.indexOf("\"") != -1) {
+ valueString = valueString.replaceAll("\"", "");
+ }
+ assertTrue(scriptBodyString.contains("tinymce.PluginManager.load("));
+ assertTrue(scriptBodyString.contains(keyString));
+ assertTrue(scriptBodyString.contains(valueString));
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Method to load properties from property file
+ *
+ * @param name - properties file name
+ * @return Properties
+ * @throws IOException
+ */
+ private Properties loadProperties(String name) throws IOException {
+ Properties properties = new Properties();
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream is = loader.getResourceAsStream(name + ".properties");
+ if (is == null) {
+ fail("Can't load propertioes file for test");
+ }
+ properties.load(is);
+ return properties;
+ }
+
+}
Property changes on: trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/EditorRendererTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/EditorIconTest.java
===================================================================
--- trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/EditorIconTest.java (rev 0)
+++ trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/EditorIconTest.java 2008-11-22 14:49:50 UTC (rev 11304)
@@ -0,0 +1,114 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.Color;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.util.HtmlColor;
+import org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons;
+import org.richfaces.renderkit.html.images.EditorIcons;
+import org.richfaces.renderkit.html.images.EditorSimpleThemeIcons;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * Editor icon images resource classes test
+ *
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorIconTest extends AbstractAjax4JsfTestCase{
+
+ public EditorIconTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Method to test resource classes saving of parameters functionality
+ */
+ public void testSaveResources(){
+
+ EditorAdvancedThemeIcons advIcon = new EditorAdvancedThemeIcons();
+ EditorSimpleThemeIcons simpleIcon = new EditorSimpleThemeIcons();
+
+ Skin skin = SkinFactory.getInstance().getSkin(facesContext);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(facesContext);
+
+ String additionalBackgroundColor = getSkinParameter(skin, defaultSkin, facesContext, EditorIcons.ADDITIONAL_BACKGROUND_COLOR);
+ String selectControlColor = getSkinParameter(skin, defaultSkin, facesContext,
+ EditorIcons.SELECT_CONTROL_COLOR);
+ String panelBorderColor = getSkinParameter(skin, defaultSkin, facesContext, EditorIcons.PANEL_BORDER_COLOR);
+ String generalTextColor = getSkinParameter(skin, defaultSkin, facesContext, EditorIcons.GENERAL_TEXT_COLOR);
+
+ assertNotNull(additionalBackgroundColor);
+ assertNotNull(selectControlColor);
+ assertNotNull(panelBorderColor);
+ assertNotNull(generalTextColor);
+
+ Color color1 = HtmlColor.decode(additionalBackgroundColor);
+ Color color2 = HtmlColor.decode(selectControlColor);
+ Color color3 = HtmlColor.decode(panelBorderColor);
+ Color color4 = HtmlColor.decode(generalTextColor);
+
+ byte [] data = (byte []) advIcon.getDataToStore(facesContext, null);
+
+ assertNotNull(data);
+ Object [] results = (Object [])advIcon.deserializeData(data);
+ assertNotNull(results);
+
+ assertEquals(color1, results[0]);
+ assertEquals(color2, results[1]);
+ assertEquals(color3, results[2]);
+ assertEquals(color4, results[3]);
+
+ data = (byte []) simpleIcon.getDataToStore(facesContext, null);
+
+ assertNotNull(data);
+ results = (Object [])simpleIcon.deserializeData(data);
+ assertNotNull(results);
+
+ assertEquals(color1, results[0]);
+ assertEquals(color2, results[1]);
+ assertEquals(color3, results[2]);
+ assertEquals(color4, results[3]);
+ }
+
+ /**
+ * Method to get skin parameter value by parameter name
+ *
+ * @param skin - current component skin
+ * @param defaultSkin - default richfaces skin
+ * @param context - faces context instance
+ * @param parameterName - name of the skin parameter
+ * @return string value of parameter
+ */
+ private String getSkinParameter(Skin skin, Skin defaultSkin, FacesContext context, String parameterName) {
+ String value = (String) skin.getParameter(context, parameterName);
+ if (null == value || "".equals(value)) {
+ value = (String) defaultSkin.getParameter(context, parameterName);
+ }
+ return value;
+
+ }
+}
Property changes on: trunk/sandbox/ui/editor/src/test/java/org/richfaces/renderkit/html/images/EditorIconTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/test/resources/editorFull.properties
===================================================================
--- trunk/sandbox/ui/editor/src/test/resources/editorFull.properties (rev 0)
+++ trunk/sandbox/ui/editor/src/test/resources/editorFull.properties 2008-11-22 14:49:50 UTC (rev 11304)
@@ -0,0 +1,10 @@
+plugins = "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template"
+theme_advanced_buttons1 = "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect"
+theme_advanced_buttons2 = "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
+theme_advanced_buttons3 = "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen"
+theme_advanced_buttons4 = "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak"
+theme_advanced_buttons5 = "|,myemotions,|"
+theme_advanced_toolbar_location = "top"
+theme_advanced_toolbar_align = "left"
+theme_advanced_statusbar_location = "bottom"
+theme_advanced_resizing = true
\ No newline at end of file
Property changes on: trunk/sandbox/ui/editor/src/test/resources/editorFull.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/test/resources/myplugins.properties
===================================================================
--- trunk/sandbox/ui/editor/src/test/resources/myplugins.properties (rev 0)
+++ trunk/sandbox/ui/editor/src/test/resources/myplugins.properties 2008-11-22 14:49:50 UTC (rev 11304)
@@ -0,0 +1 @@
+myemotions=/tiny-custom-plugins/myemotions/editor_plugin.js
\ No newline at end of file
Property changes on: trunk/sandbox/ui/editor/src/test/resources/myplugins.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
17 years, 5 months
JBoss Rich Faces SVN: r11302 - trunk/ui/orderingList/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-22 06:29:02 -0500 (Sat, 22 Nov 2008)
New Revision: 11302
Modified:
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
Log:
Bug fixing(RF-5003)
Modified: trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
--- trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-11-22 00:52:43 UTC (rev 11301)
+++ trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-11-22 11:29:02 UTC (rev 11302)
@@ -541,13 +541,10 @@
if (CONTROL_TYPE_NONE.equals(controlType)) {
return;
} else {
- if (useFacet) {
- renderChild(context, facet);
- } else {
renderDefaultControl(context, orderingList, writer, useFacet,
helper, clientId, bundleExternal, bundleApplication,
enabled, baseStyle, baseControlStyle);
- }
+
}
}
17 years, 5 months
JBoss Rich Faces SVN: r11301 - in trunk/framework/jsf-test/src/main: java/org/richfaces/test/staging and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-11-21 19:52:43 -0500 (Fri, 21 Nov 2008)
New Revision: 11301
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html
trunk/framework/jsf-test/src/main/javadoc/overview.html
Log:
javadoc packages documentation
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -5,8 +5,6 @@
import java.io.IOException;
-import javax.servlet.ServletException;
-
import org.apache.commons.httpclient.NameValuePair;
import org.richfaces.test.staging.HttpMethod;
import org.richfaces.test.staging.StagingConnection;
@@ -59,11 +57,7 @@
if(null != body && FormEncodingType.URL_ENCODED.getName().equals(contentType)){
connection.parseFormParameters(body);
}
- try {
- connection.execute();
- } catch (ServletException e) {
- throw new IOException(e.getMessage());
- }
+ connection.execute();
return new LocalWebResponse(settings,connection);
}
}
\ No newline at end of file
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -4,7 +4,6 @@
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
-import java.util.Collections;
import java.util.Set;
import java.util.logging.Logger;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -6,7 +6,6 @@
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -164,17 +164,23 @@
/**
* Execute this connection request on the associated servlet or filter chain.
- * @throws ServletException
- * @throws IOException
+ * @throws TestException if any errors were during execution.
*/
- public void execute() throws ServletException, IOException {
+ public void execute() {
if (isStarted() || isFinished()) {
throw new TestException(
"request have already been executed");
}
start();
- this.servlet.execute(request, response);
- finish();
+ try {
+ this.servlet.execute(request, response);
+ } catch (ServletException e) {
+ throw new TestException("Error execute request ",e);
+ } catch (IOException e) {
+ throw new TestException("IO Error during request execution",e);
+ } finally {
+ finish();
+ }
}
/**
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -15,7 +15,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -7,22 +7,15 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.text.DateFormat;
-import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;
import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.httpclient.HttpStatus;
-import org.junit.internal.matchers.SubstringMatcher;
-
/**
* @author asmirnov
*
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -4,14 +4,11 @@
package org.richfaces.test.staging;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
@@ -21,6 +18,7 @@
* @author asmirnov
*
*/
+@SuppressWarnings("deprecation")
abstract class StagingHttpSession implements HttpSession {
private static final int DEFAULT_INACTIVE_TIME = 30;
@@ -119,7 +117,6 @@
*
* @see javax.servlet.http.HttpSession#getSessionContext()
*/
- @SuppressWarnings("deprecation")
public HttpSessionContext getSessionContext() {
throw new NotImplementedException("Session context is not implemented");
}
@@ -168,7 +165,6 @@
*/
public boolean isNew() {
checkValid();
- // TODO Auto-generated method stub
return false;
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -71,28 +71,30 @@
private static final Logger log = ServerLogger.SERVER.getLogger();
- private List<RequestChain> servlets = new ArrayList<RequestChain>();
+ private final List<RequestChain> servlets = new ArrayList<RequestChain>();
- private RequestChain defaultServlet;
+ private RequestChain defaultServlet= new ServletContainer(null, new StaticServlet());
- private List<EventListener> contextListeners = new ArrayList<EventListener>();
+ private final List<EventListener> contextListeners = new ArrayList<EventListener>();
- private Map<String, String> initParameters = new HashMap<String, String>();
+ private final Map<String, String> initParameters = new HashMap<String, String>();
- private ServerResource serverRoot = new ServerResourcesDirectory();
+ private final ServerResource serverRoot = new ServerResourcesDirectory();
private final Map<String, String> mimeTypes = new HashMap<String, String>();
private InvocationListener invocationListener;
- private StagingServletContext context;
+ private final StagingServletContext context = new LocalContext();
private ServletContext contextProxy;
- private ServerHttpSession session;
+ private ServerHttpSession session=null;
- private HttpSession sessionProxy;
+ private HttpSession sessionProxy=null;
+ private boolean initialised=false;
+
/**
* This inner class links ServletContext calls to the server instance.
* @author asmirnov
@@ -286,7 +288,7 @@
result = defaultServlet;
}
} catch (MalformedURLException e) {
- // do nothing, just return no servlet.
+ log.warning("Mailformed request URL "+e.getMessage());
}
}
return result;
@@ -400,7 +402,7 @@
}
} catch (IOException e) {
- throw new TestException(e);
+ throw new TestException("Error read Jar content",e);
} catch (URISyntaxException e) {
throw new TestException(e);
}
@@ -532,6 +534,9 @@
*
*/
public synchronized HttpSession getSession(boolean create) {
+ if(!initialised){
+ throw new TestException("Staging server have not been initialised");
+ }
if (null == this.session && create) {
this.session = new ServerHttpSession();
// Create proxy objects.
@@ -560,8 +565,7 @@
* It should be called from test setUp method to prepare testing environment.
*/
public void init() {
- // Create context.
- this.context = new LocalContext();
+ log.info("Init staging server");
// Create Jsp factory
JspFactory.setDefaultFactory(new StaggingJspFactory(this.context));
// Create init parameters
@@ -576,7 +580,6 @@
new Class[] { ServletContext.class },
getInvocationHandler(context));
// Create default servlet
- defaultServlet = new ServletContainer(null, new StaticServlet());
final ServletContextEvent event = new ServletContextEvent(context);
fireEvent(CONTEXT_LISTENER_CLASS,
new EventInvoker<ServletContextListener>() {
@@ -588,12 +591,13 @@
try {
for (RequestChain servlet : servlets) {
// init servlet
- servlet.init(this.context);
+ servlet.init(context);
}
- defaultServlet.init(getContext());
+ defaultServlet.init(context);
} catch (ServletException e) {
- throw new TestException(e);
+ throw new TestException("Servlet initialisation error ",e);
}
+ this.initialised = true;
}
/**
@@ -602,6 +606,10 @@
*
*/
public void destroy() {
+ if(!initialised){
+ throw new TestException("Staging server have not been initialised");
+ }
+ this.initialised = false;
// Destroy session
if (null != this.session) {
// inform session listeners.
@@ -630,7 +638,8 @@
defaultServlet.destroy();
// Create Jsp factory
JspFactory.setDefaultFactory(null);
-
+ this.contextProxy = null;
+ log.info("Staging server have been destroyed");
}
/**
@@ -641,6 +650,9 @@
* @throws {@link TestException} if no servlet found to process given URL.
*/
public StagingConnection getConnection(URL url) {
+ if(!initialised){
+ throw new TestException("Staging server have not been initialised");
+ }
return new StagingConnection(this, url);
}
@@ -649,6 +661,9 @@
* @return context instance.
*/
public ServletContext getContext() {
+ if(!initialised){
+ throw new TestException("Staging server have not been initialised");
+ }
return contextProxy;
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2008-11-22 00:52:43 UTC (rev 11301)
@@ -7,7 +7,6 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -21,7 +20,6 @@
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletException;
Modified: trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html
===================================================================
--- trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html 2008-11-22 00:52:43 UTC (rev 11301)
@@ -5,6 +5,8 @@
<title>Insert title here</title>
</head>
<body>
-
+<p>This packcage contains <a href="AbstractFacesTest.html">AbstractFacesTest</a> class, wich can be used as a base point for all JSF-related test cases.</p>
+<p>The <a href="LocalWebClient.html">LocalWebClient</a> class, whether is subclass of the HtmlUnit <a href="http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/Web...">WebClient</a> class used
+as client to the local staging server <a href="org/richfaces/test/staging/StagingServer.html">StagingServer</a>.</p>
</body>
</html>
\ No newline at end of file
Modified: trunk/framework/jsf-test/src/main/javadoc/overview.html
===================================================================
--- trunk/framework/jsf-test/src/main/javadoc/overview.html 2008-11-21 22:17:26 UTC (rev 11300)
+++ trunk/framework/jsf-test/src/main/javadoc/overview.html 2008-11-22 00:52:43 UTC (rev 11301)
@@ -5,6 +5,25 @@
<title>Insert title here</title>
</head>
<body>
-
+<h1>Java web application testing framework</h1>
+<p>This is a testing framework desibned ( but not limited to ) for test JSF components and applications</p>
+<p>Though best strategy for alow-level black box testing is to use a Mock objects,
+ writing integration tests required a more real environment.
+ On the other hand, running tests on the real web, or, even more, full JEE server takes a lot of the resoures and has a own limitations.
+</p>
+<p>This framework designed as an intermediate solution. It contains <a href="org/richfaces/test/staging/StagingServer.html">staging Java Web server</a>, where is real
+ JSF framework running. This is at most Servlet 2.5 / JSP 2.1 compatible container, wich allows to run at most all JSF applications. But, in difference with real web container,
+ it is "in process" only server. That does not have network connector, session management, does not process any configuration files etc. Its advantage for a unit testing:
+ <ul>
+ <li>It has a minimal startup time, because no configuration files processed and no resource pools or other heavy objects created.</li>
+ <li>It is extremally flexible. It uses a 'virtual' web application content, that can be builded from any objects:
+ files, java resource, even dynamic classes those generate content 'on the fly'. Every test is able to use individual application content.</li>
+ <li>Not only content, but any other configuration aspects, like servlets, filters, configuration parameters can be changed from the test code.</li>
+ <li>Tests runs as a web server clients in the same JVM and thread as a server-side code does. It allows to inspect any objects on the both sides from the same code. No thread syncronisation is necessary in the test code.</li>
+ <li>It is possible to make test runs "inside" web request. For example, only one JSF lifecycle phase can be tested.
+ </ul>
+ <p>Other important part of the framework is <a href="org/richfaces/test/LocalWebClient.html">LocalWebClient</a>, subclass of the HtmlUnit <a href="http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/Web...">WebClient</a>.
+ In difference with the original client it always making local call to the staging server instead of real network protocol use. This client allows to use all HtmlUnit HTML and JavaScript testing features, even client side JavaScript test runs.</p>
+ <p>To make tests are easest, we provide <a href="org/richfaces/test/AbstractFacesTest.html">the base abstract class</a> for a Junit test with set of the template method for a fine virtual server tuning.</p>
</body>
</html>
\ No newline at end of file
17 years, 5 months