You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/11/28 18:49:31 UTC

svn commit: r480141 [31/38] - in /harmony/enhanced/jdktools/trunk/modules/jpda: ./ doc/ doc/images/ make/ src/ src/common/ src/common/other/ src/common/other/jpda/ src/common/other/jpda/jdwp/ src/common/other/jpda/jdwp/agent/ src/common/other/jpda/jdwp...

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 21.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.SourceFile command.
+ */
+public class SourceFileTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+    static final String thisCommandName = "ReferenceType.SourceFile command";
+    static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.SourceFileDebuggee";
+    }
+
+    /**
+     * This testcase exercises ReferenceType.SourceFile command.
+     * >BR>The test starts SourceFileDebuggee class, requests referenceTypeId
+     * for this class by VirtualMachine.ClassesBySignature command, then
+     * performs ReferenceType.SourceFile command and checks that returned
+     * source file name is equal to expected name.
+     */
+    public void testSourceFile001() {
+        String thisTestName = "testSourceFile001";
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+        logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+        logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+        CommandPacket sourceFileCommand = new CommandPacket(
+                JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+                JDWPCommands.ReferenceTypeCommandSet.SourceFileCommand);
+        sourceFileCommand.setNextValueAsReferenceTypeID(refTypeID);
+        
+        ReplyPacket sourceFileReply = debuggeeWrapper.vmMirror.performCommand(sourceFileCommand);
+        sourceFileCommand = null;
+        checkReplyPacket(sourceFileReply, thisCommandName);
+
+        String returnedSourceFile = sourceFileReply.getNextValueAsString();
+        String expectedSourceFile = "SourceFileDebuggee.java";
+
+        assertString(thisCommandName + " returned invalid source file,",
+                expectedSourceFile, returnedSourceFile);
+
+        logWriter.println("=> CHECK: PASSED: expected source file is returned = " +
+                returnedSourceFile);
+
+        finalSyncMessage = null;
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+        assertAllDataRead(sourceFileReply);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(SourceFileTest.class);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class StatusDebuggee extends SyncDebuggee {
+
+    public void run() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        logWriter.println("--> Debuggee: StatusDebuggee...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(StatusDebuggee.class);
+    }
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.Status command.
+ */
+public class StatusTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+    static final String thisCommandName = "ReferenceType.Status command";
+    static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusDebuggee;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.StatusDebuggee";
+    }
+
+    /**
+     * This testcase exercises ReferenceType.Status command.
+     * <BR>The test starts StatusDebuggee class, requests referenceTypeId
+     * for this class by VirtualMachine.ClassesBySignature command, then
+     * performs ReferenceType.Status command and checks that returned
+     * status' bits are expected bits.
+     */
+    public void testStatus001() {
+        String thisTestName = "testStatus001";
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+        logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+        logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+        CommandPacket checkedCommand = new CommandPacket(
+                JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+                JDWPCommands.ReferenceTypeCommandSet.StatusCommand);
+        checkedCommand.setNextValueAsReferenceTypeID(refTypeID);
+        
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+        checkedCommand = null;
+        checkReplyPacket(checkedReply, thisCommandName);
+        
+        int returnedStatus = checkedReply.getNextValueAsInt();
+        logWriter.println("=> Returned status value = 0x" + Integer.toHexString(returnedStatus));
+        
+        String statusBitsNames[] = {
+                "VERIFIED",
+                "PREPARED",
+                "INITIALIZED",
+                "ERROR",
+        };
+
+        int statusBitsValues[] = {
+                0x01,
+                0x02,
+                0x04,
+                0x08,
+        };
+        
+        int expectedStatusBits[] = {
+                0x01,
+                0x02,
+                0x04,
+                0x00,
+        };
+
+        String failMessage = "";
+        int checkedStatusBitsNumber = statusBitsNames.length;
+        logWriter.println("=> CHECK for all returned bits of status...");
+        for (int i = 0; i < checkedStatusBitsNumber; i++) {
+            int returnedStatusBit = returnedStatus & statusBitsValues[i];
+            if ( expectedStatusBits[i] != returnedStatusBit ) {
+                logWriter.println("\n## FAILURE: " + thisCommandName
+                        + " returns unexpected value for status bit \"" + statusBitsNames[i] + "\"");
+                logWriter.println
+                ("## Expected status bit = 0x" + Integer.toHexString(expectedStatusBits[i]));
+                logWriter.println
+                ("## Returned status bit = 0x" + Integer.toHexString(returnedStatusBit));
+                failMessage = failMessage +
+                    thisCommandName
+                    + " returns unexpected value for status bit \"" + statusBitsNames[i] + "\"" +
+                    ", Expected = 0x" + Integer.toHexString(expectedStatusBits[i]) +
+                    ", Returned = 0x" + Integer.toHexString(returnedStatusBit) + "; ";
+            } else {
+                logWriter.println("\n=> Expected value for status bit \"" + statusBitsNames[i]
+                    + "\" (0x" + Integer.toHexString(statusBitsValues[i]) + ") is returned: 0x"
+                    + Integer.toHexString(returnedStatusBit));
+            }
+        }
+
+        if (failMessage.length() == 0) {
+            logWriter.println
+            ("\n=> CHECK: PASSED: returned status value contains all expected status' bits");
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+        if (failMessage.length() > 0) {
+            fail(failMessage);
+        }
+        
+        assertAllDataRead(checkedReply);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(StatusTest.class);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/StatusTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValuesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValuesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValuesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValuesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.4 $
+
+ /**
+ * Created on 15.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for StackFrame.GetValues command.
+ */
+public class GetValuesTest extends JDWPStackFrameTestCase {
+
+    String testedMethodName = "nestledMethod3";
+    String testedThreadName = "";
+
+    VarInfo[] varInfos;
+
+    String varSignature[] = { "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee;", "Z",
+            "I", "Ljava/lang/String;" };
+
+    String varNames[] = { "this", "boolLocalVariable", "intLocalVariable",
+            "strLocalVariable" };
+
+    byte varTags[] = { JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.BOOLEAN_TAG,
+            JDWPConstants.Tag.INT_TAG, JDWPConstants.Tag.STRING_TAG };
+
+    private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee;";
+
+    /**
+     * This testcase exercises StackFrame.GetValues command.
+     * <BR>The test starts StackTraceDebuggee, sets breakpoint at the beginning of
+     * the tested method - 'nestledMethod3' and stops at the breakpoint.
+     * <BR> Then the test performs Method.VariableTable command and checks
+     * returned VariableTable.
+     * <BR> At last the test performs StackFrame.GetValues command and checks
+     * returned values of variables.
+     *  
+     */
+    public void testGetValues001() {
+        logWriter.println("==> testGetValues001 started...");
+        testedThreadName = synchronizer.receiveMessage();
+        // release on run()
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // pass nestledMethod1()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // enter nestledMethod2()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        //release debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        
+        //gets and checks local variables of tested method
+        examineGetValues();
+        
+        // signal to finish debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testGetValues001 - OK.");
+
+    }
+
+    private void examineGetValues() {
+        
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+        logWriter.println("=> referenceTypeID for Debuggee class = "
+                + refTypeID);
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+
+        logWriter.println("=> testedThreadID = " + threadID);
+        if (threadID == -1) {
+            printErrorAndFail("testedThread is not found!");
+        }
+        
+        // suspend thread
+        jdwpSuspendThread(threadID);
+
+        //get number of frames
+        int frameCount = jdwpGetFrameCount(threadID);
+        logWriter.println("=> frames count = " + frameCount);
+
+        //get frames info
+        FrameInfo[] frameIDs = jdwpGetFrames(threadID, 0, frameCount);
+        if (frameIDs.length != frameCount) {
+            printErrorAndFail("Received number of frames = "
+                    + frameIDs.length + " differ from expected number = "
+                    + frameCount);
+        }
+
+        //check and print methods info
+        long methodID = 0;
+        long frameID = 0;
+        String methodName = "";
+        boolean testedMethodChecked = false;
+        for (int i = 0; i < frameCount; i++) {
+            logWriter.println("\n");
+            methodName = getMethodName(frameIDs[i].location.classID,
+                    frameIDs[i].location.methodID);
+            logWriter.println("=> method name = " + methodName);
+            logWriter.println("=> methodID = " + frameIDs[i].location.methodID);
+            logWriter.println("=> frameID = " + frameIDs[i].frameID);
+            logWriter.println("\n");
+            if (methodName.equals(testedMethodName)) {
+                methodID = frameIDs[i].location.methodID;
+                frameID = frameIDs[i].frameID;
+                methodName = getMethodName(frameIDs[i].location.classID,
+                        frameIDs[i].location.methodID);
+                testedMethodChecked = true;
+            }
+        }
+        if (testedMethodChecked) {
+            logWriter.println("=> Tested method is found");
+            logWriter.println("=> method name = " + testedMethodName);
+            logWriter.println("=> methodID = " + methodID);
+            logWriter.println("=> frameID = " + frameID);
+
+        } else {
+            printErrorAndFail("Tested method is not found");
+        }
+
+        //getting Variable Table
+        logWriter.println("");
+        logWriter.println("=> Getting Variable Table...");
+        varInfos = jdwpGetVariableTable(refTypeID, methodID);
+        if (checkVarTable(varInfos)) {
+            logWriter.println("=> Variable table check passed.");
+        } else {
+            printErrorAndFail("Variable table check failed.");
+        }
+
+        //prepare and perform GetValues command
+        logWriter.println("");
+        logWriter.println("=> Send StackFrame::GetValues command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.GetValuesCommand);
+        packet.setNextValueAsThreadID(threadID);
+        packet.setNextValueAsFrameID(frameID);
+
+        logWriter.println("=> Thread: " + threadID);
+        logWriter.println("=> Frame: " + frameID);
+        packet.setNextValueAsInt(varTags.length);
+        for (int i = 0; i < varTags.length; i++) {
+            logWriter.println("");
+            logWriter.println("=> For variable #"+i+":");
+            packet.setNextValueAsInt(varInfos[i].getSlot());
+            logWriter.println("=> Slot = "+varInfos[i].getSlot());
+            packet.setNextValueAsByte(varTags[i]);
+            logWriter.println("=> Tag = "+JDWPConstants.Tag.getName(varTags[i]));
+            logWriter.println("");
+        }
+
+        //check reply for errors
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "StackFrame::GetValues command");
+
+        //check number of retrieved values
+        int numberOfValues = reply.getNextValueAsInt();
+        logWriter.println("=> Number of values = " + numberOfValues);
+        if (numberOfValues != varTags.length) {
+            printErrorAndFail("Unexpected number of values: "
+                    + numberOfValues + " instead of "+varTags.length);
+        }
+
+        boolean success = true;
+        //print and check values of variables
+        logWriter.println("=> Values of variables: ");
+
+        Value val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.OBJECT_TAG) {
+            logWriter.println("=> Tag is correct");
+            logWriter.println("");
+            
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: CLASS_OBJECT_TAG");
+            logWriter.printError("");
+            success = false;
+        }
+
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.BOOLEAN_TAG) {
+            logWriter.println("=>Tag is correct");
+            boolean boolValue = val.getBooleanValue();
+            if (boolValue) {
+                logWriter.println("=> "+varInfos[1].getName() + " = " + boolValue);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("Unexpected value of boolean variable: "
+                                + boolValue + " instead of: true");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: boolean");
+            logWriter.printError("");
+            success = false;
+        }
+
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.INT_TAG) {
+            logWriter.println("=>Tag is correct");
+            int intValue = val.getIntValue();
+            if (intValue == -512) {
+                logWriter.println("=> "+varInfos[2].getName() + " = " + intValue);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("unexpected value of int variable: "
+                                + intValue + " instead of: -512");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: integer");
+            logWriter.printError("");
+            success = false;
+        }
+
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.STRING_TAG) {
+            logWriter.println("=>Tag is correct");
+            long strLocalVariableID = val.getLongValue();
+            String strLocalVariable = getStringValue(strLocalVariableID);
+            if (strLocalVariable.equals("test string")) {
+                logWriter.println("=> "+varInfos[2].getName() + " = "
+                        + strLocalVariable);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("Unexpected value of string variable: "
+                                + strLocalVariable
+                                + " instead of: "
+                                + "test string");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: string");
+            logWriter.printError("");
+            success = false;
+        }
+        assertTrue(logWriter.getErrorMessage(), success);
+    }
+
+    //prints variables info, checks signatures
+    boolean checkVarTable(VarInfo[] varInfos) {
+        boolean success = true;
+        logWriter.println("==> Number of variables = " + varInfos.length);
+        if (varInfos.length != varTags.length) {
+            
+            printErrorAndFail("Unexpected number of variables: "
+                    + varInfos.length + " instead of " + varTags.length);
+        }
+        for (int i = 0; i < varInfos.length; i++) {
+            logWriter.println("");
+            logWriter.println("=> Name = " + varInfos[i].getName());
+            //## take codeIndex and length and check them
+            logWriter.println("=> Slot = " + varInfos[i].getSlot());
+            logWriter.println("=> Sign = " + varInfos[i].getSignature());
+            if (!(varSignature[i].equals(varInfos[i].getSignature()))) {
+                logWriter
+                        .printError("Unexpected signature of variable = "
+                                + varInfos[i].getName()
+                                + ", on slot = "
+                                + varInfos[i].getSlot()
+                                + ", with unexpected signature = "
+                                + varInfos[i].getSignature()
+                                + " instead of signature = " + varSignature[i]);
+                success = false;
+            }
+            if (!(varNames[i].equals(varInfos[i].getName()))) {
+                logWriter.printError("Unexpected name of variable  "
+                        + varInfos[i].getName() + ", on slot = "
+                        + varInfos[i].getSlot() + " instead of name = "
+                        + varNames[i]);
+                success = false;
+            }
+
+            logWriter.println("");
+        }
+        return success;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(GetValuesTest.class);
+    }
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValuesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/JDWPStackFrameTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/JDWPStackFrameTestCase.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/JDWPStackFrameTestCase.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/JDWPStackFrameTestCase.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.Location;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+
+
+public class JDWPStackFrameTestCase extends JDWPSyncTestCase {
+    
+    public class FrameInfo {
+        long frameID;
+        Location location;
+        
+        public FrameInfo(long frameID, Location location) {
+            super();
+            this.frameID = frameID;
+            this.location = location;
+        }
+        
+        /**
+         * @return Returns the frameID.
+         */
+        public long getFrameID() {
+            return frameID;
+        }
+        /**
+         * @return Returns the location.
+         */
+        public Location getLocation() {
+            return location;
+        }
+    }
+    
+    public class VarInfo {
+        int slot;
+        String signature, name;
+        
+        
+        public VarInfo(String name, int slot, String signature) {
+            this.slot = slot;
+            this.signature = signature;
+            this.name = name;
+        }
+        
+        public int getSlot() {
+            return slot;
+        }
+        
+        public String getSignature() {
+            return signature;
+        }
+        
+        public String getName() {
+            return name;
+        }
+        
+    }
+    
+    protected String getDebuggeeClassName() {
+        return StackTraceDebuggee.class.getName();
+    }
+    
+    protected int jdwpGetFrameCount(long threadID) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.FrameCountCommand);
+        packet.setNextValueAsThreadID(threadID);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::FrameCount command");
+        
+        int frameCount = reply.getNextValueAsInt();
+        return frameCount;
+    }
+
+    protected FrameInfo[] jdwpGetFrames(long threadID, int startFrame, int length) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
+        packet.setNextValueAsThreadID(threadID);
+        packet.setNextValueAsInt(startFrame);
+        packet.setNextValueAsInt(length);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::FramesCommand command");
+               
+        int frames = reply.getNextValueAsInt();
+        FrameInfo[] frameInfos = new FrameInfo[frames];
+        for (int i = 0; i < frames; i++) {
+            long frameID = reply.getNextValueAsLong();
+            Location location = reply.getNextValueAsLocation();
+            frameInfos[i] = new FrameInfo(frameID, location);
+        }
+        return frameInfos;
+    }
+    
+    protected VarInfo[] jdwpGetVariableTable(long classID, long methodID) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.MethodCommandSet.CommandSetID,
+                JDWPCommands.MethodCommandSet.VariableTableCommand);
+        packet.setNextValueAsClassID(classID);
+        packet.setNextValueAsMethodID(methodID);
+
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "Method::VariableTable command");
+        
+        reply.getNextValueAsInt();
+        int varNumber = reply.getNextValueAsInt();
+        
+        VarInfo[] varInfos = new VarInfo[varNumber];
+        for (int i = 0; i < varNumber; i++) {
+            reply.getNextValueAsLong();
+            String name = reply.getNextValueAsString();
+            String sign = reply.getNextValueAsString();
+            reply.getNextValueAsInt();
+
+            int slot = reply.getNextValueAsInt();
+            varInfos[i] = new VarInfo(name, slot, sign);
+        }
+        return varInfos;
+    }
+
+    protected long[] jdwpGetAllThreads() {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllThreadsCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllThreads command");
+        
+        int frames = reply.getNextValueAsInt();
+        
+        long[] frameIDs = new long[frames]; 
+        for (int i = 0; i < frames; i++) {
+            frameIDs[i] = reply.getNextValueAsLong();
+        }
+        
+        return frameIDs;
+    }
+
+    protected String jdwpGetThreadName(long threadID) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.NameCommand);
+        packet.setNextValueAsThreadID(threadID);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::Name command");
+        
+        String name= reply.getNextValueAsString();
+        return name;
+    }
+    
+    protected void jdwpSuspendThread(long threadID) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.SuspendCommand);
+        packet.setNextValueAsThreadID(threadID);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::Suspend command");
+    }
+    
+    protected void jdwpResumeThread(long threadID) {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
+        packet.setNextValueAsThreadID(threadID);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::Resume command");
+    }
+ 
+    protected void jdwpPopFrames(long threadID, long frameID) {
+        CommandPacket popFramesCommand = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.PopFramesCommand);
+        popFramesCommand.setNextValueAsThreadID(threadID);
+        popFramesCommand.setNextValueAsFrameID(frameID);
+
+        ReplyPacket reply = debuggeeWrapper.vmMirror
+                .performCommand(popFramesCommand);
+        checkReplyPacket(reply, "StackFrame::PopFramesCommand command");
+    }
+
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/JDWPStackFrameTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFrames002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFrames002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFrames002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFrames002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,457 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 1.05.2006
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for StackFrame.PopFrames command.
+ */
+public class PopFrames002Test extends JDWPStackFrameTestCase {
+
+    private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee;";
+
+    private String breakpointMethodName = "nestledMethod4";
+
+    private String methodToPop = "nestledMethod2";
+
+    private long timeoutToWait = 2000;
+
+    private long timeOfMethodInvocation = timeoutToWait * 5;
+
+    private static final byte NUMBER_OF_FRAMES_TO_POP = 3;
+
+    protected String getDebuggeeClassName() {
+        return PopFramesDebuggee.class.getName();
+    }
+
+    /**
+     * This testcase exercises StackFrame.PopFrames command to discard several frames at once.
+     * <BR>The test starts PopFramesDebuggee class, sets a breakpoint
+     * in 'nestledMethod4', stops at breakpoint and prints stack.
+     * <BR>Then the test performs StackFrame.PopFrame command to discard several frames at once,
+     * prints stack and checks that discarded frames are not returned 
+     * by ThreadReference.Frames command. 
+     * <BR>Then the test resumes debuggee and checks stop on the same breakpoint.
+     */
+    public void testPopSeveralFrames() {
+        logWriter.println("==> testPopSeveralFrames started");
+        
+        //check capability, relevant for this test
+        logWriter.println("=> Check capability: canPopFrames");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canPopFrames;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canPopFrames");
+            return;
+        }
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // find checked method
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+
+        // long methodID = getMethodID(refTypeID, breakpointMethodName);
+        logWriter.println("=> Set breakpoint at the beginning of " + breakpointMethodName);
+        long requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+                refTypeID, breakpointMethodName);
+
+        // release debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // receive event in nestledMethod4
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        long breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> breakpointThreadID = " + breakpointThreadID);
+
+        // print stack frames
+        logWriter.println("");
+        logWriter.println("=> Get frames before PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+        logWriter.println("=> Frames before popFrame");
+        printStackFrame(frameInfos.length, frameInfos);
+        logWriter.println("=> Number of frames before command: "
+                + frameInfos.length);
+
+        // find stack frame for popped method
+        logWriter.println("");
+        logWriter.println("=> Find frameID of method = " + methodToPop + " for PopFrames command");
+        long frameID = 0;
+        long methodID = getMethodID(refTypeID, methodToPop);
+        if (methodID == -1) {
+            logWriter.println("##FAILURE: error during getting methodID of " + methodToPop);
+        }
+        boolean isMethodFound = false;
+        for (int j = 0; j < frameInfos.length; j++) {
+            if (frameInfos[j].location.methodID == methodID) {
+                frameID = frameInfos[j].getFrameID();
+                isMethodFound = true;
+                break;
+            }
+        }
+        if (!isMethodFound) {
+            logWriter
+                    .println("##FAILURE: there is no frame for checked method");
+            fail("There is no frame for checked method");
+        }
+
+        logWriter.println("=> frameID for PopFrames command = " + frameID);
+        
+        // pop stack frames
+        logWriter.println("=> Pop " + NUMBER_OF_FRAMES_TO_POP + " frames at once");
+
+        logWriter.println("");
+        logWriter.println("=> Perform PopFrames command for method = " + methodToPop + " with frameID = " + frameID);
+        jdwpPopFrames(breakpointThreadID, frameID);
+
+        logWriter.println("=> Get frames after PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] newFrameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+
+        logWriter.println("");
+        logWriter.println("=> Frames after popFrame");
+        logWriter.println("=> newNumberOfFrames = " + newFrameInfos.length);
+
+        printStackFrame(newFrameInfos.length, newFrameInfos);
+        logWriter.println("=> Check that " + NUMBER_OF_FRAMES_TO_POP + " were discarded");
+        int numberOfPoppedFrames = frameInfos.length - newFrameInfos.length;
+        assertEquals("not all frames were discarded", numberOfPoppedFrames,
+                NUMBER_OF_FRAMES_TO_POP);
+
+        for (int i = numberOfPoppedFrames; i < (frameInfos.length); i++) {
+            if (frameInfos[i].location.methodID != newFrameInfos[i
+                    - numberOfPoppedFrames].location.methodID) {
+                logWriter.println("## FAILURE: frames number " + i + " and "
+                        + (i - numberOfPoppedFrames) + " are not equal");
+                fail("frames number are not equal");
+            }
+        }
+
+        logWriter.println("=> Ckeck PASSED");
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> TEST popSeveralFrames PASSED");
+
+    }
+
+    /**
+     * This testcase exercises StackFrame.PopFrames command performing it several times.
+     * <BR>The test starts PopFramesDebuggee class, sets a breakpoint
+     * in 'nestledMethod4', stops at breakpoint and prints stack.
+     * <BR>Then the test performs StackFrame.PopFrame command several times
+     * to discard frames one after another,
+     * prints stack and checks that discarded frames are not returned 
+     * by ThreadReference.Frames command. 
+     * <BR>Then the test resumes debuggee and checks stop on the same breakpoint.
+     */
+    public void testPopSeveralTimes() {
+        logWriter.println("==> testPopSeveralTimes started");
+
+        //check capability, relevant for this test
+        logWriter.println("=> Check capability: canPopFrames");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canPopFrames;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canPopFrames");
+            return;
+        }
+        // pass nestledMethod1()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // find checked method
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+
+        logWriter.println("=> Set breakpoint at the beginning of " + breakpointMethodName);
+        long requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+                refTypeID, breakpointMethodName);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // receive event
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        long breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> breakpointThreadID = " + breakpointThreadID);
+
+        // print stack frames
+        logWriter.println("");
+        logWriter.println("=> Get frames before PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+        logWriter.println("=> Frames before popFrame");
+        printStackFrame(frameInfos.length, frameInfos);
+        int framesBeforePop = frameInfos.length;
+        logWriter
+                .println("=> Number of frames before command: " + framesBeforePop);
+
+        logWriter.println("");
+        logWriter.println("=> Pop " + NUMBER_OF_FRAMES_TO_POP
+                + " frames one after another");
+        logWriter.println("");
+        for (int i = 0; i < 3; i++) {
+            logWriter.println("=> Pop frame#" + i);
+            frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+            logWriter.println("=> Perform PopFrames command with frameID = " + frameInfos[0].getFrameID());
+            jdwpPopFrames(breakpointThreadID, frameInfos[0].getFrameID());
+        }
+        
+        logWriter.println("=> Get frames after PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] newFrameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+
+        logWriter.println("");
+        logWriter.println("=> Frames after popFrame");
+        logWriter.println("=> newNumberOfFrames = " + newFrameInfos.length);
+
+        printStackFrame(newFrameInfos.length, newFrameInfos);
+        
+        logWriter.println("=> Check that " + NUMBER_OF_FRAMES_TO_POP + " frames were discarded");
+        int numberOfPoppedFrames = framesBeforePop - newFrameInfos.length;
+        assertEquals("not all frames were discarded", numberOfPoppedFrames,
+                NUMBER_OF_FRAMES_TO_POP);
+
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> TEST popSeveralTimes PASSED");
+    }
+
+    /**
+     * This testcase exercises StackFrame.PopFrames command when thread is not suspended.
+     * <BR>The test starts PopFramesDebuggee class, sets a breakpoint
+     * in 'nestledMethod4', stops at breakpoint and prints stack.
+     * <BR>Then the test performs ClassType.InvokeMethodCommand without waiting reply, and
+     * waits to ensure that method was started. 
+     * <BR>During working of method the test performs StackFrame.PopFrames command.
+     * Then the test checks that StackFrame.PopFrames command
+     * returns error: THREAD_NOT_SUSPENDED or INVALID_FRAMEID.
+     * <BR>Next, the test receives reply from invoked method and resumes debuggee..
+     */
+    public void testPopFramesWithInvokeMethods() {
+        logWriter.println("==> testPopFramesWithInvokeMethods started");
+
+        //check capability, relevant for this test
+        logWriter.println("=> Check capability: canPopFrames");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canPopFrames;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canPopFrames");
+            return;
+        }
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // find checked method
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+        
+        logWriter.println("=> Set breakpoint at the beginning of " + breakpointMethodName);
+        long requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+                refTypeID, breakpointMethodName);
+
+        // release debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // receive event
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        long breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> breakpointThreadID = " + breakpointThreadID);
+
+        // print stack frames
+        logWriter.println("");
+        logWriter.println("=> Get frames before PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+        printStackFrame(frameInfos.length, frameInfos);
+        logWriter.println("=> Number of frames before command: "
+                + frameInfos.length);
+
+        // find frameID to pop
+        logWriter.println("");
+        logWriter.println("=> Find frameID of method = " + methodToPop + " for PopFrames command");
+        long frameID = 0;
+        long methodID = getMethodID(refTypeID, methodToPop);
+        boolean isMethodFound = false;
+        for (int j = 0; j < frameInfos.length; j++) {
+            if (frameInfos[j].location.methodID == methodID) {
+                frameID = frameInfos[j].getFrameID();
+                isMethodFound = true;
+                break;
+            }
+        }
+        if (!isMethodFound) {
+            logWriter
+                    .println("##FAILURE: there is no frame for checked method");
+            fail("There is no frame for checked method");
+        }
+
+        logWriter.println("=> frameID for PopFrames command = " + frameID);
+        
+        // create JDWP command for MethodInvoke with a long running method
+        long debuggeeRefTypeID = debuggeeWrapper.vmMirror
+                .getClassID(debuggeeSignature);
+        logWriter.println("=> Find toInvokeMethodID for method: " + PopFramesDebuggee.METHOD_TO_INVOKE_NAME);
+        long toInvokeMethodID = debuggeeWrapper.vmMirror.getMethodID(
+                debuggeeRefTypeID, PopFramesDebuggee.METHOD_TO_INVOKE_NAME);
+        if (toInvokeMethodID == -1) {
+            logWriter
+                    .println("## FAILURE: Can NOT get toInvokeMethodID for method: "
+                            + PopFramesDebuggee.METHOD_TO_INVOKE_NAME);
+            fail("## Can NOT get toInvokeMethodID");
+        }
+        logWriter.println("=> toInvokeMethodID = " + toInvokeMethodID);
+        
+        int invokeCommandID = 0;
+        CommandPacket invokeCommand = new CommandPacket(
+                JDWPCommands.ClassTypeCommandSet.CommandSetID,
+                JDWPCommands.ClassTypeCommandSet.InvokeMethodCommand);
+        invokeCommand.setNextValueAsClassID(debuggeeRefTypeID);
+        invokeCommand.setNextValueAsThreadID(breakpointThreadID);
+        invokeCommand.setNextValueAsMethodID(toInvokeMethodID);
+        invokeCommand.setNextValueAsInt(1); // args number
+        invokeCommand.setNextValueAsValue(new Value(timeOfMethodInvocation));
+        invokeCommand
+                .setNextValueAsInt(JDWPConstants.InvokeOptions.INVOKE_SINGLE_THREADED);
+
+        // send MethodInvoke command, but not wait for reply
+        try {
+            logWriter
+                    .println("=> Send InvokeMethod command for method: " + PopFramesDebuggee.METHOD_TO_INVOKE_NAME);
+            invokeCommandID = debuggeeWrapper.vmMirror
+                    .sendCommand(invokeCommand);
+        } catch (Exception e) {
+            logWriter.println("Exception during invokeCommand: " + e);
+            throw new TestErrorException(e);
+        }
+
+        // wait to ensure that method invocation started
+        logWriter.println("=> Wait " + timeoutToWait
+                + " mls to ensure that method invocation started");
+        Object waitObj = new Object();
+        synchronized (waitObj) {
+            try {
+                waitObj.wait(timeoutToWait);
+            } catch (InterruptedException e) {
+                logWriter.println("##Exception while waiting on object: " + e);
+                throw new TestErrorException(e);
+            }
+        }
+
+        // perform PopFrame command
+        logWriter.println("=> Perform PopFrames command for method = " + methodToPop + " with frameID = " + frameID + " and expect errors");
+        CommandPacket popFramesCommand = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.PopFramesCommand);
+        popFramesCommand.setNextValueAsThreadID(breakpointThreadID);
+        popFramesCommand.setNextValueAsFrameID(frameID);
+
+        ReplyPacket popFrameReply = debuggeeWrapper.vmMirror
+                .performCommand(popFramesCommand);
+        int res = popFrameReply.getErrorCode();
+        logWriter.println("=> Returned error code: " + res + " ("
+                + JDWPConstants.Error.getName(res) + ")");
+
+        // check that PopFrames returns error, because thread is resumed by
+        // InvokeMethod
+        if (res == JDWPConstants.Error.NONE) {
+            logWriter
+                    .println("##PopFrames command returned no error for thread resumed by InvokeMethod");
+            fail("##PopFrames command returned no error for thread resumed by InvokeMethod");
+        }
+
+        logWriter.println("=> Receive reply of invoked method: " + PopFramesDebuggee.METHOD_TO_INVOKE_NAME);
+        try {
+            ReplyPacket reply = debuggeeWrapper.vmMirror
+                    .receiveReply(invokeCommandID);
+            checkReplyPacket(reply, "ClassType::InvokeMethod command");
+        } catch (Exception e) {
+            logWriter
+                    .println("##Exception while receiving reply for invoke command: "
+                            + e);
+            throw new TestErrorException(e);
+        }
+
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> TEST testPopFramesWithInvokeMethods PASSED");
+    }
+
+    void printStackFrame(int NumberOfFrames, FrameInfo[] frameInfos) {
+        for (int i = 0; i < NumberOfFrames; i++) {
+            logWriter.println(" ");
+            logWriter
+                    .println("=> #" + i + " frameID=" + frameInfos[i].frameID);
+            String methodName = getMethodName(frameInfos[i].location.classID,
+                    frameInfos[i].location.methodID);
+            logWriter.println("=> method name=" + methodName);
+        }
+        logWriter.println("");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(PopFrames002Test.class);
+    }
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFrames002Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 1.05.2006
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class PopFramesDebuggee extends SyncDebuggee {
+    
+    public static final String METHOD_TO_INVOKE_NAME = "methodToInvoke";
+    
+    public static long methodToInvoke(long timeToSleep) {
+        
+        Object obj = new Object();
+        synchronized (obj) {
+            try {
+                obj.wait(timeToSleep);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return timeToSleep;
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(PopFramesDebuggee.class);
+    }
+
+    public void run() {
+        logWriter.println("Entering nestledMethod1");
+        nestledMethod1();
+    }
+    
+    private void nestledMethod1() {
+        logWriter.println("Entering nestledMethod2");
+        nestledMethod2();
+    }
+
+    private void nestledMethod2() {
+        logWriter.println("Entering nestledMethod3");
+        //next line for breakpoint
+        nestledMethod3();
+    }
+    
+    private void nestledMethod3() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("Entering nestledMethod4");
+        //next line for breakpoint
+        nestledMethod4();
+    } 
+
+    private void nestledMethod4() {
+        boolean boolLocalVariable = true;
+        int intLocalVariable = -512;
+        String strLocalVariable = "test string";
+        logWriter.println("nestledMethod4 achieved");
+        logWriter.println("boolLocalVariable = " + boolLocalVariable);
+        logWriter.println("intLocalVariable = " + intLocalVariable);
+        logWriter.println("strLocalVariable = " +strLocalVariable);
+                       
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("PopFramesDebuggee is ended");        
+    }
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk, Aleksander V. Budniy
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for StackFrame.PopFrames command.
+ */
+public class PopFramesTest extends JDWPStackFrameTestCase {
+
+    private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee;";
+
+    private String breakpointMethodName = "nestledMethod4";
+
+    private String methodToPop = "nestledMethod4";
+
+    protected String getDebuggeeClassName() {
+        return PopFramesDebuggee.class.getName();
+    }
+
+    /**
+     * This testcase exercises StackFrame.PopFrames command to discard one top frame.
+     * <BR>The test starts PopFramesDebuggee class, sets a breakpoint
+     * in 'nestledMethod4', stops at breakpoint and prints stack.
+     * <BR>Then the test performs StackFrame.PopFrame command for one top frame,
+     * prints stack and checks that discarded frame is not returned 
+     * by ThreadReference.Frames command. 
+     * <BR>Then the test resumes debuggee and checks stop on the same breakpoint.
+     */
+    public void testPopFramesTest001() {
+        logWriter.println("==> testPopFramesTest001 started");
+        
+        //check capability, relevant for this test
+        logWriter.println("=> Check capability: canPopFrames");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canPopFrames;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canPopFrames");
+            return;
+        }
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // find checked method
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+                
+        logWriter.println("=> Set breakpoint at the beginning of " + breakpointMethodName);
+        long requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+                refTypeID, breakpointMethodName);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // receive event
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        long breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> breakpointThreadID = " + breakpointThreadID);
+
+        // print stack frames
+        logWriter.println("");
+        logWriter.println("=> Get frames before PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+        logWriter.println("=> Frames before popFrame");
+        printStackFrame(frameInfos.length, frameInfos);
+        logWriter.println("=> Number of frames before command: "
+                + frameInfos.length);
+
+        // find stack frame for popped method
+        logWriter.println("");
+        logWriter.println("=> Find frameID of method = " + methodToPop + " for PopFrames command");
+        long frameID = 0;
+        long methodID = getMethodID(refTypeID, methodToPop);
+        if (methodID == -1) {
+            logWriter.println("##FAILURE: error during getting methodID of " + methodToPop);
+        }
+        boolean isMethodFound = false;
+        for (int i = 0; i < frameInfos.length; i++) {
+            if (frameInfos[i].location.methodID == methodID) {
+                frameID = frameInfos[i].getFrameID();
+                isMethodFound = true;
+                break;
+            }
+        }
+        if (!isMethodFound) {
+            logWriter
+                    .println("##FAILURE: there is no frame for checked method");
+            fail("There is no frame for checked method");
+        }
+
+        logWriter.println("=> frameID for PopFrames command = " + frameID);
+
+        logWriter.println("");
+        logWriter.println("=> Perform PopFrames command for method = " + methodToPop + " with frameID = " + frameID);
+        // pop stack frame
+        CommandPacket popFramesCommand = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.PopFramesCommand);
+        popFramesCommand.setNextValueAsThreadID(breakpointThreadID);
+        popFramesCommand.setNextValueAsFrameID(frameID);
+
+        ReplyPacket err = debuggeeWrapper.vmMirror
+                .performCommand(popFramesCommand);
+        checkReplyPacket(err, "StackFrame::PopFrames command");
+
+        logWriter.println("=> Get frames after PopFrames command, thread = " + breakpointThreadID);
+        FrameInfo[] newFrameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+
+        logWriter.println("");
+        logWriter.println("=> Frames after popFrame");
+        logWriter.println("=> newNumberOfFrames = " + newFrameInfos.length);
+
+        printStackFrame(newFrameInfos.length, newFrameInfos);
+
+        // check if expected frames are popped
+        logWriter.println("=> Check that only one frame was discarded: frameID = " + frameID + ", method = " + methodToPop);
+        int numberOfPoppedFrames = frameInfos.length - newFrameInfos.length;
+        assertEquals("frame is not discarded", numberOfPoppedFrames, 1);
+
+        for (int i = numberOfPoppedFrames; i < (frameInfos.length); i++) {
+            if (frameInfos[i].location.methodID != newFrameInfos[i
+                    - numberOfPoppedFrames].location.methodID) {
+                logWriter.println("## FAILURE: frames number " + i + " and "
+                        + (i - numberOfPoppedFrames) + " are not equal");
+                fail("frames number are not equal");
+            }
+        }
+        logWriter.println("=> Ckeck PASSED");
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        logWriter.println("=> Wait for breakpoint in " + breakpointMethodName);
+        breakpointThreadID = debuggeeWrapper.vmMirror
+                .waitForBreakpoint(requestID);
+
+        logWriter.println("=> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> TEST PASSED");
+
+    }
+
+    void printStackFrame(int NumberOfFrames, FrameInfo[] frameInfos) {
+        for (int i = 0; i < NumberOfFrames; i++) {
+            logWriter.println(" ");
+            logWriter
+                    .println("=> #" + i + " frameID=" + frameInfos[i].frameID);
+            String methodName = getMethodName(frameInfos[i].location.classID,
+                    frameInfos[i].location.methodID);
+            logWriter.println("=> method name=" + methodName);
+        }
+        logWriter.println(" ");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(PopFramesTest.class);
+    }
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/SetValuesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/SetValuesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/SetValuesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/SetValuesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,343 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.4 $
+
+ /**
+ * Created on 15.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.StackFrame;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for StackFrame.SetValues command.
+ */
+public class SetValuesTest extends JDWPStackFrameTestCase {
+
+    String testedMethodName = "nestledMethod3";
+    String testedThreadName = "";
+
+    VarInfo[] varInfos;
+
+    String varSignature[] = { "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee;", "Z",
+            "I", "Ljava/lang/String;" };
+
+    String varNames[] = { "this", "boolLocalVariable", "intLocalVariable",
+            "strLocalVariable" };
+
+    byte varTags[] = { JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.BOOLEAN_TAG,
+            JDWPConstants.Tag.INT_TAG, JDWPConstants.Tag.STRING_TAG };
+
+    private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee;";
+
+    /**
+     * This testcase exercises StackFrame.SetValues command.
+     * <BR>The test starts StackTraceDebuggee, sets breakpoint at the beginning of
+     * the tested method - 'nestledMethod3' and stops at the breakpoint.
+     * <BR> Then the test performs Method.VariableTable command and checks
+     * returned VariableTable.
+     * <BR> Next, the test performs StackFrame.SetValues command and checks
+     * result of this command with help of StackFrame.GetValues command - 
+     * returned values of variables should be equal to values which were set.
+     *  
+     */
+    public void testSetValues001() {
+        logWriter.println("==> testSetValues001 started...");
+        testedThreadName = synchronizer.receiveMessage();
+        // release on run()
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // pass nestledMethod1()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // enter nestledMethod2()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        //release debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        
+        //sets and checks local variables of tested method
+        examineGetValues();
+        
+        // signal to finish debuggee
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testSetValues001 - OK.");
+
+    }
+
+    private void examineGetValues() {
+        
+        long refTypeID = getClassIDBySignature(debuggeeSignature);
+        logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+        logWriter.println("=> referenceTypeID for Debuggee class = "
+                + refTypeID);
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+
+        logWriter.println("=> testedThreadID = " + threadID);
+        if (threadID == -1) {
+            printErrorAndFail("testedThread is not found!");
+        }
+        
+        // suspend thread
+        jdwpSuspendThread(threadID);
+
+        //get number of frames
+        int frameCount = jdwpGetFrameCount(threadID);
+        logWriter.println("=> frames count = " + frameCount);
+
+        //get frames info
+        FrameInfo[] frameIDs = jdwpGetFrames(threadID, 0, frameCount);
+        if (frameIDs.length != frameCount) {
+            printErrorAndFail("Received number of frames = "
+                    + frameIDs.length + " differ from expected number = "
+                    + frameCount);
+        }
+
+        //check and print methods info
+        long methodID = 0;
+        long frameID = 0;
+        String methodName = "";
+        boolean testedMethodChecked = false;
+        for (int i = 0; i < frameCount; i++) {
+            logWriter.println("\n");
+            methodName = getMethodName(frameIDs[i].location.classID,
+                    frameIDs[i].location.methodID);
+            logWriter.println("=> method name = " + methodName);
+            logWriter.println("=> methodID = " + frameIDs[i].location.methodID);
+            logWriter.println("=> frameID = " + frameIDs[i].frameID);
+            logWriter.println("\n");
+            if (methodName.equals(testedMethodName)) {
+                methodID = frameIDs[i].location.methodID;
+                frameID = frameIDs[i].frameID;
+                methodName = getMethodName(frameIDs[i].location.classID,
+                        frameIDs[i].location.methodID);
+                testedMethodChecked = true;
+            }
+        }
+        if (testedMethodChecked) {
+            logWriter.println("=> Tested method is found");
+            logWriter.println("=> method name = " + testedMethodName);
+            logWriter.println("=> methodID = " + methodID);
+            logWriter.println("=> frameID = " + frameID);
+
+        } else {
+            printErrorAndFail("Tested method is not found");
+        }
+
+        //getting Variable Table
+        logWriter.println("");
+        logWriter.println("=> Getting Variable Table...");
+        varInfos = jdwpGetVariableTable(refTypeID, methodID);
+        if (checkVarTable(varInfos)) {
+            logWriter.println("=> Variable table check passed.");
+        } else {
+            printErrorAndFail("Variable table check failed.");
+        }
+        
+        //prepare and perform SetValues command
+        logWriter.println("");
+        logWriter.println("==> Send StackFrame::SetValues command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.SetValuesCommand);
+        packet.setNextValueAsThreadID(threadID);
+        packet.setNextValueAsLong(frameID);
+
+        packet.setNextValueAsInt(varTags.length-2);
+        packet.setNextValueAsInt(varInfos[1].getSlot());
+        packet.setNextValueAsValue(new Value(false));
+        packet.setNextValueAsInt(varInfos[2].getSlot());
+        packet.setNextValueAsValue(new Value((int)12345));
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "StackFrame::SetValues command");
+
+        //prepare and perform GetValues command
+        logWriter.println("");
+        logWriter.println("=> Send StackFrame::GetValues command...");
+        packet = new CommandPacket(
+                JDWPCommands.StackFrameCommandSet.CommandSetID,
+                JDWPCommands.StackFrameCommandSet.GetValuesCommand);
+        packet.setNextValueAsThreadID(threadID);
+        packet.setNextValueAsFrameID(frameID);
+
+        logWriter.println("=> Thread: " + threadID);
+        logWriter.println("=> Frame: " + frameID);
+        packet.setNextValueAsInt(varTags.length);
+        for (int i = 0; i < varTags.length; i++) {
+            logWriter.println("");
+            logWriter.println("=> For variable #"+i+":");
+            packet.setNextValueAsInt(varInfos[i].getSlot());
+            logWriter.println("=> Slot = "+varInfos[i].getSlot());
+            packet.setNextValueAsByte(varTags[i]);
+            logWriter.println("=> Tag = "+JDWPConstants.Tag.getName(varTags[i]));
+            logWriter.println("");
+        }
+
+        //check reply for errors
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "StackFrame::GetValues command");
+
+        //check number of retrieved values
+        int numberOfValues = reply.getNextValueAsInt();
+        logWriter.println("=> Number of values = " + numberOfValues);
+        if (numberOfValues != varTags.length) {
+            logWriter.println("##FAILURE: unexpected number of values: "
+                    + numberOfValues + " instead of "+varTags.length);
+            assertTrue(false);
+        }
+
+        boolean success = true;
+        //print and check values of variables
+        logWriter.println("=> Values of variables: ");
+
+        Value val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.OBJECT_TAG) {
+            logWriter.println("=> Tag is correct");
+            logWriter.println("");
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: CLASS_OBJECT_TAG");
+            logWriter.printError("");
+            success = false;
+        }
+        
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.BOOLEAN_TAG) {
+            logWriter.println("=>Tag is correct");
+            boolean boolValue = val.getBooleanValue();
+            if (!boolValue) {
+                logWriter.println("=> "+varInfos[1].getName() + " = " + boolValue);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("Unexpected value of boolean variable: "
+                                + boolValue + " instead of: false");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: boolean");
+            logWriter.printError("");
+            success = false;
+        }
+
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.INT_TAG) {
+            logWriter.println("=>Tag is correct");
+            int intValue = val.getIntValue();
+            if (intValue == 12345) {
+                logWriter.println("=> "+varInfos[2].getName() + " = " + intValue);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("Unexpected value of int variable: "
+                                + intValue + " instead of: 12345");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: integer");
+            logWriter.printError("");
+            success = false;
+        }
+
+        val = reply.getNextValueAsValue();
+        if (val.getTag() == JDWPConstants.Tag.STRING_TAG) {
+            logWriter.println("=>Tag is correct");
+            long strLocalVariableID = val.getLongValue();
+            String strLocalVariable = getStringValue(strLocalVariableID);
+            if (strLocalVariable.equals("test string")) {
+                logWriter.println("=> "+varInfos[2].getName() + " = "
+                        + strLocalVariable);
+                logWriter.println("");
+            } else {
+                logWriter
+                        .printError("Unexpected value of string variable: "
+                                + strLocalVariable
+                                + " instead of: "
+                                + "test string");
+                logWriter.printError("");
+                success = false;
+            }
+        } else {
+            logWriter.printError("Unexpected tag of variable: "
+                    + JDWPConstants.Tag.getName(val.getTag()) + " instead of: string");
+            logWriter.printError("");
+            success = false;
+        }
+        assertTrue(logWriter.getErrorMessage(), success);
+    }
+
+    //prints variables info, checks signatures
+    boolean checkVarTable(VarInfo[] varInfos) {
+        boolean success = true;
+        logWriter.println("==> Number of variables = " + varInfos.length);
+        if (varInfos.length != varTags.length) {
+            
+            printErrorAndFail("Unexpected number of variables: "
+                    + varInfos.length + " instead of " + varTags.length);
+        }
+        for (int i = 0; i < varInfos.length; i++) {
+            logWriter.println("");
+            logWriter.println("=> Name = " + varInfos[i].getName());
+            //## take codeIndex and length and check them
+            logWriter.println("=> Slot = " + varInfos[i].getSlot());
+            logWriter.println("=> Sign = " + varInfos[i].getSignature());
+            if (!(varSignature[i].equals(varInfos[i].getSignature()))) {
+                logWriter
+                        .printError("Unexpected signature of variable = "
+                                + varInfos[i].getName()
+                                + ", on slot = "
+                                + varInfos[i].getSlot()
+                                + ", with unexpected signature = "
+                                + varInfos[i].getSignature()
+                                + " instead of signature = " + varSignature[i]);
+                success = false;
+                ;
+            }
+            if (!(varNames[i].equals(varInfos[i].getName()))) {
+                logWriter.println("Unexpected name of variable  "
+                        + varInfos[i].getName() + ", on slot = "
+                        + varInfos[i].getSlot() + " instead of name = "
+                        + varNames[i]);
+                success = false;
+                ;
+            }
+
+            logWriter.println("");
+        }
+        return success;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(SetValuesTest.class);
+    }
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/SetValuesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native