01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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 Anton V. Karnachuk
21: * @version $Revision: 1.3 $
22: */
23:
24: /**
25: * Created on 14.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.Method;
27:
28: import java.io.UnsupportedEncodingException;
29:
30: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
31: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
32: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
33: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
34:
35: /**
36: * JDWP Unit test for Method.VariableTable command.
37: */
38: public class VariableTableTest extends JDWPMethodTestCase {
39:
40: public static void main(String[] args) {
41: junit.textui.TestRunner.run(VariableTableTest.class);
42: }
43:
44: /**
45: * This testcase exercises Method.VariableTable command.
46: * <BR>It runs MethodDebuggee, receives methods of debuggee.
47: * For each received method sends Method.VariableTable command
48: * and prints returned VariableTable.
49: */
50: public void testVariableTableTest001()
51: throws UnsupportedEncodingException {
52: logWriter.println("testVariableTableTest001 started");
53: synchronizer
54: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
55:
56: long classID = getClassIDBySignature("L"
57: + getDebuggeeClassName().replace('.', '/') + ";");
58:
59: MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
60: assertFalse("Invalid number of methods: 0",
61: methodsInfo.length == 0);
62:
63: for (int i = 0; i < methodsInfo.length; i++) {
64: logWriter.println(methodsInfo[i].toString());
65:
66: // get variable table for this class
67: CommandPacket packet = new CommandPacket(
68: JDWPCommands.MethodCommandSet.CommandSetID,
69: JDWPCommands.MethodCommandSet.VariableTableCommand);
70: packet.setNextValueAsClassID(classID);
71: packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
72: ReplyPacket reply = debuggeeWrapper.vmMirror
73: .performCommand(packet);
74: checkReplyPacket(reply, "Method::VariableTable command");
75:
76: int argCnt = reply.getNextValueAsInt();
77: logWriter.println("argCnt = " + argCnt);
78: int slots = reply.getNextValueAsInt();
79: logWriter.println("slots = " + slots);
80: for (int j = 0; j < slots; j++) {
81: long codeIndex = reply.getNextValueAsLong();
82: logWriter.println("codeIndex = " + codeIndex);
83: String name = reply.getNextValueAsString();
84: logWriter.println("name = " + name);
85: String signature = reply.getNextValueAsString();
86: logWriter.println("signature = " + signature);
87: int length = reply.getNextValueAsInt();
88: logWriter.println("length = " + length);
89: int slot = reply.getNextValueAsInt();
90: logWriter.println("slot = " + slot);
91: }
92:
93: }
94:
95: synchronizer
96: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
97: }
98: }
|