001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.debug.jdi.tests;
011:
012: import java.util.List;
013:
014: import com.sun.jdi.request.EventRequestManager;
015: import com.sun.jdi.request.MonitorContendedEnterRequest;
016: import com.sun.jdi.request.MonitorContendedEnteredRequest;
017: import com.sun.jdi.request.MonitorWaitRequest;
018: import com.sun.jdi.request.MonitorWaitedRequest;
019:
020: /**
021: * Test cases for the implementation of providing argumebnt information even if
022: * no debugging information is present in the new java 1.6 VM
023: *
024: * @since 3.3
025: */
026: public class ContendedMonitorTests extends AbstractJDITest {
027:
028: EventRequestManager erm = null;
029:
030: /** setup test info locally **/
031: public void localSetUp() {
032: erm = fVM.eventRequestManager();
033: }
034:
035: /**
036: * test to see if a the 1.6 VM can get monitor events info and that
037: * a non-1.6VM cannot.
038: */
039: public void testCanRequestMonitorEvents() {
040: if (fVM.version().indexOf("1.6") > -1) {
041: assertTrue(
042: "Should have ability to request monitor events info",
043: fVM.canRequestMonitorEvents());
044: } else {
045: assertTrue(
046: "Should not have ability to request monitor events info",
047: !fVM.canRequestMonitorEvents());
048: }
049: }
050:
051: /**
052: * test getting monitor contended enter requests from the event request manager
053: * this test is not applicable to non 1.6 VMs
054: */
055: public void testMonitorContendedEnterRequests() {
056: if (!fVM.canRequestMonitorEvents()) {
057: return;
058: }
059: MonitorContendedEnterRequest req = erm
060: .createMonitorContendedEnterRequest();
061: req.enable();
062: List list = erm.monitorContendedEnterRequests();
063: assertNotNull("list should not be null", list);
064: assertTrue("list should be of size 1", list.size() == 1);
065: assertTrue("req should be enabled",
066: ((MonitorContendedEnterRequest) list.get(0))
067: .isEnabled());
068: }
069:
070: /**
071: * test getting monitor contended entered requests from the event request manager
072: * this test is not applicable to non 1.6 VMs
073: */
074: public void testMonitorContendedEnteredRequests() {
075: if (!fVM.canRequestMonitorEvents()) {
076: return;
077: }
078: MonitorContendedEnteredRequest req = erm
079: .createMonitorContendedEnteredRequest();
080: req.enable();
081: List list = erm.monitorContendedEnteredRequests();
082: assertNotNull("list should not be null", list);
083: assertTrue("list should be of size 1", list.size() == 1);
084: assertTrue("req should be enabled",
085: ((MonitorContendedEnteredRequest) list.get(0))
086: .isEnabled());
087: }
088:
089: /**
090: * test getting monitor wait requests from the event request manager
091: * this test is not applicable to non 1.6 VMs
092: */
093: public void testMonitorWaitRequest() {
094: if (!fVM.canRequestMonitorEvents()) {
095: return;
096: }
097: MonitorWaitRequest req = erm.createMonitorWaitRequest();
098: req.enable();
099: List list = erm.monitorWaitRequests();
100: assertNotNull("list should not be null", list);
101: assertTrue("list should be of size 1", list.size() == 1);
102: assertTrue("req should be enabled", ((MonitorWaitRequest) list
103: .get(0)).isEnabled());
104: }
105:
106: /**
107: * test getting monitor waited requests from the event request manager
108: * this test is not applicable to non 1.6 VMs
109: */
110: public void testMonitorWaitedRequest() {
111: if (!fVM.canRequestMonitorEvents()) {
112: return;
113: }
114: MonitorWaitedRequest req = erm.createMonitorWaitedRequest();
115: req.enable();
116: List list = erm.monitorWaitedRequests();
117: assertNotNull("list should not be null", list);
118: assertTrue("list should be of size 1", list.size() == 1);
119: assertTrue("req should be enabled",
120: ((MonitorWaitedRequest) list.get(0)).isEnabled());
121: }
122:
123: }
|