[richfaces-svn-commits] JBoss Rich Faces SVN: r308 - in trunk/richfaces/menu-components/src/test/java/org/richfaces: component and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Apr 6 10:16:36 EDT 2007


Author: F.antonov
Date: 2007-04-06 10:16:36 -0400 (Fri, 06 Apr 2007)
New Revision: 308

Added:
   trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
Removed:
   trunk/richfaces/menu-components/src/test/java/org/richfaces/component/html/
   trunk/richfaces/menu-components/src/test/java/org/richfaces/taglib/
Modified:
   trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
Log:
Menu components test cases development.

Added: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java	                        (rev 0)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java	2007-04-06 14:16:36 UTC (rev 308)
@@ -0,0 +1,112 @@
+/**
+ * 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.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlOutputText;
+
+import org.richfaces.component.html.HtmlMenuGroup;
+import org.richfaces.component.html.HtmlMenuItem;
+import org.richfaces.renderkit.html.MenuItemRenderer;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import org.ajax4jsf.framework.renderer.ComponentVariables;
+import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
+
+
+/**
+ * Unit test for MenuGroup Component.
+ */
+public class MenuGroupComponentTest 
+    extends AbstractAjax4JsfTestCase
+{
+	private static Set javaScripts = new HashSet();
+	
+/*	static {		
+        javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript()");
+        javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript()");
+        javaScripts.add("org.ajax4jsf.framework.util.command.CommandScript()");
+	}
+*/	
+	private UIMenuGroup menuGroup;
+	private UIForm form;
+	
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public MenuGroupComponentTest( String testName )
+    {
+        super( testName );
+    }
+    
+    public void setUp() throws Exception {
+    	super.setUp();
+    	
+    	form = new HtmlForm();
+        form.setId("form");
+        facesContext.getViewRoot().getChildren().add(form);
+
+        menuGroup = (HtmlMenuGroup) application.createComponent(HtmlMenuGroup.COMPONENT_TYPE);
+        menuGroup.setId("menuGroup");
+        menuGroup.setValue("Menu Group");
+    	
+		form.getChildren().add(menuGroup);
+    }
+
+    public void tearDown() throws Exception {
+    	super.tearDown();
+    	menuGroup = null;
+    	form = null;
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testMenuGroupRender() throws Exception
+    {
+    	HtmlPage page = renderView();
+        assertNotNull(page);
+        System.out.println(page.asXml());
+        HtmlElement div = page.getHtmlElementById(menuGroup.getClientId(facesContext));
+        assertNotNull(div);
+        assertEquals("div", div.getNodeName());
+    }
+
+}

Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java	2007-04-06 13:56:20 UTC (rev 307)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java	2007-04-06 14:16:36 UTC (rev 308)
@@ -50,7 +50,7 @@
 
 
 /**
- * Unit test for simple Component.
+ * Unit test for MenuItem Component.
  */
 public class MenuItemComponentTest 
     extends AbstractAjax4JsfTestCase
@@ -63,7 +63,7 @@
         javaScripts.add("org.ajax4jsf.framework.util.command.CommandScript()");
 	}
 */	
-	private HtmlMenuItem menuItem;
+	private UIMenuItem menuItem;
 	private UIForm form;
 	
     /**
@@ -104,7 +104,7 @@
     	HtmlPage page = renderView();
         assertNotNull(page);
         System.out.println(page.asXml());
-        HtmlElement div = page.getHtmlElementById(form.getId() + ":" + menuItem.getId());
+        HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
         assertNotNull(div);
         assertEquals("div", div.getNodeName());
     }
@@ -116,7 +116,7 @@
     	HtmlPage page = renderView();
         assertNotNull(page);
         System.out.println(page.asXml());
-        HtmlElement span = page.getHtmlElementById(form.getId() + ":" + menuItem.getId() + ":icon");
+        HtmlElement span = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":icon");
         assertEquals("span", span.getNodeName());
         assertNotNull(span);
     }
@@ -128,19 +128,19 @@
         assertNotNull(page);
         System.out.println(page.asXml());
         
-        HtmlElement span = page.getHtmlElementById(form.getId() + ":" + menuItem.getId() + ":disabled");
+        HtmlElement span = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":disabled");
         assertNotNull(span);
         assertEquals("span", span.getNodeName());        
         String classAttr = span.getAttributeValue("class");
         Assert.assertTrue(classAttr.contains("dr-menu-label dr-menu-label-disabled rich-menu-item-label rich-menu-item-label-disabled"));
         
-        span = page.getHtmlElementById(form.getId() + ":" + menuItem.getId() + ":icon");
+        span = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":icon");
         assertNotNull(span);
         assertEquals("span", span.getNodeName());        
         classAttr = span.getAttributeValue("class");
-        Assert.assertTrue(classAttr.contains("dr-menu-icon dr-menu-icon-disabled rich-menu-item-icon rich-menu-item-icon-disabled"));
+        Assert.assertTrue(classAttr.contains("dr-menu-icon rich-menu-item-icon dr-menu-icon-disabled rich-menu-item-icon-disabled"));
         
-        HtmlElement div = page.getHtmlElementById(form.getId() + ":" + menuItem.getId());
+        HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
         assertNotNull(div);
         assertEquals("div", div.getNodeName());        
         classAttr = div.getAttributeValue("class");
@@ -150,24 +150,25 @@
     public void testEnabledMenuItem() throws Exception
     {
     	assertEquals(false, menuItem.isDisabled());
-    	menuItem.setIconClass("iconClass");
+    	menuItem.getAttributes().put("iconClass", "iconClass");
     	HtmlPage page = renderView();
         assertNotNull(page);
         System.out.println(page.asXml());
         
-        HtmlElement anchor = page.getHtmlElementById(form.getId() + ":" + menuItem.getId() + ":anchor");
+        HtmlElement anchor = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":anchor");
         assertNotNull(anchor);
         assertEquals("a", anchor.getNodeName());        
         String classAttr = anchor.getAttributeValue("class");
         Assert.assertTrue(classAttr.contains("dr-menu-label rich-menu-item-label"));
         
-        HtmlElement span = page.getHtmlElementById(form.getId() + ":" + menuItem.getId() + ":icon");
+        HtmlElement span = page.getHtmlElementById(menuItem.getClientId(facesContext) + ":icon");
         assertNotNull(span);
         assertEquals("span", span.getNodeName());        
         classAttr = span.getAttributeValue("class");
-        Assert.assertTrue(classAttr.contains("dr-menu-icon rich-menu-item-icon " + menuItem.getIconClass()));
+        Assert.assertTrue(classAttr.contains("dr-menu-icon rich-menu-item-icon"));
+        Assert.assertTrue(classAttr.contains((String) menuItem.getAttributes().get("iconClass")));
         
-        HtmlElement div = page.getHtmlElementById(form.getId() + ":" + menuItem.getId());
+        HtmlElement div = page.getHtmlElementById(menuItem.getClientId(facesContext));
         assertNotNull(div);
         assertEquals("div", div.getNodeName());        
         classAttr = div.getAttributeValue("class");
@@ -206,6 +207,6 @@
                 assertTrue(found);
             }
         }
-    }
-*/  
+    }	*/
+  
 }




More information about the richfaces-svn-commits mailing list