[richfaces-svn-commits] JBoss Rich Faces SVN: r273 - in trunk/richfaces/separator/src/test/java/org/richfaces: component and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Apr 4 10:57:38 EDT 2007
Author: A.Skokov
Date: 2007-04-04 10:57:38 -0400 (Wed, 04 Apr 2007)
New Revision: 273
Added:
trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
trunk/richfaces/separator/src/test/java/org/richfaces/component/html/
trunk/richfaces/separator/src/test/java/org/richfaces/component/html/HtmlSeparatorTest.java
trunk/richfaces/separator/src/test/java/org/richfaces/taglib/
trunk/richfaces/separator/src/test/java/org/richfaces/taglib/SeparatorTagTest.java
Removed:
trunk/richfaces/separator/src/test/java/org/richfaces/component/JSFComponentTest.java
Log:
test for separator added
Deleted: trunk/richfaces/separator/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-04 14:55:32 UTC (rev 272)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-04 14:57:38 UTC (rev 273)
@@ -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 );
- }
-}
Added: trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java (rev 0)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-04-04 14:57:38 UTC (rev 273)
@@ -0,0 +1,115 @@
+/**
+ * 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 com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import junit.framework.Assert;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.component.html.HtmlSeparator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlOutputText;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Unit test for Separator component.
+ */
+public class SeparatorComponentTest extends AbstractAjax4JsfTestCase {
+
+ private HtmlSeparator ui;
+ private UIComponent form;
+ private UIOutput out1;
+ private UIOutput out2;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SeparatorComponentTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+
+ out1 = (UIOutput)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ out1.setValue("output1");
+ form.getChildren().add(out1);
+
+ ui = (HtmlSeparator)application.createComponent(HtmlSeparator.COMPONENT_TYPE);
+ ui.setId("separator");
+ form.getChildren().add(ui);
+
+ out2 = (UIOutput)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ out2.setValue("output2");
+ form.getChildren().add(out2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ ui = null;
+ form = null;
+ out1 = null;
+ out2 = null;
+ }
+
+ /**
+ * Test component rendering
+ *
+ * @throws Exception
+ */
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ Assert.assertNotNull(page);
+ System.out.println(page.asXml());
+
+ HtmlElement div1 = page.getHtmlElementById(form.getId() + ":" + ui.getId());
+ Assert.assertNotNull(div1);
+ Assert.assertEquals("div", div1.getNodeName());
+
+ HtmlElement div2 = (HtmlElement)div1.getHtmlElementsByTagName("div").get(0);
+ String classAttr = div2.getAttributeValue("class");
+ Assert.assertTrue(classAttr.contains("rich-separator"));
+ String styleAttr = div2.getAttributeValue("style");
+ Assert.assertTrue(styleAttr.contains("org.richfaces.renderkit.html.images.BevelSeparatorImage"));
+ }
+}
Added: trunk/richfaces/separator/src/test/java/org/richfaces/component/html/HtmlSeparatorTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/component/html/HtmlSeparatorTest.java (rev 0)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/component/html/HtmlSeparatorTest.java 2007-04-04 14:57:38 UTC (rev 273)
@@ -0,0 +1,68 @@
+/**
+ * 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.html;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import junit.framework.Assert;
+
+/**
+ * Unit test for HtmlSeparator.
+ */
+public class HtmlSeparatorTest extends AbstractAjax4JsfTestCase {
+
+ /**
+ * Create the test case
+ *
+ * @param name name of the test case
+ */
+ public HtmlSeparatorTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test save/restore state
+ *
+ * @throws Exception
+ */
+ public void testSaveStateFacesContext() throws Exception {
+ HtmlSeparator ui = new HtmlSeparator();
+ ui.setStyleClass("styleClass");
+ Object state = ui.saveState(facesContext);
+ HtmlSeparator newDs = new HtmlSeparator();
+ newDs.restoreState(facesContext, state);
+ Assert.assertEquals("styleClass", newDs.getStyleClass());
+ }
+}
Added: trunk/richfaces/separator/src/test/java/org/richfaces/taglib/SeparatorTagTest.java
===================================================================
--- trunk/richfaces/separator/src/test/java/org/richfaces/taglib/SeparatorTagTest.java (rev 0)
+++ trunk/richfaces/separator/src/test/java/org/richfaces/taglib/SeparatorTagTest.java 2007-04-04 14:57:38 UTC (rev 273)
@@ -0,0 +1,98 @@
+/**
+ * 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.taglib;
+
+import junit.framework.Assert;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlSeparator;
+
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * Test for SeparatorTag
+ */
+public class SeparatorTagTest extends AbstractAjax4JsfTestCase {
+
+ SeparatorTag tag;
+
+ /**
+ * Create the test case
+ *
+ * @param name name of the test case
+ */
+ public SeparatorTagTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ tag = new SeparatorTag();
+ tag.setParent(new UIComponentTag(){
+
+ public String getComponentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRendererType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int doStartTag() throws JspException {
+ // TODO Auto-generated method stub
+ return Tag.EVAL_BODY_INCLUDE;
+ }
+
+ public int doEndTag() throws JspException {
+ // TODO Auto-generated method stub
+ return Tag.EVAL_BODY_INCLUDE;
+ }
+
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ tag = null;
+ }
+
+ /**
+ * Test method for {@link org.richfaces.taglib.SeparatorTag#setProperties(javax.faces.component.UIComponent)}.
+ * @throws javax.servlet.jsp.JspException
+ */
+ public void testSetPropertiesUIComponent() throws JspException {
+ HtmlSeparator ui = new HtmlSeparator();
+
+ tag.setStyleClass("styleClass");
+ tag.setProperties(ui);
+ Assert.assertEquals("styleClass", ui.getStyleClass());
+ }
+}
More information about the richfaces-svn-commits
mailing list