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.VMDisconnectedException;
13:
14: /**
15: * Tests for JDI com.sun.jdi.VirtualMachine.exit().
16: */
17: public class VirtualMachineExitTest extends AbstractJDITest {
18: /**
19: * Creates a new test .
20: */
21: public VirtualMachineExitTest() {
22: super ();
23: }
24:
25: /**
26: * Init the fields that are used by this test only.
27: */
28: public void localSetUp() {
29: }
30:
31: /**
32: * Make sure the test leaves the VM in the same state it found it.
33: */
34: public void localTearDown() {
35: // Finish the shut down
36: shutDownTarget();
37:
38: // Start up again
39: launchTargetAndStartProgram();
40: }
41:
42: /**
43: * Run all tests and output to standard output.
44: * @param args
45: */
46: public static void main(String[] args) {
47: new VirtualMachineExitTest().runSuite(args);
48: }
49:
50: /**
51: * Gets the name of the test case.
52: * @see junit.framework.TestCase#getName()
53: */
54: public String getName() {
55: return "com.sun.jdi.VirtualMachine.exit(int)";
56: }
57:
58: /**
59: * Test JDI exit().
60: */
61: public void testJDIExit() {
62: try {
63: fVM.exit(0);
64: } catch (VMDisconnectedException e) {
65: assertTrue("1", false);
66: }
67:
68: try {
69: Thread.sleep(200);
70: assertTrue("2", !vmIsRunning());
71: fVM.allThreads();
72: assertTrue("3", false);
73: } catch (VMDisconnectedException e) {
74: } catch (InterruptedException e) {
75: }
76: }
77: }
|