1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     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 package org.apache.harmony.jpda.tests.jdwp.StackFrame;
20 
21 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
22 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
23 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
24 import org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject;
25 import org.apache.harmony.jpda.tests.framework.jdwp.Value;
26 import org.apache.harmony.jpda.tests.jdwp.share.JDWPProxyTestCase;
27 
28 /**
29  * JDWP Unit test for StackFrame.ThisObject command on proxy method.
30  */
31 public class ProxyThisObjectTest extends JDWPProxyTestCase {
32 
testThisObject()33     public void testThisObject() {
34         logWriter.println("testThisObject started");
35 
36         EventContext context = stopInProxyMethod();
37 
38         Value proxyObjectValue = getExpectedProxyObjectValue();
39 
40         logWriter.println("==> Send StackFrame::ThisObject command...");
41         CommandPacket packet = new CommandPacket(
42                 JDWPCommands.StackFrameCommandSet.CommandSetID,
43                 JDWPCommands.StackFrameCommandSet.ThisObjectCommand);
44         packet.setNextValueAsThreadID(context.getThreadId());
45         packet.setNextValueAsLong(context.getFrameId());
46         ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
47         checkReplyPacket(reply, "StackFrame.ThisObject");
48         TaggedObject taggedObject = reply.getNextValueAsTaggedObject();
49         assertAllDataRead(reply);
50 
51         assertEquals("Unexpected object id", proxyObjectValue.getLongValue(),
52                 taggedObject.objectID);
53         assertEquals("Unexpected object tag", proxyObjectValue.getTag(),
54                 taggedObject.tag);
55 
56         // Resume debuggee before leaving.
57         resumeDebuggee();
58 
59         logWriter.println("testThisObject finished");
60     }
61 }
62