Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: afd8cacd5826da804951b3efaea4ed0179ab8c52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.jdi.tests;

import java.util.List;

import com.sun.jdi.IncompatibleThreadStateException;
import com.sun.jdi.Method;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.event.BreakpointEvent;
import com.sun.jdi.request.BreakpointRequest;
import com.sun.jdi.request.EventRequest;

/**
 * Test cases for the implementation of providing argumebnt information even if 
 * no debugging information is present in the new java 1.6 VM
 * 
 * @since 3.3
 */
public class MonitorFrameInfoTests extends AbstractJDITest {

	/** setup test info locally **/
	public void localSetUp() {}

	/**
	 * test to see if a the 1.6 VM can get monitor frame info and that 
	 * a non-1.6VM cannot.
	 */
	public void testCanGetMonitorFrameInfo() {
		if(fVM.version().indexOf("1.6") > -1) {
			assertTrue("Should have monitor frame info", fVM.canGetMonitorFrameInfo());
		}
		else {
			assertTrue("Should not have monitor frame info", !fVM.canGetMonitorFrameInfo());
		}
	}
	
	/**
	 * test to make sure the proper frames and monitors are collected for the corresponding thread ref.
	 * this test has no effect in a non-1.6VM
	 */
	public void testOwnedMonitorsAndFrames() {
		if(!fVM.canGetMonitorFrameInfo()) {
			return;
		}
		try {
			Method method = getMethod("sync", "()V");
			BreakpointRequest br = fVM.eventRequestManager().createBreakpointRequest(method.location());
			br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
			br.enable();
			EventWaiter waiter = new EventWaiter(br, true);
			fEventReader.addEventListener(waiter);
			triggerEvent("monitorinfo");
			BreakpointEvent bpe = (BreakpointEvent) waiter.waitEvent(10000);
			ThreadReference tref = bpe.thread();
			List list = tref.ownedMonitorsAndFrames();
			assertNotNull("list cannot be null", list);
			assertTrue("there should be one monitor", list.size() == 1);
			fEventReader.removeEventListener(waiter);
			tref.resume();
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (IncompatibleThreadStateException e) {
			e.printStackTrace();
		}
	}
	
}

Back to the top