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.event.VMDisconnectEvent;
13:
14: /**
15: * Tests for JDI com.sun.jdi.event.VMDisconnectEvent.
16: */
17: public class VMDisconnectEventTest extends AbstractJDITest {
18:
19: private VMDisconnectEvent fVMDisconnectEvent;
20:
21: /**
22: * Creates a new test.
23: */
24: public VMDisconnectEventTest() {
25: super ();
26: }
27:
28: /**
29: * Init the fields that are used by this test only.
30: */
31: public void localSetUp() {
32: // Prepare to receive the event
33: VMDisconnectEventWaiter waiter = new VMDisconnectEventWaiter(
34: null, true);
35: fEventReader.addEventListener(waiter);
36:
37: // Trigger a vm death event by shutting down the VM
38: killVM();
39:
40: // Wait for the event to come in
41: fVMDisconnectEvent = (VMDisconnectEvent) waitForEvent(waiter,
42: 10000);
43: // Wait 10s max
44: fEventReader.removeEventListener(waiter);
45: }
46:
47: /**
48: * Make sure the test leaves the VM in the same state it found it.
49: */
50: public void localTearDown() {
51: // Finish the shut down
52: shutDownTarget();
53:
54: // Start up again
55: launchTargetAndStartProgram();
56: }
57:
58: /**
59: * Run all tests and output to standard output.
60: * @param args
61: */
62: public static void main(java.lang.String[] args) {
63: new VMDisconnectEventTest().runSuite(args);
64: }
65:
66: /**
67: * Gets the name of the test case.
68: * @see junit.framework.TestCase#getName()
69: */
70: public String getName() {
71: return "com.sun.jdi.event.VMDeathEvent";
72: }
73:
74: /**
75: * Test that we received the event.
76: */
77: public void testJDIVMDeath() {
78: assertTrue("1", fVMDisconnectEvent != null);
79: }
80: }
|