01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.ui.tests.search;
11:
12: import junit.framework.Test;
13: import junit.framework.TestSuite;
14: import org.eclipse.search2.internal.ui.InternalSearchUI;
15:
16: import org.eclipse.jdt.ui.leaktest.LeakTestCase;
17: import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
18:
19: import org.eclipse.jdt.internal.ui.search.JavaSearchQuery;
20: import org.eclipse.jdt.internal.ui.search.JavaSearchResult;
21:
22: /**
23: */
24: public class SearchLeakTest extends LeakTestCase {
25: public SearchLeakTest(String name) {
26: super (name);
27: }
28:
29: public static Test allTests() {
30: return new LeakTestSetup(new JUnitSourceSetup(new TestSuite(
31: SearchLeakTest.class)));
32: }
33:
34: public static Test suite() {
35: return allTests();
36: }
37:
38: public void testRemoveSearchQueries() throws Exception {
39: JavaSearchQuery query1 = SearchTestHelper
40: .runMethodRefQuery("junit.framework.Test",
41: "countTestCases", new String[0]);
42: JavaSearchQuery query2 = SearchTestHelper.runMethodRefQuery(
43: "junit.framework.TestCase", "countTestCases",
44: new String[0]);
45: InternalSearchUI.getInstance().removeQuery(query1);
46: InternalSearchUI.getInstance().removeQuery(query2);
47: query1 = null;
48: query2 = null;
49: assertEquals(0, getInstanceCount(JavaSearchResult.class));
50: }
51:
52: public void testRemoveAllQueries() throws Exception {
53: SearchTestHelper.runMethodRefQuery("junit.framework.Test",
54: "countTestCases", new String[0]);
55: SearchTestHelper.runMethodRefQuery("junit.framework.TestCase",
56: "countTestCases", new String[0]);
57: InternalSearchUI.getInstance().removeAllQueries();
58: assertEquals(0, getInstanceCount(JavaSearchResult.class));
59: }
60: }
|