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.ReplyPacket;
31: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
32:
33: /**
34: * JDWP Unit test for Method.LineTable command.
35: */
36: public class LineTableTest extends JDWPMethodTestCase {
37:
38: public static void main(String[] args) {
39: junit.textui.TestRunner.run(LineTableTest.class);
40: }
41:
42: /**
43: * This testcase exercises Method.LineTable command.
44: * <BR>It runs MethodDebuggee, receives methods of debuggee.
45: * For each received method sends Method.LineTable command
46: * and prints returned LineTable.
47: */
48: public void testLineTableTest001()
49: throws UnsupportedEncodingException {
50: logWriter.println("testLineTableTest001 started");
51: synchronizer
52: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
53:
54: long classID = getClassIDBySignature("L"
55: + getDebuggeeClassName().replace('.', '/') + ";");
56:
57: MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
58: assertFalse("Invalid number of methods: 0",
59: methodsInfo.length == 0);
60:
61: for (int i = 0; i < methodsInfo.length; i++) {
62: logWriter.println(methodsInfo[i].toString());
63:
64: // get variable table for this class
65: ReplyPacket reply = getLineTable(classID, methodsInfo[i]
66: .getMethodID());
67:
68: long start = reply.getNextValueAsLong();
69: logWriter.println("start = " + start);
70: long end = reply.getNextValueAsLong();
71: logWriter.println("end = " + end);
72:
73: int lines = reply.getNextValueAsInt();
74: logWriter.println("lines = " + lines);
75:
76: for (int j = 0; j < lines; j++) {
77: long lineCodeIndex = reply.getNextValueAsLong();
78: logWriter.println("lineCodeIndex = " + lineCodeIndex);
79: int lineNumber = reply.getNextValueAsInt();
80: logWriter.println("lineNumber = " + lineNumber);
81: }
82: }
83:
84: synchronizer
85: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
86: }
87: }
|