Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b601e603398cbc237d1896672b2ec57ca1cd1d1d (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*******************************************************************************
 * 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.request.EventRequestManager;
import com.sun.jdi.request.MonitorContendedEnterRequest;
import com.sun.jdi.request.MonitorContendedEnteredRequest;
import com.sun.jdi.request.MonitorWaitRequest;
import com.sun.jdi.request.MonitorWaitedRequest;

/**
 * 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 ContendedMonitorTests extends AbstractJDITest {

	EventRequestManager erm = null;
	
	/** setup test info locally **/
	@Override
	public void localSetUp() {
		erm = fVM.eventRequestManager();
	}

	/**
	 * test to see if a the 1.6 VM can get monitor events info and that 
	 * a non-1.6VM cannot.
	 */
	public void testCanRequestMonitorEvents() {
		if(fVM.version().indexOf("1.6") > -1) {
			assertTrue("Should have ability to request monitor events info", fVM.canRequestMonitorEvents());
		}
		else {
			assertTrue("Should not have ability to request monitor events info", !fVM.canRequestMonitorEvents());
		}
	}
	
	/**
	 * test getting monitor contended enter requests from the event request manager
	 * this test is not applicable to non 1.6 VMs
	 */
	public void testMonitorContendedEnterRequests() {
		if(!fVM.canRequestMonitorEvents()) {
			return;
		}
		MonitorContendedEnterRequest req = erm.createMonitorContendedEnterRequest();
		req.enable();
		List list = erm.monitorContendedEnterRequests();
		assertNotNull("list should not be null", list);
		assertTrue("list should be of size 1", list.size() == 1);
		assertTrue("req should be enabled", ((MonitorContendedEnterRequest)list.get(0)).isEnabled());
	}
	
	/**
	 * test getting monitor contended entered requests from the event request manager
	 * this test is not applicable to non 1.6 VMs
	 */
	public void testMonitorContendedEnteredRequests() {
		if(!fVM.canRequestMonitorEvents()) {
			return;
		}
		MonitorContendedEnteredRequest req = erm.createMonitorContendedEnteredRequest();
		req.enable();
		List list = erm.monitorContendedEnteredRequests();
		assertNotNull("list should not be null", list);
		assertTrue("list should be of size 1", list.size() == 1);
		assertTrue("req should be enabled", ((MonitorContendedEnteredRequest)list.get(0)).isEnabled());
	}
	
	/**
	 * test getting monitor wait requests from the event request manager
	 * this test is not applicable to non 1.6 VMs
	 */
	public void testMonitorWaitRequest() {
		if(!fVM.canRequestMonitorEvents()) {
			return;
		}	
		MonitorWaitRequest req = erm.createMonitorWaitRequest();
		req.enable();
		List list = erm.monitorWaitRequests();
		assertNotNull("list should not be null", list);
		assertTrue("list should be of size 1", list.size() == 1);
		assertTrue("req should be enabled", ((MonitorWaitRequest)list.get(0)).isEnabled());
	}
	
	/**
	 * test getting monitor waited requests from the event request manager
	 * this test is not applicable to non 1.6 VMs
	 */
	public void testMonitorWaitedRequest() {
		if(!fVM.canRequestMonitorEvents()) {
			return;
		}
		MonitorWaitedRequest req = erm.createMonitorWaitedRequest();
		req.enable();
		List list = erm.monitorWaitedRequests();
		assertNotNull("list should not be null", list);
		assertTrue("list should be of size 1", list.size() == 1);
		assertTrue("req should be enabled", ((MonitorWaitedRequest)list.get(0)).isEnabled());
	}
	
}

Back to the top