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.debug.jdi.tests;
11:
12: import java.util.Iterator;
13: import java.util.List;
14:
15: import com.sun.jdi.ClassLoaderReference;
16: import com.sun.jdi.ReferenceType;
17:
18: /**
19: * Tests for JDI com.sun.jdi.ClassLoaderReference.
20: */
21: public class ClassLoaderReferenceTest extends AbstractJDITest {
22:
23: private ClassLoaderReference fClassLoader;
24:
25: /**
26: * Creates a new test.
27: */
28: public ClassLoaderReferenceTest() {
29: super ();
30: }
31:
32: /**
33: * Init the fields that are used by this test only.
34: */
35: public void localSetUp() {
36: // Get the class loader of org.eclipse.debug.jdi.tests.program.MainClass
37: fClassLoader = getClassLoaderReference();
38: }
39:
40: /**
41: * Run all tests and output to standard output.
42: * @param args
43: */
44: public static void main(java.lang.String[] args) {
45: new ClassLoaderReferenceTest().runSuite(args);
46: }
47:
48: /**
49: * Gets the name of the test case.
50: * @see junit.framework.TestCase#getName()
51: */
52: public String getName() {
53: return "com.sun.jdi.ClassLoaderReference";
54: }
55:
56: /**
57: * Test JDI definedClasses().
58: */
59: public void testJDIDefinedClasses() {
60: Iterator defined = fClassLoader.definedClasses().iterator();
61: int i = 0;
62: while (defined.hasNext())
63: assertTrue(Integer.toString(i++),
64: defined.next() instanceof ReferenceType);
65: }
66:
67: /**
68: * Test JDI visibleClasses().
69: */
70: public void testJDIVisibleClasses() {
71: List visible = fClassLoader.visibleClasses();
72: Iterator defined = fClassLoader.definedClasses().iterator();
73: while (defined.hasNext()) {
74: ReferenceType next = (ReferenceType) defined.next();
75: assertTrue(next.name(), visible.contains(next));
76: }
77: }
78: }
|