junit.swingui
Class TestTreeModel

java.lang.Object
  extended by junit.swingui.TestTreeModel
All Implemented Interfaces:
TreeModel

 class TestTreeModel
extends Object
implements TreeModel

A tree model for a Test.


Field Summary
private  Hashtable fErrors
           
private  Hashtable fFailures
           
private  Vector fModelListeners
           
private  Test fRoot
           
private  Hashtable fRunTests
           
 
Constructor Summary
TestTreeModel(Test root)
          Constructs a tree model with the given test as its root.
 
Method Summary
(package private)  void addError(Test t)
          Remembers a test error
(package private)  void addFailure(Test t)
          Remembers a test failure
(package private)  void addRunTest(Test t)
          Remembers that a test was run
 void addTreeModelListener(TreeModelListener l)
          adds a TreeModelListener
 int findTest(Test target, Test node, Vector path)
          Finds the path to a test.
 void fireNodeChanged(TreePath path, int index)
          Fires a node changed event
 Object getChild(Object parent, int index)
          Gets the test at the given index
 int getChildCount(Object parent)
          Gets the number of tests.
 int getIndexOfChild(Object parent, Object child)
          Gets the index of a test in a test suite
 Object getRoot()
          Returns the root of the tree
(package private)  boolean isError(Test t)
          Tests whether a test was an error
(package private)  boolean isFailure(Test t)
          Tests whether a test was a failure
 boolean isLeaf(Object node)
          Tests if the test is a leaf.
(package private)  TestSuite isTestSuite(Object node)
          Tests if the node is a TestSuite.
 void removeTreeModelListener(TreeModelListener l)
          Removes a TestModelListener
(package private)  void resetResults()
          Resets the test results
 void valueForPathChanged(TreePath path, Object newValue)
          Called when the value of the model object was changed in the view
(package private)  boolean wasRun(Test t)
          Returns whether a test was run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fRoot

private Test fRoot

fModelListeners

private Vector fModelListeners

fFailures

private Hashtable fFailures

fErrors

private Hashtable fErrors

fRunTests

private Hashtable fRunTests
Constructor Detail

TestTreeModel

public TestTreeModel(Test root)
Constructs a tree model with the given test as its root.

Method Detail

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
adds a TreeModelListener

Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes a TestModelListener

Specified by:
removeTreeModelListener in interface TreeModel

findTest

public int findTest(Test target,
                    Test node,
                    Vector path)
Finds the path to a test. Returns the index of the test in its parent test suite.


fireNodeChanged

public void fireNodeChanged(TreePath path,
                            int index)
Fires a node changed event


getChild

public Object getChild(Object parent,
                       int index)
Gets the test at the given index

Specified by:
getChild in interface TreeModel

getChildCount

public int getChildCount(Object parent)
Gets the number of tests.

Specified by:
getChildCount in interface TreeModel

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Gets the index of a test in a test suite

Specified by:
getIndexOfChild in interface TreeModel

getRoot

public Object getRoot()
Returns the root of the tree

Specified by:
getRoot in interface TreeModel

isLeaf

public boolean isLeaf(Object node)
Tests if the test is a leaf.

Specified by:
isLeaf in interface TreeModel

isTestSuite

TestSuite isTestSuite(Object node)
Tests if the node is a TestSuite.


valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Called when the value of the model object was changed in the view

Specified by:
valueForPathChanged in interface TreeModel

addFailure

void addFailure(Test t)
Remembers a test failure


addError

void addError(Test t)
Remembers a test error


addRunTest

void addRunTest(Test t)
Remembers that a test was run


wasRun

boolean wasRun(Test t)
Returns whether a test was run


isError

boolean isError(Test t)
Tests whether a test was an error


isFailure

boolean isFailure(Test t)
Tests whether a test was a failure


resetResults

void resetResults()
Resets the test results