1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /** 20 * @author Vitaly A. Provodin 21 */ 22 23 /** 24 * Created on 10.02.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.VirtualMachine; 27 28 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; 29 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands; 30 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; 31 import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase; 32 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 33 34 35 /** 36 * JDWP Unit test for VirtualMachine.CapabilitiesNew command. 37 */ 38 public class CapabilitiesNewTest extends JDWPSyncTestCase { 39 40 static Object [][] capabilitiesFlags = { 41 {"canWatchFieldModification", "true"}, 42 {"canWatchFieldAccess", "true"}, 43 {"canGetBytecodes", "true"}, 44 {"canGetSyntheticAttribute", "true"}, 45 {"canGetOwnedMonitorInfo", "true"}, 46 {"canGetCurrentContendedMonitor", "true"}, 47 {"canGetMonitorInfo", "true"}, 48 {"canRedefineClasses", null}, 49 {"canAddMethod", null}, 50 {"canUnrestrictedlyRedefineClasses", null}, 51 {"canPopFrames", null}, 52 {"canUseInstanceFilters", "true"}, 53 {"canGetSourceDebugExtension", "true"}, 54 {"canRequestVMDeathEvent", null}, 55 {"canSetDefaultStratum", null}, 56 {"canGetInstanceInfo", "true"}, 57 {"canRequestMonitorEvents", null}, 58 {"canGetMonitorFrameInfo", "true"}, 59 {"canUseSourceNameFilters", null}, 60 {"canGetConstantPool", null}, 61 {"canForceEarlyReturn", null}, 62 {"reserved22", null}, 63 {"reserved23", null}, 64 {"reserved24", null}, 65 {"reserved25", null}, 66 {"reserved26", null}, 67 {"reserved27", null}, 68 {"reserved28", null}, 69 {"reserved29", null}, 70 {"reserved30", null}, 71 {"reserved31", null}, 72 {"reserved32", null} 73 }; 74 75 @Override 76 protected String getDebuggeeClassName() { 77 return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld"; 78 } 79 80 /** 81 * This testcase exercises VirtualMachine.CapabilitiesNew command. 82 * <BR>At first the test starts HelloWorld debuggee. 83 * <BR> Then the test performs VirtualMachine.CapabilitiesNew command and checks that: 84 * all returned capabilities' values are expected values and that 85 * there are no extra data in the reply packet; 86 */ 87 public void testCapabilitiesNew001() { 88 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 89 90 CommandPacket packet = new CommandPacket( 91 JDWPCommands.VirtualMachineCommandSet.CommandSetID, 92 JDWPCommands.VirtualMachineCommandSet.CapabilitiesNewCommand); 93 logWriter.println("\trequest capabilities"); 94 ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet); 95 checkReplyPacket(reply, "VirtualMachine::CapabilitiesNew command"); 96 97 boolean flag; 98 boolean testFailed = false; 99 for (int i = 0; i < 32; i++) { 100 flag = reply.getNextValueAsBoolean(); 101 logWriter.println("\tReceived " + capabilitiesFlags[i][0] + " = " 102 + flag); 103 if ( (capabilitiesFlags[i][1] != null) != flag ) { 104 testFailed = true; 105 logWriter.println("\t ## FAILURE: Expected " + capabilitiesFlags[i][0] + 106 " = " + (capabilitiesFlags[i][1] != null)); 107 } else { 108 logWriter.println("\t OK - it is expected value!"); 109 } 110 } 111 if ( testFailed ) { 112 printErrorAndFail("Unexpected received capabilities values found out"); 113 } else { 114 logWriter.println("testCapabilitiesNew001 - OK!"); 115 } 116 assertAllDataRead(reply); 117 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 118 } 119 } 120