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.lang.reflect.Method;
13: import junit.framework.TestCase;
14:
15: /**
16: * Wrapper to be able to use the JDI tests in a test suite without
17: * starting and shutting down the VM after each test.
18: */
19: public class JDITestCase extends TestCase {
20: private AbstractJDITest fTest;
21:
22: /**
23: * Creates a new test for the given JDI test.
24: * @param test
25: * @param name
26: */
27: public JDITestCase(AbstractJDITest test, String name) {
28: super (name);
29: fTest = test;
30: }
31:
32: /**
33: * Override to run the test and assert its state.
34: * @exception Throwable if any exception is thrown
35: */
36: protected void runTest() throws Throwable {
37: Method runMethod = null;
38: try {
39: runMethod = fTest.getClass().getMethod(getName(),
40: new Class[0]);
41: } catch (NoSuchMethodException e) {
42: e.fillInStackTrace();
43: throw e;
44: }
45: try {
46: fTest.verbose("Running " + getName());
47: runMethod.invoke(fTest, new Class[0]);
48: } catch (java.lang.reflect.InvocationTargetException e) {
49: if (e.getTargetException() instanceof NotYetImplementedException)
50: System.out.println("\n" + getName()
51: + " is not yet implemented.");
52: else {
53: e.fillInStackTrace();
54: throw e.getTargetException();
55: }
56: } catch (IllegalAccessException e) {
57: e.fillInStackTrace();
58: throw e;
59: }
60: }
61:
62: /**
63: * Init tests
64: */
65: protected void setUp() {
66: // Ignore setUp since it is done once for all tests in the test suite
67: }
68:
69: /**
70: * Tears down the fixture.
71: */
72: protected void tearDown() {
73: // Ignore tearDown since it is done once for all tests in the test suite
74: }
75:
76: /**
77: * Returns a string representation of the test case
78: * @see junit.framework.TestCase#toString()
79: */
80: public String toString() {
81: return fTest.getClass().getName() + "." + getName() + "()";
82: }
83: }
|