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.StringReference;
13: import com.sun.jdi.event.ModificationWatchpointEvent;
14: import com.sun.jdi.request.WatchpointRequest;
15:
16: /**
17: * Tests for JDI com.sun.jdi.ModificationWatchpointEvent.
18: */
19: public class ModificationWatchpointEventTest extends AbstractJDITest {
20:
21: private ModificationWatchpointEvent fWatchpointEvent;
22: private WatchpointRequest fWatchpointRequest;
23:
24: /**
25: * Creates a new test.
26: */
27: public ModificationWatchpointEventTest() {
28: super ();
29: }
30:
31: /**
32: * Init the fields that are used by this test only.
33: */
34: public void localSetUp() {
35: // Trigger a static modification watchpoint event
36: fWatchpointRequest = getStaticModificationWatchpointRequest();
37: fWatchpointEvent = (ModificationWatchpointEvent) triggerAndWait(
38: fWatchpointRequest,
39: "StaticModificationWatchpointEvent", false);
40: // Interrupt the VM so that we can test valueToBe()
41: }
42:
43: /**
44: * Make sure the test leaves the VM in the same state it found it.
45: */
46: public void localTearDown() {
47: // Ensure that the modification of the "fString" field has completed
48: fVM.resume();
49: waitUntilReady();
50:
51: // Remove the modification watchpoint request
52: fVM.eventRequestManager()
53: .deleteEventRequest(fWatchpointRequest);
54:
55: // Set the value of the "fString" field back to its original value
56: resetStaticField();
57: }
58:
59: /**
60: * Run all tests and output to standard output.
61: * @param args
62: */
63: public static void main(java.lang.String[] args) {
64: new ModificationWatchpointEventTest().runSuite(args);
65: }
66:
67: /**
68: * Gets the name of the test case.
69: * @see junit.framework.TestCase#getName()
70: */
71: public String getName() {
72: return "com.sun.jdi.event.ModificationWatchpointEvent";
73: }
74:
75: /**
76: * Test JDI valueToBe().
77: */
78: public void testJDIValueToBe() {
79: assertEquals("1", "Hello Universe",
80: ((StringReference) fWatchpointEvent.valueToBe())
81: .value());
82: }
83: }
|