01: /*
02: * Copyright (C) 2006 Rob Manning
03: * manningr@users.sourceforge.net
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree;
20:
21: import java.util.HashMap;
22: import java.util.Map;
23:
24: import net.sourceforge.squirrel_sql.BaseSQuirreLTestCase;
25: import net.sourceforge.squirrel_sql.client.ApplicationManager;
26: import net.sourceforge.squirrel_sql.client.session.ISession;
27: import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
28: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
29: import net.sourceforge.squirrel_sql.test.TestUtil;
30:
31: public class ObjectTreeTest extends BaseSQuirreLTestCase {
32:
33: ObjectTree tree = null;
34: ISession session = null;
35:
36: public static void main(String[] args) {
37:
38: junit.textui.TestRunner.run(ObjectTreeTest.class);
39: }
40:
41: protected void setUp() throws Exception {
42: super .setUp();
43: ApplicationManager.initApplication();
44: session = TestUtil.getEasyMockSession("Oracle");
45: tree = new ObjectTree(session);
46: }
47:
48: protected void tearDown() throws Exception {
49: super .tearDown();
50: }
51:
52: /**
53: * A test to check that the tree can correctly find a previously-selected
54: * node when row counts are being shown and the node's row count has
55: * changed (i.e. the user added or deleted records)
56: */
57: public void testMatchKeyPrefixDeletedRows() {
58: Map<String, Object> map = new HashMap<String, Object>();
59: String tableKey = "table(100)";
60: map.put(tableKey, null);
61:
62: IDatabaseObjectInfo dbInfo = TestUtil
63: .getEasyMockDatabaseObjectInfo("catalog", "schema",
64: "table", "schema.table",
65: DatabaseObjectType.TABLE);
66: ObjectTreeNode node = new ObjectTreeNode(session, dbInfo);
67:
68: // Test to see that table(100) matches table(0). It should since only
69: // the row count is different.
70: assertEquals(true, tree.matchKeyPrefix(map, node, "table(0)"));
71:
72: // Test to see if we can fool matchKeyPrefix into assuming that there
73: // will be '(' on the end of the path since row count is enabled. Yet
74: // we'll send in a string that doesn't have this characteristic.
75: assertEquals(true, tree.matchKeyPrefix(map, node, "table"));
76:
77: }
78:
79: }
|