harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [32/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...
Date Tue, 28 Nov 2006 17:49:31 GMT
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/StackTraceDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.2 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+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 StackTraceDebuggee extends SyncDebuggee {
+
+    public static void main(String [] args) {
+        runDebuggee(StackTraceDebuggee.class);
+    }
+
+    public void run() {
+        String currentThreadName = Thread.currentThread().getName();
+        synchronizer.sendMessage(currentThreadName);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        nestledMethod1();
+    }
+    
+    private void nestledMethod1() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        nestledMethod2();
+    }
+
+    private void nestledMethod2() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        nestledMethod3();
+    }
+
+    private void nestledMethod3() {
+        boolean boolLocalVariable = true;
+        int intLocalVariable = -512;
+        String strLocalVariable = "test string";
+        logWriter.println("boolLocalVariable = " + boolLocalVariable);
+        logWriter.println("intLocalVariable = " + intLocalVariable);
+        logWriter.println("strLocalVariable = " +strLocalVariable);
+                
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+    }
+
+}
\ No newline at end of file

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/ThisObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/ThisObjectTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/ThisObjectTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StackFrame/ThisObjectTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,226 @@
+/*
+ * 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 24.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.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for StackFrame.ThisObject command.
+ */
+public class ThisObjectTest extends JDWPStackFrameTestCase {
+
+    public static String[] KNOWN_METHOD_NAMES = {
+        "nestledMethod1",
+        "nestledMethod2",
+        "nestledMethod3",
+    };
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ThisObjectTest.class);
+    }
+
+    /**
+     * This testcase exercises StackFrame.ThisObject command.
+     * <BR>The test starts StackTraceDebuggee and
+     * checks if StackFrame.ThisObject command returns correct data for each stack frame 
+     * of main thread in debuggee, taking into account calls to known methods.
+     */
+    public void testThisObjectTest001() {
+        logWriter.println("==> ThisObjectTestTest001 started");
+        //boolean success = true;
+        
+        // select main thread
+        String mainThreadName = synchronizer.receiveMessage();
+        logWriter.println("==> Searching for main thread by name: " + mainThreadName);
+        long mainThread = debuggeeWrapper.vmMirror.getThreadID(mainThreadName);
+        logWriter.println("==> Found main thread: " + mainThread);
+        
+        // release on run()
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // pass nestledMethod1()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // pass nestledMethod2()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        // enter nestledMethod3()
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        if ( mainThread == -1 ) {
+            logWriter.println("## FAILURE: main thread is not found!");
+            //assert True(false);
+            fail("main thread is not found!");
+        }
+
+        // suspend thread
+        logWriter.println("==> Suspending main thread");
+        jdwpSuspendThread(mainThread);
+        
+        logWriter.println("==> Getting frames count");
+        int frameCount = jdwpGetFrameCount(mainThread);
+        logWriter.println("==> frames count = " + frameCount);
+        
+        logWriter.println("==> Getting frames");
+        FrameInfo[] frameIDs = jdwpGetFrames(mainThread, 0, frameCount);
+        logWriter.println("==> frames count = " + frameIDs.length);
+        assertEquals("Invlid number of frames,", frameCount, frameIDs.length);
+        //assertTrue(frameIDs.length == frameCount);
+        
+        for (int i = 0; i < frameCount; i++) {
+            logWriter.println("\n==> frame #" + i);
+
+            long frameID = frameIDs[i].frameID;
+            logWriter.println("==> frameID=" + frameID);
+            if (frameID == 0) {
+                logWriter.println("## FAILURE: ThreadReference.Frames returned NULL FrameID for frame #" + i);
+                //success = false;
+                fail("ThreadReference.Frames returned NULL FrameID for frame #" + i);
+                continue;
+            }
+            
+            // logWriter.println("  location=" + frameIDs[i].location);
+
+            String methodName = debuggeeWrapper.vmMirror.getMethodName(frameIDs[i].location.classID, frameIDs[i].location.methodID);
+            logWriter.println("==> method name=" + methodName);
+
+            String methodSig = debuggeeWrapper.vmMirror.getMethodSignature(frameIDs[i].location.classID, frameIDs[i].location.methodID);
+            logWriter.println("==> method signature=" + methodSig);
+
+            String classSig = debuggeeWrapper.vmMirror.getClassSignature(frameIDs[i].location.classID);
+            logWriter.println("==> class signature=" + classSig);
+
+            // get ThisObject
+            logWriter.println("==> Send StackFrame::ThisObject command...");
+            CommandPacket packet = new CommandPacket(
+                    JDWPCommands.StackFrameCommandSet.CommandSetID,
+                    JDWPCommands.StackFrameCommandSet.ThisObjectCommand);
+            packet.setNextValueAsThreadID(mainThread);
+            packet.setNextValueAsLong(frameIDs[i].getFrameID());
+            
+            ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            long knownMethodsThisObject = 0;
+            if (reply.getErrorCode() == JDWPConstants.Error.NONE) {
+                TaggedObject thisObject = reply.getNextValueAsTaggedObject();
+                logWriter.println("==> thisObject:");
+                logWriter.println("==> tag=" + thisObject.tag + "(" 
+                        + JDWPConstants.Tag.getName(thisObject.tag) + ")");
+                logWriter.println("==> id=" + thisObject.objectID);
+                if (thisObject.objectID != 0) {
+                    long classID = getObjectReferenceType(thisObject.objectID);
+                    logWriter.println("==> class=" + debuggeeWrapper.vmMirror.getClassSignature(classID));
+                }
+
+                for (int j = 0; j < KNOWN_METHOD_NAMES.length; j++) {
+                    if (KNOWN_METHOD_NAMES[j].equals(methodName)) {
+                        logWriter.println("==> frame for known method: " + KNOWN_METHOD_NAMES[j]);
+                        if (thisObject.objectID == 0) {
+                            logWriter.println
+                            ("## FAILURE: StackFrame.ThisObject returned NULL ObjectID for known method: " + methodName);
+                            //success = false;
+                            fail("StackFrame.ThisObject returned NULL ObjectID for known method: " + methodName);
+                        } else {
+                            if ( knownMethodsThisObject != 0 ) {
+                                if ( knownMethodsThisObject != thisObject.objectID ) {
+                                    logWriter.println
+                                    ("## FAILURE: Returned unexpected ObjectID for known method: " + methodName);
+                                    logWriter.println
+                                    ("## Expected ObjectID: " + knownMethodsThisObject);
+                                    //success = false;
+                                    fail("Returned unexpected ObjectID for known method: " + methodName);
+                                }
+                            } else {
+                                knownMethodsThisObject = thisObject.objectID;
+                            }
+                        }
+                        if (thisObject.tag != JDWPConstants.Tag.OBJECT_TAG) {
+                            logWriter.println
+                            ("## FAILURE: StackFrame.ThisObject returned not OBJECT_TAG for known method: " + methodName);
+                            //success = false;
+                            fail("StackFrame.ThisObject returned not OBJECT_TAG for known method: " + methodName);
+                        }
+                    }
+                }
+                
+                String mainMethod = "main";
+                if (mainMethod.equals(methodName)) {
+                    logWriter.println("==> frame for method: " + mainMethod);
+                    if (thisObject.objectID != 0) {
+                        logWriter.println
+                        ("## FAILURE: Returned unexpected ObjectID for method: " + mainMethod);
+                        logWriter.println
+                        ("## Expected ObjectID: " + 0);
+                        //success = false;
+                        fail("Returned unexpected ObjectID for method: " + mainMethod);
+                    }
+                    if (thisObject.tag != JDWPConstants.Tag.OBJECT_TAG) {
+                        logWriter.println
+                        ("## FAILURE: StackFrame.ThisObject returned not OBJECT_TAG for method: " + mainMethod);
+                        //success = false;
+                        fail("StackFrame.ThisObject returned not OBJECT_TAG for method: " + mainMethod);
+                    }
+                }
+
+                assertAllDataRead(reply);
+                /*if (!reply.isAllDataRead()) {
+                    logWriter.println("## FAILURE: Extra bytes in reply for StackFrame.ThisObject");
+                    success = false;
+                }*/
+                
+            } else {
+                logWriter.println
+                ("## FAILURE: StackFrame::ThisObject command returns unexpected ERROR = "
+                        + reply.getErrorCode() 
+                        + "(" + JDWPConstants.Error.getName(reply.getErrorCode()) + ")");
+                logWriter.println("## Expected ERROR = " + JDWPConstants.Error.NONE 
+                        + "(" + JDWPConstants.Error.getName(JDWPConstants.Error.NONE) + ")");
+                //success = false;
+                fail("StackFrame::ThisObject command returns unexpected ERROR = " + reply.getErrorCode() 
+                        + "(" + JDWPConstants.Error.getName(reply.getErrorCode()) + ")"
+                        + ", Expected ERROR = " + JDWPConstants.Error.NONE 
+                        + "(" + JDWPConstants.Error.getName(JDWPConstants.Error.NONE) + ")");
+            }
+        }
+
+        // resume thread
+        logWriter.println("==> Resuming main thread");
+        jdwpResumeThread(mainThread);    
+
+        // release nestledMethod3()
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        //assertTrue(success);
+        logWriter.println("==> ThisObjectTestTest001 finished");
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StringReference/ValueTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StringReference/ValueTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StringReference/ValueTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/StringReference/ValueTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,86 @@
+/*
+ * 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 07.02.2005
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.StringReference;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for StringReference.Value command.
+ */
+public class ValueTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ValueTest.class);
+    }
+
+    protected void checkString(String testString) throws UnsupportedEncodingException {
+        logWriter.println("=> Test string: \"" + testString + "\"");
+
+        // create new string
+        long stringID = createString(testString);
+        
+        // get string from StringID
+        String returnedTestString = getStringValue(stringID);
+        logWriter.println("=> Returned string: \"" + returnedTestString + "\"");
+
+        assertString("StringReference::Value command returned invalid string,",
+                testString, returnedTestString);
+    }
+
+    /**
+     * This testcase exercises StringReference.Value command.
+     * <BR>The test starts HelloWorld debuggee, create some strings
+     * with VirtualMachine.CreateString command.
+     * <BR> Then the test checks that for each created string
+     * StringReference.Value command returns string which is 
+     * equal to string used for CreateString command.
+     */
+    public void testStringReferenceValueTest001() throws UnsupportedEncodingException {
+        logWriter.println("StringReferenceValueTest001 started");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        
+        checkString("");
+        checkString("1234567890");
+        checkString("Some test string with various ASCII symbols "
+            + "~!@#$%^&*()_+|}{\"'?><,./");
+        checkString("Some test string with various national symbols " 
+            + "\u00a9\u0436\u0433\u0404\u0490\u00ad\u0408\u0438\u0439\u00a7\u0435"
+            + "\u043a\u043d\u00a6\u00a4\u00ab\u00ae\u0430\u0407\u00a0\u045e\u043b"
+            + "\u0434\u043f\u0437\u0431\u00ac\u0401\u0432\u043c\u040e\u043e.");
+        
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,110 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
+
+import org.apache.harmony.jpda.tests.framework.DebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+
+/**
+ * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.ChildrenTest</code>.
+ * This debuggee is started as follow:
+ * <ol>
+ *      <li>the group <code>PARENT_GROUP</code> is created
+ *      <li>the group <code>CHILD_GROUP</code> is created as a child of
+ *          the <code>PARENT_GROUP</code>  
+ *      <li>the tested thread <code>TESTED_THREAD</code> is started so this
+ *          thread belongs to the <code>PARENT_GROUP</code>.
+ * </ol>
+ */
+public class ChildrenDebuggee extends SyncDebuggee {
+
+    public static final String PARENT_GROUP  = "ParentGroup";
+    public static final String CHILD_GROUP   = "ChildGroup";
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+    
+    public void run() {
+        ThreadGroup thrdGroupParent = new ThreadGroup(PARENT_GROUP);
+        ThreadGroup thrdGroupChild = new ThreadGroup(thrdGroupParent, CHILD_GROUP);
+        DebuggeeThread thrd = new DebuggeeThread(thrdGroupParent, TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                
+            }
+        }
+
+        synchronized(waitForFinish){
+            logWriter.println("thread is finished");
+        }
+        
+        logWriter.println("DUMP{" + thrdGroupChild + "}");
+    }
+
+    class DebuggeeThread extends Thread {
+
+        LogWriter logWriter;
+        DebuggeeSynchronizer synchronizer;
+
+        public DebuggeeThread(ThreadGroup thrdGroup, String name,
+                LogWriter logWriter, DebuggeeSynchronizer synchronizer) {
+            super(thrdGroup, name);
+            this.logWriter = logWriter;
+            this.synchronizer = synchronizer;
+        }
+
+        public void run() {
+
+            synchronized(ChildrenDebuggee.waitForFinish){
+
+                synchronized(ChildrenDebuggee.waitForStart){
+
+                    ChildrenDebuggee.waitForStart.notifyAll();
+
+                    logWriter.println(getName() +  ": started");
+                    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+                    logWriter.println(getName() +  ": wait for SGNL_CONTINUE");
+                    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+                    logWriter.println(getName() +  ": finished");
+                }
+            }
+        }
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(ChildrenDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ChildrenTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,133 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
+
+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 ThreadGroupReference.Children command.
+ */
+public class ChildrenTest extends JDWPSyncTestCase {
+
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.ChildrenDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadGroupReference.Children command.
+     * <BR>At first the test starts ChildrenDebuggee.
+     * <BR> Then the test with help of the ThreadGroupReference.Children command checks
+     * that the group 'PARENT_GROUP' has one child thread - 'TESTED_THREAD' 
+     * and one child group - 'CHILD_GROUP'.
+     *  
+     */
+    public void testChildren001() {
+        logWriter.println("==> ChildrenTest.testChildren001 START...");
+        logWriter.println("==> Wait for SGNL_READY...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        logWriter.println("==> Get testedThreadID...");
+        CommandPacket packet;
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(NameDebuggee.TESTED_THREAD);
+        logWriter.println("==> testedThreadID = " + threadID);
+
+        long groupID;
+        String groupName;
+
+        // getting the thread group ID
+        logWriter.println("==> Send ThreadReference.ThreadGroup command for testedThreadID...");
+        packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
+        packet.setNextValueAsThreadID(threadID);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference.ThreadGroup command");
+        
+        groupID = reply.getNextValueAsThreadGroupID();
+        logWriter.println("==> groupID = " + groupID);
+
+        logWriter.println("==> Send ThreadGroupReference.Children command...");
+        packet = new CommandPacket(
+                JDWPCommands.ThreadGroupReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadGroupReferenceCommandSet.ChildrenCommand);
+        packet.setNextValueAsThreadID(groupID);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadGroupReference.Children command");
+
+        logWriter.println("\n==> Children of the group: \""
+                + debuggeeWrapper.vmMirror.getThreadGroupName(groupID)
+                + "\": ");
+
+        int childThreads = reply.getNextValueAsInt();
+        if (childThreads != 1) {
+            logWriter.println("## FAILURE: Unexpected number of child threads = " + childThreads);
+            logWriter.println("## Expected number of child threads = 1");
+            assertEquals("Invalid number of child threads,", 1, childThreads);
+        }
+        long childThreadID = reply.getNextValueAsThreadID();
+        String threadName = debuggeeWrapper.vmMirror.getThreadName(childThreadID);
+        logWriter.println
+        ("==> thread: threadID = " + childThreadID + "; threadName = " + threadName);
+                
+        if (threadID != childThreadID) {
+            logWriter.println("## FAILURE: Unexpected ID of child thread = " + childThreadID);
+            logWriter.println("## Expected ID of child thread = " + threadID);
+            assertEquals("Invalid ID of child thread,", threadID, childThreadID);
+        }
+        if (!threadName.equals(NameDebuggee.TESTED_THREAD)) {
+            logWriter.println("## FAILURE: unexpected thread name, it is expected: "
+                    + NameDebuggee.TESTED_THREAD);
+            assertString("Invalid thread name,", NameDebuggee.TESTED_THREAD, threadName);
+        }
+
+        int childGroups = reply.getNextValueAsInt();
+        if (childGroups != 1) {
+            logWriter.println("## FAILURE: Unexpected number of child groups " + childGroups);
+            logWriter.println("## Expected number = 1");
+            assertEquals("Invalid number of child groups,", 1, childGroups);
+        }
+
+        groupID = reply.getNextValueAsThreadGroupID();
+        groupName = debuggeeWrapper.vmMirror.getThreadGroupName(groupID);
+
+        logWriter.println("\n==> group: groupID = " + groupID + "; groupName = " + groupName);
+
+        assertString("Invalid group name,", NameDebuggee.CHILD_GROUP, groupName);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ChildrenTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,109 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
+
+import org.apache.harmony.jpda.tests.framework.DebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+
+/**
+ * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.NameTest</code>
+ * and <code>org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.ParentTest</code>.
+ * This debuggee is started as follow:
+ * <ol>
+ *      <li>the group <code>PARENT_GROUP</code> is created
+ *      <li>the group <code>CHILD_GROUP</code> is created as a child of
+ *          the <code>PARENT_GROUP</code>  
+ *      <li>the tested thread <code>TESTED_THREAD</code> is started so this
+ *          thread belongs to the <code>CHILD_GROUP</code>.
+ * </ol>
+ */
+public class NameDebuggee extends SyncDebuggee {
+
+    public static final String PARENT_GROUP  = "ParentGroup";
+    public static final String CHILD_GROUP   = "ChildGroup";
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+    
+    public void run() {
+        ThreadGroup thrdGroupParent = new ThreadGroup(PARENT_GROUP);
+        ThreadGroup thrdGroupChild = new ThreadGroup(thrdGroupParent, CHILD_GROUP);
+        DebuggeeThread thrd = new DebuggeeThread(thrdGroupChild, TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                
+            }
+        }
+
+        synchronized(waitForFinish){
+            logWriter.println("thread is finished");
+        }
+    }
+
+    class DebuggeeThread extends Thread {
+
+        LogWriter logWriter;
+        DebuggeeSynchronizer synchronizer;
+
+        public DebuggeeThread(ThreadGroup thrdGroup, String name,
+                LogWriter logWriter, DebuggeeSynchronizer synchronizer) {
+            super(thrdGroup, name);
+            this.logWriter = logWriter;
+            this.synchronizer = synchronizer;
+        }
+
+        public void run() {
+
+            synchronized(NameDebuggee.waitForFinish){
+
+                synchronized(NameDebuggee.waitForStart){
+
+                    NameDebuggee.waitForStart.notifyAll();
+
+                    logWriter.println(getName() +  ": started");
+                    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+                    logWriter.println(getName() +  ": wait for SGNL_CONTINUE");
+                    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+                    logWriter.println(getName() +  ": finished");
+                }
+            }
+        }
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(NameDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/NameTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,88 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
+
+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 ThreadGroupReference.Name command.
+ */
+public class NameTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.NameDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadGroupReference.Name command.
+     * <BR>At first the test starts NameDebuggee.
+     * <BR> Then the test with help of the ThreadGroupReference.Name command checks
+     * that for the thread 'TESTED_THREAD' the group name is 'CHILD_GROUP'.
+     *  
+     */
+    public void testName001() {
+        logWriter.println("wait for SGNL_READY");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        CommandPacket packet;
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(NameDebuggee.TESTED_THREAD);
+
+        long groupID;
+        String groupName;
+
+        // getting the thread group ID
+        packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
+        packet.setNextValueAsThreadID(threadID);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::ThreadGroup command");
+
+        groupID = reply.getNextValueAsThreadGroupID();
+        groupName = debuggeeWrapper.vmMirror.getThreadGroupName(groupID);
+
+        logWriter.println("\tthreadID=" + threadID
+                    + "; threadName=" + NameDebuggee.TESTED_THREAD
+                    + "; groupID=" + groupID
+                    + "; groupName=" + groupName);
+
+        assertString("ThreadReference::ThreadGroup command returned invalid group name,",
+                NameDebuggee.CHILD_GROUP, groupName);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(NameTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ParentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ParentTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ParentTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadGroupReference/ParentTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,98 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
+
+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 ThreadGroupReference.Parent command.
+ */
+public class ParentTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.NameDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadGroupReference.Parent command.
+     * <BR>At first the test starts NameDebuggee.
+     * <BR> Then the test with help of the ThreadGroupReference.Parent command checks
+     * that the parent group of the group of the tested thread is group
+     * with name 'PARENT_GROUP'.
+     *  
+     */
+    public void testParent001() {
+        logWriter.println("wait for SGNL_READY");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        CommandPacket packet;
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(NameDebuggee.TESTED_THREAD);
+
+        long groupID;
+        String groupName;
+
+        // getting the thread group ID
+        packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
+        packet.setNextValueAsThreadID(threadID);
+       
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::ThreadGroup command");
+
+        groupID = reply.getNextValueAsThreadGroupID();
+
+        packet = new CommandPacket(
+                JDWPCommands.ThreadGroupReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadGroupReferenceCommandSet.ParentCommand);
+        packet.setNextValueAsThreadID(groupID);
+        
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadGroupReference::Parent command");
+
+        groupID = reply.getNextValueAsThreadGroupID();
+
+        groupName = debuggeeWrapper.vmMirror.getThreadGroupName(groupID);
+
+        logWriter.println("\tgroupID=" + groupID
+                    + "; groupName=" + groupName);
+
+        assertString("ThreadGroupReference::Parent command returned invalid group name,",
+                NameDebuggee.PARENT_GROUP, groupName);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ParentTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,111 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.DebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * The class specifies debuggee for
+ * <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.CurrentContendedMonitorTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code> which
+ * invokes <code>wait()</code>.
+ */
+public class CurrentContendedMonitorDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_THREAD = "TestedThread";
+
+    static Object waitForStart = new Object();
+
+    static Object waitForFinish = new Object();
+
+    DebuggeeThread thrd;
+
+    public void run() {
+        thrd = new DebuggeeThread(TESTED_THREAD, logWriter, synchronizer);
+        try {
+            synchronized (waitForStart) {
+                thrd.start();
+                try {
+                    waitForStart.wait();
+                } catch (InterruptedException e) {
+                    throw new TestErrorException(e);
+                }
+            }
+            logWriter.println("thread started");
+
+            synchronized (waitForStart) {
+                synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+            }
+
+            synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        } finally {
+            if (thrd.isAlive()) {
+                logWriter.println("Thread is alive. Interrupt thread");
+                thrd.interrupt();
+            }
+        }
+    }
+
+    class DebuggeeThread extends Thread {
+
+        LogWriter logWriter;
+
+        DebuggeeSynchronizer synchronizer;
+
+        public DebuggeeThread(String name, LogWriter logWriter,
+                DebuggeeSynchronizer synchronizer) {
+            super(name);
+            this.logWriter = logWriter;
+            this.synchronizer = synchronizer;
+        }
+
+        public void run() {
+
+            synchronized (CurrentContendedMonitorDebuggee.waitForFinish) {
+
+                synchronized (CurrentContendedMonitorDebuggee.waitForStart) {
+                    CurrentContendedMonitorDebuggee.waitForStart.notifyAll();
+
+                    try {
+                        logWriter.println("Thread waits on object..");
+                        CurrentContendedMonitorDebuggee.waitForStart.wait();
+                    } catch (InterruptedException e) {
+                        logWriter.println("Expected " + e);
+                        //synchronizer.sendMessage(e.toString());
+                    }
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        runDebuggee(CurrentContendedMonitorDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/CurrentContendedMonitorTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,147 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.7 $
+ */
+
+/**
+ * Created on 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+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.TaggedObject;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ThreadReference.CurrentContendedMonitor command.
+ */
+public class CurrentContendedMonitorTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.CurrentContendedMonitorDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.CurrentContendedMonitor command.
+     * <BR>At first the test starts CurrentContendedMonitorDebuggee which runs 
+     * the tested thread 'TESTED_THREAD'.
+     * <BR> Then the test performs the ThreadReference.CurrentContendedMonitor command 
+     * for the tested thread. 
+     * <BR>After getting monitor object from command, the test
+     * performs the ObjectReference.MonitorInfo command for this monitor object 
+     * and checks that the waiter for this monitor is the 'TESTED_THREAD' thread.
+     *  
+     */
+    public void testCurrentContendedMonitor001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        
+        //check capability, relevant for this test
+        debuggeeWrapper.vmMirror.capabilities();
+        logWriter.println("=> Check capability: canGetMonitorInfo");
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetMonitorInfo;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canGetMonitorInfo");
+            return;
+        }
+        logWriter.println("=> Check capability: canGetCurrentContendedMonitor");
+        isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetCurrentContendedMonitor;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canGetCurrentContendedMonitor");
+            return;
+        }
+       
+        // getting ID of the tested thread
+        logWriter.println
+        ("==> testedThreadName = " + CurrentContendedMonitorDebuggee.TESTED_THREAD);
+        logWriter.println("==> Get testedThreadID...");
+        long testedThreadID = 
+            debuggeeWrapper.vmMirror.getThreadID(CurrentContendedMonitorDebuggee.TESTED_THREAD);
+        logWriter.println("==> testedThreadID = " + testedThreadID);
+        logWriter.println("==> suspend testedThread...");
+        debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+        // getting the thread group ID
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.CurrentContendedMonitorCommand);
+        packet.setNextValueAsThreadID(testedThreadID);
+        logWriter.println("send \"CurrentContendedMonitor\" command");
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::CurrentContendedMonitor command");
+        
+        TaggedObject tobj = reply.getNextValueAsTaggedObject();
+        
+        logWriter.println("\ttagged-object tag: "
+                + JDWPConstants.Tag.getName(tobj.tag) + "(" + tobj.tag + ") "
+                + "ID: " + tobj.objectID);
+        
+        packet = new CommandPacket(
+                JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+                JDWPCommands.ObjectReferenceCommandSet.MonitorInfoCommand);
+        packet.setNextValueAsObjectID(tobj.objectID);
+        ReplyPacket replyObj = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(replyObj, "ObjectReference::MonitorInfo command");
+        
+        replyObj.getNextValueAsThreadID();
+        replyObj.getNextValueAsInt();
+        int waiters = replyObj.getNextValueAsInt();
+        long waiterID;
+        String waiterName;
+        for (int i = 0; i < waiters; i++) {
+            waiterID = replyObj.getNextValueAsThreadID();
+            waiterName = debuggeeWrapper.vmMirror.getThreadName(waiterID);
+            logWriter.println("\twaiter: "
+                    + " " + waiterName
+                    + "(" + waiterID + ")");
+            if (waiterID != testedThreadID) {
+                logWriter.printError("wrong owner: " + waiterID);
+                assertEquals("ObjectReference::MonitorInfo returned wrong owner ID,",
+                        testedThreadID, waiterID);
+            }
+            assertString("ObjectReference::MonitorInfo  returned invalid waiter name,",
+                    OwnedMonitorsDebuggee.TESTED_THREAD, waiterName);
+        }
+
+        // interrupt
+        packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.InterruptCommand);
+        packet.setNextValueAsThreadID(testedThreadID);
+        logWriter.println("send \"Interrupt\" command");
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::Interrupt command");
+        
+        short err = reply.getErrorCode();
+        if (err != JDWPConstants.Error.NONE) {
+            logWriter.printError("Unexpected " + JDWPConstants.Error.getName(err));
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CurrentContendedMonitorTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FrameCountTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FrameCountTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FrameCountTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FrameCountTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,114 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 18.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+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.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ThreadReference.FrameCount command.
+ */
+public class FrameCountTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.FramesDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.CurrentContendedMonitor command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR> Then the tests requests list of frames for main thread by invoking
+     * the JDWP command ThreadReference.Frames and compares size of
+     * this list with the value got via invoking ThreadReference.FrameCount command.
+     * <BR>The test expects that these values are equal, otherwise the test fail.
+     *  
+     */
+    public void testFrameCount001() {
+        logWriter.println("==> testFrameCount001 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        long threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        int expectedCount = getFramesCount(threadID);
+        logWriter.println("\texpected count = " + expectedCount);
+        
+        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();
+        logWriter.println("\tframe count = " + frameCount);
+
+        if (frameCount != expectedCount) {
+            printErrorAndFail("Unexpected frame count = " + frameCount
+                    + ", expected value " + expectedCount);
+        }
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    private int getFramesCount(long threadID) {
+
+        logWriter.println("getting frames of the thread");
+
+        short err;
+        
+        // getting frames of the thread
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
+        packet.setNextValueAsThreadID(threadID);
+        packet.setNextValueAsInt(0);
+        packet.setNextValueAsInt(-1);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        err = reply.getErrorCode(); 
+        if ( err != JDWPConstants.Error.NONE) {
+            logWriter.println("\tthreadID=" + threadID
+                    + " - " + JDWPConstants.Error.getName(err));
+            return 0;
+        }
+        int framesCount = reply.getNextValueAsInt();
+        return framesCount;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(FrameCountTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,69 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.FramesTest</code>.
+ * It recursively invokes the method <code>FramesDebuggee.recursiveMethod</code>
+ * thereby the specified depth <code>FramesDebuggee.DEPTH</code> of recursion
+ * is reached. 
+ */
+public class FramesDebuggee extends SyncDebuggee {
+
+    public final static int DEPTH = 10; 
+    public final static String METHOD_NAME = "recursiveMethod";
+    public volatile static String THREAD_NAME = "TBD";
+
+    private int depthCount = 0; 
+
+    private void recursiveMethod() {
+        depthCount++;
+
+        if (depthCount < DEPTH) {
+            logWriter.println("\tinvoke tested method: depth=" + depthCount);
+            recursiveMethod();
+        }
+
+        if (depthCount == DEPTH) {
+            logWriter.println("\tsending SGNL_READY signal");
+            synchronizer.sendMessage(THREAD_NAME);
+            synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        }
+        depthCount--;
+    }
+
+    public void run() {
+        THREAD_NAME = Thread.currentThread().getName();
+        recursiveMethod();
+    }
+
+    public static void main(String[] args) {
+        runDebuggee(FramesDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/FramesTest.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 Vitaly A. Provodin
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 15.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import java.util.Vector;
+import java.util.Enumeration;
+
+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.Location;
+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 ThreadReference.Frames command.
+ */
+public class FramesTest extends JDWPSyncTestCase {
+
+    short err;
+    long threadID;
+
+    class FrameStruct {
+        long frameID;
+        Location loc;
+        FrameStruct(long frameID, Location loc) {
+            this.frameID = frameID;
+            this.loc = loc;
+        }
+    }
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.FramesDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Frames command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR> Then the tests performs the ThreadReference.Frames command 
+     * for the main thread with parameters: 
+     * <BR>startFrame=0, length=(amount_of_all_frames + 1)
+     * <BR>It is expected the error INVALID_LENGTH is returned.
+     */
+    public void testFrames005() {
+        logWriter.println("==> testFrames005 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        Vector allFrames = getFrames(0, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        String methodName, classSignature;
+        int i = 0;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                    + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+        }
+
+        allFrames = getFrames(0, allFrames.size() + 1);
+        if (err == JDWPConstants.Error.INVALID_LENGTH) {
+            logWriter.println("Cought expected error - " + JDWPConstants.Error.getName(err)
+                    + "(" + err + ")");
+        } else {
+            printErrorAndFail("unexpected behaviour: error is "
+                    + JDWPConstants.Error.getName(err) + "(" + err + ")"
+                    + " but  must be "
+                    + JDWPConstants.Error.getName(JDWPConstants.Error.INVALID_LENGTH)
+                    + "(" + JDWPConstants.Error.INVALID_LENGTH + ")");
+        }
+        logWriter.println("==> testFrames005 OK. "); 
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Frames command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR> Then the tests performs the ThreadReference.Frames command 
+     * for the main thread with parameters: 
+     * <BR>startFrame=(amount_of_all_frames + 1), length=-1
+     * <BR>It is expected the error INVALID_INDEX is returned.
+     */
+    public void testFrames004() {
+        logWriter.println("==> testFrames004 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        Vector allFrames = getFrames(0, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        String methodName, classSignature;
+        int i = 0;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                       + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+        }
+
+        allFrames = getFrames(allFrames.size() + 1, -1);
+        if (err == JDWPConstants.Error.INVALID_INDEX) {
+            logWriter.println("Cought expected error - " + JDWPConstants.Error.getName(err)
+                    + "(" + err + ")");
+        } else {
+            printErrorAndFail("unexpected behaviour: error is "
+                    + JDWPConstants.Error.getName(err) + "(" + err + ")"
+                    + " but  must be "
+                    + JDWPConstants.Error.getName(JDWPConstants.Error.INVALID_INDEX)
+                    + "(" + JDWPConstants.Error.INVALID_INDEX + ")");
+        }
+                    
+        logWriter.println("==> testFrames004 OK. "); 
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Frames command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR> Then the tests performs the ThreadReference.Frames command 
+     * for the main thread with parameters: 
+     * <BR>startFrame=amount_of_all_frames, length=-1
+     * <BR>It is expected an empty set of frames is returned.
+     */
+    public void testFrames003() {
+        logWriter.println("==> testFrames003 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        Vector allFrames = getFrames(0, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        String methodName, classSignature;
+        int i = 0;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+               logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                       + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+        }
+
+        allFrames = getFrames(allFrames.size(), -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        if (allFrames.size() == 0) {
+            logWriter.println("empty set of frames is returned");
+        } else {
+            printErrorAndFail("it is expected an empty set of frames, but frameCount = "
+                    + allFrames.size());
+        }
+                    
+        logWriter.println("==> testFrames003 OK. "); 
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Frames command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR>Then the test by ThreadReference.Frames command 
+     * requests all frames and looks for the first frame
+     * which has location in the 'recursiveMethod'.
+     * <BR>The index of such frame is passed as startFrame parameter for
+     * the second invocation of ThreadReference.Frames command.
+     * <BR>The length (the second parameter) is set to 'FramesDebuggee.DEPTH'.
+     * <BR>It is expected that the amount of returned frames is equal to
+     * 'FramesDebuggee.DEPTH' and all returned frames have locations in
+     * 'recursiveMethod'.
+     */
+    public void testFrames002() {
+        logWriter.println("==> testFrames002 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        Vector allFrames = getFrames(0, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        String methodName, classSignature;
+        int frameNumber = 0;
+        int i = 0;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            if (frameNumber == 0 && FramesDebuggee.METHOD_NAME.equals(methodName)) {
+                frameNumber = i;
+            }
+               logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                       + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+        }
+
+        if (frameNumber <= 0) {
+            printErrorAndFail("frameNumber is unexpectedly equal to " + frameNumber);
+        }
+        
+        allFrames = getFrames(frameNumber, FramesDebuggee.DEPTH);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        i = frameNumber;
+        int methodCount = 0;
+        String unexpectedMethods = null;
+        String depthError = null;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                    + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+               
+               if (methodName.equals(FramesDebuggee.METHOD_NAME)) {
+                   methodCount++;
+               } else {
+                   logWriter.printError("unexpected method - " + methodName);
+                   unexpectedMethods = null == unexpectedMethods ? methodName : unexpectedMethods + "," + methodName;
+               }
+        }
+        
+        if (methodCount != FramesDebuggee.DEPTH) {
+            logWriter.printError(depthError = ("Number of " + FramesDebuggee.METHOD_NAME + " in frames "
+                    + methodCount + "  but expected " + FramesDebuggee.DEPTH));
+        }
+        
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        if (null != unexpectedMethods) {
+            logWriter.println("==> testFrames002 FAILED "); 
+            fail("unexpected method(s): " + unexpectedMethods);
+        }
+        else if (null != depthError) {
+            logWriter.println("==> testFrames002 FAILED "); 
+            fail(depthError);
+        } else {   
+            logWriter.println("==> testFrames002 OK. "); 
+        }
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Frames command.
+     * <BR>At first the test starts FramesDebuggee which recursively invokes 
+     * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
+     * 'FramesDebuggee.DEPTH' of recursion is reached. 
+     * <BR>Then the test by ThreadReference.Frames command 
+     * requests all frames and looks for the first frame
+     * which has location in the 'recursiveMethod'.
+     * <BR>The index of such frame is passed as startFrame parameter for
+     * the second invocation of ThreadReference.Frames command.
+     * <BR>The length (the second parameter) is set to '-1'.
+     * <BR>It is expected that the amount of returned frames which are located in
+     * 'recursiveMethod' is equal to 'FramesDebuggee.DEPTH'.
+     */
+    public void testFrames001() {
+        logWriter.println("==> testFrames001 START "); 
+        String testedThreadName = synchronizer.receiveMessage();
+
+        logWriter.println
+        ("==> testedThreadName = |" + testedThreadName +"|"); 
+        threadID = debuggeeWrapper.vmMirror.getThreadID(testedThreadName);
+        logWriter.println("==> threadID = " + threadID); 
+        debuggeeWrapper.vmMirror.suspendThread(threadID);
+        
+        Vector allFrames = getFrames(0, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        String methodName, classSignature;
+        int frameNumber = 0;
+        int i = 0;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            if (frameNumber == 0 && FramesDebuggee.METHOD_NAME.equals(methodName)) {
+                frameNumber = i;
+            }
+            logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                    + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+        }
+
+        if (frameNumber <= 0) {
+            logWriter.printError("frameNumber is unexpectedly equal to " + frameNumber);
+            assertTrue("Invalid frameNumber", frameNumber > 0);
+        }
+        
+        allFrames = getFrames(frameNumber, -1);
+        if (err != JDWPConstants.Error.NONE) {
+            printErrorAndFail("Unexpected ERROR = " + err 
+                    + "(" + JDWPConstants.Error.getName(err) + ")");
+        }
+        i = frameNumber;
+        int methodCount = 0;
+        boolean testCondition;
+        String unexpectedMethods = null;
+        String depthError = null;
+        for (Enumeration e = allFrames.elements(); e.hasMoreElements(); i++) {
+            FrameStruct frame = (FrameStruct )e.nextElement();
+            methodName = getMethodName(frame.loc.classID, frame.loc.methodID);
+            classSignature = getClassSignature(frame.loc.classID);
+            logWriter.println("\t" + i + ". frameID=" + frame.frameID
+                    + " - " + classSignature
+                    + methodName
+                    + "(" + frame.loc.index + ")");
+               testCondition = (i == frameNumber
+                       && !methodName.equals(FramesDebuggee.METHOD_NAME));
+               if (testCondition) {
+                   logWriter.printError("unexpected method name of the first frame - "
+                           + methodName);
+                   unexpectedMethods = null == unexpectedMethods ? methodName : unexpectedMethods + "," + methodName;
+               }
+               
+               if (methodName.equals(FramesDebuggee.METHOD_NAME)) {
+                   methodCount++;
+               }
+        }
+
+        if (methodCount != FramesDebuggee.DEPTH) {
+            logWriter.printError(depthError = ("Number of " + FramesDebuggee.METHOD_NAME + " in frames "
+                    + methodCount + "  but expected " + FramesDebuggee.DEPTH));
+        }
+
+        debuggeeWrapper.vmMirror.resumeThread(threadID);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        if (null != unexpectedMethods) {
+            logWriter.println("==> testFrames001 FAILED "); 
+            fail("unexpected method(s): " + unexpectedMethods);
+        }
+        else if (null != depthError) {
+            logWriter.println("==> testFrames001 FAILED "); 
+            fail(depthError);
+        } else {   
+            logWriter.println("==> testFrames001 OK. "); 
+        }
+    }
+
+    private Vector getFrames(int startFrame, int length) {
+
+        Vector frames = new Vector();
+        
+        logWriter.println("startFrame=" + startFrame
+                + "; length=" + length);
+
+        // getting frames of the thread
+        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);
+        err = reply.getErrorCode(); 
+        if ( err != JDWPConstants.Error.NONE) {
+            logWriter.println("\tthreadID=" + threadID
+                    + " - " + JDWPConstants.Error.getName(err));
+            return null;
+        }
+        int framesCount = reply.getNextValueAsInt();
+        long frameID;
+        Location loc;
+        logWriter.println("framesCount=" + framesCount);
+        for (int j = 0; j < framesCount; j++) {
+               frameID = reply.getNextValueAsFrameID();
+               loc = reply.getNextValueAsLocation();
+               frames.add(new FrameStruct(frameID, loc));
+           }
+        return frames;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(FramesTest.class);
+    }
+}

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



Mime
View raw message