01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.util.List;
13:
14: import com.sun.jdi.IncompatibleThreadStateException;
15: import com.sun.jdi.Method;
16: import com.sun.jdi.ThreadReference;
17: import com.sun.jdi.event.BreakpointEvent;
18: import com.sun.jdi.request.BreakpointRequest;
19: import com.sun.jdi.request.EventRequest;
20:
21: /**
22: * Test cases for the implementation of providing argumebnt information even if
23: * no debugging information is present in the new java 1.6 VM
24: *
25: * @since 3.3
26: */
27: public class MonitorFrameInfoTests extends AbstractJDITest {
28:
29: /** setup test info locally **/
30: public void localSetUp() {
31: }
32:
33: /**
34: * test to see if a the 1.6 VM can get monitor frame info and that
35: * a non-1.6VM cannot.
36: */
37: public void testCanGetMonitorFrameInfo() {
38: if (fVM.version().indexOf("1.6") > -1) {
39: assertTrue("Should have monitor frame info", fVM
40: .canGetMonitorFrameInfo());
41: } else {
42: assertTrue("Should not have monitor frame info", !fVM
43: .canGetMonitorFrameInfo());
44: }
45: }
46:
47: /**
48: * test to make sure the proper frames and monitors are collected for the corresponding thread ref.
49: * this test has no effect in a non-1.6VM
50: */
51: public void testOwnedMonitorsAndFrames() {
52: if (!fVM.canGetMonitorFrameInfo()) {
53: return;
54: }
55: try {
56: Method method = getMethod("sync", "()V");
57: BreakpointRequest br = fVM.eventRequestManager()
58: .createBreakpointRequest(method.location());
59: br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
60: br.enable();
61: EventWaiter waiter = new EventWaiter(br, true);
62: fEventReader.addEventListener(waiter);
63: triggerEvent("monitorinfo");
64: BreakpointEvent bpe = (BreakpointEvent) waiter
65: .waitEvent(10000);
66: ThreadReference tref = bpe.thread();
67: List list = tref.ownedMonitorsAndFrames();
68: assertNotNull("list cannot be null", list);
69: assertTrue("there should be one monitor", list.size() == 1);
70: fEventReader.removeEventListener(waiter);
71: tref.resume();
72: } catch (InterruptedException e) {
73: e.printStackTrace();
74: } catch (IncompatibleThreadStateException e) {
75: e.printStackTrace();
76: }
77: }
78:
79: }
|