[richfaces-svn-commits] JBoss Rich Faces SVN: r339 - in trunk/richfaces/gmap/src: test/java/org/richfaces/component and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Tue Apr 10 09:31:14 EDT 2007
Author: sergeyhalipov
Date: 2007-04-10 09:31:14 -0400 (Tue, 10 Apr 2007)
New Revision: 339
Added:
trunk/richfaces/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java
Removed:
trunk/richfaces/gmap/src/test/java/org/richfaces/component/JSFComponentTest.java
Modified:
trunk/richfaces/gmap/src/main/java/org/richfaces/component/UIGmap.java
Log:
JUnit tests for gmap component.
Modified: trunk/richfaces/gmap/src/main/java/org/richfaces/component/UIGmap.java
===================================================================
--- trunk/richfaces/gmap/src/main/java/org/richfaces/component/UIGmap.java 2007-04-10 13:02:07 UTC (rev 338)
+++ trunk/richfaces/gmap/src/main/java/org/richfaces/component/UIGmap.java 2007-04-10 13:31:14 UTC (rev 339)
@@ -29,7 +29,7 @@
*/
public abstract class UIGmap extends UIComponentBase {
- private static final String COMPONENT_TYPE = "org.richfaces.Gmap";
+ public static final String COMPONENT_TYPE = "org.richfaces.Gmap";
private static final String COMPONENT_FAMILY = "org.richfaces.Gmap";
Copied: trunk/richfaces/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java (from rev 332, trunk/richfaces/gmap/src/test/java/org/richfaces/component/JSFComponentTest.java)
===================================================================
--- trunk/richfaces/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java (rev 0)
+++ trunk/richfaces/gmap/src/test/java/org/richfaces/component/GmapComponentTest.java 2007-04-10 13:31:14 UTC (rev 339)
@@ -0,0 +1,145 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.html.DomNode;
+import com.gargoylesoftware.htmlunit.html.DomText;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+/**
+ * Unit test for simple Component.
+ */
+public class GmapComponentTest extends AbstractAjax4JsfTestCase {
+ private UIForm form = null;
+ private UIComponent gmap = null;
+ private static Set javaScripts = new HashSet();
+
+ private final static String TEST_STYLE = "width:500px; height:400px";
+
+ static {
+ javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("script/gmap.js");
+ javaScripts.add("http://maps.google.com");
+ }
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public GmapComponentTest( String testName )
+ {
+ super( testName );
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ form = new HtmlForm();
+ facesContext.getViewRoot().getChildren().add(form);
+
+ gmap = application.createComponent(UIGmap.COMPONENT_TYPE);
+ gmap.setId("gmap");
+
+ gmap.getAttributes().put("style", TEST_STYLE);
+ gmap.getAttributes().put("showGLargeMapControl", "true");
+ gmap.getAttributes().put("showGMapTypeControl", "true");
+ gmap.getAttributes().put("gmapVar", "testGmap");
+
+ form.getChildren().add(gmap);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ gmap = null;
+ form = null;
+ }
+
+ public void testRendcerComponent() throws Exception {
+ HtmlPage renderedView = renderView();
+
+ HtmlElement htmlGmap = renderedView.getHtmlElementById(gmap.getClientId(facesContext));
+
+ assertNotNull(htmlGmap);
+ assertTrue("div".equals(htmlGmap.getTagName()));
+ assertEquals(htmlGmap.getAttributeValue("style"), TEST_STYLE);
+
+ assertTrue(htmlGmap.getAttributeValue("class").contains("dr-gmap"));
+ assertTrue(htmlGmap.getAttributeValue("class").contains("rich-gmap"));
+
+ }
+
+ public void testRenderStyle() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List links = page.getDocumentElement().getHtmlElementsByTagName("link");
+ assertEquals(1, links.size());
+
+ HtmlElement link = (HtmlElement) links.get(0);
+ assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/gmap.xcss"));
+ }
+
+ 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);
+ }
+ }
+ }
+
+}
Deleted: trunk/richfaces/gmap/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/gmap/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-10 13:02:07 UTC (rev 338)
+++ trunk/richfaces/gmap/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-10 13:31:14 UTC (rev 339)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class JSFComponentTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public JSFComponentTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
More information about the richfaces-svn-commits
mailing list