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 com.sun.jdi.ObjectCollectedException;
13: import com.sun.jdi.event.ThreadDeathEvent;
14:
15: /**
16: * Tests for JDI com.sun.jdi.event.ThreadDeathEvent.
17: */
18: public class ThreadDeathEventTest extends AbstractJDITest {
19:
20: private ThreadDeathEvent fEvent;
21:
22: /**
23: * Creates a new test.
24: */
25: public ThreadDeathEventTest() {
26: super ();
27: }
28:
29: /**
30: * Init the fields that are used by this test only.
31: */
32: public void localSetUp() {
33: // Make sure the entire VM is not suspended before we start a new thread
34: // (otherwise this new thread will start suspended and we will never get the
35: // ThreadDeath event)
36: fVM.resume();
37:
38: // Trigger a thread end event
39: fEvent = (ThreadDeathEvent) triggerAndWait(fVM
40: .eventRequestManager().createThreadDeathRequest(),
41: "ThreadDeathEvent", true);
42: }
43:
44: /**
45: * Make sure the test leaves the VM in the same state it found it.
46: */
47: public void localTearDown() {
48: // The test has resumed the test thread, so suspend it
49: waitUntilReady();
50: }
51:
52: /**
53: * Run all tests and output to standard output.
54: * @param args
55: */
56: public static void main(java.lang.String[] args) {
57: new ThreadDeathEventTest().runSuite(args);
58: }
59:
60: /**
61: * Gets the name of the test case.
62: * @see junit.framework.TestCase#getName()
63: */
64: public String getName() {
65: return "com.sun.jdi.event.ThreadDeathEvent";
66: }
67:
68: /**
69: * Test JDI thread().
70: */
71: public void testJDIThread() {
72: try {
73: assertEquals("1", "Test Thread Death Event", fEvent
74: .thread().name());
75: } catch (ObjectCollectedException e) {
76: // Workaround known problem in Sun's VM
77: }
78: }
79: }
|