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.5 $
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.IsObsolete command.
37: */
38: public class IsObsoleteTest extends JDWPMethodTestCase {
39:
40: public static void main(String[] args) {
41: junit.textui.TestRunner.run(IsObsoleteTest.class);
42: }
43:
44: /**
45: * This testcase exercises Method.IsObsolete command.
46: * <BR>It runs MethodDebuggee, receives checked method,
47: * which is not obsolete, and checks it with Method.IsObsolete command.
48: */
49: public void testIsObsoleteTest001()
50: throws UnsupportedEncodingException {
51: logWriter.println("testObsoleteTest001 started");
52:
53: //check capability, relevant for this test
54: logWriter.println("=> Check, can VM redefine classes");
55: debuggeeWrapper.vmMirror.capabilities();
56: boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canRedefineClasses;
57: if (!isCapability) {
58: logWriter
59: .println("##WARNING: this VM can't redefine classes");
60: return;
61: }
62:
63: synchronizer
64: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
65:
66: long classID = getClassIDBySignature("L"
67: + getDebuggeeClassName().replace('.', '/') + ";");
68:
69: MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
70: assertFalse("Invalid number of methods",
71: methodsInfo.length == 0);
72:
73: for (int i = 0; i < methodsInfo.length; i++) {
74: logWriter.println(methodsInfo[i].toString());
75:
76: // get variable table for this class
77: CommandPacket packet = new CommandPacket(
78: JDWPCommands.MethodCommandSet.CommandSetID,
79: JDWPCommands.MethodCommandSet.IsObsoleteCommand);
80: packet.setNextValueAsClassID(classID);
81: packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
82: ReplyPacket reply = debuggeeWrapper.vmMirror
83: .performCommand(packet);
84: checkReplyPacket(reply, "Method::IsObsolete command");
85:
86: boolean isObsolete = reply.getNextValueAsBoolean();
87: logWriter.println("isObsolete=" + isObsolete);
88: }
89:
90: synchronizer
91: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
92: }
93: }
|