Author: maksimkaszynski
Date: 2008-03-25 12:17:52 -0400 (Tue, 25 Mar 2008)
New Revision: 7187
Modified:
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-2726
Modified:
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
---
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2008-03-25
16:17:48 UTC (rev 7186)
+++
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2008-03-25
16:17:52 UTC (rev 7187)
@@ -45,6 +45,7 @@
import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.tests.HtmlTestUtils;
import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.SpinnerButtonDown;
import org.richfaces.renderkit.html.images.SpinnerButtonGradient;
@@ -65,14 +66,13 @@
private UIForm form = null;
private UIComponent spinner = null;
private UICommand command = null;
- private static Set javaScripts = new HashSet();
+ private static Set<String> javaScripts = new HashSet<String>();
static {
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/SpinnerScript.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
- javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
}
/**
@@ -231,27 +231,18 @@
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List scripts = page.getDocumentElement().getHtmlElementsByTagName(
- "script");
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
- String srcAttr = item.getSrcAttribute();
-
- 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);
- }
- }
+
+ List<String> scriptSources = HtmlTestUtils.extractScriptSources(page);
+ for (String javascript : javaScripts) {
+ boolean found = false;
+ for (String script : scriptSources) {
+ if (script.indexOf(javascript) >= 0) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Component script " + javascript + " is not found in
the response", found);
+ }
}
public void testUpdate() throws Exception {