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 TestUpdatingList extends TestCase {
25: private BaseListModel baseListModel;
26: private ListSearcher listSearcher;
27:
28: RestaurantInfo infoToAdd1, infoToAdd2;
29:
30: protected void setUp() throws Exception {
31: baseListModel = new BaseListModel(DataStore.getRestaurants());
32: listSearcher = new ListSearcher(baseListModel);
33:
34: infoToAdd1 = new RestaurantInfo();
35: infoToAdd1.setName("Pino's");
36:
37: infoToAdd2 = new RestaurantInfo();
38: infoToAdd2.setName("Pino's");
39: infoToAdd2.setType("Italian");
40: }
41:
42: public void testAddWithoutSearch() {
43: assertEquals(baseListModel.getSize(), listSearcher.getSize());
44: int count = listSearcher.getSize();
45: baseListModel.addRow(infoToAdd1);
46: count++;
47: assertEquals(count, listSearcher.getSize());
48: }
49:
50: public void testRemoveWithoutSearch() {
51: assertEquals(baseListModel.getSize(), listSearcher.getSize());
52: baseListModel.addRow(infoToAdd1);
53: int count = listSearcher.getSize();
54: baseListModel.removeRow(infoToAdd1);
55: count--;
56: assertEquals(count, listSearcher.getSize());
57: }
58:
59: public void testAddWithSearch() {
60: assertEquals(baseListModel.getSize(), listSearcher.getSize());
61: listSearcher.search("pino's");
62: int count = listSearcher.getSize();
63: baseListModel.addRow(infoToAdd2);
64: count++;
65: assertEquals(count, listSearcher.getSize());
66: }
67:
68: public void testRemoveWithSearch() {
69: assertEquals(baseListModel.getSize(), listSearcher.getSize());
70: baseListModel.addRow(infoToAdd1);
71: listSearcher.search("pino's");
72: int count = listSearcher.getSize();
73: baseListModel.removeRow(infoToAdd1);
74: count--;
75: assertEquals(count, listSearcher.getSize());
76: }
77:
78: }
|