TreeModelSupport { public void fireTreeStructureChanged(TreePath subTreePath) { if (subTreePath != null) { Contract.asNotNull(subTreePath.getPath(), "path must not contain null elements"); } Object[] pairs = listeners.getListenerList(); TreeModelEvent e = null; for (int i = pairs.length - 2; i >= 0; i -= 2) { if (pairs[i] == TreeModelListener.class) { if (e == null) e = createStructureChangedEvent(subTreePath); ((TreeModelListener) pairs[i + 1]).treeStructureChanged(e); } } } TreeModelSupport(TreeModel model); void fireNewRoot(); void firePathLeafStateChanged(TreePath path); void fireTreeStructureChanged(TreePath subTreePath); void firePathChanged(TreePath path); void fireChildChanged(TreePath parentPath, int index, Object child); void fireChildrenChanged(TreePath parentPath, int[] indices,
            Object[] children); void fireChildAdded(TreePath parentPath, int index, Object child); void fireChildRemoved(TreePath parentPath, int index, Object child); void fireChildrenAdded(TreePath parentPath, int[] indices,
            Object[] children); void fireChildrenRemoved(TreePath parentPath, int[] indices,
            Object[] children); void addTreeModelListener(TreeModelListener l); TreeModelListener[] getTreeModelListeners(); void removeTreeModelListener(TreeModelListener l);  }
@Test public void testTreeStructureChangedNullPath() { support.fireTreeStructureChanged(null); assertEquals(1, report.getEventCount()); assertEquals(1, report.getStructureEventCount()); TreeModelEvent structureEvent = report.getLastStructureEvent(); assertNull(structureEvent.getChildren()); assertNull(structureEvent.getTreePath()); assertNull(structureEvent.getPath()); }
@Test public void testTreeStructureChangedNotNullPathElements() { TreePath path = new TreePath(new Object[] {null}); try { support.fireTreeStructureChanged(path); fail("must not allow null path elements"); } catch (NullPointerException e) { } }
@Test public void testTreeStructureChangedNotNullPath() { Object root = model.getRoot(); Object child = model.getChild(root, 0); TreePath path = new TreePath(new Object[] {root, child}); support.fireTreeStructureChanged(path); assertEquals(1, report.getEventCount()); assertEquals(1, report.getStructureEventCount()); TreeModelEvent structureEvent = report.getLastStructureEvent(); assertEquals(path, structureEvent.getTreePath()); }