harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [35/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/SuspendTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/SuspendTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/SuspendTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/SuspendTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,210 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * 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;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ThreadReference.Suspend command.
+ */
+public class SuspendTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.SuspendDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.Suspend command.
+     * <BR>At first the test starts SuspendDebuggee which starts and runs some tested threads.
+     * <BR>After the tested threads starts, the test for every tested thread does:
+     * <BR>&nbsp;&nbsp; - suspends thread by ThreadReference.Suspend command;
+     * <BR>&nbsp;&nbsp; - performs the ThreadReference.Status command for tested thread;
+     * <BR>It is expected that for every tested thread returned suspend 
+     * status is SUSPEND_STATUS_SUSPENDED status;
+     */
+    public void testSuspend001() {
+        logWriter.println("==> testSuspend001: 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);
+            printErrorAndFail("Can NOT get number of started threads from debuggee! ");
+        }
+        if ( testedThreadsNumber == 0 ) {
+            logWriter.println("==>  There are no started threads in debuggee to test!");
+            return;
+        }
+        logWriter.println("==>  Number of started threads in debuggee to test = " + testedThreadsNumber);
+        String[] testedThreadsNames = new String[testedThreadsNumber];
+        long[] testedThreadsIDs = new long[testedThreadsNumber];
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            testedThreadsNames[i] = SuspendDebuggee.THREAD_NAME_PATTERN + i;
+            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);
+            printErrorAndFail("Can NOT get all ThreadID in debuggee! ");
+        }
+        int threads = allThreadIDReply.getNextValueAsInt();
+        logWriter.println("==>  Number of all threads in debuggee = " + threads);
+        boolean suspendCommandFailed = false;
+        boolean statusCommandFailed = false;
+        boolean suspendStatusFailed = false;
+        boolean resumeThreadFailed = false;
+        
+        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;
+                }
+            }
+            if ( k == testedThreadsNumber ) {
+                // it is not thread to test
+                continue;
+            }
+            
+            logWriter.println("\n==> Check for Thread: threadID = " + threadID 
+                    + "; threadName = " + threadName);
+
+            // suspending the thread
+            logWriter.println("==> Send ThreadReference.Suspend command..."); 
+            CommandPacket packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.SuspendCommand);
+            packet.setNextValueAsThreadID(threadID);
+            ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Suspend command") ) {
+                suspendCommandFailed = true;
+                continue;
+            }
+
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(threadID);
+            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 = " + threadName);
+                logWriter.println("##          Expected suspendStatus  = "  
+                    + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
+                    + "(" + JDWPConstants.SuspendStatus.getName
+                    (JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) +")");
+                suspendStatusFailed = true;
+                continue;
+            }
+
+            // resuming the thread
+            int resumeErr = debuggeeWrapper.vmMirror.resumeThread(threadID).getErrorCode();
+            if (resumeErr != JDWPConstants.Error.NONE) {
+                logWriter.println("## FAILURE: Can NOT resume thread = " + threadName);
+                logWriter.println("##          Received ERROR while resume thread = " + resumeErr
+                    + "(" + JDWPConstants.Error.getName(resumeErr) +")");
+                resumeThreadFailed = true;
+            }
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        String errorMessage = "";
+        if ( suspendCommandFailed ) {
+            errorMessage = "## Error found out while ThreadReference.Suspend 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";
+        }
+        if ( resumeThreadFailed ) {
+            errorMessage = errorMessage + "## Error found out while resuming thread!\n";
+        }
+
+        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 ) {
+            errorMessage = errorMessage + "## Some of tested threads are not found!\n";
+        }
+
+        if ( ! errorMessage.equals("") ) {
+            printErrorAndFail("\ntestSuspend001 FAILED:\n" + errorMessage);
+        }
+        logWriter.println("\n==> testSuspend001 - OK!");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(SuspendTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Debuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,185 @@
+/*
+ * 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 19.06.2006
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class ThreadGroup002Debuggee extends SyncDebuggee {
+    public static final int THREAD_NUMBER_LIMIT = 6; 
+    public static final String THREAD_NAME_PATTERN = "ThreadGroup002Debuggee_Thread_"; 
+    public static final String THREAD_GROUP_NAME_PATTERN = "ThreadGroup002Debuggee_Thread_Group_"; 
+
+    static ThreadGroup002Debuggee ThreadGroup002DebuggeeThis;
+
+    static volatile boolean allThreadsToFinish = false;
+    static int createdThreadsNumber = 0;
+    static volatile int startedThreadsNumber = 0;
+
+    static int firstThreadsNumber = 0;
+
+    static ThreadGroup002Debuggee_Thread[] ThreadGroup002DebuggeeThreads = null;
+    static ThreadGroup[] ThreadGroup002DebuggeeThreadGroups = new ThreadGroup[2];
+
+    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("--> ThreadGroup002Debuggee: START...");
+        ThreadGroup002DebuggeeThis = this;
+        logWriter.println("--> ThreadGroup002Debuggee: Create thread groups...");
+        ThreadGroup002DebuggeeThreadGroups[0] = 
+            new ThreadGroup(THREAD_GROUP_NAME_PATTERN + 0);
+        ThreadGroup002DebuggeeThreadGroups[1] = 
+            new ThreadGroup(THREAD_GROUP_NAME_PATTERN + 1);
+
+        logWriter.println("--> ThreadGroup002Debuggee: Create and start tested threads...");
+        try {
+            ThreadGroup002DebuggeeThreads = new ThreadGroup002Debuggee_Thread[THREAD_NUMBER_LIMIT]; 
+            for (int i=0; i < THREAD_NUMBER_LIMIT; i++) {
+                ThreadGroup002DebuggeeThreads[i] = 
+                    new ThreadGroup002Debuggee_Thread(ThreadGroup002DebuggeeThreadGroups[i%2], i);
+                ThreadGroup002DebuggeeThreads[i].start();
+                createdThreadsNumber++;
+            }
+        } catch ( Throwable thrown) {
+            logWriter.println
+            ("--> ThreadGroup002Debuggee: Exception while creating threads: " + thrown);
+        }
+        logWriter.println
+        ("--> ThreadGroup002Debuggee: Created threads number = " + createdThreadsNumber);
+        
+        while ( startedThreadsNumber != createdThreadsNumber ) {
+            waitMlsecsTime(100);
+        }
+        if ( createdThreadsNumber != 0 ) {
+            logWriter.println("--> ThreadGroup002Debuggee: All created threads are started!");
+        }
+
+        synchronizer.sendMessage(Integer.toString(createdThreadsNumber));
+
+        String mainThreadName = Thread.currentThread().getName();
+        synchronizer.sendMessage(mainThreadName);
+
+        String mainThreadGroupName = Thread.currentThread().getThreadGroup().getName();
+        synchronizer.sendMessage(mainThreadGroupName);
+
+
+        logWriter.println("--> ThreadGroup002Debuggee: Wait for signal from test to continue...");
+        String messageFromTest = synchronizer.receiveMessage();  // signal to continue or to finish
+        
+        if ( ! messageFromTest.equals("FINISH") ) {
+            logWriter.println
+            ("--> ThreadGroup002Debuggee: Send signal to the first threads to finish...");
+            
+            firstThreadsNumber = createdThreadsNumber/2;
+            for (int i=0; i < firstThreadsNumber; i++) {
+                while ( ThreadGroup002DebuggeeThreads[i].isAlive() ) {
+                    waitMlsecsTime(10);
+                }
+            }
+            logWriter.println
+            ("--> ThreadGroup002Debuggee: First threads finished - number of finished threads = " +
+                    firstThreadsNumber);
+            
+            synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+            
+            logWriter.println("--> ThreadGroup002Debuggee: Wait for signal from test to finish...");
+            synchronizer.receiveMessage();  // signal to finish
+        }
+
+        logWriter.println
+        ("--> ThreadGroup002Debuggee: Send signal to all threads to finish and wait...");
+        allThreadsToFinish = true;
+
+        for (int i=0; i < createdThreadsNumber; i++) {
+            while ( ThreadGroup002DebuggeeThreads[i].isAlive() ) {
+                waitMlsecsTime(10);
+            }
+        }
+        logWriter.println
+        ("--> ThreadGroup002Debuggee: All threads finished!");
+
+        logWriter.println("--> ThreadGroup002Debuggee: FINISH...");
+
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(ThreadGroup002Debuggee.class);
+    }
+
+}
+
+class ThreadGroup002Debuggee_Thread extends Thread {
+    
+    int threadNumber;
+    int threadKind;
+    
+    public ThreadGroup002Debuggee_Thread(ThreadGroup group, int threadNumber) {
+        super(group, ThreadGroup002Debuggee.THREAD_NAME_PATTERN + threadNumber);
+        this.threadNumber = threadNumber;
+        threadKind = threadNumber % 3;
+    }
+
+    public void run() {
+        ThreadGroup002Debuggee parent = ThreadGroup002Debuggee.ThreadGroup002DebuggeeThis;
+        synchronized (parent) { 
+            ThreadGroup002Debuggee.startedThreadsNumber++;
+        }
+        while ( ! ThreadGroup002Debuggee.allThreadsToFinish ) {
+            switch ( threadKind ) {
+            case 0:
+                ThreadGroup002Debuggee.waitMlsecsTime(100);
+                break;
+            case 1:
+                ThreadGroup002Debuggee.sleepMlsecsTime(100);
+            }
+            if (threadNumber < ThreadGroup002Debuggee.firstThreadsNumber ) {
+                return;
+            }
+        }
+    }
+}
+
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,294 @@
+/*
+ * 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 19.06.2006
+ */
+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;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for ThreadReference.ThreadGroup command.
+ */
+public class ThreadGroup002Test extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+    static final String debuggeeSignature = 
+            "Lorg/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroup002Debuggee;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ThreadGroup002Debuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.ThreadGroup command.
+     * <BR>At first the test starts ThreadGroup002Debuggee which creates some thread  
+     * groups and starts some tested threads which belong to different created thread groups.
+     * <BR>After the tested threads start, at first the test wait for the some first
+     * tested threads to finish. 
+     * <BR> Then the test for every tested thread does:
+     * <BR>&nbsp;&nbsp; - performs ThreadReference.Status command;
+     * <BR>&nbsp;&nbsp; - performs the ThreadReference.ThreadGroup command;
+     * <BR>&nbsp;&nbsp; - performs the ThreadGroupReference.name command;
+     * <BR>It is expected that 
+     * <BR>&nbsp;&nbsp; - all threads with status ZOMBIE are only finished tested threads;
+     * <BR>&nbsp;&nbsp; - all threads without status ZOMBIE are only NOT finished tested threads;
+     * <BR>&nbsp;&nbsp; - if status of thread is ZOMBIE then returned groupID must be null;
+     * <BR>&nbsp;&nbsp; - if status of thread is not ZOMBIE then returned groupID must not be null;
+     * <BR>&nbsp;&nbsp; - thread group name should be expected name for thread which is not ZOMBIE;
+     */
+    public void testThreadGroup002() {
+        logWriter.println("==> testThreadGroup002: 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);
+            synchronizer.sendMessage("FINISH");
+            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];
+        String[] testedThreadGroupsNames = new String[testedThreadsNumber];
+        long[] testedThreadsIDs = new long[testedThreadsNumber];
+        String debuggeeMainThreadName = synchronizer.receiveMessage();
+        String debuggeeMainThreadGroupName = synchronizer.receiveMessage();
+        for (int i = 0; i < testedThreadsNumber; i++) {
+            if ( i < (testedThreadsNumber-1) ) {
+                testedThreadsNames[i] = ThreadGroup002Debuggee.THREAD_NAME_PATTERN + i;
+                testedThreadGroupsNames[i] = ThreadGroup002Debuggee.THREAD_GROUP_NAME_PATTERN + (i%2);
+            } else {
+                testedThreadsNames[i] = debuggeeMainThreadName;
+                testedThreadGroupsNames[i] = debuggeeMainThreadGroupName;
+            }
+            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);
+            synchronizer.sendMessage("FINISH");
+            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 ) {
+            synchronizer.sendMessage("FINISH");
+            printErrorAndFail("\n## Some of tested threads are not found!");
+        }
+
+        logWriter.println("==> Send signal to debuggee to continue and to finish some first threads...");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("==> Wait signal from the debuggee that some first threads finished...");
+        String messageFromDebuggee = synchronizer.receiveMessageWithoutException("testThreadGroup002");
+        if ( ! JPDADebuggeeSynchronizer.SGNL_READY.equals(messageFromDebuggee) ) {
+            logWriter.println("## FAILURE: Could NOT receive expected signal from debuggee!");
+            printErrorAndFail("\n## Could NOT receive expected signal from debuggee! ");
+        }
+        int finishedTestedThreadsNumber = testedThreadsNumber/2;
+        logWriter.println
+        ("==> Number of debuggee's finished threads = " +  finishedTestedThreadsNumber);
+        
+        CommandPacket packet = null;
+        ReplyPacket reply = null;
+        String errorMessage = "";
+
+        boolean statusCommandFailed = false;
+        boolean threadStatusFailed = false;
+        boolean groupIDFailed = false;
+        boolean threadGroupCommandFailed = false;
+        boolean groupNameFailed = false;
+
+        logWriter.println
+        ("\n==> Check that ThreadReference.ThreadGroup command returns expected thread group for each tsted thread...");
+        
+        for (int threadCount = 0; threadCount < testedThreadsNumber; threadCount++) {
+            logWriter.println("\n==> Check for Thread: threadID = " + testedThreadsIDs[threadCount] 
+                    + "; threadName = " + testedThreadsNames[threadCount]);
+            logWriter.println("==> Send ThreadReference.Status command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(testedThreadsIDs[threadCount]);
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.Status command") ) {
+                statusCommandFailed = true;
+                continue;
+            }
+
+            int threadStatus = reply.getNextValueAsInt();
+            //int suspendStatus =
+            reply.getNextValueAsInt();
+
+            logWriter.println("==> thread status of checked thread = " + threadStatus + "("
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + ")");
+            
+            logWriter.println("==> Send ThreadReference.ThreadGroup command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
+            packet.setNextValueAsThreadID(testedThreadsIDs[threadCount]);
+            
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.ThreadGroup command") ) {
+                threadGroupCommandFailed = true;
+                continue;
+            }
+
+            long threadGroupID = reply.getNextValueAsThreadGroupID();
+            logWriter.println("==> thread groupID for checked thread = " + threadGroupID);
+            if (threadStatus == JDWPConstants.ThreadStatus.ZOMBIE) {
+                if ( threadCount >= finishedTestedThreadsNumber ) {
+                    logWriter.println("## FAILURE: Unexpected status for checked thread!");
+                    logWriter.println("##          Thread witn number = " + threadCount +
+                            " should NOT be ZOMBIE!");  
+                    threadStatusFailed = true;
+                    continue;
+                }
+                // according to JVMTI spec groupID is NULL if the thread has died
+                if ( threadGroupID != 0 ) {
+                    logWriter.println("## FAILURE: Unexpected thread groupID for checked thread with status = ZOMBIE!");
+                    logWriter.println("##          Expected thread groupID = 0");  
+                    groupIDFailed = true;
+                }
+                continue;
+            } else {
+                if ( threadCount < finishedTestedThreadsNumber ) {
+                    logWriter.println("## FAILURE: Unexpected status for checked thread!");
+                    logWriter.println("##          Thread witn number = " + threadCount +
+                            " should be ZOMBIE!");  
+                    threadStatusFailed = true;
+                    continue;
+                }
+                if ( threadGroupID == 0 ) {
+                    logWriter.println("## FAILURE: Unexpected thread groupID for checked thread with status != ZOMBIE!");
+                    logWriter.println("##          Expected thread groupID != 0");  
+                    groupIDFailed = true;
+                    continue;
+                }
+            }
+            
+            logWriter.println("==> Getting thread group name by ThreadGroupReference.Name command..."); 
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadGroupReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadGroupReferenceCommandSet.NameCommand);
+            packet.setNextValueAsThreadID(threadGroupID);
+            
+            reply = debuggeeWrapper.vmMirror.performCommand(packet);
+            if ( ! checkReplyPacketWithoutFail(reply, "ThreadReference.ThreadGroup command") ) {
+                threadGroupCommandFailed = true;
+                continue;
+            }
+
+            String threadGroupName = reply.getNextValueAsString();
+            logWriter.println("==> thread group name for checked thread = '" + threadGroupName + "'");
+
+            if ( ! testedThreadGroupsNames[threadCount].equals(threadGroupName) ) {
+                logWriter.println("## FAILURE: Unexpected thread group name for checked thread!");
+                logWriter.println("##          Expected thread group name = '" + 
+                        testedThreadGroupsNames[threadCount] + "'");  
+                groupNameFailed = true;
+            }
+        }
+
+        if ( statusCommandFailed ) {
+            errorMessage = errorMessage + 
+            "## Error found out while ThreadReference.Status command performing!\n";
+        }
+
+        if ( threadStatusFailed ) {
+            errorMessage = errorMessage + 
+            "## Unexpected thread status found out for some tested threads!\n";
+        }
+
+        if ( groupIDFailed ) {
+            errorMessage = errorMessage + 
+            "## Unexpected thread groupID found out for some tested threads!\n";
+        }
+
+        if ( threadGroupCommandFailed ) {
+            errorMessage = errorMessage + 
+            "## Error found out while ThreadReference.ThreadGroup command performing!\n";
+        }
+
+        if ( groupNameFailed ) {
+            errorMessage = errorMessage + 
+            "## Unexpected thread group name found out for some tested threads!\n";
+        }
+
+        logWriter.println("==> Send signal to debuggee to finish...");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        if ( ! errorMessage.equals("") ) {
+            printErrorAndFail("\ntestThreadGroup002 FAILED:\n" + errorMessage);
+        }
+
+        logWriter.println("\n==> testThreadGroup002 - OK!");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ThreadGroup002Test.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,130 @@
+/*
+ * 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 18.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.ThreadGroupTest</code>.
+ * This debuggee is started as follow:
+ * <ol>
+ *      <li>the tested group <code>TESTED_GROUP</code> is created 
+ *      <li>the tested thread <code>TESTED_THREAD</code> is started so this
+ *          thread belongs to that thread group
+ * </ol>
+ * For different goals of tests, the debuggee sends the <code>SGNL_READY</code>
+ * signal to and waits for the <code>SGNL_CONTINUE</code> signal from debugger
+ * in two places:
+ * <ul>
+ *      <li>right away when the tested thread has been started
+ *      <li>when the tested thread has been finished
+ * </ul>
+ */
+public class ThreadGroupDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_GROUP = "TestedGroup";
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+    
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+    
+    public void run() {
+        ThreadGroup thrdGroup = new ThreadGroup(TESTED_GROUP);
+        DebuggeeThread thrd = new DebuggeeThread(thrdGroup, TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                
+            }
+        }
+
+        while ( thrd.isAlive() ) {
+            waitMlsecsTime(100);
+        }
+
+//        synchronized(waitForFinish){
+            logWriter.println("thread is finished");
+//        }
+        logWriter.println("send SGNL_READY");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    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(ThreadGroupDebuggee.waitForFinish){
+
+                synchronized(ThreadGroupDebuggee.waitForStart){
+
+                    ThreadGroupDebuggee.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(ThreadGroupDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ThreadGroupTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,113 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * Created on 15.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.ThreadGroup command.
+ */
+public class ThreadGroupTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ThreadGroupDebuggee";
+    }
+
+    /**
+     * This testcase exercises ThreadReference.ThreadGroup command.
+     * <BR>At first the test starts ThreadGroupDebuggee which creates 
+     * 'TESTED_GROUP' ThreadGroup and starts the 'TESTED_THREAD' thread which 
+     * belongs to that thread group.
+     * <BR>After the tested thread starts but does not finish, test requests all 
+     * debuggee threads by VirtualMachine.AllThreads command and looks for tested thread.
+     * <BR>If the tested thread is not found the test fails.
+     * <BR>If the tested thread is found the test checks that 
+     * ThreadReference.ThreadGroup command for tested thread returns 'TESTED_GROUP' thread group.
+     */
+    public void testThreadGroup001() {
+        logWriter.println("wait for SGNL_READY");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // getting ID of the tested thread
+        CommandPacket packet;
+        logWriter.println("get all threads");
+        ReplyPacket replyThread, reply = debuggeeWrapper.vmMirror.getAllThreadID();
+        int threads = reply.getNextValueAsInt();
+        logWriter.println("exercise threads = " + threads);
+
+        long threadID, groupID;
+        String groupName, threadName;
+        int count = 0;
+
+        for (int i = 0; i < threads; i++) {
+            threadID = reply.getNextValueAsThreadID();
+            
+            // getting the thread group ID
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
+            packet.setNextValueAsThreadID(threadID);
+            
+            replyThread = debuggeeWrapper.vmMirror.performCommand(packet);
+            checkReplyPacket(replyThread, "ThreadReference::ThreadGroup command");
+
+            groupID = replyThread.getNextValueAsThreadGroupID();
+
+            groupName = debuggeeWrapper.vmMirror.getThreadGroupName(groupID);
+            threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+
+            logWriter.println("\tthreadID=" + threadID
+                    + "; threadName=" + threadName
+                    + "; groupID=" + groupID
+                    + "; groupName=" + groupName);
+
+            if (threadName.equals(ThreadGroupDebuggee.TESTED_THREAD)) {
+                if (!groupName.equals(ThreadGroupDebuggee.TESTED_GROUP)) {
+                    printErrorAndFail("unexpected group name, it is expected: "
+                            + ThreadGroupDebuggee.TESTED_GROUP);
+                }
+                count++;
+            }
+        }
+        if (count == 0) {
+            printErrorAndFail("Tested thread is not found in all_threads list.");
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("waiting for finishing thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ThreadGroupTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,224 @@
+/*
+ * 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 03.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+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 VirtualMachine.AllClasses command.
+ */
+public class AllClassesTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllClasses command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.AllClasses command and checks that:
+     * <BR>&nbsp;&nbsp; - number of reference types returned by command has
+     *                    non-zero value;
+     * <BR>&nbsp;&nbsp; - there are no classes with the 'ARRAY' or
+     *                    'PRIMITIVE' bits in the status flag;
+     */
+    public void testAllClasses002() {
+        logWriter.println("==> testAllClasses002: START...");
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("==> Send VirtualMachine::AllClasses command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllClasses command");
+
+        long typeID;   
+        String signature;   
+        int status;
+
+        int classes = reply.getNextValueAsInt();
+        assertTrue(classes > 0);
+
+        int count = 0;
+        for (int i = 0; i < classes; i++) {
+
+            reply.getNextValueAsByte();
+            typeID = reply.getNextValueAsReferenceTypeID();
+            signature = reply.getNextValueAsString();
+            status = reply.getNextValueAsInt();
+
+            if ( (status & JDWPConstants.ClassStatus.ARRAY) != 0 ){
+                logWriter.println("## FAILURE: Unexpected status is returned:");
+                logWriter.println("##          ReferenceTypeId = " + typeID);
+                logWriter.println("##          Class signature: " + signature);
+                logWriter.println("##          Class status = 0x" + Integer.toHexString(status) 
+                    + "(" + JDWPConstants.ClassStatus.getName(status)+ ")");
+                logWriter.println("##          Status \"0x"
+                        + Integer.toHexString(JDWPConstants.ClassStatus.ARRAY) 
+                        + "("
+                        + JDWPConstants.ClassStatus.getName(JDWPConstants.ClassStatus.ARRAY)
+                        + ")\" must NOT be returned!");
+                count++;
+            }
+            if ( (status & JDWPConstants.ClassStatus.PRIMITIVE) != 0 ){
+                logWriter.println("## FAILURE: Unexpected status is returned:");
+                logWriter.println("##          ReferenceTypeId = " + typeID);
+                logWriter.println("##          Class signature: " + signature);
+                logWriter.println("##          Class status = 0x" + Integer.toHexString(status) 
+                    + "(" + JDWPConstants.ClassStatus.getName(status)+ ")");
+                logWriter.println("##          Status \"0x"
+                        + Integer.toHexString(JDWPConstants.ClassStatus.PRIMITIVE) 
+                        + "("
+                        + JDWPConstants.ClassStatus.getName(JDWPConstants.ClassStatus.PRIMITIVE)
+                        + ")\" must NOT be returned!");
+                count++;
+            }
+        }
+        assertEquals("count must be 0", 0, count);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testAllClasses002: OK.");
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllClasses command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.AllClasses command and checks that:
+     * <BR>&nbsp;&nbsp; - number of reference types returned by command has
+     * non-zero value;
+     * <BR>&nbsp;&nbsp; - refTypeTag takes one of the TypeTag constants:
+     *                    'CLASS', 'INTERFACE', 'ARRAY';
+     * <BR>&nbsp;&nbsp; - length of the signature string is not zero and starts with 'L' or
+     *                    '[' symbols;
+     * <BR>&nbsp;&nbsp; - signature of at least one class contains the "HelloWorld" string;
+     * <BR>&nbsp;&nbsp; - All data were read from reply packet;
+     */
+    public void testAllClasses001() {
+        logWriter.println("==> testAllClasses001: START...");
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("==> Send VirtualMachine::AllClasses command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllClasses command");
+
+        byte refTypeTag;
+        String refTypeTagName;
+        long typeID;   
+        String signature;   
+        int status;
+        String msgLine;
+        boolean flagForHelloWorld = false;
+
+        int classes = reply.getNextValueAsInt();
+        logWriter.println("==> Number of reference types = " + classes);
+        assertTrue(classes > 0);
+        
+        int printBound_1 = classes;
+        int printBound_2 = 0;
+        if ( classes > 50 ) {
+            printBound_1 = 5;
+            printBound_2 = classes - 5;
+        }
+        for (int i = 0; i < classes; i++) {
+
+            boolean infoIsPrinted = false;
+            refTypeTag = reply.getNextValueAsByte();
+            try {
+                refTypeTagName = JDWPConstants.TypeTag.getName(refTypeTag);
+            } catch ( Throwable thrown ) {
+                refTypeTagName = "UnknownTagName";
+            }
+            msgLine = "\n" + i + ". " + refTypeTagName;
+            typeID = reply.getNextValueAsReferenceTypeID();
+            signature = reply.getNextValueAsString();
+            msgLine = msgLine + ": " + signature;
+            status = reply.getNextValueAsInt();
+            msgLine = msgLine + " " + JDWPConstants.ClassStatus.getName(status);
+            if ( (i < printBound_1) || (i >= printBound_2) ) {
+                logWriter.println(msgLine);
+                logWriter.println("\treferenceTypeID = " + typeID);
+                logWriter.println("\trefTypeTag = " + refTypeTagName
+                        + "(" + refTypeTag + ")");
+                logWriter.println("\tsignature = " + signature);
+                if ( i == (printBound_1-1) ) {
+                    logWriter.println("...\n...\n...");
+                }
+                infoIsPrinted = true;
+            }
+            
+            try {
+                assertTrue(refTypeTag == JDWPConstants.TypeTag.ARRAY
+                        || refTypeTag == JDWPConstants.TypeTag.CLASS
+                        || refTypeTag == JDWPConstants.TypeTag.INTERFACE);
+
+                assertTrue(signature.length() > 0);
+                assertTrue(signature.toCharArray()[0] == 'L' 
+                        || signature.toCharArray()[0] == '[');
+            } catch ( Throwable thrown) {
+                // some assert is cought
+                if ( !infoIsPrinted ) {
+                    logWriter.println(msgLine);
+                    logWriter.println("\treferenceTypeID = " + typeID);
+                    logWriter.println("\trefTypeTag = " + refTypeTagName
+                            + "(" + refTypeTag + ")");
+                    logWriter.println("\tsignature = " + signature );
+                }
+                logWriter.println("## FAILURE is found out for this referenceType!\n");
+                assertTrue(refTypeTag == JDWPConstants.TypeTag.ARRAY
+                        || refTypeTag == JDWPConstants.TypeTag.CLASS
+                        || refTypeTag == JDWPConstants.TypeTag.INTERFACE);
+
+                assertTrue(signature.length() > 0);
+                assertTrue(signature.toCharArray()[0] == 'L' 
+                        || signature.toCharArray()[0] == '[');
+            }
+
+            if (signature.indexOf("HelloWorld") != -1)
+                flagForHelloWorld = true;
+        }
+        assertAllDataRead(reply);
+        assertTrue("HelloWorld has not been found in signatures of returned reference types",
+                flagForHelloWorld);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testAllClasses001: OK.");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllClassesTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesWithGenericTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesWithGenericTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesWithGenericTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllClassesWithGenericTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,235 @@
+/*
+ * 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.8 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+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 VirtualMachine.AllClassesWithGeneric command.
+ */
+public class AllClassesWithGenericTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllClassesWithGeneric command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.AllClassesWithGeneric 
+     * command and checks that:
+     * <BR>&nbsp;&nbsp; - number of reference types returned by command has
+     *                    non-zero value;
+     * <BR>&nbsp;&nbsp; - there are no classes with the 'ARRAY' or
+     *                    'PRIMITIVE' bits in the status flag;
+     */
+    public void testAllClassesWithGeneric002() {
+        logWriter.println("==> testAllClassesWithGeneric002: START...");
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("==> Send VirtualMachine::AllClassesWithGeneric command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllClassesWithGenericCommand);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllClassesWithGeneric command");
+
+        long typeID;   
+        String signature, genericSignature;
+        int status;
+
+        int classes = reply.getNextValueAsInt();
+        assertTrue(classes > 0);
+
+        int count = 0;
+        for (int i = 0; i < classes; i++) {
+
+            reply.getNextValueAsByte();
+            typeID = reply.getNextValueAsReferenceTypeID();
+            signature = reply.getNextValueAsString();
+            genericSignature = reply.getNextValueAsString();
+            status = reply.getNextValueAsInt();
+
+            if ( (status & JDWPConstants.ClassStatus.ARRAY) != 0 ){
+                logWriter.println("## FAILURE: Unexpected status is returned:");
+                logWriter.println("##          ReferenceTypeId = " + typeID);
+                logWriter.println("##          Class signature: " + signature);
+                logWriter.println("##          Class generic signature: " + genericSignature);
+                logWriter.println("##          Class status = 0x" + Integer.toHexString(status) 
+                    + "(" + JDWPConstants.ClassStatus.getName(status)+ ")");
+                logWriter.println("##          Status \"0x"
+                        + Integer.toHexString(JDWPConstants.ClassStatus.ARRAY) 
+                        + "("
+                        + JDWPConstants.ClassStatus.getName(JDWPConstants.ClassStatus.ARRAY)
+                        + ")\" must NOT be returned!");
+                count++;
+            }
+            if ( (status & JDWPConstants.ClassStatus.PRIMITIVE) != 0 ){
+                logWriter.println("## FAILURE: Unexpected status is returned:");
+                logWriter.println("##          ReferenceTypeId = " + typeID);
+                logWriter.println("##          Class signature: " + signature);
+                logWriter.println("##          Class generic signature: " + genericSignature);
+                logWriter.println("##          Class status = 0x" + Integer.toHexString(status) 
+                    + "(" + JDWPConstants.ClassStatus.getName(status)+ ")");
+                logWriter.println("##          Status \"0x"
+                        + Integer.toHexString(JDWPConstants.ClassStatus.PRIMITIVE) 
+                        + "("
+                        + JDWPConstants.ClassStatus.getName(JDWPConstants.ClassStatus.PRIMITIVE)
+                        + ")\" must NOT be returned!");
+                count++;
+            }
+        }
+        assertEquals("count must be 0", 0, count);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testAllClassesWithGeneric002: OK.");
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllClassesWithGeneric command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.AllClassesWithGeneric
+     * command and checks that:
+     * <BR>&nbsp;&nbsp; - number of reference types returned by command has
+     * non-zero value;
+     * <BR>&nbsp;&nbsp; - refTypeTag takes one of the TypeTag constants:
+     *                    'CLASS', 'INTERFACE', 'ARRAY';
+     * <BR>&nbsp;&nbsp; - length of the signature string is not zero and starts with 'L' or
+     *                    '[' symbols;
+     * <BR>&nbsp;&nbsp; - signature of at least one class contains the "HelloWorld" string;
+     * <BR>&nbsp;&nbsp; - All data were read from reply packet;
+     */
+    public void testAllClassesWithGeneric001() {
+
+        logWriter.println("==> testAllClassesWithGeneric001: START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("==> Send VirtualMachine::AllClassesWithGeneric command...");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllClassesWithGenericCommand);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllClassesWithGeneric command");
+
+        byte refTypeTag;
+        String refTypeTagName;
+        long typeID;   
+        String signature, genericSignature;   
+        int status;
+        String msgLine;
+        boolean flagForHelloWorld = false;
+
+        int classes = reply.getNextValueAsInt();
+        logWriter.println("==> Number of reference types = " + classes);
+        assertTrue("VirtualMachine::AllClassesWithGeneric command returned invalid number of classes: " + classes,
+                classes > 0);
+
+        int printBound_1 = classes;
+        int printBound_2 = 0;
+        if ( classes > 50 ) {
+            printBound_1 = 5;
+            printBound_2 = classes - 5;
+        }
+        for (int i = 0; i < classes; i++) {
+
+            boolean infoIsPrinted = false;
+            refTypeTag = reply.getNextValueAsByte();
+            try {
+                refTypeTagName = JDWPConstants.TypeTag.getName(refTypeTag);
+            } catch ( Throwable thrown ) {
+                refTypeTagName = "UnknownTagName";
+            }
+            msgLine = "\n" + i + ". " + refTypeTagName;
+            typeID = reply.getNextValueAsReferenceTypeID();
+            signature = reply.getNextValueAsString();
+            msgLine = msgLine + ": " + signature;
+            genericSignature = reply.getNextValueAsString();
+            status = reply.getNextValueAsInt();
+            msgLine = msgLine + " " + JDWPConstants.ClassStatus.getName(status);
+            if ( (i < printBound_1) || (i >= printBound_2) ) {
+                logWriter.println(msgLine);
+                logWriter.println("\treferenceTypeID = " + typeID);
+                logWriter.println("\trefTypeTag = " + refTypeTagName
+                        + "(" + refTypeTag + ")");
+                logWriter.println("\tsignature = " + signature);
+                logWriter.println("\tgenericSignature = " + genericSignature);
+                if ( i == (printBound_1-1) ) {
+                    logWriter.println("...\n...\n...");
+                }
+                infoIsPrinted = true;
+            }
+
+            try {
+                assertTrue(refTypeTag == JDWPConstants.TypeTag.ARRAY
+                        || refTypeTag == JDWPConstants.TypeTag.CLASS
+                        || refTypeTag == JDWPConstants.TypeTag.INTERFACE);
+
+                assertTrue(signature.length() > 0);
+                assertTrue(signature.toCharArray()[0] == 'L' 
+                        || signature.toCharArray()[0] == '[');
+            } catch ( Throwable thrown) {
+                // some assert is cought
+                if ( !infoIsPrinted ) {
+                    logWriter.println(msgLine);
+                    logWriter.println("\treferenceTypeID = " + typeID);
+                    logWriter.println("\trefTypeTag = " + refTypeTagName
+                            + "(" + refTypeTag + ")");
+                    logWriter.println("\tsignature = " + signature );
+                    logWriter.println("\tgenericSignature = " + genericSignature);
+                }
+                logWriter.println("## FAILURE is found out for this referenceType!\n");
+                assertTrue("Unexpected refTypeTag",
+                        refTypeTag == JDWPConstants.TypeTag.ARRAY
+                        || refTypeTag == JDWPConstants.TypeTag.CLASS
+                        || refTypeTag == JDWPConstants.TypeTag.INTERFACE);
+
+                assertTrue("Invalid signature",
+                        signature.length() > 0);
+                assertTrue("Invalid signature",
+                        signature.toCharArray()[0] == 'L' 
+                        || signature.toCharArray()[0] == '[');
+            }
+            if (signature.indexOf("HelloWorld") != -1)
+                flagForHelloWorld = true;
+        }
+
+        assertAllDataRead(reply);
+        assertTrue("HelloWorld has not been found in signatures of returned reference types", flagForHelloWorld);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> testAllClassesWithGeneric001: OK.");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllClassesWithGenericTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsDebuggee.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.2 $
+ */
+
+/**
+ * Created on 19.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+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.VirtualMachine.AllThreadsTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code> and for
+ * different goals of tests, the debuggee sends the <code>SGNL_READY</code>
+ * signal to and waits for the <code>SGNL_CONTINUE</code> signal from debugger
+ * in two places:
+ * <ul>
+ *      <li>right away when the tested thread has been started
+ *      <li>when the tested thread has been finished
+ * </ul>
+ */
+public class AllThreadsDebuggee extends SyncDebuggee {
+
+    static Object waitTimeObject = new Object();
+    static void waitMlsecsTime(long mlsecsTime) { 
+        synchronized(waitTimeObject) {
+            try {
+                waitTimeObject.wait(mlsecsTime);
+            } catch (Throwable throwable) {
+                 // ignore
+            }
+        }
+    }
+
+    public static final String TESTED_THREAD = "TestedThread";
+
+    static Object waitForStart = new Object();
+
+    public void run() {
+        DebuggeeThread thrd = new DebuggeeThread(TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                
+            }
+        }
+
+        logWriter.println("Wait for thread to finish...");
+        while ( thrd.isAlive() ) {
+            waitMlsecsTime(1000);
+        }
+        logWriter.println("thread finished");
+        logWriter.println("send SGNL_READY");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    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() {
+
+            logWriter.println(getName() +  ": started...");
+            synchronized(AllThreadsDebuggee.waitForStart){
+
+                AllThreadsDebuggee.waitForStart.notifyAll();
+            }
+
+            synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+            logWriter.println(getName() +  ": wait for SGNL_CONTINUE");
+            synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+            logWriter.println(getName() +  ": is finishing...");
+        }
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(AllThreadsDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/AllThreadsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,235 @@
+/*
+ * 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 09.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+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 VirtualMachine.AllThreads command.
+ */
+public class AllThreadsTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.AllThreadsDebuggee";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllThreads command.
+     * <BR>At first the test starts AllThreadsDebuggee which runs the TESTED_THREAD thread
+     * which starts and finishes.
+     * <BR> Then the test performs VirtualMachine.AllThreads command and checks that
+     * the tested thread is not returned by command;
+     */
+    public void testAllThreads003() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("waiting for finishing thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("send AllThreads cmd");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllThreadsCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllThreads command");
+
+        long threadID;
+        int threadStatus, suspendStatus;
+        String threadName;
+        ReplyPacket replyName;
+
+        int threads = reply.getNextValueAsInt();
+        logWriter.println("Number of threads = " + threads);
+        assertTrue("Number of threads must be > 0", threads > 0);
+
+        for (int i = 0; i < threads; i++) {
+
+            threadID = reply.getNextValueAsThreadID();
+            threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(threadID);
+            
+            replyName = debuggeeWrapper.vmMirror.performCommand(packet);
+            checkReplyPacket(replyName, "ThreadReference::Status command"); 
+
+            threadStatus = replyName.getNextValueAsInt();
+            suspendStatus = replyName.getNextValueAsInt();
+
+            logWriter.println("\t" + threadID + " "
+                    + "\"" + threadName + "\" "
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + " "
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus));
+
+            if (threadName.equals(AllThreadsDebuggee.TESTED_THREAD)) {
+                printErrorAndFail(AllThreadsDebuggee.TESTED_THREAD
+                        + " must not be in all_thread list");
+            }
+        }
+        assertAllDataRead(reply);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllThreads command.
+     * <BR>At first the test starts AllThreadsDebuggee which runs the TESTED_THREAD thread
+     * which starts but does not finish.
+     * <BR> Then the test performs VirtualMachine.AllThreads command and checks that
+     * all threads returned by command have only valid thread status:
+     * <BR>'RUNNING' or 'MONITOR' or 'SLEEPING' or 'ZOMBIE' or 'WAIT' status;
+     */
+    public void testAllThreads002() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("send AllThreads cmd");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllThreadsCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllThreads command");
+
+        long threadID;
+        int threadStatus, suspendStatus;
+        String threadName;
+        int count = 0;
+        ReplyPacket replyName;
+
+        int threads = reply.getNextValueAsInt();
+        logWriter.println("Number of threads = " + threads);
+        assertTrue("Number of threads must be > 0", threads > 0);
+
+        boolean threadStatusFailed = false;
+        for (int i = 0; i < threads; i++) {
+
+            threadID = reply.getNextValueAsThreadID();
+            threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+
+            packet = new CommandPacket(
+                    JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+                    JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
+            packet.setNextValueAsReferenceTypeID(threadID);
+                        
+            replyName = debuggeeWrapper.vmMirror.performCommand(packet);
+            checkReplyPacket(replyName, "ThreadReference::Status command");
+
+            threadStatus = replyName.getNextValueAsInt();
+            suspendStatus = replyName.getNextValueAsInt();
+
+            logWriter.println("\t" + threadID + " "
+                    + "\"" + threadName + "\" "
+                    + JDWPConstants.ThreadStatus.getName(threadStatus) + " "
+                    + JDWPConstants.SuspendStatus.getName(suspendStatus));
+            if (threadStatus == JDWPConstants.ThreadStatus.RUNNING
+                    || threadStatus == JDWPConstants.ThreadStatus.MONITOR
+                    || threadStatus == JDWPConstants.ThreadStatus.SLEEPING
+                    || threadStatus == JDWPConstants.ThreadStatus.ZOMBIE
+                    || threadStatus == JDWPConstants.ThreadStatus.WAIT) {
+            } else {
+                logWriter.println
+                ("## FAILURE: Unknown thread status is found out!");
+                threadStatusFailed = true;
+                count++;
+            }
+        }
+        if (threadStatusFailed) {
+            printErrorAndFail("\nThreads with unknown thread status found out!\n" +
+                    "Number of such threads = " + count +"\n");
+        }
+        assertAllDataRead(reply);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("waiting for finishing thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.AllThreads command.
+     * <BR>At first the test starts AllThreadsDebuggee which runs the TESTED_THREAD thread
+     * which starts but does not finish.
+     * <BR> Then the test performs VirtualMachine.AllThreads command and checks that
+     * the tested thread is returned by command in the list of threads;
+     */
+    public void testAllThreads001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("send AllThreads cmd");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllThreadsCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::AllThreads command");
+
+        long threadID;
+        String threadName;
+        int count = 0;
+
+        int threads = reply.getNextValueAsInt();
+        logWriter.println("Number of threads = " + threads);
+        assertTrue("Number of threads must be > 0", threads > 0);
+
+        for (int i = 0; i < threads; i++) {
+            threadID = reply.getNextValueAsThreadID();
+            threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+
+            if (threadName.equals(AllThreadsDebuggee.TESTED_THREAD)) {
+                count++;
+                logWriter.println("\t" + threadID + " "
+                        + "\"" + threadName + "\" found");
+            }
+        }
+        if (count != 1) {
+            if (count == 0) {
+                printErrorAndFail(AllThreadsDebuggee.TESTED_THREAD + " not found");
+            }
+            if (count > 1 || count < 0) {
+                printErrorAndFail(AllThreadsDebuggee.TESTED_THREAD
+                        + " unexpected amount: " + count);
+            }
+        }
+        assertAllDataRead(reply);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("waiting for finishing thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllThreadsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesNewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesNewTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesNewTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesNewTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,122 @@
+/*
+ * 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.6 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+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 VirtualMachine.CapabilitiesNew command.
+ */
+public class CapabilitiesNewTest extends JDWPSyncTestCase {
+
+    static Object [][] capabilitiesFlags = {
+            {"canWatchFieldModification", new Object()},   
+            {"canWatchFieldAccess", new Object()},
+            {"canGetBytecodes", new Object()},
+            {"canGetSyntheticAttribute", new Object()},
+            {"canGetOwnedMonitorInfo", new Object()},
+            {"canGetCurrentContendedMonitor", new Object()},
+            {"canGetMonitorInfo", new Object()},
+            {"canRedefineClasses", new Object()},   
+            {"canAddMethod", null},
+            {"canUnrestrictedlyRedefineClasses", null},
+            {"canPopFrames", new Object()},
+            {"canUseInstanceFilters", new Object()},
+            {"canGetSourceDebugExtension", new Object()},
+            {"canRequestVMDeathEvent", new Object()},
+            {"canSetDefaultStratum", null},
+            {"reserved16", null},
+            {"reserved17", null},
+            {"reserved18", null},
+            {"reserved19", null},
+            {"reserved20", null},
+            {"reserved21", null},
+            {"reserved22", null},
+            {"reserved23", null},
+            {"reserved24", null},
+            {"reserved25", null},
+            {"reserved26", null},
+            {"reserved27", null},
+            {"reserved28", null},
+            {"reserved29", null},
+            {"reserved30", null},
+            {"reserved31", null},
+            {"reserved32", null} 
+    }; 
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.CapabilitiesNew command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.CapabilitiesNew command and checks that:
+     * all returned capabilities' values are expected values and that
+     * there are no extra data in the reply packet;
+     */
+    public void testCapabilitiesNew001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.CapabilitiesNewCommand);
+        logWriter.println("\trequest capabilities");
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::CapabilitiesNew command");
+
+        boolean flag;
+        boolean testFailed = false;
+        for (int i = 0; i < 32; i++) {
+            flag = reply.getNextValueAsBoolean();   
+            logWriter.println("\tReceived " + capabilitiesFlags[i][0] +  " = "
+                    + flag);
+            if ( (capabilitiesFlags[i][1] != null) !=  flag ) {
+                testFailed = true;
+                logWriter.println("\t   ## FAILURE: Expected " + capabilitiesFlags[i][0] + 
+                        " = " + (capabilitiesFlags[i][1] != null));
+            } else {
+                logWriter.println("\t   OK - it is expected value!");
+            }
+        }
+        if ( testFailed ) {
+            printErrorAndFail("Unexpected received capabilities values found out");
+        } else {
+            logWriter.println("testCapabilitiesNew001 - OK!");
+        }
+        assertAllDataRead(reply);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CapabilitiesNewTest.class);
+    }
+}



Mime
View raw message