01: package abbot.tester;
02:
03: import java.awt.Point;
04: import javax.swing.JTable;
05:
06: import junit.extensions.abbot.TestHelper;
07: import junit.framework.TestCase;
08:
09: public class JTableLocationTest extends TestCase {
10:
11: public void testParsePoint() {
12: JTableLocation loc = new JTableLocation();
13: String parse = "(1,1)";
14: assertEquals("Badly parsed: " + parse, new JTableLocation(
15: new Point(1, 1)), loc.parse(parse));
16: }
17:
18: public void testParseCell() {
19: JTableLocation loc = new JTableLocation();
20: String parse = "[1,2]";
21: assertEquals("Badly parsed: " + parse,
22: new JTableLocation(1, 2), loc.parse(parse));
23: parse = " [ 10 , 20 ] ";
24: assertEquals("Badly parsed: " + parse, new JTableLocation(10,
25: 20), loc.parse(parse));
26: }
27:
28: public void testParseValue() {
29: JTableLocation loc = new JTableLocation();
30: String parse = "\"some value\"";
31: assertEquals("Badly parsed: " + parse, new JTableLocation(parse
32: .substring(1, parse.length() - 1)), loc.parse(parse));
33: }
34:
35: public void testLookupNonexistentValue() {
36: JTableLocation loc = new JTableLocation("green");
37: try {
38: String[][] data = new String[][] { { "0 one", "0 two", },
39: { "1 one", "1 two", }, };
40: String[] names = { "one", "two", };
41: loc.getPoint(new JTable(data, names));
42: fail("Exception should be thrown when value does not exist");
43: } catch (LocationUnavailableException e) {
44: }
45: }
46:
47: public void testLookupNonexistentCell() {
48: JTableLocation loc = new JTableLocation(10, 10);
49: try {
50: String[][] data = new String[][] { { "0 one", "0 two", },
51: { "1 one", "1 two", }, };
52: String[] names = { "one", "two", };
53: loc.getPoint(new JTable(data, names));
54: fail("Exception should be thrown when cell does not exist");
55: } catch (LocationUnavailableException e) {
56: }
57: }
58:
59: public JTableLocationTest(String name) {
60: super (name);
61: }
62:
63: public static void main(String[] args) {
64: TestHelper.runTests(args, JTableLocationTest.class);
65: }
66: }
|