[richfaces-svn-commits] JBoss Rich Faces SVN: r421 - in trunk/richfaces/tree/src/test/java/org/richfaces/component: state and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sat Apr 14 07:59:48 EDT 2007


Author: nbelaevski
Date: 2007-04-14 07:59:48 -0400 (Sat, 14 Apr 2007)
New Revision: 421

Added:
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java
Log:
Tree state events tests added

Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java	                        (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java	2007-04-14 11:59:48 UTC (rev 421)
@@ -0,0 +1,99 @@
+/**
+ * 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.state.events;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIOutput;
+import javax.faces.event.FacesListener;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 14.04.2007
+ * 
+ */
+public class CollapseAllCommandEventTest extends TestCase {
+
+	private CollapseAllCommandEvent event;
+	/**
+	 * @param name
+	 */
+	public CollapseAllCommandEventTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		this.event = new CollapseAllCommandEvent(new UIOutput());
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+
+		this.event = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#isAppropriateListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testIsAppropriateListenerFacesListener() {
+		assertTrue((event.isAppropriateListener(new MockTreeStateCommandsListener())));
+		assertFalse((event.isAppropriateListener(new FacesListener() {
+			
+		})));
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerFacesListener() {
+		MockTreeStateCommandsListener listener = new MockTreeStateCommandsListener();
+		
+		event.processListener(listener);
+		assertTrue(listener.isCollapseAll());
+		assertFalse(listener.isExpandAll());
+		assertNull(listener.getExpandNode());
+		assertNull(listener.getCollapseNode());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerExceptionHandle() {
+		MockTreeStateCommandsListener listener = new MockExceptionTreeStateCommandsListener();
+		
+		try {
+			event.processListener(listener);
+
+			fail();
+		} catch (FacesException e) {
+		}
+	}
+}

Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java	                        (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java	2007-04-14 11:59:48 UTC (rev 421)
@@ -0,0 +1,113 @@
+/**
+ * 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.state.events;
+
+import java.util.ArrayList;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIOutput;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.component.ListRowKey;
+import org.richfaces.component.TreeRowKey;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 14.04.2007
+ * 
+ */
+public class CollapseNodeCommandEventTest extends TestCase {
+
+	private CollapseNodeCommandEvent event;
+	private TreeRowKey treeRowKey;
+	
+	/**
+	 * @param name
+	 */
+	public CollapseNodeCommandEventTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		ArrayList keyBase = new ArrayList();
+		keyBase.add("string");
+		keyBase.add(new Object());
+		keyBase.add(new Long(-17));
+
+		this.treeRowKey = new ListRowKey(keyBase);
+		this.event = new CollapseNodeCommandEvent(new UIOutput(), treeRowKey);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+
+		this.event = null;
+		this.treeRowKey = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#isAppropriateListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testIsAppropriateListenerFacesListener() {
+		assertTrue((event.isAppropriateListener(new MockTreeStateCommandsListener())));
+		assertFalse((event.isAppropriateListener(new FacesListener() {
+			
+		})));
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerFacesListener() {
+		MockTreeStateCommandsListener listener = new MockTreeStateCommandsListener();
+		
+		event.processListener(listener);
+		assertSame(treeRowKey, listener.getCollapseNode());
+		assertFalse(listener.isExpandAll());
+		assertFalse(listener.isCollapseAll());
+		assertNull(listener.getExpandNode());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerExceptionHandle() {
+		MockTreeStateCommandsListener listener = new MockExceptionTreeStateCommandsListener();
+		
+		try {
+			event.processListener(listener);
+
+			fail();
+		} catch (FacesException e) {
+		}
+	}
+}

Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java	                        (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java	2007-04-14 11:59:48 UTC (rev 421)
@@ -0,0 +1,99 @@
+/**
+ * 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.state.events;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIOutput;
+import javax.faces.event.FacesListener;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 14.04.2007
+ * 
+ */
+public class ExpandAllCommandEventTest extends TestCase {
+
+	private ExpandAllCommandEvent event;
+	/**
+	 * @param name
+	 */
+	public ExpandAllCommandEventTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		this.event = new ExpandAllCommandEvent(new UIOutput());
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+
+		this.event = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#isAppropriateListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testIsAppropriateListenerFacesListener() {
+		assertTrue((event.isAppropriateListener(new MockTreeStateCommandsListener())));
+		assertFalse((event.isAppropriateListener(new FacesListener() {
+			
+		})));
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerFacesListener() {
+		MockTreeStateCommandsListener listener = new MockTreeStateCommandsListener();
+		
+		event.processListener(listener);
+		assertTrue(listener.isExpandAll());
+		assertFalse(listener.isCollapseAll());
+		assertNull(listener.getExpandNode());
+		assertNull(listener.getCollapseNode());
+	}
+	
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerExceptionHandle() {
+		MockTreeStateCommandsListener listener = new MockExceptionTreeStateCommandsListener();
+		
+		try {
+			event.processListener(listener);
+
+			fail();
+		} catch (FacesException e) {
+		}
+	}
+}

Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java	                        (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java	2007-04-14 11:59:48 UTC (rev 421)
@@ -0,0 +1,113 @@
+/**
+ * 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.state.events;
+
+import java.util.ArrayList;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIOutput;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.component.ListRowKey;
+import org.richfaces.component.TreeRowKey;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 14.04.2007
+ * 
+ */
+public class ExpandNodeCommandEventTest extends TestCase {
+
+	private ExpandNodeCommandEvent event;
+	private TreeRowKey treeRowKey;
+
+	/**
+	 * @param name
+	 */
+	public ExpandNodeCommandEventTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		ArrayList keyBase = new ArrayList();
+		keyBase.add("string");
+		keyBase.add(new Object());
+		keyBase.add(new Long(-17));
+
+		this.treeRowKey = new ListRowKey(keyBase);
+		this.event = new ExpandNodeCommandEvent(new UIOutput(), treeRowKey);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+
+		this.event = null;
+		this.treeRowKey = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#isAppropriateListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testIsAppropriateListenerFacesListener() {
+		assertTrue((event.isAppropriateListener(new MockTreeStateCommandsListener())));
+		assertFalse((event.isAppropriateListener(new FacesListener() {
+			
+		})));
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerFacesListener() {
+		MockTreeStateCommandsListener listener = new MockTreeStateCommandsListener();
+		
+		event.processListener(listener);
+		assertSame(treeRowKey, listener.getExpandNode());
+		assertFalse(listener.isExpandAll());
+		assertFalse(listener.isCollapseAll());
+		assertNull(listener.getCollapseNode());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.component.state.events.TreeStateCommandEvent#processListener(javax.faces.event.FacesListener)}.
+	 */
+	public final void testProcessListenerExceptionHandle() {
+		MockTreeStateCommandsListener listener = new MockExceptionTreeStateCommandsListener();
+		
+		try {
+			event.processListener(listener);
+
+			fail();
+		} catch (FacesException e) {
+		}
+	}
+}

Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java	                        (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java	2007-04-14 11:59:48 UTC (rev 421)
@@ -0,0 +1,92 @@
+/**
+ * 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.state.events;
+
+import java.io.IOException;
+
+import org.richfaces.component.TreeRowKey;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 14.04.2007
+ * 
+ */
+class MockTreeStateCommandsListener implements TreeStateCommandsListener {
+
+	private boolean collapseAll;
+	private boolean expandAll;
+	private TreeRowKey collapseNode;
+	private TreeRowKey expandNode;
+
+	public void collapseAll() throws IOException {
+		this.collapseAll = true;
+	}
+
+	public void collapseNode(TreeRowKey rowKey) throws IOException {
+		this.collapseNode = rowKey;
+	}
+
+	public void expandAll() throws IOException {
+		this.expandAll = true;
+	}
+
+	public void expandNode(TreeRowKey rowKey) throws IOException {
+		this.expandNode = rowKey;
+	}
+
+	public boolean isCollapseAll() {
+		return collapseAll;
+	}
+
+	public boolean isExpandAll() {
+		return expandAll;
+	}
+
+	public TreeRowKey getCollapseNode() {
+		return collapseNode;
+	}
+
+	public TreeRowKey getExpandNode() {
+		return expandNode;
+	}
+
+}
+
+class MockExceptionTreeStateCommandsListener extends MockTreeStateCommandsListener {
+
+	public void collapseAll() throws IOException {
+		throw new IOException();
+	}
+
+	public void collapseNode(TreeRowKey rowKey) throws IOException {
+		throw new IOException();
+	}
+
+	public void expandAll() throws IOException {
+		throw new IOException();
+	}
+
+	public void expandNode(TreeRowKey rowKey) throws IOException {
+		throw new IOException();
+	}
+	
+}




More information about the richfaces-svn-commits mailing list