Author: A.Skokov
Date: 2007-04-04 09:38:01 -0400 (Wed, 04 Apr 2007)
New Revision: 269
Removed:
trunk/richfaces/suggestionbox/src/test/resources/
Modified:
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java
Log:
test updated
Modified:
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
===================================================================
---
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-04-04
13:24:46 UTC (rev 268)
+++
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-04-04
13:38:01 UTC (rev 269)
@@ -28,11 +28,10 @@
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.html.HtmlSuggestionBox;
-import org.richfaces.renderkit.html.SuggestionBoxRenderer;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlForm;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -42,21 +41,21 @@
* Unit test for SuggestionBox component.
*/
public class SuggestionBoxComponentTest extends AbstractAjax4JsfTestCase {
- static Set sbScripts = new HashSet();
+ private static Set javaScripts = new HashSet();
static {
- sbScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- sbScripts.add("prototype.js");
- sbScripts.add("org.ajax4jsf.framework.resource.SmartPositionScript");
- sbScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
- sbScripts.add("org/richfaces/renderkit/html/scripts/scriptaculo.js");
-
sbScripts.add("org/richfaces/renderkit/html/scripts/suggestionbox.js");
-
sbScripts.add("org/richfaces/renderkit/html/scripts/suggestionbox.js");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("prototype.js");
+
javaScripts.add("org.ajax4jsf.framework.resource.SmartPositionScript");
+
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
+
javaScripts.add("org/richfaces/renderkit/html/scripts/scriptaculo.js");
+
javaScripts.add("org/richfaces/renderkit/html/scripts/suggestionbox.js");
+
javaScripts.add("org/richfaces/renderkit/html/scripts/suggestionbox.js");
}
- HtmlSuggestionBox sb;
- UIComponent form;
- UIComponent input;
+ private HtmlSuggestionBox sb;
+ private UIInput input;
+ private UIForm form;
/**
* Create the test case
@@ -70,19 +69,17 @@
public void setUp() throws Exception {
super.setUp();
- form = createComponent(UIForm.COMPONENT_TYPE, UIForm.class.getName(), null, null,
null);
- input = createComponent(HtmlInputText.COMPONENT_TYPE,
HtmlInputText.class.getName(), null, null, null);
-
+ form = new HtmlForm();
form.setId("form");
- input.setId("text");
facesContext.getViewRoot().getChildren().add(form);
+ input = new UIInput();
+ input.setId("text");
form.getChildren().add(input);
- sb = new HtmlSuggestionBox();
+ sb =
(HtmlSuggestionBox)application.createComponent(HtmlSuggestionBox.COMPONENT_TYPE);
sb.setId("suggestionBox");
sb.setFor(input.getId());
- renderKit.addRenderer(HtmlSuggestionBox.COMPONENT_FAMILY,
HtmlSuggestionBox.COMPONENT_TYPE, new SuggestionBoxRenderer());
form.getChildren().add(sb);
}
@@ -95,7 +92,7 @@
}
/**
- * Rigourous Test :-)
+ * Test component rendering
*
* @throws Exception
*/
@@ -103,10 +100,15 @@
HtmlPage page = renderView();
Assert.assertNotNull(page);
System.out.println(page.asXml());
+
HtmlElement div = page.getHtmlElementById(form.getId() + ":" +
sb.getId());
Assert.assertNotNull(div);
Assert.assertEquals("div", div.getNodeName());
- Assert.assertEquals("dr-sb-common-container rich-sb-common-container",
div.getAttributeValue("class"));
+
+ String classAttr = div.getAttributeValue("class");
+ Assert.assertTrue(classAttr.contains("dr-sb-common-container"));
+ Assert.assertTrue(classAttr.contains("rich-sb-common-container"));
+
HtmlElement table = page.getHtmlElementById(form.getId() + ":" +
sb.getId() + ":suggest");
Assert.assertNotNull(table);
Assert.assertEquals("table", table.getNodeName());
@@ -116,7 +118,7 @@
}
/**
- * Rigourous Test :-)
+ * Test style rendering
*
* @throws Exception
*/
@@ -130,7 +132,7 @@
}
/**
- * Rigourous Test :-)
+ * Test script rendering
*
* @throws Exception
*/
@@ -144,7 +146,7 @@
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = sbScripts.iterator(); srcIt.hasNext();) {
+ for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
String src = (String) srcIt.next();
found = srcAttr.contains(src);
Modified:
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java
===================================================================
---
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java 2007-04-04
13:24:46 UTC (rev 268)
+++
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java 2007-04-04
13:38:01 UTC (rev 269)
@@ -39,7 +39,12 @@
super.tearDown();
}
- public void testSaveStateFacesContext() {
+ /**
+ * Test save/restore state
+ *
+ * @throws Exception
+ */
+ public void testSaveStateFacesContext() throws Exception {
HtmlSuggestionBox htmlSuggestionBox = new HtmlSuggestionBox();
htmlSuggestionBox.setStyleClass("styleClass");
htmlSuggestionBox.setSelectedClass("selectedClass");
Show replies by date