Author: mgrigorov
Date: Wed Oct  6 19:04:23 2010
New Revision: 1005205

URL: http://svn.apache.org/viewvc?rev=1005205&view=rev
Log:
WICKET-2888 Nullpointer when inserting [i.e. moving] a node in a TreeTable 
(AbstactTree, treeNodesInserted)

Add tests provided by Pedro Santos


Added:
    
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/
    
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java
   (with props)
    
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html
   (with props)
    
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java
   (with props)

Added: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java?rev=1005205&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java
 Wed Oct  6 19:04:23 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.extensions.markup.html.tree;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Try to move the c3 node to the c2 at the described tree model:
+ * 
+ * - c1
+ * 
+ * - c2
+ * 
+ * - - cc2
+ * 
+ * - c3
+ * 
+ * @see http://issues.apache.org/jira/browse/WICKET-2888
+ */
+public class MoveChildToParentNodeMarkedForRecreationTest extends TestCase
+{
+       public void test()
+       {
+               WicketTester tester = new WicketTester();
+               
tester.startPage(MoveChildToParentNodeMarkedForRecreationTestPage.class);
+               tester.clickLink("moveC3ToC2");
+       }
+}

Propchange: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html?rev=1005205&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html
 Wed Oct  6 19:04:23 2010
@@ -0,0 +1,23 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+        http://www.apache.org/licenses/LICENSE-2.0
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<a wicket:id="moveC3ToC2">moveC3ToC2</a>
+<div wicket:id="tree"></div>
+</body>
+</html>
\ No newline at end of file

Propchange: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java?rev=1005205&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java
 Wed Oct  6 19:04:23 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.extensions.markup.html.tree;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebPage;
+
+public class MoveChildToParentNodeMarkedForRecreationTestPage extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       private final Tree treeTable;
+       private DefaultMutableTreeNode c2;
+       private DefaultMutableTreeNode c3;
+
+       public MoveChildToParentNodeMarkedForRecreationTestPage()
+       {
+               treeTable = new Tree("tree", getTreeModel());
+               treeTable.getTreeState().expandAll();
+               add(treeTable);
+               add(new AjaxLink("moveC3ToC2")
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public void onClick(AjaxRequestTarget target)
+                       {
+                               treeTable.modelChanging();
+                               DefaultTreeModel model = 
(DefaultTreeModel)treeTable.getDefaultModelObject();
+                               model.removeNodeFromParent(c3);
+                               model.insertNodeInto(c3, c2, 
model.getChildCount(c2));
+                               treeTable.modelChanged();
+                               treeTable.nodeSelected(c2);
+                               treeTable.updateTree(target);
+                       }
+               });
+       }
+
+       private javax.swing.tree.TreeModel getTreeModel()
+       {
+               DefaultMutableTreeNode root = new 
DefaultMutableTreeNode("root");
+               DefaultMutableTreeNode c1 = new DefaultMutableTreeNode("c1");
+               c2 = new DefaultMutableTreeNode("c2");
+               c3 = new DefaultMutableTreeNode("c3");
+               DefaultMutableTreeNode cc2 = new DefaultMutableTreeNode("cc2");
+               DefaultTreeModel model = new DefaultTreeModel(root);
+               model.insertNodeInto(c1, root, 0);
+               model.insertNodeInto(c2, root, 1);
+               model.insertNodeInto(cc2, c2, 0);
+               model.insertNodeInto(c3, root, 2);
+               return model;
+       }
+
+
+}

Propchange: 
wicket/branches/wicket-1.4.x/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTestPage.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to