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 Anton V. Karnachuk
021: * @version $Revision: 1.3 $
022: */
023:
024: /**
025: * Created on 14.02.2005
026: */package org.apache.harmony.jpda.tests.jdwp.Method;
027:
028: import java.io.UnsupportedEncodingException;
029:
030: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
031: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
032: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
033: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
034:
035: /**
036: * JDWP Unit test for Method.VariableTableWithGeneric command.
037: */
038:
039: public class VariableTableWithGenericTest extends JDWPMethodTestCase {
040:
041: public static void main(String[] args) {
042: junit.textui.TestRunner.run(VariableTableWithGenericTest.class);
043: }
044:
045: /**
046: * This testcase exercises Method.VariableTableWithGeneric command.
047: * <BR>It runs MethodDebuggee, receives methods of debuggee.
048: * For each received method sends Method.VariableTableWithGeneric command
049: * and prints returned VariableTable.
050: */
051: public void testVariableTableWithGenericTest001()
052: throws UnsupportedEncodingException {
053: logWriter.println("VariableTableWithGeneric started");
054: synchronizer
055: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
056:
057: long classID = getClassIDBySignature("L"
058: + getDebuggeeClassName().replace('.', '/') + ";");
059:
060: MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
061: assertFalse("Invalid number of methods: 0",
062: methodsInfo.length == 0);
063:
064: for (int i = 0; i < methodsInfo.length; i++) {
065: logWriter.println(methodsInfo[i].toString());
066:
067: // get variable table for this class
068: CommandPacket packet = new CommandPacket(
069: JDWPCommands.MethodCommandSet.CommandSetID,
070: JDWPCommands.MethodCommandSet.VariableTableWithGenericCommand);
071: packet.setNextValueAsClassID(classID);
072: packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
073: ReplyPacket reply = debuggeeWrapper.vmMirror
074: .performCommand(packet);
075: checkReplyPacket(reply,
076: "Method::VariableTableWithGeneric command");
077:
078: int argCnt = reply.getNextValueAsInt();
079: logWriter.println("argCnt = " + argCnt);
080: int slots = reply.getNextValueAsInt();
081: logWriter.println("slots = " + slots);
082: for (int j = 0; j < slots; j++) {
083: long codeIndex = reply.getNextValueAsLong();
084: logWriter.println("codeIndex = " + codeIndex);
085: String name = reply.getNextValueAsString();
086: logWriter.println("name = " + name);
087: String signature = reply.getNextValueAsString();
088: logWriter.println("signature = " + signature);
089: String genericSignature = reply.getNextValueAsString();
090: logWriter.println("genericSignature = "
091: + genericSignature);
092: int length = reply.getNextValueAsInt();
093: logWriter.println("length = " + length);
094: int slot = reply.getNextValueAsInt();
095: logWriter.println("slot = " + slot);
096: }
097: }
098:
099: synchronizer
100: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
101: }
102: }
|