01: package org.apache.lucene.swing.models;
02:
03: /**
04: * Copyright 2005 The Apache Software Foundation
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import junit.framework.TestCase;
20:
21: /**
22: * @author Jonathan Simon - jonathan_s_simon@yahoo.com
23: */
24: public class TestUpdatingTable extends TestCase {
25: private BaseTableModel baseTableModel;
26: private TableSearcher tableSearcher;
27:
28: RestaurantInfo infoToAdd1, infoToAdd2;
29:
30: protected void setUp() throws Exception {
31: baseTableModel = new BaseTableModel(DataStore.getRestaurants());
32: tableSearcher = new TableSearcher(baseTableModel);
33:
34: infoToAdd1 = new RestaurantInfo();
35: infoToAdd1.setName("Pino's");
36: infoToAdd1.setType("Italian");
37:
38: infoToAdd2 = new RestaurantInfo();
39: infoToAdd2.setName("Pino's");
40: infoToAdd2.setType("Italian");
41: }
42:
43: public void testAddWithoutSearch() {
44: assertEquals(baseTableModel.getRowCount(), tableSearcher
45: .getRowCount());
46: int count = tableSearcher.getRowCount();
47: baseTableModel.addRow(infoToAdd1);
48: count++;
49: assertEquals(count, tableSearcher.getRowCount());
50: }
51:
52: public void testRemoveWithoutSearch() {
53: assertEquals(baseTableModel.getRowCount(), tableSearcher
54: .getRowCount());
55: int count = tableSearcher.getRowCount();
56: baseTableModel.addRow(infoToAdd1);
57: baseTableModel.removeRow(infoToAdd1);
58: assertEquals(count, tableSearcher.getRowCount());
59: }
60:
61: public void testAddWithSearch() {
62: assertEquals(baseTableModel.getRowCount(), tableSearcher
63: .getRowCount());
64: tableSearcher.search("pino's");
65: int count = tableSearcher.getRowCount();
66: baseTableModel.addRow(infoToAdd2);
67: count++;
68: assertEquals(count, tableSearcher.getRowCount());
69: }
70:
71: public void testRemoveWithSearch() {
72: assertEquals(baseTableModel.getRowCount(), tableSearcher
73: .getRowCount());
74: baseTableModel.addRow(infoToAdd1);
75: tableSearcher.search("pino's");
76: int count = tableSearcher.getRowCount();
77: baseTableModel.removeRow(infoToAdd1);
78: count--;
79: assertEquals(count, tableSearcher.getRowCount());
80: }
81:
82: }
|