harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [33/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/ThreadReference/InterruptDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,107 @@
+/*
+ * 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 22.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.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+
+/**
+ * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.InterruptTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code> and blocks it 
+ * in  an invocation of the <code>wait()</code> method.
+ * If it receives an <code>InterruptedException</code>, it notifies debugger via
+ * the synchronization channel.  
+ */
+public class InterruptDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+    
+    public void run() {
+        DebuggeeThread thrd = new DebuggeeThread(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(String name, LogWriter logWriter,
+                DebuggeeSynchronizer synchronizer) {
+            super(name);
+            this.logWriter = logWriter;
+            this.synchronizer = synchronizer;
+        }
+
+        public void run() {
+
+            synchronized(InterruptDebuggee.waitForFinish){
+
+                synchronized(InterruptDebuggee.waitForStart){
+
+                    InterruptDebuggee.waitForStart.notifyAll();
+
+                    logWriter.println(getName() +  ": started");
+                    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+                    try {
+                        InterruptDebuggee.waitForStart.wait();
+                    } catch (InterruptedException e) {
+                        logWriter.println("Expected " + e);
+                        synchronizer.sendMessage(e.toString());
+                    }
+
+                    logWriter.println(getName() +  ": wait for SGNL_CONTINUE");
+                    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+                    logWriter.println(getName() +  ": finished");
+                }
+            }
+        }
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(InterruptDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/InterruptTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,108 @@
+/*
+ * 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.Interrupt command.
+ */
+public class InterruptTest extends JDWPSyncTestCase {
+
+    static String waitForString = "java.lang.InterruptedException";
+    boolean isReceived = false;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.InterruptDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Interrupt command.
+     * <BR>At first the test starts InterruptDebuggee which runs
+     * the tested thread 'TESTED_THREAD' and blocks it in invocation of
+     * the 'wait()' method. 
+     * <BR> Then the tests performs the ThreadReference.Interrupt command 
+     * for tested thread. 
+     * <BR>After sending Interrupt command, the test waits signals via synchronization
+     * channel that 'InterruptedException' was thrown.
+     */
+    public void testInterrupt001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        logWriter.println("get thread ID");
+        long threadID = 
+            debuggeeWrapper.vmMirror.getThreadID(InterruptDebuggee.TESTED_THREAD);
+
+        // getting the thread group ID
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.InterruptCommand);
+        packet.setNextValueAsThreadID(threadID);
+        logWriter.println("send \"Interrupt\" command");
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        
+        short err = reply.getErrorCode();
+        logWriter.println("error = " + err);
+
+        if (err == JDWPConstants.Error.NONE) {
+            Thread thrd = new RecvThread();
+            thrd.start();
+            try {
+                thrd.join(settings.getTimeout());
+            } catch(InterruptedException e) {
+                
+            }
+        }
+
+        if (!isReceived) {
+            printErrorAndFail(waitForString + " is not received");
+        } else {
+            logWriter.println(waitForString + " is received");
+        }
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    class RecvThread extends Thread {
+        
+        public void run() {
+            logWriter.println("wait for " + waitForString);
+            isReceived = synchronizer.receiveMessage(waitForString);
+        }
+
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(InterruptTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/NameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/NameTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/NameTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/NameTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,84 @@
+/*
+ * 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 11.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.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ThreadReference.Name command.
+ */
+public class NameTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Name command.
+     * <BR>At first the test starts HelloWorld debuggee. 
+     * <BR> Then the tests performs the ThreadReference.Name command 
+     * for every thread in debuggee. 
+     * <BR>It is expected that the returned names are not empty.
+     */
+    public void testName001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        ReplyPacket thrdReply, reply = debuggeeWrapper.vmMirror.getAllThreadID();
+
+        CommandPacket packet;
+        long threadID;
+        String threadName;
+        int threads = reply.getNextValueAsInt();
+        for (int i = 0 ;i < threads; i++) {
+            threadID = reply.getNextValueAsThreadID();
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.NameCommand);
+            packet.setNextValueAsThreadID(threadID);
+            
+            thrdReply = debuggeeWrapper.vmMirror.performCommand(packet);
+            checkReplyPacket(thrdReply, "ThreadReference::Name command");
+
+            threadName = thrdReply.getNextValueAsString(); 
+            logWriter.println("\tthreadID = " + threadID + " threadName = "
+                    + threadName);
+            if (threadName.length() == 0) {
+                printErrorAndFail("Empty name for thread with ID=" + threadID);
+            }
+        }
+
+        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/ThreadReference/NameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,99 @@
+/*
+ * 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 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.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+
+/**
+ * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code> which
+ * synchronized with test via the <code>SGNL_READY</code> and
+ * <code>SGNL_CONTINUE</code> signals.
+ */
+public class OwnedMonitorsDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+    
+    public void run() {
+        DebuggeeThread thrd = new DebuggeeThread(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(String name, LogWriter logWriter,
+                DebuggeeSynchronizer synchronizer) {
+            super(name);
+            this.logWriter = logWriter;
+            this.synchronizer = synchronizer;
+        }
+
+        public void run() {
+
+            synchronized(OwnedMonitorsDebuggee.waitForFinish){
+
+                synchronized(OwnedMonitorsDebuggee.waitForStart){
+
+                    OwnedMonitorsDebuggee.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(OwnedMonitorsDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,116 @@
+/*
+ * 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 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.OwnedMonitors command.
+ */
+public class OwnedMonitorsTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.OwnedMonitors command.
+     * <BR>At first the test starts OwnedMonitorsDebuggee which runs
+     * the tested thread 'TESTED_THREAD'. 
+     * <BR> Then the tests performs the ThreadReference.OwnedMonitors command 
+     * for the tested thread and gets list of monitor objects. 
+     * <BR>After this for each received monitor object the test performs 
+     * ObjectReference.MonitorInfo command.
+     * <BR>it is expected that this command returns the 'TESTED_THREAD' thread
+     * as owner for each monitor.
+     */
+    public void testOwnedMonitors001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        logWriter.println("==> testedThreadName = " + OwnedMonitorsDebuggee.TESTED_THREAD);
+        logWriter.println("==> Get testedThreadID...");
+        long testedThreadID = 
+            debuggeeWrapper.vmMirror.getThreadID(OwnedMonitorsDebuggee.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.OwnedMonitorsCommand);
+        packet.setNextValueAsThreadID(testedThreadID);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ThreadReference::OwnedMonitors command");
+        
+        int owned = reply.getNextValueAsInt();
+        logWriter.println("owned monitors: " + owned);
+
+        String ownerName;
+        long ownerThread;
+
+        for (int i =0; i < owned; i++) {
+            TaggedObject tobj = reply.getNextValueAsTaggedObject();
+
+            logWriter.println("\t" + i + " tagged-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");
+            
+            ownerThread = replyObj.getNextValueAsThreadID();
+            ownerName = debuggeeWrapper.vmMirror.getThreadName(ownerThread);
+            logWriter.println("\towner: "
+                    + " " + ownerName
+                    + "(" + ownerThread + ")");
+            if (ownerThread != testedThreadID) {
+                printErrorAndFail("wrong owner: " + ownerThread);
+            }
+            if (!ownerName.equals(OwnedMonitorsDebuggee.TESTED_THREAD)) {
+                printErrorAndFail("wrong owner name: " + ownerName);
+            }
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(OwnedMonitorsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,149 @@
+/*
+ * 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.3 $
+ */
+
+/**
+ * Created on 08.06.2006 
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class ResumeDebuggee extends SyncDebuggee {
+    public static final int THREAD_NUMBER_LIMIT = 6; 
+    public static final String THREAD_NAME_PATTERN = "ResumeDebuggee_Thread_"; 
+    public static final String TO_FINISH_DEBUGGEE_FIELD_NAME = "debuggeToFinish"; 
+
+    static ResumeDebuggee resumeDebuggeeThis;
+
+    static volatile boolean allThreadsToFinish = false;
+    static int debuggeToFinish = 0;
+    static int createdThreadsNumber = 0;
+    static volatile int startedThreadsNumber = 0;
+
+    static ResumeDebuggee_Thread[] resumeDebuggeeThreads = null;
+
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+    
+    static void sleepMlsecsTime(long mlsecsTime) { 
+        try {
+            Thread.sleep(mlsecsTime);
+        } catch (Throwable throwable) {
+             // ignore
+        }
+    }
+    
+    public void run() {
+        
+        logWriter.println("--> ResumeDebuggee: START...");
+        resumeDebuggeeThis = this;
+
+        logWriter.println("--> ResumeDebuggee: Create and start tested threads...");
+        try {
+            resumeDebuggeeThreads = new ResumeDebuggee_Thread[THREAD_NUMBER_LIMIT]; 
+            for (int i=0; i < THREAD_NUMBER_LIMIT; i++) {
+                resumeDebuggeeThreads[i]= new ResumeDebuggee_Thread(i);
+                resumeDebuggeeThreads[i].start();
+                createdThreadsNumber++;
+            }
+        } catch ( Throwable thrown) {
+            logWriter.println
+            ("--> ResumeDebuggee: Exception while creating threads: " + thrown);
+        }
+        logWriter.println
+        ("--> ResumeDebuggee: Created threads number = " + createdThreadsNumber);
+        
+        while ( startedThreadsNumber != createdThreadsNumber ) {
+            waitMlsecsTime(100);
+        }
+        if ( createdThreadsNumber != 0 ) {
+            logWriter.println("--> ResumeDebuggee: All created threads are started!");
+        }
+
+        synchronizer.sendMessage(Integer.toString(createdThreadsNumber));
+
+        String mainThreadName = Thread.currentThread().getName();
+        synchronizer.sendMessage(mainThreadName);
+
+        logWriter.println("--> ResumeDebuggee: Wait for signal from test to finish...");
+        while ( debuggeToFinish != 99 ) { // is set up by debugger - ResumeTest
+            waitMlsecsTime(100);
+        }
+
+        logWriter.println
+        ("--> ResumeDebuggee: Send signal to all threads to finish and wait...");
+        allThreadsToFinish = true;
+
+        for (int i=0; i < createdThreadsNumber; i++) {
+            while ( resumeDebuggeeThreads[i].isAlive() ) {
+                waitMlsecsTime(10);
+            }
+        }
+        logWriter.println
+        ("--> ResumeDebuggee: All threads finished!");
+
+        logWriter.println("--> ResumeDebuggee: FINISH...");
+
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(ResumeDebuggee.class);
+    }
+
+}
+
+class ResumeDebuggee_Thread extends Thread {
+    
+    int threadKind;
+    
+    public ResumeDebuggee_Thread(int threadNumber) {
+        super(ResumeDebuggee.THREAD_NAME_PATTERN + threadNumber);
+        threadKind = threadNumber % 3;
+    }
+
+    public void run() {
+        ResumeDebuggee parent = ResumeDebuggee.resumeDebuggeeThis;
+        synchronized (parent) { 
+            ResumeDebuggee.startedThreadsNumber++;
+        }
+        while ( ! ResumeDebuggee.allThreadsToFinish ) {
+            switch ( threadKind ) {
+            case 0:
+                ResumeDebuggee.waitMlsecsTime(100);
+                break;
+            case 1:
+                ResumeDebuggee.sleepMlsecsTime(100);
+            }
+        }
+    }
+}
+
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,445 @@
+/*
+ * 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, Anatoly F. Bondarenko
+ * @version $Revision: 1.7 $
+ */
+
+/**
+ * Created on 15.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.exceptions.*;
+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;
+
+
+/**
+ * JDWP Unit test for ThreadReference.Resume command.
+ */
+public class ResumeTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+    static final String debuggeeSignature = 
+            "Lorg/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ResumeDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Resume command.
+     * <BR>At first the test starts ResumeDebuggee which starts and runs some tested threads. 
+     * <BR> Then the tests checks that for every tested thread the ThreadReference.Resume
+     * command acts according to spec:
+     * <BR>&nbsp;&nbsp; - command does not cause any error if thread is not suspended;
+     * <BR>&nbsp;&nbsp; - command does not resume thread actually if number of suspendings
+     *   is greater than number of resumings;
+     * <BR>&nbsp;&nbsp; - command resumes thread actually if number of suspendings
+     *   is equal to number of resumings;
+     */
+    public void testResume001() {
+        logWriter.println("==> testResume001: START...");
+        String debuggeeMessage = synchronizer.receiveMessage();
+        int testedThreadsNumber = 0;
+        try {
+            testedThreadsNumber = Integer.valueOf(debuggeeMessage).intValue();
+        } catch (NumberFormatException exception) {
+            logWriter.println
+                ("## FAILURE: Exception while getting number of started threads from debuggee = " + exception);
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            printErrorAndFail("\n## Can NOT get number of started threads from debuggee! ");
+        }
+        testedThreadsNumber++; // to add debuggee main thread
+        logWriter.println("==>  Number of threads in debuggee to test = " + testedThreadsNumber);
+        String[] testedThreadsNames = new String[testedThreadsNumber];
+        long[] testedThreadsIDs = new long[testedThreadsNumber];
+        String debuggeeMainThreadName = synchronizer.receiveMessage();
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            if ( i < (testedThreadsNumber-1) ) {
+                testedThreadsNames[i] = ResumeDebuggee.THREAD_NAME_PATTERN + i;
+            } else {
+                testedThreadsNames[i] = debuggeeMainThreadName;
+            }
+            testedThreadsIDs[i] = 0;
+        }
+
+        // getting ID of the tested thread
+        ReplyPacket allThreadIDReply = null;
+        try {
+            allThreadIDReply = debuggeeWrapper.vmMirror.getAllThreadID();
+        } catch (ReplyErrorCodeException exception) {
+            logWriter.println
+                ("## FAILURE: Exception in vmMirror.getAllThreadID() = " + exception);
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            printErrorAndFail("\n## Can NOT get all ThreadID in debuggee! ");
+        }
+        int threads = allThreadIDReply.getNextValueAsInt();
+        logWriter.println("==>  Number of all threads in debuggee = " + threads);
+        for (int i = 0; i < threads; i++) {
+            long threadID = allThreadIDReply.getNextValueAsThreadID();
+            String threadName = null;
+            try {
+                threadName = debuggeeWrapper.vmMirror.getThreadName(threadID); 
+            } catch (ReplyErrorCodeException exception) {
+                logWriter.println
+                    ("==> WARNING: Can NOT get thread name for threadID = " + threadID);
+                continue;
+            }
+            int k = 0;
+            for (; k < testedThreadsNumber; k++) {
+                if ( threadName.equals(testedThreadsNames[k]) ) {
+                    testedThreadsIDs[k] = threadID;
+                    break;
+                }
+            }
+        }
+            
+        boolean testedThreadNotFound = false;
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            if ( testedThreadsIDs[i] == 0 ) {
+                logWriter.println("## FAILURE: Tested thread is not found out among debuggee threads!");
+                logWriter.println("##          Thread name = " + testedThreadsNames[i]);
+                testedThreadNotFound = true;
+            }
+        }
+        if ( testedThreadNotFound ) {
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            printErrorAndFail("\n## Some of tested threads are not found!");
+        }
+
+        CommandPacket packet = null;
+        ReplyPacket reply = null;
+        String errorMessage = "";
+
+        boolean resumeCommandFailed = false;
+        boolean statusCommandFailed = false;
+        boolean suspendStatusFailed = false;
+        boolean suspendCommandFailed = false;
+
+        logWriter.println
+        ("\n==> Check that ThreadReference.Resume command does not cause any error if thread is not suspended...");
+
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            logWriter.println("\n==> Check for Thread: threadID = " + testedThreadsIDs[i] 
+                    + "; threadName = " + testedThreadsNames[i]);
+            logWriter.println("==> Send ThreadReference.Resume command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
+            packet.setNextValueAsThreadID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Resume command") ) {
+                resumeCommandFailed = true;
+            } else {
+                logWriter.println("==> OK - ThreadReference.Resume command without any error!"); 
+            }
+        }
+
+        if ( resumeCommandFailed ) {
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            printErrorAndFail("\n## Error found out while ThreadReference.Resume command performing!");
+        }
+
+        logWriter.println
+        ("\n==> Check that ThreadReference.Resume command resumes threads after VirtualMachine.Suspend command...");
+
+        logWriter.println("\n==> Send VirtualMachine.Suspend command..."); 
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.SuspendCommand);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        int errorCode = reply.getErrorCode();
+        if ( errorCode !=  JDWPConstants.Error.NONE ) {
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            logWriter.println("## FAILURE: VirtualMachine.Suspend command returns error = " + errorCode
+                    + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+            printErrorAndFail("## VirtualMachine.Suspend command FAILED!");
+        } else {
+            logWriter.println("==> VirtualMachine.Suspend command is OK!"); 
+        }
+
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            logWriter.println("\n==> Check for Thread: threadID = " + testedThreadsIDs[i] 
+                + "; threadName = " + testedThreadsNames[i]);
+
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            int threadStatus = reply.getNextValueAsInt();
+            int suspendStatus = reply.getNextValueAsInt();
+
+            logWriter.println("==> threadStatus = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            logWriter.println("==> suspendStatus = " + suspendStatus + "("
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus) + ")");
+            if (suspendStatus
+                    != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+                logWriter.println("## FAILURE: Unexpected suspendStatus for thread!");
+                logWriter.println("##          Expected suspendStatus  = "  
+                    + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
+                    + "(" + JDWPConstants.SuspendStatus.getName
+                    (JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) +")");
+                suspendStatusFailed = true;
+                continue;
+            }
+            
+            logWriter.println("==> Send ThreadReference.Resume command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
+            packet.setNextValueAsThreadID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Resume command") ) {
+                resumeCommandFailed = true;
+                continue;
+            }
+            
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            threadStatus = reply.getNextValueAsInt();
+            suspendStatus = reply.getNextValueAsInt();
+
+            logWriter.println("==> threadStatus = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            logWriter.println("==> suspendStatus = " + suspendStatus + "("
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus) + ")");
+            if (suspendStatus
+                    == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+                logWriter.println
+                    ("## FAILURE: Thread still is suspended after ThreadReference.Resume command!");
+                suspendStatusFailed = true;
+            }
+        }
+
+        logWriter.println("\n==> Send VirtualMachine.Resume command..."); 
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ResumeCommand);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        errorCode = reply.getErrorCode();
+        if ( errorCode !=  JDWPConstants.Error.NONE ) {
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            logWriter.println("## FAILURE: VirtualMachine.Resume command returns error = " + errorCode
+                + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+            printErrorAndFail("## VirtualMachine.Resume command FAILED!");
+        } else {
+            logWriter.println("==> VirtualMachine.Resume command is OK!"); 
+        }
+
+        if ( statusCommandFailed ) {
+            errorMessage = errorMessage + "## Error found out while ThreadReference.Status command performing!\n";
+        }
+        if ( suspendStatusFailed ) {
+            errorMessage = errorMessage + "## Unexpected suspendStatus found out!\n";
+        }
+        if ( resumeCommandFailed ) {
+            errorMessage = errorMessage + "## Error found out while ThreadReference.Resume command performing!\n";
+        }
+        if ( ! errorMessage.equals("") ) {
+            setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+            printErrorAndFail("\ntestResume001 FAILED:\n" + errorMessage);
+        }
+
+        logWriter.println
+        ("\n==> Check ThreadReference.Resume command after ThreadReference.Suspend command...");
+        
+        int suspendNumber = 3;
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            logWriter.println("\n==> Check for Thread: threadID = " + testedThreadsIDs[i] 
+                + "; threadName = " + testedThreadsNames[i]);
+            logWriter.println("==> Send ThreadReference.Suspend commands: number of commandss = " 
+                    + suspendNumber + "..."); 
+            int j = 0;
+            for (; j < suspendNumber; j++) {
+                packet = new CommandPacket(
+                        JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                        JDWPCommands.ThreadReferenceCommandSet.SuspendCommand);
+                packet.setNextValueAsThreadID(testedThreadsIDs[i]);
+                reply = debuggeeWrapper.vmMirror.performCommand(packet);
+                if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Suspend command") ) {
+                    break;
+                }
+            }
+            if ( j < suspendNumber ) {
+                suspendCommandFailed = true;
+                continue;
+            }
+            
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            int threadStatus = reply.getNextValueAsInt();
+            int suspendStatus = reply.getNextValueAsInt();
+
+            logWriter.println("==> threadStatus = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            logWriter.println("==> suspendStatus = " + suspendStatus + "("
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus) + ")");
+            if (suspendStatus
+                    != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+                logWriter.println("## FAILURE: Unexpected suspendStatus for thread!");
+                logWriter.println("##          Expected suspendStatus  = "  
+                    + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
+                    + "(" + JDWPConstants.SuspendStatus.getName
+                    (JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) +")");
+                suspendStatusFailed = true;
+                continue;
+            }
+            
+            logWriter.println
+            ("==> Send ThreadReference.Resume command 1 time - thread must NOT be actually resumed..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
+            packet.setNextValueAsThreadID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Resume command") ) {
+                resumeCommandFailed = true;
+                continue;
+            }
+
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            threadStatus = reply.getNextValueAsInt();
+            suspendStatus = reply.getNextValueAsInt();
+
+            logWriter.println("==> threadStatus = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            logWriter.println("==> suspendStatus = " + suspendStatus + "("
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus) + ")");
+            if (suspendStatus
+                    != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+                logWriter.println("## FAILURE: Unexpected suspendStatus for thread!");
+                logWriter.println("##          Expected suspendStatus  = "  
+                    + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
+                    + "(" + JDWPConstants.SuspendStatus.getName
+                    (JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) +")");
+                suspendStatusFailed = true;
+                continue;
+            }
+            
+            logWriter.println("==> Send ThreadReference.Resume commands: number of commands = " 
+                    + (suspendNumber-1) + " - thread must be actually resumed"); 
+            j = 0;
+            for (; j < (suspendNumber-1); j++) {
+                packet = new CommandPacket(
+                        JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                        JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
+                packet.setNextValueAsThreadID(testedThreadsIDs[i]);
+                reply = debuggeeWrapper.vmMirror.performCommand(packet);
+                if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Resume command") ) {
+                    break;
+                }
+            }
+            if ( j < (suspendNumber-1) ) {
+                resumeCommandFailed = true;
+                continue;
+            }
+            
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            threadStatus = reply.getNextValueAsInt();
+            suspendStatus = reply.getNextValueAsInt();
+
+            logWriter.println("==> threadStatus = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            logWriter.println("==> suspendStatus = " + suspendStatus + "("
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus) + ")");
+            if (suspendStatus
+                    == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+                logWriter.println
+                    ("## FAILURE: Thread still is suspended after ThreadReference.Resume commands: " 
+                    + "number of total resume commands = "+ suspendNumber + " !");
+                suspendStatusFailed = true;
+            }
+        }
+
+        if ( suspendCommandFailed ) {
+            errorMessage = errorMessage + "## Error found out while ThreadReference.Suspend command performing!\n";
+        }
+        if ( resumeCommandFailed ) {
+            errorMessage = errorMessage + "## Error found out while ThreadReference.Resume command performing!\n";
+        }
+        if ( statusCommandFailed ) {
+            errorMessage = errorMessage + "## Error found out while ThreadReference.Status command performing!\n";
+        }
+        if ( suspendStatusFailed ) {
+            errorMessage = errorMessage + "## Unexpected suspendStatus found out!\n";
+        }
+
+        setStaticIntField(debuggeeSignature, ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
+        if ( ! errorMessage.equals("") ) {
+            printErrorAndFail("\ntestResume001 FAILED:\n" + errorMessage);
+        }
+
+        logWriter.println("\n==> testResume001 - OK!");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ResumeTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Debuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,108 @@
+/*
+ * 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 31.03.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.Status002Test</code>.
+ */
+public class Status002Debuggee extends SyncDebuggee {
+
+    static Status002Debuggee status002DebuggeeThis;
+    static volatile boolean status002DebuggeeThreadStarted = false;
+
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+    
+    public void run() {
+        logWriter.println("--> Debuggee: Status002Debuggee: START");
+        status002DebuggeeThis = this;
+        
+        String status002DebuggeeThreadName = "Status002DebuggeeThread";
+        Status002Debuggee_Thread status002DebuggeeThread
+            = new Status002Debuggee_Thread(status002DebuggeeThreadName); 
+
+        status002DebuggeeThread.start();
+
+        while ( ! status002DebuggeeThreadStarted ) {
+            waitMlsecsTime(1000);
+        }
+        logWriter.println("--> Debuggee: Status002Debuggee: will sleep for 10 seconds");
+        waitMlsecsTime(10000); // to make sure that status002DebuggeeThread is sleeping
+
+        synchronizer.sendMessage(status002DebuggeeThreadName);
+        synchronizer.receiveMessage(); // signal to finish
+        
+        try {
+            status002DebuggeeThread.interrupt();
+        } catch (Throwable thrown) {
+            // ignore 
+        }
+        while ( status002DebuggeeThread.isAlive() ) {
+            waitMlsecsTime(100);
+        }
+
+        logWriter.println("--> Debuggee: Status002Debuggee: FINISH");
+        System.exit(0);
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(Status002Debuggee.class);
+    }
+}
+
+class Status002Debuggee_Thread extends Thread {
+
+    public Status002Debuggee_Thread(String name) {
+        super(name);
+    }
+
+    public void run() {
+        Status002Debuggee parent = Status002Debuggee.status002DebuggeeThis;
+        parent.logWriter.println("--> Thread: " + getName() +  ": started...");
+        long mlsecTimeToSleep = 1000 * 60 * 3;
+        parent.logWriter.println
+        ("--> Thread: " + getName() +  ": will sleep " + mlsecTimeToSleep + " mlsecs");
+        Status002Debuggee.status002DebuggeeThreadStarted = true;
+        try {
+            Thread.sleep(mlsecTimeToSleep);
+        } catch (Throwable thrown) {
+            // ignore 
+        }
+        parent.logWriter.println("--> Thread: " + getName() +  ": is finishibg...");
+    }
+}
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,129 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * Created on 31.03.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.Status command for the sleeping Thread.
+ */
+public class Status002Test extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.Status002Debuggee";
+    }
+
+    String getThreadSuspendStatusName(int suspendStatus) {
+    
+        String result = JDWPConstants.SuspendStatus.getName(suspendStatus);
+        if ( result.equals("") ) {
+            result = "NOT_SUSPENDED";
+        }
+        return result;
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Status command for the sleeping Thread.
+     * <BR>At first the test starts Status002Debuggee which runs
+     * the tested thread and blocks it in invocation of
+     * the 'Thread.sleep()' method. 
+     * <BR> Then the tests performs the ThreadReference.Status command 
+     * for tested thread. 
+     * <BR>It is expected that:
+     * <BR>&nbsp;&nbsp; - returned thread status is SLEEPING status;
+     * <BR>&nbsp;&nbsp; - returned suspend status is not SUSPEND_STATUS_SUSPENDED status;
+     */
+    public void testStatus003() {
+        String thisTestName = "testStatus003";
+        logWriter.println("==> " + thisTestName +
+                " for ThreadReference.Status command: START...");
+        logWriter.println("==> This " + thisTestName + 
+            " checks command for SLEEPING Thread: which is sleeping in Thread.sleep(Time) method...");
+        String checkedThreadName = synchronizer.receiveMessage();
+        logWriter.println("=> checkedThreadName = " + checkedThreadName);
+
+        long checkedThreadID = debuggeeWrapper.vmMirror.getThreadID(checkedThreadName);
+        logWriter.println("=> checkedThreadID = " + checkedThreadID);
+
+        logWriter.println
+        ("=> Send ThreadReference.Status command for checked Thread and check reply...");
+        CommandPacket checkedCommand = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+        checkedCommand.setNextValueAsThreadID(checkedThreadID);
+        
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+        checkReplyPacket(checkedReply, "ThreadReference.Status command");
+        
+        int threadStatus = checkedReply.getNextValueAsInt();
+        int suspendStatus = checkedReply.getNextValueAsInt();
+
+        logWriter.println("\n=> Returned thread status = 0x" + Integer.toHexString(threadStatus)
+                + "(" + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+        if (threadStatus != JDWPConstants.ThreadStatus.SLEEPING) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned: "
+                + Integer.toHexString(threadStatus)
+                + "(" + JDWPConstants.ThreadStatus.getName(threadStatus) + ")"
+                + "\nExpected thread status: 0x"
+                + Integer.toHexString(JDWPConstants.ThreadStatus.SLEEPING)
+                + "(" + JDWPConstants.ThreadStatus.getName(JDWPConstants.ThreadStatus.SLEEPING) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread status is returned");
+        }
+
+        logWriter.println
+            ("\n=> Returned thread suspend status = 0x" + Integer.toHexString(suspendStatus)
+            + "(" + getThreadSuspendStatusName(suspendStatus) + ")");
+        if (suspendStatus == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned:"
+                + Integer.toHexString(0)
+                + "(" + getThreadSuspendStatusName(0) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread suspend status is returned");
+        }
+
+        logWriter.println("=> Send to Debuggee signal to funish ...");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> " + thisTestName +
+                " for ThreadReference.Status command: FINISH...");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Status002Test.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Debuggee.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 Anatoly F. Bondarenko
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 31.03.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.Status003Test</code>.
+ */
+public class Status003Debuggee extends SyncDebuggee {
+
+    static Status003Debuggee status003DebuggeeThis;
+    static volatile boolean status003DebuggeeThreadStarted = false;
+
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+    
+    public void run() {
+        logWriter.println("--> Debuggee: Status003Debuggee: START");
+        status003DebuggeeThis = this;
+        
+        String status003DebuggeeThreadName = "Status003DebuggeeThread";
+        Status003Debuggee_Thread status003DebuggeeThread
+            = new Status003Debuggee_Thread(status003DebuggeeThreadName); 
+
+        status003DebuggeeThread.start();
+
+        while ( ! status003DebuggeeThreadStarted ) {
+            waitMlsecsTime(1000);
+        }
+        logWriter.println("--> Debuggee: Status003Debuggee: will sleep for 10 seconds");
+        waitMlsecsTime(10000); // to make sure that status003DebuggeeThread is sleeping
+
+        synchronizer.sendMessage(status003DebuggeeThreadName);
+        synchronizer.receiveMessage(); // signal to finish  
+ 
+        try {
+            status003DebuggeeThread.interrupt();
+        } catch (Throwable thrown) {
+            // ignore 
+        }
+        while ( status003DebuggeeThread.isAlive() ) {
+            waitMlsecsTime(100);
+        }
+
+        logWriter.println("--> Debuggee: Status003Debuggee: FINISH");
+        System.exit(0);
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(Status003Debuggee.class);
+    }
+}
+
+class Status003Debuggee_Thread extends Thread {
+
+    public Status003Debuggee_Thread(String name) {
+        super(name);
+    }
+
+    public void run() {
+        Status003Debuggee parent = Status003Debuggee.status003DebuggeeThis;
+        parent.logWriter.println("--> Thread: " + getName() +  ": started...");
+        long mlsecTimeToSleep = 1000 * 60 * 3;
+        parent.logWriter.println
+        ("--> Thread: " + getName() +  ": will wait " + mlsecTimeToSleep + " mlsecs");
+        Status003Debuggee.status003DebuggeeThreadStarted = true;
+        Object ObjectForWait = new Object();
+        synchronized(ObjectForWait) {
+            try {
+                ObjectForWait.wait(mlsecTimeToSleep);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+        parent.logWriter.println("--> Thread: " + getName() +  ": is finishibg...");
+    }
+}
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status003Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,126 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * Created on 31.03.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.Status command for the Thread waiting for time.
+ */
+public class Status003Test extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.Status003Debuggee";
+    }
+
+    String getThreadSuspendStatusName(int suspendStatus) {
+    
+        String result = JDWPConstants.SuspendStatus.getName(suspendStatus);
+        if ( result.equals("") ) {
+            result = "NOT_SUSPENDED";
+        }
+        return result;
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Status command for the Thread waiting for time.
+     * <BR>At first the test starts Status003Debuggee which runs
+     * the tested thread and blocks it in invocation of
+     * the 'Object.wait(mlsecTime)' method. 
+     * <BR> Then the tests performs the ThreadReference.Status command 
+     * for tested thread. 
+     * <BR>It is expected that:
+     * <BR>&nbsp;&nbsp; - returned thread status is WAIT status;
+     * <BR>&nbsp;&nbsp; - returned suspend status is not SUSPEND_STATUS_SUSPENDED status;
+     */
+    public void testStatus004() {
+        String thisTestName = "testStatus004";
+        logWriter.println("==> " + thisTestName + " for ThreadReference.Status command: START...");
+        logWriter.println("==> This " + thisTestName
+            + " checks command for TIMED_WAITING Thread: which is waiting in Object.wait(Time) method...");
+        String checkedThreadName = synchronizer.receiveMessage();
+        logWriter.println("=> checkedThreadName = " + checkedThreadName);
+
+        long checkedThreadID = debuggeeWrapper.vmMirror.getThreadID(checkedThreadName);
+        logWriter.println("=> checkedThreadID = " + checkedThreadID);
+
+        logWriter.println
+        ("=> Send ThreadReference.Status command for checked Thread and check reply...");
+        CommandPacket checkedCommand = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+        checkedCommand.setNextValueAsThreadID(checkedThreadID);
+        
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+        checkReplyPacket(checkedReply, "ThreadReference.Status command");
+        
+        int threadStatus = checkedReply.getNextValueAsInt();
+        int suspendStatus = checkedReply.getNextValueAsInt();
+
+        logWriter.println("\n=> Returned thread status = 0x" + Integer.toHexString(threadStatus)
+                + "(" + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+        if (threadStatus != JDWPConstants.ThreadStatus.WAIT) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned:"
+                + "\nExpected thread status = 0x"
+                + Integer.toHexString(JDWPConstants.ThreadStatus.WAIT)
+                + "(" + JDWPConstants.ThreadStatus.getName(JDWPConstants.ThreadStatus.WAIT) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread status is returned");
+        }
+
+        logWriter.println
+            ("\n=> Returned thread suspend status = 0x" + Integer.toHexString(suspendStatus)
+            + "(" + getThreadSuspendStatusName(suspendStatus) + ")");
+        if (suspendStatus == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned:"
+                + "## Expected thread status = 0x"
+                + Integer.toHexString(0)
+                + "(" + getThreadSuspendStatusName(0) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread suspend status is returned");
+        }
+
+        logWriter.println("=> Send to Debuggee signal to funish ...");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> " + thisTestName + " for ThreadReference.Status command: FINISH...");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Status003Test.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Debuggee.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 Anatoly F. Bondarenko
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 31.03.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.Status004Test</code>.
+ */
+public class Status004Debuggee extends SyncDebuggee {
+
+    static Status004Debuggee status004DebuggeeThis;
+    static volatile boolean status004DebuggeeThreadStarted = false;
+
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+    
+    public void run() {
+        logWriter.println("--> Debuggee: Status004Debuggee: START");
+        status004DebuggeeThis = this;
+        
+        String status004DebuggeeThreadName = "Status004DebuggeeThread";
+        Status004Debuggee_Thread status004DebuggeeThread
+            = new Status004Debuggee_Thread(status004DebuggeeThreadName); 
+
+        status004DebuggeeThread.start();
+
+        while ( ! status004DebuggeeThreadStarted ) {
+            waitMlsecsTime(1000);
+        }
+        logWriter.println("--> Debuggee: Status004Debuggee: will sleep for 10 seconds");
+        waitMlsecsTime(10000); // to make sure that status004DebuggeeThread is sleeping
+
+        synchronizer.sendMessage(status004DebuggeeThreadName);
+        synchronizer.receiveMessage(); // signal to finish  
+        
+        try {
+            status004DebuggeeThread.interrupt();
+        } catch (Throwable thrown) {
+            // ignore 
+        }
+        while ( status004DebuggeeThread.isAlive() ) {
+            waitMlsecsTime(100);
+        }
+
+        logWriter.println("--> Debuggee: Status004Debuggee: FINISH");
+        System.exit(0);
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(Status004Debuggee.class);
+    }
+}
+
+class Status004Debuggee_Thread extends Thread {
+
+    public Status004Debuggee_Thread(String name) {
+        super(name);
+    }
+
+    public void run() {
+        Status004Debuggee parent = Status004Debuggee.status004DebuggeeThis;
+        parent.logWriter.println("--> Thread: " + getName() +  ": started...");
+        parent.logWriter.println
+        ("--> Thread: " + getName() +  ": will wait UNDEFINITELY");
+        Status004Debuggee.status004DebuggeeThreadStarted = true;
+        Object ObjectForWait = new Object();
+        synchronized(ObjectForWait) {
+            try {
+                ObjectForWait.wait();
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+        parent.logWriter.println("--> Thread: " + getName() +  ": is finishibg...");
+    }
+}
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/Status004Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * Created on 31.03.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.Status command for the Thread waiting UNDEFINITELY.
+ */
+public class Status004Test extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.Status004Debuggee";
+    }
+
+    String getThreadSuspendStatusName(int suspendStatus) {
+        String result = JDWPConstants.SuspendStatus.getName(suspendStatus);
+        if ( result.equals("") ) {
+            result = "NOT_SUSPENDED";
+        }
+        return result;
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Status command for the Thread waiting UNDEFINITELY.
+     * <BR>At first the test starts Status004Debuggee which runs
+     * the tested thread and blocks it in invocation of
+     * the 'Object.wait()' method. 
+     * <BR> Then the tests performs the ThreadReference.Status command 
+     * for tested thread. 
+     * <BR>It is expected that:
+     * <BR>&nbsp;&nbsp; - returned thread status is WAIT status;
+     * <BR>&nbsp;&nbsp; - returned suspend status is not SUSPEND_STATUS_SUSPENDED status;
+     */
+    public void testStatus005() {
+        String thisTestName = "testStatus005";
+        logWriter.println("==> " + thisTestName + " for ThreadReference.Status command: START...");
+        logWriter.println("==> This " + thisTestName
+            + " checks command for WAITING Thread: which is waiting UNDEFINITELY in Object.wait() method...");
+        String checkedThreadName = synchronizer.receiveMessage();
+        logWriter.println("=> checkedThreadName = " + checkedThreadName);
+
+        long checkedThreadID = debuggeeWrapper.vmMirror.getThreadID(checkedThreadName);
+        logWriter.println("=> checkedThreadID = " + checkedThreadID);
+
+        logWriter.println
+        ("=> Send ThreadReference.Status command for checked Thread and check reply...");
+        CommandPacket checkedCommand = new CommandPacket(
+                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+        checkedCommand.setNextValueAsThreadID(checkedThreadID);
+        
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+        checkReplyPacket(checkedReply, "ThreadReference.Status command");
+        
+        int threadStatus = checkedReply.getNextValueAsInt();
+        int suspendStatus = checkedReply.getNextValueAsInt();
+
+        logWriter.println("\n=> Returned thread status = 0x" + Integer.toHexString(threadStatus)
+                + "(" + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+        if (threadStatus != JDWPConstants.ThreadStatus.WAIT) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned:"
+                + "\n Expected thread status = 0x"
+                + Integer.toHexString(JDWPConstants.ThreadStatus.WAIT)
+                + "(" + JDWPConstants.ThreadStatus.getName(JDWPConstants.ThreadStatus.WAIT) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread status is returned");
+        }
+
+        logWriter.println
+            ("\n=> Returned thread suspend status = 0x" + Integer.toHexString(suspendStatus)
+            + "(" + getThreadSuspendStatusName(suspendStatus) + ")");
+        if (suspendStatus == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
+            finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+            printErrorAndFail("Unexpected thread status is returned:"
+                + "\n Expected thread status = 0x"
+                + Integer.toHexString(0)
+                + "(" + getThreadSuspendStatusName(0) + ")");
+        } else {
+            logWriter.println("=> OK - Expected thread suspend status is returned");
+        }
+
+        logWriter.println("=> Send to Debuggee signal to funish ...");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> " + thisTestName + " for ThreadReference.Status command: FINISH...");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Status004Test.class);
+    }
+}

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



Mime
View raw message