TreePath p1B = new TreePath("AA");
TreePath[] p1 = new TreePath[] {p1A, p1B};
TreePath p2 = new TreePath("B");
TreePath p3 = new TreePath("C");
boolean[] b = new boolean[] {true, false};
TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, b, p2, p3);
harness.check(tse.getSource(), m);
harness.check(tse.getPath(), p1A);
harness.check(tse.getPaths().length, 2);
harness.check(tse.getPaths()[0], p1A);
harness.check(tse.getPaths()[1], p1B);
harness.check(tse.isAddedPath(), true);
harness.check(tse.isAddedPath(0), true);
harness.check(tse.isAddedPath(1), false);
harness.check(tse.getOldLeadSelectionPath(), p2);
harness.check(tse.getNewLeadSelectionPath(), p3);
// check null source
boolean pass = false;
try
{
tse = new TreeSelectionEvent(null, p1, b, p2, p3);
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// check null path array
tse = new TreeSelectionEvent(m, null, b, p2, p3);
// ...constructor allows it, but then fails at getPath()
pass = false;
try
{
tse.getPath();
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
tse.getPaths();
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// check null boolean array
tse = new TreeSelectionEvent(m, p1, null, p2, p3);
pass = false;
try
{
tse.isAddedPath();
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
pass = false;
try
{
tse.isAddedPath(0);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// check null old path
tse = new TreeSelectionEvent(m, p1, b, null, p3);
harness.check(tse.getOldLeadSelectionPath(), null);
// check null new path
tse = new TreeSelectionEvent(m, p1, b, p2, null);
harness.check(tse.getNewLeadSelectionPath(), null);
}