01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Anton Avtamonov
19: * @version $Revision$
20: */package javax.swing.event;
21:
22: import javax.swing.BasicSwingTestCase;
23: import javax.swing.table.DefaultTableModel;
24: import javax.swing.table.TableModel;
25:
26: public class TableModelEventTest extends BasicSwingTestCase {
27: private TableModelEvent event;
28:
29: public TableModelEventTest(final String name) {
30: super (name);
31: }
32:
33: @Override
34: protected void tearDown() throws Exception {
35: event = null;
36: }
37:
38: public void testTableModelEvent() throws Exception {
39: TableModel model = new DefaultTableModel();
40: event = new TableModelEvent(model);
41: assertEquals(model, event.getSource());
42: assertEquals(0, event.getFirstRow());
43: assertEquals(Integer.MAX_VALUE, event.getLastRow());
44: assertEquals(TableModelEvent.ALL_COLUMNS, event.getColumn());
45: assertEquals(TableModelEvent.UPDATE, event.getType());
46: event = new TableModelEvent(model, 3);
47: assertEquals(model, event.getSource());
48: assertEquals(3, event.getFirstRow());
49: assertEquals(3, event.getLastRow());
50: assertEquals(TableModelEvent.ALL_COLUMNS, event.getColumn());
51: assertEquals(TableModelEvent.UPDATE, event.getType());
52: event = new TableModelEvent(model, 6, 2);
53: assertEquals(model, event.getSource());
54: assertEquals(6, event.getFirstRow());
55: assertEquals(2, event.getLastRow());
56: assertEquals(TableModelEvent.ALL_COLUMNS, event.getColumn());
57: assertEquals(TableModelEvent.UPDATE, event.getType());
58: event = new TableModelEvent(model, 6, 2, 5);
59: assertEquals(model, event.getSource());
60: assertEquals(6, event.getFirstRow());
61: assertEquals(2, event.getLastRow());
62: assertEquals(5, event.getColumn());
63: assertEquals(TableModelEvent.UPDATE, event.getType());
64: event = new TableModelEvent(model, 6, 2, 5,
65: TableModelEvent.INSERT);
66: assertEquals(model, event.getSource());
67: assertEquals(6, event.getFirstRow());
68: assertEquals(2, event.getLastRow());
69: assertEquals(5, event.getColumn());
70: assertEquals(TableModelEvent.INSERT, event.getType());
71: }
72: }
|