JBoss Rich Faces SVN: r19616 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-20 10:34:47 -0400 (Wed, 20 Oct 2010)
New Revision: 19616
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
Log:
https://jira.jboss.org/browse/RFPL-869
* tests for header classes fixed
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-10-20 14:27:01 UTC (rev 19615)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-10-20 14:34:47 UTC (rev 19616)
@@ -31,6 +31,7 @@
import static org.testng.Assert.assertTrue;
import java.net.URL;
+
import javax.faces.event.PhaseId;
import org.jboss.test.selenium.css.CssProperty;
@@ -38,7 +39,6 @@
import org.jboss.test.selenium.encapsulated.JavaScript;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.conditions.IsDisplayed;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -58,9 +58,13 @@
private JQueryLocator[] itemContents = {pjq("div[id$=item1:content]"), pjq("div[id$=item2:content]"),
pjq("div[id$=item3:content]"), pjq("div[id$=item4:content]"), pjq("div[id$=item5:content]")};
private IsDisplayed isDisplayed = IsDisplayed.getInstance();
- private JQueryLocator activeHeaders = pjq("div.rf-ac-itm-hdr-act");
- private JQueryLocator inactiveHeaders = pjq("div.rf-ac-itm-hdr-inact");
- private JQueryLocator disabledHeaders = pjq("div.rf-ac-itm-hdr-dis");
+ private JQueryLocator[] activeHeaders = {pjq("div.rf-ac-itm-hdr-act:eq(0)"), pjq("div.rf-ac-itm-hdr-act:eq(1)"),
+ pjq("div.rf-ac-itm-hdr-act:eq(2)"), pjq("div.rf-ac-itm-hdr-act:eq(3)"), pjq("div.rf-ac-itm-hdr-act:eq(4)")};
+ private JQueryLocator[] inactiveHeaders = {pjq("div.rf-ac-itm-hdr-inact:eq(0)"),
+ pjq("div.rf-ac-itm-hdr-inact:eq(1)"), pjq("div.rf-ac-itm-hdr-inact:eq(2)"),
+ pjq("div.rf-ac-itm-hdr-inact:eq(3)"), pjq("div.rf-ac-itm-hdr-inact:eq(4)")};
+ private JQueryLocator[] disabledHeaders = {pjq("div.rf-ac-itm-hdr-dis:eq(0)"), pjq("div.rf-ac-itm-hdr-dis:eq(1)"),
+ pjq("div.rf-ac-itm-hdr-dis:eq(2)"), pjq("div.rf-ac-itm-hdr-dis:eq(3)"), pjq("div.rf-ac-itm-hdr-dis:eq(4)")};
@Override
public URL getTestUrl() {
@@ -237,15 +241,15 @@
selenium.type(pjq("input[id$=itemHeaderClassActiveInput]"), "metamer-ftest-class");
selenium.waitForPageToLoad();
- for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ for (JQueryLocator loc : activeHeaders) {
assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
}
- for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ for (JQueryLocator loc : inactiveHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
}
- for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ for (JQueryLocator loc : disabledHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
}
}
@@ -255,15 +259,15 @@
selenium.type(pjq("input[id$=itemHeaderClassDisabledInput]"), "metamer-ftest-class");
selenium.waitForPageToLoad();
- for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ for (JQueryLocator loc : activeHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
}
- for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ for (JQueryLocator loc : inactiveHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
}
- for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ for (JQueryLocator loc : disabledHeaders) {
assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
}
}
@@ -273,15 +277,15 @@
selenium.type(pjq("input[id$=itemHeaderClassInactiveInput]"), "metamer-ftest-class");
selenium.waitForPageToLoad();
- for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ for (JQueryLocator loc : activeHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
}
- for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ for (JQueryLocator loc : inactiveHeaders) {
assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
}
- for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ for (JQueryLocator loc : disabledHeaders) {
assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
}
}
13 years, 8 months
JBoss Rich Faces SVN: r19615 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-10-20 10:27:01 -0400 (Wed, 20 Oct 2010)
New Revision: 19615
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
Log:
https://jira.jboss.org/browse/RFPL-869
* testItemHeaderClassInactive, testItemHeaderClassDisabled and testItemHeaderClassActive fixed
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-10-20 10:58:29 UTC (rev 19614)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-10-20 14:27:01 UTC (rev 19615)
@@ -38,6 +38,7 @@
import org.jboss.test.selenium.encapsulated.JavaScript;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.conditions.IsDisplayed;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -57,8 +58,9 @@
private JQueryLocator[] itemContents = {pjq("div[id$=item1:content]"), pjq("div[id$=item2:content]"),
pjq("div[id$=item3:content]"), pjq("div[id$=item4:content]"), pjq("div[id$=item5:content]")};
private IsDisplayed isDisplayed = IsDisplayed.getInstance();
- private String[] phasesNames = {"RESTORE_VIEW 1", "APPLY_REQUEST_VALUES 2", "PROCESS_VALIDATIONS 3",
- "UPDATE_MODEL_VALUES 4", "INVOKE_APPLICATION 5", "RENDER_RESPONSE 6"};
+ private JQueryLocator activeHeaders = pjq("div.rf-ac-itm-hdr-act");
+ private JQueryLocator inactiveHeaders = pjq("div.rf-ac-itm-hdr-inact");
+ private JQueryLocator disabledHeaders = pjq("div.rf-ac-itm-hdr-dis");
@Override
public URL getTestUrl() {
@@ -137,7 +139,8 @@
selenium.click(itemHeaders[2]);
waitGui.failWith("Item 3 is not displayed.").until(isDisplayed.locator(itemContents[2]));
- assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES, PhaseId.PROCESS_VALIDATIONS, PhaseId.RENDER_RESPONSE);
+ assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES, PhaseId.PROCESS_VALIDATIONS,
+ PhaseId.RENDER_RESPONSE);
}
@Test
@@ -231,17 +234,56 @@
@Test
public void testItemHeaderClassActive() {
- testStyleClass(itemHeaders[0], "itemHeaderClassActive");
+ selenium.type(pjq("input[id$=itemHeaderClassActiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassActive does not work");
+ }
}
@Test
public void testItemHeaderClassDisabled() {
- testStyleClass(itemHeaders[3], "itemHeaderClassDisabled");
+ selenium.type(pjq("input[id$=itemHeaderClassDisabledInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassDisabled does not work");
+ }
}
@Test
public void testItemHeaderClassInactive() {
- testStyleClass(itemHeaders[1], "itemHeaderClassInactive");
+ selenium.type(pjq("input[id$=itemHeaderClassInactiveInput]"), "metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ for (JQueryLocator loc : activeHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
+ }
+
+ for (JQueryLocator loc : inactiveHeaders.getAllChildren()) {
+ assertTrue(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
+ }
+
+ for (JQueryLocator loc : disabledHeaders.getAllChildren()) {
+ assertFalse(selenium.belongsClass(loc, "metamer-ftest-class"), "itemHeaderClassInactive does not work");
+ }
}
@Test
13 years, 8 months
JBoss Rich Faces SVN: r19613 - trunk/ui/input/ui/src/test/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-20 04:24:52 -0400 (Wed, 20 Oct 2010)
New Revision: 19613
Modified:
trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
Log:
fix test
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-10-20 06:14:32 UTC (rev 19612)
+++ trunk/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-10-20 08:24:52 UTC (rev 19613)
@@ -67,7 +67,7 @@
DomNode text = label.getFirstChild();
assertEquals(DomNode.TEXT_NODE, text.getNodeType());
- HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_default:edit']");
+ HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_defaultEdit']");
assertEquals("span", edit.getNodeName());
assertEquals("rf-ii-edit rf-ii-none", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
@@ -76,7 +76,7 @@
assertEquals("rf-ii-fld", input.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
assertEquals(text.getNodeValue(), input.getAttribute(HtmlConstants.VALUE_ATTRIBUTE));
- List<?> buttons = page.getByXPath("//*[@id = 'form:input_default:btn']");
+ List<?> buttons = page.getByXPath("//*[@id = 'form:input_defaultBtn']");
assertEquals(true, buttons.isEmpty());
}
@@ -95,7 +95,7 @@
DomNode text = label.getFirstChild();
assertEquals(DomNode.TEXT_NODE, text.getNodeType());
- HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_edit:edit']");
+ HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:input_editEdit']");
assertEquals("span", edit.getNodeName());
assertEquals("rf-ii-edit", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
@@ -104,15 +104,15 @@
assertEquals("rf-ii-fld", input.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
assertEquals(text.getNodeValue(), input.getAttribute(HtmlConstants.VALUE_ATTRIBUTE));
- HtmlElement button = page.getFirstByXPath("//*[@id = 'form:input_edit:btn']");
+ HtmlElement button = page.getFirstByXPath("//*[@id = 'form:input_editBtn']");
assertEquals("span", button.getNodeName());
- HtmlElement okButton = page.getFirstByXPath("//*[@id = 'form:input_edit:okbtn']");
+ HtmlElement okButton = page.getFirstByXPath("//*[@id = 'form:input_editOkbtn']");
assertEquals("input", okButton.getNodeName());
assertEquals("rf-ii-btn", okButton.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
assertEquals("image", okButton.getAttribute(HtmlConstants.TYPE_ATTR));
- HtmlElement cancelButton = page.getFirstByXPath("//*[@id = 'form:input_edit:cancelbtn']");
+ HtmlElement cancelButton = page.getFirstByXPath("//*[@id = 'form:input_editCancelbtn']");
assertEquals("input", cancelButton.getNodeName());
assertEquals("rf-ii-btn", cancelButton.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
assertEquals("image", cancelButton.getAttribute(HtmlConstants.TYPE_ATTR));
@@ -124,7 +124,7 @@
HtmlPage page = environment.getPage("/test.jsf");
edit(page, "input_default", "Another Test String");
blur(page);
- DomText text = page.getFirstByXPath("//*[@id = 'form:input_default:label']/text()");
+ DomText text = page.getFirstByXPath("//*[@id = 'form:input_defaultLabel']/text()");
assertEquals("Another Test String", text.getTextContent());
HtmlElement span = page.getFirstByXPath("//*[@id = 'form:input_default']");
assertEquals("rf-ii-d-s rf-ii-c-s", span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
@@ -136,7 +136,7 @@
}
private void typeNewValue(HtmlPage page, String inplaceInputId, String value) throws Exception {
- HtmlElement input = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + ":input']");
+ HtmlElement input = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + "Input']");
input.setAttribute(HtmlConstants.VALUE_ATTRIBUTE, "");
input.type(value);
}
@@ -144,7 +144,7 @@
private void edit(HtmlPage page, String inplaceInputId, String value) throws Exception {
HtmlElement span = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + "']");
span.click();
- HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + ":edit']");
+ HtmlElement edit = page.getFirstByXPath("//*[@id = 'form:" + inplaceInputId + "Edit']");
assertEquals("rf-ii-edit", edit.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
typeNewValue(page, inplaceInputId, value);
}
@@ -154,10 +154,10 @@
HtmlPage page = environment.getPage("/test.jsf");
edit(page, "input_controls", "Another Test String");
- HtmlElement cancel = page.getFirstByXPath("//*[@id = 'form:input_controls:cancelbtn']");
+ HtmlElement cancel = page.getFirstByXPath("//*[@id = 'form:input_controlsCancelbtn']");
cancel.mouseDown();
- DomText text = page.getFirstByXPath("//*[@id = 'form:input_controls:label']/text()");
+ DomText text = page.getFirstByXPath("//*[@id = 'form:input_controlsLabel']/text()");
assertEquals("Test String", text.getTextContent());
HtmlElement span = page.getFirstByXPath("//*[@id = 'form:input_controls']");
@@ -165,10 +165,10 @@
edit(page, "input_controls", "Another Test String");
- HtmlElement ok = page.getFirstByXPath("//*[@id = 'form:input_controls:okbtn']");
+ HtmlElement ok = page.getFirstByXPath("//*[@id = 'form:input_controlsOkbtn']");
ok.mouseDown();
- text = page.getFirstByXPath("//*[@id = 'form:input_controls:label']/text()");
+ text = page.getFirstByXPath("//*[@id = 'form:input_controlsLabel']/text()");
assertEquals("Another Test String", text.getTextContent());
span = page.getFirstByXPath("//*[@id = 'form:input_controls']");
@@ -178,7 +178,7 @@
blur(page);
- text = page.getFirstByXPath("//*[@id = 'form:input_controls:label']/text()");
+ text = page.getFirstByXPath("//*[@id = 'form:input_controlsLabel']/text()");
assertEquals("Test String", text.getTextContent());
}
13 years, 8 months
JBoss Rich Faces SVN: r19612 - modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-10-20 02:14:32 -0400 (Wed, 20 Oct 2010)
New Revision: 19612
Modified:
modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
Log:
Draft of rich:calendar complete
Modified: modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
===================================================================
--- modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-10-20 03:31:28 UTC (rev 19611)
+++ modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-10-20 06:14:32 UTC (rev 19612)
@@ -15,7 +15,6 @@
</para>
<!-- <rich:calendar> -->
- <!-- TODO in M4
<section id="sect-Component_Reference-Rich_inputs-richcalendar">
<title><sgmltag><rich:calendar></sgmltag></title>
<para>
@@ -149,9 +148,8 @@
</itemizedlist>
</section>
</section>
- -->
- <!-- TODO not in M3 -->
+ <!-- TODO not in M4 -->
<!--
<section id="sect-Component_Reference-Rich_inputs-richcolorPicker">
<title><sgmltag><rich:colorPicker></sgmltag></title>
@@ -285,7 +283,7 @@
</section>
</section>
- <!-- TODO not in M3 -->
+ <!-- TODO not in M4 -->
<!--<rich:autocompleteBehavior>-->
<!--
<section id="sect-Component_Reference-Rich_inputs-richautocompleteBehavior">
@@ -336,7 +334,7 @@
</section>
-->
- <!-- TODO not in M3 -->
+ <!-- TODO not in M4 -->
<!--
<section id="sect-Component_Reference-Rich_inputs-richeditor">
<title><sgmltag><rich:editor></sgmltag></title>
@@ -456,13 +454,13 @@
</para>
<para>
The user can confirm and save their input by pressing the <keycap>Enter</keycap> key or cancel by pressing the <keycap>Esc</keycap> key. Alternatively, buttons for confirming or canceling can be added to the component by setting <code>showControls="true"</code>.
- <!-- TODO not in M3
+ <!-- TODO not in M4
These buttons can be positioned using the <varname>controlsHorizontalPosition</varname> attribute with settings of <literal>left</literal>, <literal>right</literal>, or <literal>center</literal>, and the <varname>controlsVerticalPosition</varname> attribute with settings <literal>bottom</literal>, <literal>center</literal>, or <literal>top</literal>. The confirmation control icons can be altered using the <varname>saveControlIcon</varname> and <varname>cancelControlIcon</varname>. Further customization is possible through the use of facets.
-->
</para>
</section>
- <!-- TODO not in M3
+ <!-- TODO not in M4
<section id="sect-Component_Reference-richinplaceInput-richinplaceInput_events">
<title><sgmltag><rich:inplaceInput></sgmltag> events</title>
<para>
@@ -525,7 +523,7 @@
</section>
</section>
- <!-- TODO not in M3 -->
+ <!-- TODO not in M4 -->
<!--<rich:inplaceSelect>-->
<!--
<section id="sect-Component_Reference-Rich_inputs-richinplaceSelect">
13 years, 8 months
JBoss Rich Faces SVN: r19611 - in modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US: images and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-10-19 23:31:28 -0400 (Tue, 19 Oct 2010)
New Revision: 19611
Added:
modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselectOne-Selection_items.xml_sample
modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richselectOne-richselectOne.png
Log:
Added selectOne extras
Added: modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselectOne-Selection_items.xml_sample
===================================================================
--- modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselectOne-Selection_items.xml_sample (rev 0)
+++ modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselectOne-Selection_items.xml_sample 2010-10-20 03:31:28 UTC (rev 19611)
@@ -0,0 +1,4 @@
+<rich:selectOne>
+ <f:selectItem itemLabel="constantOption" itemValue="0">
+ <f:selectItems="#{bean.items}">
+</rich:selectOne>
Added: modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richselectOne-richselectOne.png
===================================================================
(Binary files differ)
Property changes on: modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richselectOne-richselectOne.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
13 years, 8 months
JBoss Rich Faces SVN: r19610 - modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-10-19 23:30:01 -0400 (Tue, 19 Oct 2010)
New Revision: 19610
Modified:
modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
Log:
Draft of richselectOne complete
Modified: modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
===================================================================
--- modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-10-19 23:53:42 UTC (rev 19609)
+++ modules/docs/branches/m4/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-10-20 03:30:01 UTC (rev 19610)
@@ -787,14 +787,46 @@
The <sgmltag><rich:selectOne></sgmltag> component provides a drop-down list box for selecting a single value from multiple options. The component supports keyboard navigation and can optionally accept typed input as a combo-box.
</para>
+ <figure id="figu-Component_Reference-richselectOne-richselectOne">
+ <title><sgmltag><rich:selectOne></sgmltag></title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/figu-Component_Reference-richselectOne-richselectOne.png" format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ A <sgmltag><rich:selectOne></sgmltag> component used as a combo-box.
+ </para>
+ </textobject>
+ </mediaobject>
+ </figure>
+
<section id="sect-Component_Reference-richselectOne-Basic_usage">
<title>Basic usage</title>
<para>
Simple usage of the <sgmltag><rich:selectOne></sgmltag> component does not need any attributes declared, but child tags to manage the list of selections are required. An <sgmltag><f:selectItem></sgmltag> tag manages the currently selected value, while an <sgmltag><f:selectItems></sgmltag> tag points to the list of selection items.
</para>
+ <example id="exam-Component_Reference-richselectOne-Selection_items">
+ <title>Selection items</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richselectOne-Selection_items.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
+ <para>
+ The arrow keys on a keyboard can be used to highlight different items in the list, even if the list is closed with the control still focused. If the control loses focus or the <keycap function="enter">Enter</keycap> key is pressed, the highlighted option is chosen as the value and the list is closed. Pressing the <keycap function="escape">Esc</keycap> key will close the list but not change the value.
+ </para>
</section>
- <!--FIXME: finish draft -->
+ <section id="sect-Component_Reference-richselectOne-Using_richselectOne_as_a_combo-box">
+ <title>Using <sgmltag><rich:selectOne></sgmltag> as a combo-box</title>
+ <para>
+ Combo-boxes are drop-down lists that allow the user to type into a text field to scroll through or filter the list. By default, the <sgmltag><rich:selectOne></sgmltag> component functions as a drop-down list. To add keyboard support to make it function like a combo-box, set <code>enableManualInput="true"</code>.
+ </para>
+ <para>
+ Once the user begins typing, the first available matching option is highlighted. If the typed text does not match any values in the list, no value is chosen and the drop-down list displays as empty. Other keyboard interaction remains the same as the basic drop-down list.
+ </para>
+ <para>
+ Typing text into a combo-box causes the list to scroll to the relevant item by default. This behavior can be changed so that the typed text filters the contents of the list instead, showing only those items that begin with the typed text. To use typed text as a filter for combo-box lists, set <code>filterOnUpdates="true"</code>.
+ </para>
+ </section>
<section id="sect-Component_Reference-richselectOne-Reference_data">
<title>Reference data</title>
13 years, 8 months
JBoss Rich Faces SVN: r19609 - in branches/RF-8742/ui/validator/ui/src: main/java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-19 19:53:42 -0400 (Tue, 19 Oct 2010)
New Revision: 19609
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererGetScriptTest.java
Log:
OPEN - issue RF-9507: ClientValidatorRendererunit tests and implementation.
https://jira.jboss.org/browse/RF-9507
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-10-19 18:10:00 UTC (rev 19608)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -23,8 +23,13 @@
package org.richfaces.component;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
+import org.richfaces.renderkit.html.ComponentValidatorScript;
+
/**
* <p class="changed_added_4_0">This component user to render Client Validator scripts. Any ClientValidatorBehavior that requires additional scripts should put them
* to this component, associated with "form" target in view resources.</p>
@@ -33,4 +38,13 @@
*/
public class UIValidatorScript extends UIOutput {
+ public List<UIComponent> getScripts() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String addScript(ComponentValidatorScript script){
+ return null;
+
+ }
}
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-19 18:10:00 UTC (rev 19608)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -6,6 +6,7 @@
import javax.faces.FacesException;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
import javax.faces.render.ClientBehaviorRenderer;
import org.richfaces.component.UIValidatorScript;
@@ -51,7 +52,7 @@
return null;
}
- UIValidatorScript getOrCreateValidatorScriptResource(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior){
+ UIValidatorScript getOrCreateValidatorScriptResource(FacesContext facesContext){
return null;
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-10-19 18:10:00 UTC (rev 19608)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -1,69 +1,197 @@
package org.richfaces.renderkit.html;
+import static org.easymock.EasyMock.*;
+import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
+import static org.junit.matchers.JUnitMatchers.*;
+import java.util.ArrayList;
+import java.util.Map;
+
import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.NumberConverter;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
import org.ajax4jsf.javascript.JSLiteral;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.richfaces.validator.ConverterDescriptor;
+import org.richfaces.validator.LibraryResource;
import org.richfaces.validator.LibraryScript;
import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
+(a)RunWith(MockTestRunner.class)
public class RendererGetComponentScriptTest extends RendererTestBase {
+ private static final String JSF_AJAX_REQUEST = "jsf.ajax.request(this,event)";
+
private static final String NUMBER_CONVERTER = "numConverter";
+ private static final Matcher<LibraryResource> CORE_LIBRARY_MATCHER = new BaseMatcher<LibraryResource>() {
+
+ public boolean matches(Object arg0) {
+ if (arg0 instanceof LibraryResource) {
+ LibraryResource resource = (LibraryResource) arg0;
+ return ORG_RICHFACES.equals(resource.getLibrary())
+ && CLIENT_VALIDATORS_JS.equals(resource.getResourceName());
+ }
+ return false;
+ }
+
+ public void describeTo(Description arg0) {
+ arg0.appendText("Library is RichFaces core validators");
+ }
+ };
+
+ @Mock
+ private ConverterDescriptor converterDescription;
+
/**
- * <p class="changed_added_4_0">Test generated script for case there is no client-side converter.</p>
+ * <p class="changed_added_4_0">
+ * Test generated script for case there is no client-side converter.
+ * </p>
+ *
+ * @throws Exception
*/
+ @SuppressWarnings("unchecked")
@Test
- public void testCreateValidatorScriptNoConverter() {
+ public void testCreateValidatorScriptNoConverter() throws Exception {
ClientValidatorRenderer renderer = createStubRenderer(null, createValidatorFunction());
+ setupBehavior(NumberConverter.class, Min.class);
+ exceptGetAjaxScript();
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ String script = validatorScript.toScript();
+ // check what generated script contains ajax call only.
+ assertThat(
+ script,
+ allOf(containsString(JSF_AJAX_REQUEST), not(containsString(REGEX_VALIDATOR)),
+ not(containsString(NUMBER_CONVERTER))));
}
+ private void exceptGetAjaxScript() {
+ expect(mockBehavior.getAjaxScript(behaviorContext)).andReturn(JSF_AJAX_REQUEST);
+ }
/**
- * <p class="changed_added_4_0">Test generated script for case there is no client-side validator scripts.</p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param renderer
+ * @return
*/
+ private ComponentValidatorScript callGetScript(ClientValidatorRenderer renderer) {
+ controller.replay();
+ ComponentValidatorScript validatorScript = renderer.createValidatorScript(behaviorContext, mockBehavior);
+ controller.verify();
+ return validatorScript;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Test generated script for case there is no client-side validator scripts.
+ * </p>
+ *
+ * @throws Exception
+ */
@Test
- public void testCreateValidatorScriptNoValidator() {
+ public void testCreateValidatorScriptNoValidator() throws Exception {
ClientValidatorRenderer renderer = createStubRenderer(createConverterFunction());
+ setupBehavior(NumberConverter.class, Min.class);
+ exceptGetAjaxScript();
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ String script = validatorScript.toScript();
+ // check what generated script contains ajax call only.
+ assertThat(
+ script,
+ allOf(containsString(JSF_AJAX_REQUEST), not(containsString(REGEX_VALIDATOR)),
+ not(containsString(NUMBER_CONVERTER))));
}
/**
- * <p class="changed_added_4_0">Test generated script for case there is no client-side script for some validator, but exists for other</p>
+ * <p class="changed_added_4_0">
+ * Test generated script for case there is no client-side script for some validator, but exists for other
+ * </p>
+ *
+ * @throws Exception
*/
@Test
- public void testCreateValidatorScriptPartialValidator() {
- fail("Not yet implemented");
+ public void testCreateValidatorScriptPartialValidator() throws Exception {
+ ClientValidatorRenderer renderer = createStubRenderer(createConverterFunction(), createValidatorFunction());
+ setupBehavior(NumberConverter.class, Min.class, Max.class);
+ exceptGetAjaxScript();
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ String script = validatorScript.toScript();
+ // check what generated script contains ajax and client side scripts.
+ assertThat(script,
+ allOf(containsString(JSF_AJAX_REQUEST), containsString(REGEX_VALIDATOR), containsString(NUMBER_CONVERTER)));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
/**
- * <p class="changed_added_4_0">Test case when validation does not required at all.</p>
+ * <p class="changed_added_4_0">
+ * Test case when validation does not required at all.
+ * </p>
+ *
+ * @throws Exception
*/
@Test
- public void testCreateValidatorScriptEmptyValidator() {
- fail("Not yet implemented");
+ public void testCreateValidatorScriptEmptyValidator() throws Exception {
+ ClientValidatorRenderer renderer = createStubRenderer(createConverterFunction());
+ setupBehavior(NumberConverter.class);
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ assertNull(validatorScript);
}
/**
- * <p class="changed_added_4_0">Test for case when client side converter is not required.</p>
+ * <p class="changed_added_4_0">
+ * Test for case when client side converter is not required.
+ * </p>
+ *
+ * @throws Exception
*/
@Test
- public void testCreateValidatorScriptNullConverter() {
- fail("Not yet implemented");
+ public void testCreateValidatorScriptNullConverter() throws Exception {
+ ClientValidatorRenderer renderer = createStubRenderer(null, createValidatorFunction());
+ setupBehavior(null, Min.class);
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ String script = validatorScript.toScript();
+ // check what generated script contains ajax and client side scripts.
+ assertThat(
+ script,
+ allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
+ not(containsString(NUMBER_CONVERTER))));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
/**
- * <p class="changed_added_4_0">Test case when all converter and validators available on client.</p>
+ * <p class="changed_added_4_0">
+ * Test case when all converter and validators available on client.
+ * </p>
+ *
+ * @throws Exception
*/
@Test
- public void testCreateValidatorScriptClientOnly() {
- fail("Not yet implemented");
+ public void testCreateValidatorScriptClientOnly() throws Exception {
+ ClientValidatorRenderer renderer = createStubRenderer(createConverterFunction(), createValidatorFunction());
+ setupBehavior(NumberConverter.class, Min.class);
+ ComponentValidatorScript validatorScript = callGetScript(renderer);
+ String script = validatorScript.toScript();
+ // check what generated script contains ajax and client side scripts.
+ assertThat(
+ script,
+ allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
+ containsString(NUMBER_CONVERTER)));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
-
+
private LibraryScriptFunction createValidatorFunction() {
return createFunction(REGEX_VALIDATOR, ClientValidatorRenderer.CONVERTED_VALUE_VAR, VALIDATOR_MESSAGE);
}
@@ -72,45 +200,70 @@
return createFunction(NUMBER_CONVERTER, ClientValidatorRenderer.VALUE_VAR, VALIDATOR_MESSAGE);
}
- private LibraryScriptFunction createFunction(final String name,String var,String message) {
+ private LibraryScriptFunction createFunction(final String name, String var, String message) {
LibraryScript libraryScript = new LibraryScript() {
-
+
public String getResourceName() {
return CLIENT_VALIDATORS_JS;
}
-
+
public String getLibrary() {
return ORG_RICHFACES;
}
-
+
public String getName() {
return name;
}
};
- return new LibraryScriptFunction(libraryScript,new JSLiteral(var),message,VALIDATOR_PARAMS);
+ return new LibraryScriptFunction(libraryScript, new JSLiteral(var), message, VALIDATOR_PARAMS);
}
-
- private ClientValidatorRenderer createStubRenderer(final LibraryScriptFunction converterFunction, final LibraryScriptFunction ...validatorFunctions){
- return new ClientValidatorRenderer(){
-
+
+ private ClientValidatorRenderer createStubRenderer(final LibraryScriptFunction converterFunction,
+ final LibraryScriptFunction... validatorFunctions) {
+ return new ClientValidatorRenderer() {
+
private int validatorsCounter = 0;
+
@Override
LibraryScriptFunction getClientSideConverterScript(ClientBehaviorContext behaviorContext,
ConverterDescriptor converter) throws ScriptNotFoundException {
- if(null == converterFunction){
+ if (null == converterFunction) {
throw new ScriptNotFoundException();
}
return converterFunction;
}
-
+
@Override
LibraryScriptFunction getClientSideValidatorScript(ClientBehaviorContext behaviorContext,
ValidatorDescriptor validator) throws ScriptNotFoundException {
- if(validatorsCounter>=validatorFunctions.length){
+ if (validatorsCounter >= validatorFunctions.length) {
throw new ScriptNotFoundException();
}
return validatorFunctions[validatorsCounter++];
}
};
}
+
+ private void setupBehavior(Class<? extends Converter> converter, Class<?>... validators) throws Exception {
+ setupBehaviorContext(input);
+ if (null != converter) {
+ setupDescription(converter, converterDescription);
+ expect(mockBehavior.getConverter(behaviorContext)).andReturn(converterDescription);
+ } else {
+ expect(mockBehavior.getConverter(behaviorContext)).andStubReturn(null);
+ }
+ ArrayList<ValidatorDescriptor> validatorDescriptors = new ArrayList<ValidatorDescriptor>(validators.length);
+ for (Class<?> validator : validators) {
+ ValidatorDescriptor validatorDescriptor = controller.createNiceMock(ValidatorDescriptor.class);
+ setupDescription(validator, validatorDescriptor);
+ validatorDescriptors.add(validatorDescriptor);
+ }
+ expect(mockBehavior.getValidators(behaviorContext)).andReturn(validatorDescriptors);
+ }
+
+ private void setupDescription(Class<?> converter, ValidatorDescriptor descriptor) {
+ expect((Class) descriptor.getValidatorClass()).andStubReturn(converter);
+ expect(converterDescription.getMessage()).andStubReturn(VALIDATOR_MESSAGE);
+ expect((Map) converterDescription.getValidatorParameters()).andStubReturn(VALIDATOR_PARAMS);
+ }
}
Added: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -0,0 +1,108 @@
+package org.richfaces.renderkit.html;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.component.UIValidatorScript;
+import org.richfaces.component.behavior.ClientValidatorBehavior;
+
+import com.google.common.collect.Lists;
+
+(a)RunWith(MockTestRunner.class)
+public class RendererGetOrCreateResourceTest extends RendererTestBase {
+
+ private static final String FUNCTION_NAME = "inputValidate";
+
+ @Mock
+ private UIViewRoot viewRoot;
+
+ @Mock
+ private ComponentValidatorScript validatorScript;
+
+ private UIValidatorScript scriptResource;
+
+ /**
+ * <p class="changed_added_4_0">No resource exist in view, create a new one and store in "form" target.</p>
+ */
+ @Test
+ public void testCreateValidatorScriptResource() {
+ FacesContext facesContext = recordResources(null,null);
+ expect(environment.getApplication().createComponent(UIValidatorScript.COMPONENT_TYPE)).andReturn(scriptResource);
+ viewRoot.addComponentResource(facesContext, scriptResource);expectLastCall();
+ verifyResult(facesContext);
+ }
+
+ private FacesContext recordResources(UIComponent formResource,UIComponent bodyResource) {
+ FacesContext facesContext = recordViewRoot();
+ recordViewResources("form", formResource);
+ recordViewResources("body", bodyResource);
+ return facesContext;
+ }
+
+ private void verifyResult(FacesContext facesContext) {
+ controller.replay();
+ assertSame(scriptResource,renderer.getOrCreateValidatorScriptResource(facesContext));
+ controller.verify();
+ }
+
+ /**
+ * <p class="changed_added_4_0">Resource already exists in "form" target</p>
+ */
+ @Test
+ public void testGetValidatorScriptResourceForm() {
+ FacesContext facesContext = recordResources(scriptResource,null);
+ verifyResult(facesContext);
+ }
+
+ /**
+ * <p class="changed_added_4_0">Resource already exists in "body" target</p>
+ */
+ @Test
+ public void testGetValidatorScriptResourceBody() {
+ FacesContext facesContext = recordResources(null,scriptResource);
+ verifyResult(facesContext);
+ }
+
+ @Test
+ public void buildAndStoreScript() throws Exception {
+ FacesContext facesContext = recordResources(scriptResource,null);
+ ClientValidatorRenderer renderer = new ClientValidatorRenderer(){
+ ComponentValidatorScript createValidatorScript(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior) {
+ return validatorScript;
+ };
+ };
+ setupBehaviorContext(input);
+ expect(input.getClientId(facesContext)).andReturn(FUNCTION_NAME);
+ controller.replay();
+ assertEquals(FUNCTION_NAME, renderer.buildAndStoreValidatorScript(behaviorContext, mockBehavior));
+ assertEquals(1, scriptResource.getScripts().size());
+ controller.verify();
+ }
+
+
+ private void recordViewResources(String target, UIComponent resource){
+ FacesContext facesContext = environment.getFacesContext();
+ List<UIComponent> resources = Lists.newArrayList();
+ if(null != resource){
+ resources.add(resource);
+ }
+ expect(viewRoot.getComponentResources(facesContext, target)).andStubReturn(resources);
+ }
+
+ private FacesContext recordViewRoot() {
+ FacesContext facesContext = environment.getFacesContext();
+ expect(facesContext.getViewRoot()).andStubReturn(viewRoot);
+ return facesContext;
+ }
+}
Property changes on: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-19 18:10:00 UTC (rev 19608)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -2,6 +2,7 @@
import java.util.Map;
+import org.jboss.test.faces.mock.Mock;
import org.richfaces.component.behavior.BehaviorTestBase;
import org.richfaces.component.behavior.ClientValidatorBehavior;
@@ -14,15 +15,15 @@
protected static final String REGEX_VALIDATOR = "regexValidator";
protected static final String VALIDATOR_MESSAGE = "Validator Message";
protected static final Map<String, ? extends Object> VALIDATOR_PARAMS = ImmutableMap.of("foo", "value", "bar", 10);
+
protected ClientValidatorRenderer renderer = new ClientValidatorRenderer();
+
+ @Mock
+ protected ClientValidatorBehavior mockBehavior;
public RendererTestBase() {
super();
}
- @Override
- protected ClientValidatorBehavior createBehavior() {
- return controller.createMock(ClientValidatorBehavior.class);
- }
}
\ No newline at end of file
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererGetScriptTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererGetScriptTest.java 2010-10-19 18:10:00 UTC (rev 19608)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererGetScriptTest.java 2010-10-19 23:53:42 UTC (rev 19609)
@@ -17,7 +17,7 @@
@Test(expected=NullPointerException.class)
public void testGetScriptNullContext() {
- renderer.getScript(null, behavior);
+ renderer.getScript(null, mockBehavior);
}
@Test(expected=NullPointerException.class)
public void testGetScriptNullBehavior() {
13 years, 8 months
JBoss Rich Faces SVN: r19608 - in branches/RF-8742: ui/validator/ui and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-19 14:10:00 -0400 (Tue, 19 Oct 2010)
New Revision: 19608
Modified:
branches/RF-8742/bom/pom.xml
branches/RF-8742/ui/validator/ui/pom.xml
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
Log:
https://jira.jboss.org/browse/RF-9511
Modified: branches/RF-8742/bom/pom.xml
===================================================================
--- branches/RF-8742/bom/pom.xml 2010-10-19 17:33:27 UTC (rev 19607)
+++ branches/RF-8742/bom/pom.xml 2010-10-19 18:10:00 UTC (rev 19608)
@@ -194,6 +194,11 @@
<artifactId>cssparser</artifactId>
<version>0.9.5</version>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.14</version>
+ </dependency>
<!-- Optional cache dependencies -->
<dependency>
Modified: branches/RF-8742/ui/validator/ui/pom.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/pom.xml 2010-10-19 17:33:27 UTC (rev 19607)
+++ branches/RF-8742/ui/validator/ui/pom.xml 2010-10-19 18:10:00 UTC (rev 19608)
@@ -89,6 +89,11 @@
<version>1.0.5-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-10-19 17:33:27 UTC (rev 19607)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-10-19 18:10:00 UTC (rev 19608)
@@ -34,7 +34,7 @@
public class DateTimeConverterTest extends BaseConverterTest {
public DateTimeConverterTest() {
- super("org/richfaces/csv/testConverter.js");
+ super("org/richfaces/convert/testConverter.js");
}
@DataProvider(name = "successTest")
13 years, 8 months
JBoss Rich Faces SVN: r19607 - management/design-4x/panelMenu.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-10-19 13:33:27 -0400 (Tue, 19 Oct 2010)
New Revision: 19607
Modified:
management/design-4x/panelMenu/taglib-panelmenu.png
Log:
RF-9317 panelMenu components
taglib view image
Modified: management/design-4x/panelMenu/taglib-panelmenu.png
===================================================================
(Binary files differ)
13 years, 8 months
JBoss Rich Faces SVN: r19606 - in branches/RF-8742/ui/validator/ui/src/test: java/org/richfaces/convert and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-19 13:11:30 -0400 (Tue, 19 Oct 2010)
New Revision: 19606
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/resources/org/
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/test.xhtml
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/testConverter.js
Log:
https://jira.jboss.org/browse/RF-9511
Added: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseConverterTest.java (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseConverterTest.java 2010-10-19 17:11:30 UTC (rev 19606)
@@ -0,0 +1,282 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import java.text.MessageFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TimeZone;
+
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+
+import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+
+import com.gargoylesoftware.htmlunit.ScriptResult;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class BaseConverterTest {
+
+ public static final String TEST_COMPONENT_LABEL = "input";
+
+ public class TestBean {
+
+ private static final String CONVERTER_VAR = "__converter";
+
+ private String converterId;
+
+ private String clientConverterClassName;
+
+ private String submittedValue;
+
+ private String convertedValueAsScript;
+
+ private String conversionErrorMessage;
+
+ private ConverterException converterException;
+
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ private String converterParametersString;
+
+ public void setClientConverterClassName(String clientConverterClassName) {
+ this.clientConverterClassName = clientConverterClassName;
+ }
+
+ public String getClientConverterClassName() {
+ return clientConverterClassName;
+ }
+
+ public void setConverterId(String converterId) {
+ this.converterId = converterId;
+ }
+
+ public String getSubmittedValue() {
+ return submittedValue;
+ }
+
+ public String getSubmittedValueAsScript() {
+ return ScriptUtils.toScript(submittedValue);
+ }
+
+ public String getConversionErrorMessage() {
+ return conversionErrorMessage;
+ }
+
+ public void setConversionErrorMessage(String conversionErrorMessage) {
+ this.conversionErrorMessage = conversionErrorMessage;
+ }
+
+ public void setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ }
+
+ public void setSubmittedValue(String submittedValue) {
+ this.submittedValue = submittedValue;
+ }
+
+ public String getConverterParametersString() {
+ return converterParametersString;
+ }
+
+ public ConverterException getConverterException() {
+ return converterException;
+ }
+
+ private void configure(FacesContext facesContext, Converter converter) {
+ ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
+
+ VariableMapper varMapper = facesContext.getELContext().getVariableMapper();
+ ValueExpression originalExpr = varMapper.resolveVariable(CONVERTER_VAR);
+ try {
+ varMapper.setVariable(CONVERTER_VAR, expressionFactory.createValueExpression(converter, Converter.class));
+
+ for (Entry<String, Object> mapEntry: attributes.entrySet()) {
+
+ String exprString = MessageFormat.format("#'{'{0}.{1}'}'", CONVERTER_VAR, mapEntry.getKey());
+ ValueExpression ve = expressionFactory.createValueExpression(facesContext.getELContext(), exprString, Object.class);
+
+ ve.setValue(facesContext.getELContext(), mapEntry.getValue());
+ }
+ } finally {
+ varMapper.setVariable(CONVERTER_VAR, originalExpr);
+ }
+ }
+
+ private Converter createConverter(FacesContext facesContext) {
+ Converter converter = facesContext.getApplication().createConverter(converterId);
+ configure(facesContext, converter);
+ return converter;
+ }
+
+ private UIComponent createTestComponent() {
+ HtmlInputText testComponent = new HtmlInputText();
+ testComponent.setLabel(TEST_COMPONENT_LABEL);
+ return testComponent;
+ }
+
+ public String getConvertedValueAsScript() {
+ return convertedValueAsScript != null ? convertedValueAsScript : "null";
+ }
+
+ public void init() {
+ if (converterId == null || clientConverterClassName == null) {
+ throw new NullPointerException();
+ }
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Converter converter = createConverter(facesContext);
+ try {
+ Object convertedObject = converter.getAsObject(facesContext, createTestComponent(), submittedValue);
+ convertedValueAsScript = serializeObjectToScript(convertedObject);
+ } catch (ConverterException e) {
+ this.converterException = e;
+ }
+
+ converterParametersString = ScriptUtils.toScript(attributes);
+ }
+ }
+
+ private TestBean testBean;
+
+ private HtmlUnitEnvironment environment;
+
+ private String converterScriptName;
+
+ public BaseConverterTest(String converterScriptName) {
+ this.converterScriptName = converterScriptName;
+ }
+
+ @BeforeTest
+ public void setUp() throws Exception {
+ testBean = new TestBean();
+
+ environment = new HtmlUnitEnvironment();
+ environment.getServer().addResource("/test.xhtml", BaseConverterTest.class.getResource("test.xhtml"));
+ environment.getServer().addResource("/resources/converter.js", converterScriptName);
+ environment.getServer().addWebListener(new ServletRequestListener() {
+
+ public void requestInitialized(ServletRequestEvent sre) {
+ sre.getServletRequest().setAttribute("testBean", testBean);
+ }
+
+ public void requestDestroyed(ServletRequestEvent sre) {
+ }
+ });
+
+ environment.start();
+ }
+
+ @AfterTest
+ public void tearDown() throws Exception {
+ testBean = null;
+
+ environment.release();
+ environment = null;
+ }
+
+ protected String serializeObjectToScript(Object object) {
+ if (object instanceof Date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date) object);
+ calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ return new JSFunction("new Date", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
+ calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE),
+ calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND)).toScript();
+ }
+
+ return ScriptUtils.toScript(object);
+ }
+
+ public void setConversionErrorMessage(String conversionErrorMessage) {
+ testBean.setConversionErrorMessage(conversionErrorMessage);
+ }
+
+ public void setConverterId(String converterId) {
+ testBean.setConverterId(converterId);
+ }
+
+ public void setClientConverterClassName(String clientConverterClassName) {
+ testBean.setClientConverterClassName(clientConverterClassName);
+ }
+
+ public void setAttribute(String name, Object value) {
+ testBean.setAttribute(name, value);
+ }
+
+ public void assertConversionOk(String submittedValue) throws Exception {
+ testBean.setSubmittedValue(submittedValue);
+
+ HtmlPage page = environment.getPage("/test.jsf");
+
+ Assert.assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult conversionMessageResult = page.executeJavaScript("verifyConversion()");
+ if (!ScriptResult.isUndefined(conversionMessageResult)) {
+ Assert.fail(conversionMessageResult.getJavaScriptResult().toString());
+ }
+ }
+
+ public void assertConversionFailure(String submittedValue, String failureMessage) throws Exception {
+ testBean.setSubmittedValue(submittedValue);
+
+ HtmlPage page = environment.getPage("/test.jsf");
+
+ Assert.assertNotNull(testBean.getConverterException());
+ Assert.assertEquals(testBean.getConverterException().getMessage(), failureMessage);
+
+ Assert.assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult conversionErrorResult = page.executeJavaScript("window.conversionError");
+
+ if (ScriptResult.isUndefined(conversionErrorResult)) {
+ Assert.fail("converter has not thrown an error");
+ return;
+ }
+
+ Scriptable conversionError = (Scriptable) conversionErrorResult.getJavaScriptResult();
+ Assert.assertEquals(conversionError.get("message", conversionError), failureMessage);
+
+ }
+
+}
Added: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-10-19 17:11:30 UTC (rev 19606)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.convert.DateTimeConverter;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DateTimeConverterTest extends BaseConverterTest {
+
+ public DateTimeConverterTest() {
+ super("org/richfaces/csv/testConverter.js");
+ }
+
+ @DataProvider(name = "successTest")
+ public Object[][] getSuccessTestData() {
+ return new Object[][]{
+ {"17-10-2010"}
+ };
+ }
+
+ @DataProvider(name = "failuresTest")
+ public Object[][] getFailuresTestData() {
+ return new Object[][]{
+ {"10/17/2010", "Date should be in dd-MM-yyyy format"}
+ };
+ }
+
+ @Test(dataProvider = "successTest")
+ public void testSuccess(String submittedValue) throws Exception {
+ setClientConverterClassName("org.rf.DateTimeConverter");
+ setConverterId(DateTimeConverter.CONVERTER_ID);
+ setAttribute("pattern", "dd-MM-yyyy");
+
+ assertConversionOk(submittedValue);
+ }
+
+ @Test(dataProvider = "failuresTest")
+ public void testFailures(String submittedValue, String conversionErrorMessage) throws Exception {
+ setClientConverterClassName("org.rf.DateTimeConverter");
+ setConverterId(DateTimeConverter.CONVERTER_ID);
+ setAttribute("pattern", "dd-MM-yyyy");
+
+ assertConversionFailure(submittedValue, conversionErrorMessage);
+ }
+}
Added: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/test.xhtml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/test.xhtml (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/test.xhtml 2010-10-19 17:11:30 UTC (rev 19606)
@@ -0,0 +1,38 @@
+<!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:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+<f:view>
+ <f:metadata>
+ <f:event type="preRenderView" listener="#{testBean.init}"/>
+ </f:metadata>
+<h:head>
+ <h:outputScript name="converter.js" />
+</h:head>
+<h:body>
+ <script type="text/javascript">
+ window.expected = #{testBean.convertedValueAsScript};
+
+ try {
+ window.actual = #{testBean.clientConverterClassName}(#{testBean.submittedValueAsScript},
+ "#{testBean.conversionErrorMessage}", #{testBean.converterParametersString});
+ } catch (e) {
+ window.conversionError = e;
+ }
+
+ function verifyConversion() {
+ if (window.conversionError) {
+ return "conversion error caught: " + window.conversionError.message;
+ }
+
+ //TODO - implement equality checking for all supported objects in a proper way
+ if (window.actual != window.expected) {
+ return "expected [" + window.expected + "] but was [" + window.actual + "]";
+ }
+ }
+ </script>
+</h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/testConverter.js
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/testConverter.js (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/convert/testConverter.js 2010-10-19 17:11:30 UTC (rev 19606)
@@ -0,0 +1,6 @@
+window.org = {
+ rf: {
+ DateTimeConverter: function() {
+ }
+ }
+}
\ No newline at end of file
13 years, 8 months