Author: abelevich
Date: 2010-08-30 10:26:50 -0400 (Mon, 30 Aug 2010)
New Revision: 19019
Added:
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceInputTest.xhtml
Removed:
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
Modified:
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
Log:
test refactoring
Modified:
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
===================================================================
---
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-08-30
14:23:21 UTC (rev 19018)
+++
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-08-30
14:26:50 UTC (rev 19019)
@@ -31,7 +31,6 @@
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.html.DomNode;
@@ -52,17 +51,14 @@
environment = new HtmlUnitEnvironment();
environment.withWebRoot(new File("src/test/resources"));
environment.withResource("/WEB-INF/faces-config.xml",
"org/richfaces/renderkit/faces-config.xml");
- environment.withResource("/test.xhtml",
"org/richfaces/renderkit/rendererTest.xhtml");
+ environment.withResource("/test.xhtml",
"org/richfaces/renderkit/inplaceInputTest.xhtml");
environment.start();
}
@Test
- @Ignore("Updates to RF-9132 broke this test - it needs to be fixed, but is
blocking M2 release")
public void testRenderDefaultState() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
- List<?> nodes = page.getByXPath("//*[@id =
'form:input_default']");
- assertEquals(1, nodes.size());
- HtmlElement span = (HtmlElement) nodes.get(0);
+ HtmlElement span = page.getFirstByXPath("//*[@id =
'form:input_default']");
assertEquals("span", span.getNodeName());
assertEquals("rf-ii-d-s", span.getAttribute(HTML.CLASS_ATTRIBUTE));
@@ -72,10 +68,7 @@
DomNode text = label.getFirstChild();
assertEquals(DomNode.TEXT_NODE, text.getNodeType());
- List<?> editNodes = page.getByXPath("//*[@id =
'form:input_default:edit']");
- assertEquals(1, editNodes.size());
- HtmlElement edit = (HtmlElement) editNodes.get(0);
-
+ HtmlElement edit = page.getFirstByXPath("//*[@id =
'form:input_default:edit']");
assertEquals("span", edit.getNodeName());
assertEquals("rf-ii-e-s rf-ii-none",
edit.getAttribute(HTML.CLASS_ATTRIBUTE));
@@ -93,9 +86,7 @@
HtmlPage page = environment.getPage("/test.jsf");
- List<?> nodes = page.getByXPath("//*[@id =
'form:input_edit']");
- assertEquals(1, nodes.size());
- HtmlElement span = (HtmlElement) nodes.get(0);
+ HtmlElement span = page.getFirstByXPath("//*[@id =
'form:input_edit']");
assertEquals("span", span.getNodeName());
assertEquals("rf-ii-d-s", span.getAttribute(HTML.CLASS_ATTRIBUTE));
@@ -105,9 +96,7 @@
DomNode text = label.getFirstChild();
assertEquals(DomNode.TEXT_NODE, text.getNodeType());
- List<?> editNodes = page.getByXPath("//*[@id =
'form:input_edit:edit']");
- assertEquals(1, editNodes.size());
- HtmlElement edit = (HtmlElement) editNodes.get(0);
+ HtmlElement edit = page.getFirstByXPath("//*[@id =
'form:input_edit:edit']");
assertEquals("span", edit.getNodeName());
assertEquals("rf-ii-e-s", edit.getAttribute(HTML.CLASS_ATTRIBUTE));
@@ -116,24 +105,15 @@
assertEquals("rf-ii-f", input.getAttribute(HTML.CLASS_ATTRIBUTE));
assertEquals(text.getNodeValue(), input.getAttribute(HTML.VALUE_ATTRIBUTE));
- List<?> buttonNodes = page.getByXPath("//*[@id =
'form:input_edit:btn']");
- assertEquals(1, buttonNodes.size());
-
- HtmlElement button = (HtmlElement) buttonNodes.get(0);
+ HtmlElement button = page.getFirstByXPath("//*[@id =
'form:input_edit:btn']");
assertEquals("span", button.getNodeName());
- List<?> okButtonNodes = page.getByXPath("//*[@id =
'form:input_edit:okbtn']");
- assertEquals(1, okButtonNodes.size());
-
- HtmlElement okButton = (HtmlElement) okButtonNodes.get(0);
+ HtmlElement okButton = page.getFirstByXPath("//*[@id =
'form:input_edit:okbtn']");
assertEquals("input", okButton.getNodeName());
assertEquals("rf-ii-btn",
okButton.getAttribute(HTML.CLASS_ATTRIBUTE));
assertEquals("image", okButton.getAttribute(HTML.TYPE_ATTR));
- List<?> cancelButtonNodes = page.getByXPath("//*[@id =
'form:input_edit:cancelbtn']");
- assertEquals(1, cancelButtonNodes.size());
-
- HtmlElement cancelButton = (HtmlElement) cancelButtonNodes.get(0);
+ HtmlElement cancelButton = page.getFirstByXPath("//*[@id =
'form:input_edit:cancelbtn']");
assertEquals("input", cancelButton.getNodeName());
assertEquals("rf-ii-btn",
cancelButton.getAttribute(HTML.CLASS_ATTRIBUTE));
assertEquals("image", cancelButton.getAttribute(HTML.TYPE_ATTR));
@@ -144,97 +124,62 @@
public void testEdit() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
edit(page, "input_default", "Another Test String");
-
blur(page);
-
- List<?> labelNodes = page.getByXPath("//*[@id =
'form:input_default:label']/text()");
- assertEquals(1, labelNodes.size());
- DomText text = (DomText) labelNodes.get(0);
+ DomText text = page.getFirstByXPath("//*[@id =
'form:input_default:label']/text()");
assertEquals("Another Test String", text.getTextContent());
-
- List<?>nodes = page.getByXPath("//*[@id =
'form:input_default']");
- assertEquals(1, nodes.size());
- HtmlElement span = (HtmlElement) nodes.get(0);
+ HtmlElement span = page.getFirstByXPath("//*[@id =
'form:input_default']");
assertEquals("rf-ii-d-s rf-ii-c-s",
span.getAttribute(HTML.CLASS_ATTRIBUTE));
-
}
private void blur(HtmlPage page) throws Exception {
- List<?> panelNodes = page.getByXPath("//*[@id =
'form:panel']");
- assertEquals(1, panelNodes.size());
- HtmlElement panel = (HtmlElement) panelNodes.get(0);
+ HtmlElement panel = page.getFirstByXPath("//*[@id =
'form:panel']");
panel.click();
}
private void typeNewValue(HtmlPage page, String inplaceInputId, String value) throws
Exception {
- List<?> inputNodes = page.getByXPath("//*[@id = 'form:" +
inplaceInputId + ":input']");
- assertEquals(1, inputNodes.size());
- HtmlElement input = (HtmlElement) inputNodes.get(0);
+ HtmlElement input = page.getFirstByXPath("//*[@id = 'form:" +
inplaceInputId + ":input']");
input.setAttribute(HTML.VALUE_ATTRIBUTE, "");
input.type(value);
}
private void edit(HtmlPage page, String inplaceInputId, String value) throws
Exception {
- List<?> nodes = page.getByXPath("//*[@id = 'form:" +
inplaceInputId + "']");
- assertEquals(1, nodes.size());
- HtmlElement span = (HtmlElement) nodes.get(0);
+ HtmlElement span = page.getFirstByXPath("//*[@id = 'form:" +
inplaceInputId + "']");
span.click();
-
- List<?> editNodes = page.getByXPath("//*[@id = 'form:" +
inplaceInputId + ":edit']");
- assertEquals(1, editNodes.size());
- HtmlElement edit = (HtmlElement) editNodes.get(0);
+ HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:" +
inplaceInputId + ":edit']");
assertEquals("rf-ii-e-s", edit.getAttribute(HTML.CLASS_ATTRIBUTE));
-
typeNewValue(page, inplaceInputId, value);
}
@Test
public void testEditWithControls() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
-
edit(page, "input_controls", "Another Test String");
-
- List<?> cancelNodes = page.getByXPath("//*[@id =
'form:input_controls:cancelbtn']");
- assertEquals(1, cancelNodes.size());
- HtmlElement cancel = (HtmlElement) cancelNodes.get(0);
-
+
+ HtmlElement cancel = page.getFirstByXPath("//*[@id =
'form:input_controls:cancelbtn']");
cancel.mouseDown();
- List<?> labelNodes = page.getByXPath("//*[@id =
'form:input_controls:label']/text()");
- assertEquals(1, labelNodes.size());
- DomText text = (DomText) labelNodes.get(0);
+ DomText text = page.getFirstByXPath("//*[@id =
'form:input_controls:label']/text()");
assertEquals("Test String", text.getTextContent());
- List<?> nodes = page.getByXPath("//*[@id =
'form:input_controls']");
- assertEquals(1, nodes.size());
- HtmlElement span = (HtmlElement) nodes.get(0);
+ HtmlElement span = page.getFirstByXPath("//*[@id =
'form:input_controls']");
assertEquals("rf-ii-d-s", span.getAttribute(HTML.CLASS_ATTRIBUTE));
edit(page, "input_controls", "Another Test String");
- List<?> okNodes = page.getByXPath("//*[@id =
'form:input_controls:okbtn']");
- assertEquals(1, okNodes.size());
- HtmlElement ok = (HtmlElement) okNodes.get(0);
-
+ HtmlElement ok = page.getFirstByXPath("//*[@id =
'form:input_controls:okbtn']");
ok.mouseDown();
- labelNodes = page.getByXPath("//*[@id =
'form:input_controls:label']/text()");
- assertEquals(1, labelNodes.size());
- text = (DomText) labelNodes.get(0);
+ text = page.getFirstByXPath("//*[@id =
'form:input_controls:label']/text()");
assertEquals("Another Test String", text.getTextContent());
- nodes = page.getByXPath("//*[@id = 'form:input_controls']");
- assertEquals(1, nodes.size());
- span = (HtmlElement) nodes.get(0);
+ span = page.getFirstByXPath("//*[@id =
'form:input_controls']");
assertEquals("rf-ii-d-s rf-ii-c-s",
span.getAttribute(HTML.CLASS_ATTRIBUTE));
edit(page, "input_controls", "Test String");
blur(page);
- labelNodes = page.getByXPath("//*[@id =
'form:input_controls:label']/text()");
- assertEquals(1, labelNodes.size());
- text = (DomText) labelNodes.get(0);
+ text = page.getFirstByXPath("//*[@id =
'form:input_controls:label']/text()");
assertEquals("Test String", text.getTextContent());
}
Added:
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceInputTest.xhtml
===================================================================
--- trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceInputTest.xhtml
(rev 0)
+++
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceInputTest.xhtml 2010-08-30
14:26:50 UTC (rev 19019)
@@ -0,0 +1,26 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:in="http://richfaces.org/input">
+<f:view contentType="text/html" />
+
+<h:head>
+ <title>Richfaces InplaceInput</title>
+</h:head>
+
+<h:body>
+ <h:form id="form">
+ <in:inplaceInput id="input_default"
value="#{dataBean.value}"/>
+
+ <in:inplaceInput id="input_controls" showControls="true"
value="#{dataBean.value}"/>
+
+ <in:inplaceInput id="input_edit" state="edit"
showControls="true" value="#{dataBean.value}"/>
+
+ <h:panelGroup id="panel">
+ <!-- click here for blur -->
+ </h:panelGroup>
+ </h:form>
+</h:body>
+</html>
Deleted: trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
===================================================================
---
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml 2010-08-30
14:23:21 UTC (rev 19018)
+++
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml 2010-08-30
14:26:50 UTC (rev 19019)
@@ -1,26 +0,0 @@
-<!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:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:in="http://richfaces.org/input">
-<f:view contentType="text/html" />
-
-<h:head>
- <title>Richfaces InplaceInput</title>
-</h:head>
-
-<h:body>
- <h:form id="form">
- <in:inplaceInput id="input_default"
value="#{dataBean.value}"/>
-
- <in:inplaceInput id="input_controls" showControls="true"
value="#{dataBean.value}"/>
-
- <in:inplaceInput id="input_edit" state="edit"
showControls="true" value="#{dataBean.value}"/>
-
- <h:panelGroup id="panel">
- <!-- click here for blur -->
- </h:panelGroup>
- </h:form>
-</h:body>
-</html>