Author: maksimkaszynski
Date: 2008-03-25 12:17:17 -0400 (Tue, 25 Mar 2008)
New Revision: 7181
Modified:
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-2726
Modified:
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
---
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2008-03-25
16:10:30 UTC (rev 7180)
+++
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2008-03-25
16:17:17 UTC (rev 7181)
@@ -44,6 +44,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.SliderArrowImage;
import org.richfaces.renderkit.html.images.SliderArrowSelectedImage;
@@ -65,7 +66,7 @@
private UIForm form = null;
private UIComponent slider = null;
private UICommand command = null;
- private static Set javaScripts = new HashSet();
+ private static Set<String> javaScripts = new HashSet<String>();
/**
* Create the test case
@@ -177,31 +178,22 @@
assertTrue(link.getAttributeValue("href").contains("css/slider.xcss"));
}
+
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
//System.out.println(page.asXml());
- 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 testImages() throws Exception {