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 org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
030: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
031: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
032: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
033:
034: public class JDWPMethodTestCase extends JDWPSyncTestCase {
035:
036: protected String getDebuggeeClassName() {
037: return MethodDebuggee.class.getName();
038: }
039:
040: static class MethodInfo {
041: private long methodID;
042: private String name;
043: private String signature;
044: private int modBits;
045:
046: public MethodInfo(long methodID, String name, String signature,
047: int modBits) {
048: super ();
049: this .methodID = methodID;
050: this .name = name;
051: this .signature = signature;
052: this .modBits = modBits;
053: }
054:
055: /**
056: * @return Returns the methodID.
057: */
058: public long getMethodID() {
059: return methodID;
060: }
061:
062: /**
063: * @return Returns the modBits.
064: */
065: public int getModBits() {
066: return modBits;
067: }
068:
069: /**
070: * @return Returns the name.
071: */
072: public String getName() {
073: return name;
074: }
075:
076: /**
077: * @return Returns the signature.
078: */
079: public String getSignature() {
080: return signature;
081: }
082:
083: public String toString() {
084: return "" + methodID + " " + name + " " + signature + " "
085: + modBits;
086: }
087:
088: }
089:
090: protected MethodInfo[] jdwpGetMethodsInfo(long classID) {
091:
092: CommandPacket packet = new CommandPacket(
093: JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
094: JDWPCommands.ReferenceTypeCommandSet.MethodsCommand);
095: packet.setNextValueAsClassID(classID);
096: ReplyPacket reply = debuggeeWrapper.vmMirror
097: .performCommand(packet);
098:
099: assertTrue(reply.getErrorCode() == JDWPConstants.Error.NONE);
100: int declared = reply.getNextValueAsInt();
101:
102: MethodInfo[] methodsInfo = new MethodInfo[declared];
103: for (int i = 0; i < declared; i++) {
104: methodsInfo[i] = new MethodInfo(reply
105: .getNextValueAsMethodID(), reply
106: .getNextValueAsString(), reply
107: .getNextValueAsString(), reply.getNextValueAsInt());
108: }
109: return methodsInfo;
110: }
111: }
|