-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b80
-
generic
-
generic
In spec there is written:
public void rowsInserted(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model after the change, or firstRow > endRow
-------------------------------------
public void rowsDeleted(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model, or firstRow > endRow
--------------------------------------
public void rowsUpdated(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model, or firstRow > endRow
But methods don't throw IOBException:
-------------CODE------------------------
import javax.swing.table.TableRowSorter;
import javax.swing.table.DefaultTableModel;
import javax.swing.DefaultRowSorter;
public class TT {
public static void main(String[] args) {
TT t = new TT();
System.out.println(t.test()? "Test PASSED": "Test FAILED");
}
private boolean exceptionTest(DefaultRowSorter rs, int firstRow,
int endRow) {
String ms = firstRow + ", " + endRow + ") IOBException expected";
try {
rs.rowsInserted(firstRow, endRow);
System.out.println("rs.rowsInserted(" + ms);
rs.rowsDeleted(firstRow, endRow);
System.out.println("rs.rowsDeleted(" + ms);
rs.rowsUpdated(firstRow, endRow);
System.out.println("rs.rowsUpdated(" + ms);
return false;
} catch (IndexOutOfBoundsException e) {
return true;
}
}
public boolean test() {
boolean passed = true;
DefaultRowSorter rs = new TableRowSorter<DefaultTableModel>(
new DefaultTableModel(5, 5));
int[][] tests = {
{4, 2}, // firstRow > endRow
{4, 100}, // endRow > 5
{4, -8}, // endRow < 0
{100, 4}, // firstRow > 5
{-8, 4}, // firstRow < 0
{100, 100} // first, endRow > 5
};
for(int[] test : tests) {
if(!exceptionTest(rs, test[0], test[1])) {
passed = false;
}
}
return passed;
}
}
-------------OUTPUT----------------------------------
rs.rowsInserted(4, 2) IOBException expected
rs.rowsDeleted(4, 2) IOBException expected
rs.rowsUpdated(4, 2) IOBException expected
rs.rowsInserted(4, 100) IOBException expected
rs.rowsDeleted(4, 100) IOBException expected
rs.rowsUpdated(4, 100) IOBException expected
rs.rowsInserted(4, -8) IOBException expected
rs.rowsDeleted(4, -8) IOBException expected
rs.rowsUpdated(4, -8) IOBException expected
rs.rowsInserted(100, 4) IOBException expected
rs.rowsDeleted(100, 4) IOBException expected
rs.rowsUpdated(100, 4) IOBException expected
rs.rowsInserted(-8, 4) IOBException expected
rs.rowsDeleted(-8, 4) IOBException expected
rs.rowsUpdated(-8, 4) IOBException expected
rs.rowsInserted(100, 100) IOBException expected
rs.rowsDeleted(100, 100) IOBException expected
rs.rowsUpdated(100, 100) IOBException expected
Test FAILED
------------------------------------
The same situation with the
-------------------------------------
public void rowsUpdated(int firstRow,
int endRow,
int column)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model after the change, firstRow > endRow, or column is outside the range of the underlying model
public void rowsInserted(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model after the change, or firstRow > endRow
-------------------------------------
public void rowsDeleted(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model, or firstRow > endRow
--------------------------------------
public void rowsUpdated(int firstRow,
int endRow)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model, or firstRow > endRow
But methods don't throw IOBException:
-------------CODE------------------------
import javax.swing.table.TableRowSorter;
import javax.swing.table.DefaultTableModel;
import javax.swing.DefaultRowSorter;
public class TT {
public static void main(String[] args) {
TT t = new TT();
System.out.println(t.test()? "Test PASSED": "Test FAILED");
}
private boolean exceptionTest(DefaultRowSorter rs, int firstRow,
int endRow) {
String ms = firstRow + ", " + endRow + ") IOBException expected";
try {
rs.rowsInserted(firstRow, endRow);
System.out.println("rs.rowsInserted(" + ms);
rs.rowsDeleted(firstRow, endRow);
System.out.println("rs.rowsDeleted(" + ms);
rs.rowsUpdated(firstRow, endRow);
System.out.println("rs.rowsUpdated(" + ms);
return false;
} catch (IndexOutOfBoundsException e) {
return true;
}
}
public boolean test() {
boolean passed = true;
DefaultRowSorter rs = new TableRowSorter<DefaultTableModel>(
new DefaultTableModel(5, 5));
int[][] tests = {
{4, 2}, // firstRow > endRow
{4, 100}, // endRow > 5
{4, -8}, // endRow < 0
{100, 4}, // firstRow > 5
{-8, 4}, // firstRow < 0
{100, 100} // first, endRow > 5
};
for(int[] test : tests) {
if(!exceptionTest(rs, test[0], test[1])) {
passed = false;
}
}
return passed;
}
}
-------------OUTPUT----------------------------------
rs.rowsInserted(4, 2) IOBException expected
rs.rowsDeleted(4, 2) IOBException expected
rs.rowsUpdated(4, 2) IOBException expected
rs.rowsInserted(4, 100) IOBException expected
rs.rowsDeleted(4, 100) IOBException expected
rs.rowsUpdated(4, 100) IOBException expected
rs.rowsInserted(4, -8) IOBException expected
rs.rowsDeleted(4, -8) IOBException expected
rs.rowsUpdated(4, -8) IOBException expected
rs.rowsInserted(100, 4) IOBException expected
rs.rowsDeleted(100, 4) IOBException expected
rs.rowsUpdated(100, 4) IOBException expected
rs.rowsInserted(-8, 4) IOBException expected
rs.rowsDeleted(-8, 4) IOBException expected
rs.rowsUpdated(-8, 4) IOBException expected
rs.rowsInserted(100, 100) IOBException expected
rs.rowsDeleted(100, 100) IOBException expected
rs.rowsUpdated(100, 100) IOBException expected
Test FAILED
------------------------------------
The same situation with the
-------------------------------------
public void rowsUpdated(int firstRow,
int endRow,
int column)
Throws:
IndexOutOfBoundsException - if either argument is outside the range of the underlying model after the change, firstRow > endRow, or column is outside the range of the underlying model