001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Vitaly A. Provodin
021: * @version $Revision: 1.4 $
022: */
023:
024: /**
025: * Created on 10.02.2005
026: */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
027:
028: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
030: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
031: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
032: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
033:
034: /**
035: * JDWP Unit test for VirtualMachine.Capabilities command.
036: */
037: public class CapabilitiesTest extends JDWPSyncTestCase {
038:
039: protected String getDebuggeeClassName() {
040: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
041: }
042:
043: /**
044: * This testcase exercises VirtualMachine.Capabilities command.
045: * <BR>At first the test starts HelloWorld debuggee.
046: * <BR> Then the test performs VirtualMachine.Capabilities command and checks that:
047: * all returned capabilities' values are expected values and that
048: * there are no extra data in the reply packet;
049: */
050: public void testCapabilities001() {
051: synchronizer
052: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
053:
054: CommandPacket packet = new CommandPacket(
055: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
056: JDWPCommands.VirtualMachineCommandSet.CapabilitiesCommand);
057: logWriter.println("\trequest capabilities");
058:
059: ReplyPacket reply = debuggeeWrapper.vmMirror
060: .performCommand(packet);
061: checkReplyPacket(reply, "VirtualMachine::Capabilities command");
062:
063: boolean canWatchFieldModification = reply
064: .getNextValueAsBoolean();
065: boolean canWatchFieldAccess = reply.getNextValueAsBoolean();
066: boolean canGetBytecodes = reply.getNextValueAsBoolean();
067: boolean canGetSyntheticAttribute = reply
068: .getNextValueAsBoolean();
069: boolean canGetOwnedMonitorInfo = reply.getNextValueAsBoolean();
070: boolean canGetCurrentContendedMonitor = reply
071: .getNextValueAsBoolean();
072: boolean canGetMonitorInfo = reply.getNextValueAsBoolean();
073:
074: logWriter.println("\tcanWatchFieldModification\t= "
075: + canWatchFieldModification);
076: assertTrue("canWatchFieldModification must be true",
077: canWatchFieldModification);
078:
079: logWriter.println("\tcanWatchFieldAccess\t\t= "
080: + canWatchFieldAccess);
081: assertTrue("canWatchFieldAccess must be true",
082: canWatchFieldAccess);
083:
084: logWriter
085: .println("\tcanGetBytecodes\t\t\t= " + canGetBytecodes);
086: assertTrue("canGetBytecodes must be true", canGetBytecodes);
087:
088: logWriter.println("\tcanGetSyntheticAttribute\t= "
089: + canGetSyntheticAttribute);
090: assertTrue("canGetSyntheticAttribute must be true",
091: canGetSyntheticAttribute);
092:
093: logWriter.println("\tcanGetOwnedMonitorInfo\t\t= "
094: + canGetOwnedMonitorInfo);
095: assertTrue("canGetOwnedMonitorInfo must be true",
096: canGetOwnedMonitorInfo);
097:
098: logWriter.println("\tcanGetCurrentContendedMonitor\t= "
099: + canGetCurrentContendedMonitor);
100: assertTrue("canGetCurrentContendedMonitor must be true",
101: canGetCurrentContendedMonitor);
102:
103: logWriter.println("\tcanGetMonitorInfo\t\t= "
104: + canGetMonitorInfo);
105: assertTrue("canGetMonitorInfo must be true", canGetMonitorInfo);
106:
107: assertAllDataRead(reply);
108:
109: synchronizer
110: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
111: }
112:
113: public static void main(String[] args) {
114: junit.textui.TestRunner.run(CapabilitiesTest.class);
115: }
116: }
|