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 Anatoly F. Bondarenko
21: * @version $Revision: 1.4 $
22: */
23:
24: /**
25: * Created on 16.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
27:
28: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
29: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
30: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
31: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
32: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
33:
34: /**
35: * JDWP Unit test for ReferenceType.ClassLoader command.
36: */
37: public class ClassLoaderTest extends JDWPSyncTestCase {
38:
39: static final int testStatusPassed = 0;
40: static final int testStatusFailed = -1;
41: static final String this CommandName = "ReferenceType.ClassLoader command";
42: static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld;";
43:
44: protected String getDebuggeeClassName() {
45: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
46: }
47:
48: /**
49: * This testcase exercises ReferenceType.ClassLoader command.
50: * <BR>The test starts HelloWorld debuggee, requests referenceTypeId
51: * for it by VirtualMachine.ClassesBySignature command, then
52: * performs ReferenceType.ClassLoader command and checks that command
53: * returns reply with some classLoaderID without any ERROR
54: */
55: public void testClassLoader001() {
56: String this TestName = "testClassLoader001";
57: logWriter.println("==> " + this TestName + " for "
58: + this CommandName + ": START...");
59: synchronizer
60: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
61:
62: long refTypeID = getClassIDBySignature(debuggeeSignature);
63:
64: logWriter.println("=> Debuggee class = "
65: + getDebuggeeClassName());
66: logWriter.println("=> referenceTypeID for Debuggee class = "
67: + refTypeID);
68: logWriter.println("=> CHECK1: send " + this CommandName
69: + " and check reply for ERROR...");
70:
71: CommandPacket classLoaderCommand = new CommandPacket(
72: JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
73: JDWPCommands.ReferenceTypeCommandSet.ClassLoaderCommand);
74: classLoaderCommand.setNextValueAsReferenceTypeID(refTypeID);
75:
76: ReplyPacket classLoaderReply = debuggeeWrapper.vmMirror
77: .performCommand(classLoaderCommand);
78: classLoaderCommand = null;
79: checkReplyPacket(classLoaderReply, this CommandName);
80:
81: long returnedClassLoaderID = classLoaderReply
82: .getNextValueAsObjectID();
83: logWriter
84: .println("=> CHECK1: PASSED: Returned classLoaderID = "
85: + returnedClassLoaderID);
86:
87: assertAllDataRead(classLoaderReply);
88:
89: synchronizer
90: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
91: logWriter.println("==> " + this TestName + " for "
92: + this CommandName + ": FINISH");
93: }
94:
95: public static void main(String[] args) {
96: junit.textui.TestRunner.run(ClassLoaderTest.class);
97: }
98: }
|