Author: julien(a)jboss.com
Date: 2008-07-06 16:05:38 -0400 (Sun, 06 Jul 2008)
New Revision: 11304
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildRecursiveTestCase.java
Log:
recursive removal test case
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildRecursiveTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildRecursiveTestCase.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildRecursiveTestCase.java 2008-07-06
20:05:38 UTC (rev 11304)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RemoveChildRecursiveTestCase extends TraversalModelTestCase
+{
+
+ public void testRemoveChild()
+ {
+ test(3, null);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object
handback)
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = fooDef.addChild("bar");
+ NodeDef juuDef = barDef.addChild("juu");
+
+ //
+ fooDef.setTraversal(before[0]);
+ barDef.setTraversal(before[1]);
+ juuDef.setTraversal(before[2]);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+
mockModel.destroy(mockModel.getRoot().getChild("foo").getChild("bar"));
+ fooDef.removeChild("bar");
+
+ //
+ fooDef.setTraversal(after[0]);
+ barDef.setTraversal(after[1]);
+ juuDef.setTraversal(after[2]);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+}
\ No newline at end of file