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.6 $
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.CapabilitiesNew command.
036: */
037: public class CapabilitiesNewTest extends JDWPSyncTestCase {
038:
039: static Object[][] capabilitiesFlags = {
040: { "canWatchFieldModification", new Object() },
041: { "canWatchFieldAccess", new Object() },
042: { "canGetBytecodes", new Object() },
043: { "canGetSyntheticAttribute", new Object() },
044: { "canGetOwnedMonitorInfo", new Object() },
045: { "canGetCurrentContendedMonitor", new Object() },
046: { "canGetMonitorInfo", new Object() },
047: { "canRedefineClasses", new Object() },
048: { "canAddMethod", null },
049: { "canUnrestrictedlyRedefineClasses", null },
050: { "canPopFrames", new Object() },
051: { "canUseInstanceFilters", new Object() },
052: { "canGetSourceDebugExtension", new Object() },
053: { "canRequestVMDeathEvent", new Object() },
054: { "canSetDefaultStratum", null }, { "reserved16", null },
055: { "reserved17", null }, { "reserved18", null },
056: { "reserved19", null }, { "reserved20", null },
057: { "reserved21", null }, { "reserved22", null },
058: { "reserved23", null }, { "reserved24", null },
059: { "reserved25", null }, { "reserved26", null },
060: { "reserved27", null }, { "reserved28", null },
061: { "reserved29", null }, { "reserved30", null },
062: { "reserved31", null }, { "reserved32", null } };
063:
064: protected String getDebuggeeClassName() {
065: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
066: }
067:
068: /**
069: * This testcase exercises VirtualMachine.CapabilitiesNew command.
070: * <BR>At first the test starts HelloWorld debuggee.
071: * <BR> Then the test performs VirtualMachine.CapabilitiesNew command and checks that:
072: * all returned capabilities' values are expected values and that
073: * there are no extra data in the reply packet;
074: */
075: public void testCapabilitiesNew001() {
076: synchronizer
077: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
078:
079: CommandPacket packet = new CommandPacket(
080: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
081: JDWPCommands.VirtualMachineCommandSet.CapabilitiesNewCommand);
082: logWriter.println("\trequest capabilities");
083: ReplyPacket reply = debuggeeWrapper.vmMirror
084: .performCommand(packet);
085: checkReplyPacket(reply,
086: "VirtualMachine::CapabilitiesNew command");
087:
088: boolean flag;
089: boolean testFailed = false;
090: for (int i = 0; i < 32; i++) {
091: flag = reply.getNextValueAsBoolean();
092: logWriter.println("\tReceived " + capabilitiesFlags[i][0]
093: + " = " + flag);
094: if ((capabilitiesFlags[i][1] != null) != flag) {
095: testFailed = true;
096: logWriter.println("\t ## FAILURE: Expected "
097: + capabilitiesFlags[i][0] + " = "
098: + (capabilitiesFlags[i][1] != null));
099: } else {
100: logWriter.println("\t OK - it is expected value!");
101: }
102: }
103: if (testFailed) {
104: printErrorAndFail("Unexpected received capabilities values found out");
105: } else {
106: logWriter.println("testCapabilitiesNew001 - OK!");
107: }
108: assertAllDataRead(reply);
109: synchronizer
110: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
111: }
112:
113: public static void main(String[] args) {
114: junit.textui.TestRunner.run(CapabilitiesNewTest.class);
115: }
116: }
|