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 /**
20  * @author Vitaly A. Provodin
21  */
22 
23 /**
24  * Created on 10.02.2005
25  */
26 package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
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 /**
36  * JDWP Unit test for VirtualMachine.Capabilities command.
37  */
38 public class CapabilitiesTest extends JDWPSyncTestCase {
39 
getDebuggeeClassName()40     protected String getDebuggeeClassName() {
41         return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
42     }
43 
44     /**
45      * This testcase exercises VirtualMachine.Capabilities command.
46      * <BR>At first the test starts HelloWorld debuggee.
47      * <BR> Then the test performs VirtualMachine.Capabilities command and checks that:
48      * all returned capabilities' values are expected values and that
49      * there are no extra data in the reply packet;
50      */
testCapabilities001()51     public void testCapabilities001() {
52         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
53 
54         CommandPacket packet = new CommandPacket(
55                 JDWPCommands.VirtualMachineCommandSet.CommandSetID,
56                 JDWPCommands.VirtualMachineCommandSet.CapabilitiesCommand);
57         logWriter.println("\trequest capabilities");
58 
59         ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
60         checkReplyPacket(reply, "VirtualMachine::Capabilities command");
61 
62         boolean canWatchFieldModification     = reply.getNextValueAsBoolean();
63         boolean canWatchFieldAccess         = reply.getNextValueAsBoolean();
64         boolean canGetBytecodes             = reply.getNextValueAsBoolean();
65         boolean canGetSyntheticAttribute     = reply.getNextValueAsBoolean();
66         boolean canGetOwnedMonitorInfo         = reply.getNextValueAsBoolean();
67         boolean canGetCurrentContendedMonitor = reply.getNextValueAsBoolean();
68         boolean canGetMonitorInfo             = reply.getNextValueAsBoolean();
69 
70         logWriter.println("\tcanWatchFieldModification\t= "
71                 + canWatchFieldModification);
72         assertTrue("canWatchFieldModification must be true", canWatchFieldModification);
73 
74         logWriter.println("\tcanWatchFieldAccess\t\t= " + canWatchFieldAccess);
75         assertTrue("canWatchFieldAccess must be true", canWatchFieldAccess);
76 
77         logWriter.println("\tcanGetBytecodes\t\t\t= " + canGetBytecodes);
78         assertTrue("canGetBytecodes must be true", canGetBytecodes);
79 
80         logWriter.println("\tcanGetSyntheticAttribute\t= "
81                 + canGetSyntheticAttribute);
82         assertTrue("canGetSyntheticAttribute must be true", canGetSyntheticAttribute);
83 
84         logWriter.println("\tcanGetOwnedMonitorInfo\t\t= "
85                 + canGetOwnedMonitorInfo);
86         assertTrue("canGetOwnedMonitorInfo must be true", canGetOwnedMonitorInfo);
87 
88         logWriter.println("\tcanGetCurrentContendedMonitor\t= "
89                 + canGetCurrentContendedMonitor);
90         assertTrue("canGetCurrentContendedMonitor must be true", canGetCurrentContendedMonitor);
91 
92         logWriter.println("\tcanGetMonitorInfo\t\t= " + canGetMonitorInfo);
93         assertTrue("canGetMonitorInfo must be true", canGetMonitorInfo);
94 
95         assertAllDataRead(reply);
96 
97         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
98     }
99 }
100