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.ReferenceType;
13: import com.sun.jdi.event.ExceptionEvent;
14:
15: /**
16: * Tests for JDI com.sun.jdi.event.ExceptionEvent.
17: */
18: public class ExceptionEventTest extends AbstractJDITest {
19:
20: private ExceptionEvent fEvent;
21:
22: /**
23: * Creates a new test.
24: */
25: public ExceptionEventTest() {
26: super ();
27: }
28:
29: /**
30: * Init the fields that are used by this test only.
31: */
32: public void localSetUp() {
33: // Trigger an exception event
34: fEvent = (ExceptionEvent) triggerAndWait(getExceptionRequest(),
35: "ExceptionEvent", false);
36: }
37:
38: /**
39: * Make sure the test leaves the VM in the same state it found it.
40: */
41: public void localTearDown() {
42: // The test has interrupted the VM, so let it go
43: fVM.resume();
44:
45: // The test has resumed the test thread, so suspend it
46: waitUntilReady();
47: }
48:
49: /**
50: * Run all tests and output to standard output.
51: * @param args
52: */
53: public static void main(java.lang.String[] args) {
54: new ExceptionEventTest().runSuite(args);
55: }
56:
57: /**
58: * Gets the name of the test case.
59: * @see junit.framework.TestCase#getName()
60: */
61: public String getName() {
62: return "com.sun.jdi.event.ExceptionEvent";
63: }
64:
65: /**
66: * Test JDI catchLocation().
67: */
68: public void testJDICatchLocation() {
69: // Uncaught exception
70: assertTrue("1", fEvent.catchLocation() == null);
71:
72: // TO DO: Caught exception
73: }
74:
75: /**
76: * Test JDI exception().
77: */
78: public void testJDIException() {
79: ReferenceType expected = (ReferenceType) fVM.classesByName(
80: "java.lang.Error").get(0);
81: assertEquals("1", expected, fEvent.exception().referenceType());
82: }
83:
84: /**
85: * Test JDI thread().
86: */
87: public void testJDIThread() {
88: assertEquals("1", "Test Exception Event", fEvent.thread()
89: .name());
90: }
91: }
|