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 31.01.2005
25 */
26package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
27
28import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
29import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
30import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
31import org.apache.harmony.jpda.tests.jdwp.share.JDWPTestCase;
32
33
34/**
35 * JDWP Unit test for VirtualMachine.IDSizes command.
36 */
37public class IDSizesTest extends JDWPTestCase {
38
39    protected String getDebuggeeClassName() {
40        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.SimpleHelloWorld";
41    }
42
43    /**
44     * This testcase exercises VirtualMachine.IDSizes command.
45     * <BR>At first the test starts HelloWorld debuggee.
46     * <BR> Then the test performs VirtualMachine.IDSizes command
47     * and checks that all returned sizes are non-zero values.
48     */
49    public void testIDSizes001() {
50
51        CommandPacket packet = new CommandPacket(
52                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
53                JDWPCommands.VirtualMachineCommandSet.IDSizesCommand);
54
55        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
56        checkReplyPacket(reply, "VirtualMachine::IDSizes command");
57
58        int fieldIDSize = reply.getNextValueAsInt();
59        int methodIDSize = reply.getNextValueAsInt();
60        int objectIDSize = reply.getNextValueAsInt();
61        int referenceTypeIDSize = reply.getNextValueAsInt();
62        int frameIDSize = reply.getNextValueAsInt();
63        logWriter.println("fieldIDSize = " + fieldIDSize);
64        logWriter.println("methodIDSize = " + methodIDSize);
65        logWriter.println("objectIDSize = " + objectIDSize);
66        logWriter.println("referenceTypeIDSize = " + referenceTypeIDSize);
67        logWriter.println("frameIDSize = " + frameIDSize);
68
69        assertTrue("Invalid fieldIDSize: " + fieldIDSize, fieldIDSize > 0);
70        assertTrue("Invalid methodIDSize: " + methodIDSize, methodIDSize > 0);
71        assertTrue("Invalid objectIDSize: " + objectIDSize, objectIDSize > 0);
72        assertTrue("Invalid referenceTypeIDSize: " + referenceTypeIDSize, referenceTypeIDSize > 0);
73        assertTrue("Invalid frameIDSize: " + frameIDSize, frameIDSize > 0);
74
75        debuggeeWrapper.resume();
76    }
77}
78