harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [36/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
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesNewTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CapabilitiesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,103 @@
+/*
+ * 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 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.Capabilities command.
+ */
+public class CapabilitiesTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.Capabilities command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.Capabilities command and checks that:
+     * all returned capabilities' values are expected values and that
+     * there are no extra data in the reply packet;
+     */
+    public void testCapabilities001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.CapabilitiesCommand);
+        logWriter.println("\trequest capabilities");
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::Capabilities command");
+        
+        boolean canWatchFieldModification     = reply.getNextValueAsBoolean();   
+        boolean canWatchFieldAccess         = reply.getNextValueAsBoolean();   
+        boolean canGetBytecodes             = reply.getNextValueAsBoolean();    
+        boolean canGetSyntheticAttribute     = reply.getNextValueAsBoolean();    
+        boolean canGetOwnedMonitorInfo         = reply.getNextValueAsBoolean();   
+        boolean canGetCurrentContendedMonitor = reply.getNextValueAsBoolean();   
+        boolean canGetMonitorInfo             = reply.getNextValueAsBoolean();
+
+        logWriter.println("\tcanWatchFieldModification\t= "
+                + canWatchFieldModification);   
+        assertTrue("canWatchFieldModification must be true", canWatchFieldModification);
+        
+        logWriter.println("\tcanWatchFieldAccess\t\t= " + canWatchFieldAccess);
+        assertTrue("canWatchFieldAccess must be true", canWatchFieldAccess);
+        
+        logWriter.println("\tcanGetBytecodes\t\t\t= " + canGetBytecodes);     
+        assertTrue("canGetBytecodes must be true", canGetBytecodes);
+        
+        logWriter.println("\tcanGetSyntheticAttribute\t= "
+                + canGetSyntheticAttribute);    
+        assertTrue("canGetSyntheticAttribute must be true", canGetSyntheticAttribute);
+        
+        logWriter.println("\tcanGetOwnedMonitorInfo\t\t= "
+                + canGetOwnedMonitorInfo);   
+        assertTrue("canGetOwnedMonitorInfo must be true", canGetOwnedMonitorInfo);
+        
+        logWriter.println("\tcanGetCurrentContendedMonitor\t= "
+                + canGetCurrentContendedMonitor);   
+        assertTrue("canGetCurrentContendedMonitor must be true", canGetCurrentContendedMonitor);
+        
+        logWriter.println("\tcanGetMonitorInfo\t\t= " + canGetMonitorInfo);
+        assertTrue("canGetMonitorInfo must be true", canGetMonitorInfo);
+
+        assertAllDataRead(reply);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CapabilitiesTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassPathsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassPathsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassPathsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassPathsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Vitaly A. Provodin
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import java.io.File;
+
+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.ClassPaths command.
+ */
+public class ClassPathsTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.ClassPaths command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.ClassPaths command and checks that:
+     * <BR>&nbsp;&nbsp; - the 'baseDir' directory exists;
+     * <BR>&nbsp;&nbsp; - amount of bootclasspaths is greater than 0;
+     * <BR>&nbsp;&nbsp; - length of strings representing classpaths, bootclasspaths is not zero;
+     * <BR>&nbsp;&nbsp; - there are no extra data in the reply packet;
+     */
+    public void testClassPaths001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ClassPathsCommand);
+        logWriter.println("\trequest class paths");
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::ClassPaths command");
+
+        String baseDir = reply.getNextValueAsString();
+        logWriter.println("baseDir = " + baseDir);
+        assertTrue("baseDir = " + baseDir + " doesn't exists",
+                new File(baseDir).exists());
+
+        int classpaths = reply.getNextValueAsInt();
+        logWriter.println("classpaths = " + classpaths);
+        for (int i = 0; i < classpaths; i++) {
+            String path = reply.getNextValueAsString();
+            logWriter.println("\t" + path);
+            if(!(path.length() > 0)){
+                logWriter.println("Path length = "+path.length());
+            }
+        }
+
+        int bootclasspaths = reply.getNextValueAsInt();
+        logWriter.println("bootclasspaths = " + bootclasspaths);
+        assertTrue(bootclasspaths > 0);
+        for (int i = 0; i < bootclasspaths; i++) {
+            String path = reply.getNextValueAsString();
+            logWriter.println("\t" + path);
+            assertTrue("Invalid path", path.length() > 0);
+        }
+
+        assertAllDataRead(reply);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ClassPathsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassesBySignatureTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassesBySignatureTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassesBySignatureTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ClassesBySignatureTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,121 @@
+/*
+ * 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.ClassesBySignature command.
+ */
+public class ClassesBySignatureTest extends JDWPSyncTestCase {
+
+    static final String SIGNATURE001 = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.ClassesBySignature command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.ClassesBySignature command 
+     * for signature of HelloWorld class and checks that:
+     * <BR>&nbsp;&nbsp; - number of returned reference types is equal to 1;
+     * <BR>&nbsp;&nbsp; - the JDWP command ReferenceType.Signature for
+     * returned referenceTypeID returns the expected string signature;
+     * <BR>&nbsp;&nbsp; - there are no extra data in the reply packet;
+     */
+    public void testClassesBySignature001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
+        packet.setNextValueAsString(SIGNATURE001);
+
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::ClassesBySignature command");
+
+        byte refTypeTag;
+        long typeID;   
+        String signature;
+        int status;
+        ReplyPacket replySignature;
+
+        int classes = reply.getNextValueAsInt();
+        logWriter.println("Number of reference types = " + classes);
+        if (classes != 1) {
+            logWriter.printError("Wrong Number of reference types");
+            //assertEquals(1, classes);
+            fail("Wrong Number of reference types");
+        }
+
+        for (int i = 0; i < classes; i++) {
+
+            refTypeTag = reply.getNextValueAsByte();
+            typeID = reply.getNextValueAsReferenceTypeID();
+            status = reply.getNextValueAsInt();
+
+            logWriter.println("\trefTypeTag = "
+                    + JDWPConstants.TypeTag.getName(refTypeTag)
+                    + "(" + refTypeTag + ")");
+            if (JDWPConstants.TypeTag.CLASS != refTypeTag) {
+                printErrorAndFail("refTypeTag must be "
+                        + JDWPConstants.TypeTag.getName(JDWPConstants.TypeTag.CLASS)
+                        + "(" + JDWPConstants.TypeTag.CLASS + ")");
+            }
+
+            packet = new CommandPacket(
+                    JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+                    JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+            packet.setNextValueAsReferenceTypeID(typeID);
+            
+            replySignature = debuggeeWrapper.vmMirror.performCommand(packet);
+            signature = replySignature.getNextValueAsString();
+
+            logWriter.println("\ttypeID = " + typeID + "(" + signature + ")");
+            if (!SIGNATURE001.equals(signature)) { 
+                printErrorAndFail("Signature must be " + SIGNATURE001);
+            }
+
+            logWriter.println("\tstatus = "
+                    + JDWPConstants.ClassStatus.getName(status)
+                    + "(" + status + ")");
+        }
+        assertAllDataRead(reply);
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ClassesBySignatureTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CreateStringTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CreateStringTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CreateStringTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/CreateStringTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,87 @@
+/*
+ * 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 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.CreateString command.
+ */
+public class CreateStringTest extends JDWPSyncTestCase {
+
+    static final String CHECKED_STRING = "Hello World!"; 
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.CreateString command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.CreateString command 
+     * for some string and checks that StringReference.Value command
+     * returns the same string.
+     */
+    public void testCreateString001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.CreateStringCommand);
+        packet.setNextValueAsString(CHECKED_STRING);
+        logWriter.println("\tcreate string: " + CHECKED_STRING);
+
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::CreateString command");
+
+        long stringID = reply.getNextValueAsStringID();
+
+        packet = new CommandPacket(
+                JDWPCommands.StringReferenceCommandSet.CommandSetID,
+                JDWPCommands.StringReferenceCommandSet.ValueCommand);
+        packet.setNextValueAsObjectID(stringID);
+        logWriter.println("\trequest string value");
+
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "StringReference::Value command");
+
+        String value = reply.getNextValueAsString();
+        logWriter.println("\tgot string value: " + value);
+
+        assertString("StringReference::Value command returned invalid string value,", CHECKED_STRING, value);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CreateStringTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeObjectsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeObjectsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeObjectsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeObjectsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,127 @@
+/*
+ * 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 28.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.DisposeObjects command.
+ */
+public class DisposeObjectsTest extends JDWPSyncTestCase {
+
+    static final String CHECKED_STRING = "Hello World!"; 
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.DisposeObjects command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.CreateString command 
+     * for some string and checks that VirtualMachine.DisposeObjects command
+     * for returned by CreateString command stringID with refCount = 0
+     * does not dispose that stringID - ObjectReference::ReferenceType
+     * command should return some referenceTypeID without any error.
+     * <BR>Then the test check that repeated VirtualMachine.DisposeObjects command
+     * with refCount = 1 disposes that stringID - ObjectReference::ReferenceType
+     * command should return INVALID_OBJECT error. 
+     */
+    public void testDisposeObjects001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.CreateStringCommand);
+        packet.setNextValueAsString(CHECKED_STRING);
+        logWriter.println("\tcreate string: " + CHECKED_STRING);
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+
+        long stringID = reply.getNextValueAsStringID();
+        logWriter.println("\tstring creared: stringID = " + stringID);
+
+        logWriter.println("\tsend DisposeObjects for created string with refCount = 0" 
+                + " - string should not be disposed...");
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.DisposeObjectsCommand);
+        packet.setNextValueAsInt(1);
+        packet.setNextValueAsObjectID(stringID);
+        packet.setNextValueAsInt(0);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::DisposeObjects command");
+
+        logWriter.println
+            ("\tsend ObjectReference::ReferenceType command for created string"
+            + " to make sure that string is not disposed...");
+        packet = new CommandPacket(
+                JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+                JDWPCommands.ObjectReferenceCommandSet.ReferenceTypeCommand);
+        packet.setNextValueAsObjectID(stringID);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "ObjectReference::ReferenceType command");
+
+        byte refTypeTag = reply.getNextValueAsByte();
+        long refTypeID = reply.getNextValueAsReferenceTypeID();
+        logWriter.println("\tReturned refTypeTag = " + refTypeTag
+                + "(" + JDWPConstants.TypeTag.getName(refTypeTag) + ")");
+        logWriter.println("\tReturned ReferenceTypeID for string = " + refTypeID);
+
+        logWriter.println("\tsend DisposeObjects for created string with refCount = 1" 
+                + " - string should be disposed...");
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.DisposeObjectsCommand);
+        packet.setNextValueAsInt(1);
+        packet.setNextValueAsObjectID(stringID);
+        packet.setNextValueAsInt(1);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::DisposeObjects command");
+
+        logWriter.println
+            ("\tsend ObjectReference::ReferenceType command for disposed string"
+            + " - INVALID_OBJECT should be...");
+        packet = new CommandPacket(
+                JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+                JDWPCommands.ObjectReferenceCommandSet.ReferenceTypeCommand);
+        packet.setNextValueAsObjectID(stringID);
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        
+        checkReplyPacket(reply, "ObjectReference::ReferenceType command", JDWPConstants.Error.INVALID_OBJECT);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(DisposeObjectsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/DisposeTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,82 @@
+/*
+ * 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 09.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for VirtualMachine.Dispose command.
+ */
+public class DisposeTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.Dispose command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.Dispose command and checks that:
+     * <BR>&nbsp;&nbsp; - the reply on the Dispose command is received without any error;
+     * <BR>&nbsp;&nbsp; - next VirtualMachine.AllClasses command returns error;
+     */
+    public void testDispose001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.DisposeCommand);
+        
+        try {
+            debuggeeWrapper.vmMirror.performCommand(packet);
+        } catch (TestErrorException e) {
+            logWriter.printError("Unexpected exception " + e);
+            fail("Unexpected exception " + e);
+        }
+
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
+        try {
+            debuggeeWrapper.vmMirror.performCommand(packet);
+            fail("No exception has been thrown");
+        } catch (TestErrorException e) {
+            logWriter.println("Expected exception " + e);
+        }
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(DisposeTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ExitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ExitTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ExitTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ExitTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,83 @@
+/*
+ * 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 31.01.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.jdwp.share.JDWPTestCase;
+
+
+/**
+ * JDWP Unit test for VirtualMachine.Exit command.
+ */
+public class ExitTest extends JDWPTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.SimpleHelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.Exit command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.Exit command 
+     * with exit code = 99 and checks that debuggee exit code, received
+     * with help of debuggeeWrapper of test framework, is the same.
+     */
+    public void testExit001() {
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ExitCommand);
+        packet.setNextValueAsInt(99);
+        
+        debuggeeWrapper.vmMirror.performCommand(packet);
+        
+        int exitCode = 0;
+        boolean exitLoop;
+
+        long timeOut = settings.getTimeout();
+        long startTime = System.currentTimeMillis();
+        do {
+            try {
+                exitCode = debuggeeWrapper.process.exitValue();
+                exitLoop = true;
+            } catch (IllegalThreadStateException e) {
+                exitLoop = false;
+            }
+            if (System.currentTimeMillis() - startTime > timeOut) {
+                printErrorAndFail("Out of time: debugger did get "
+                        + "no exit codes of debuggee");
+                break;
+            }
+        } while (!exitLoop);
+
+        logWriter.println("exitCode = " + exitCode);
+        assertEquals("Invalid exit code,", 99, exitCode);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ExitTest.class);
+    }
+}
\ No newline at end of file

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsDebuggee.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.3 $
+ */
+
+/**
+ * Created on 28.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.ThreadReference.HoldEventsTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code>.
+ */
+public class HoldEventsDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+
+    public void run() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("wait for SGNL_CONTINUE to start thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        DebuggeeThread thrd = new DebuggeeThread(TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            logWriter.println("starting thread");
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                logWriter.println("" + e + " is cought");
+            }
+        }
+
+        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(HoldEventsDebuggee.waitForFinish){
+
+                synchronized(HoldEventsDebuggee.waitForStart){
+
+                    HoldEventsDebuggee.waitForStart.notifyAll();
+
+                    logWriter.println(getName() +  ": started");
+
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        runDebuggee(HoldEventsDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Vitaly A. Provodin
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 28.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for VirtualMachine.HoldEvents command.
+ */
+public class HoldEventsTest extends JDWPSyncTestCase {
+
+    CommandPacket event = null;
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.HoldEventsDebuggee";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.HoldEvents command.
+     * <BR>At first the test starts HoldEventsDebuggee.
+     * <BR> Then the test sends request for TESTED_THREAD and
+     * performs VirtualMachine.HoldEvents command.
+     * Next, the test waits for debuggee to start the 'TESTED_THREAD'
+     * thread and checks that no any events (including requested TESTED_THREAD event)
+     * are sent to test.
+     */
+    public void testHoldEvents001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        debuggeeWrapper.vmMirror.setThreadStart();
+        
+        //send HoldEvents command
+        logWriter.println("send HoldEvents");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.HoldEventsCommand);
+       
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::HoldEvents command");
+
+        logWriter.println("allow to start thread");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        EventReceiver thread = new EventReceiver(); 
+        thread.start();
+        try {
+            thread.join(settings.getTimeout());
+        } catch (InterruptedException e) {
+            
+        }
+
+        if (event == null) {
+            logWriter.println("no events were received");
+        } else {
+            logWriter.printError("unexpected event");
+            fail("unexpected event");
+        }
+
+        logWriter.println("send ReleaseEvents");
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ReleaseEventsCommand);
+        debuggeeWrapper.vmMirror.performCommand(packet);
+       
+        event = debuggeeWrapper.vmMirror.receiveCertainEvent(JDWPConstants.EventKind.THREAD_START);
+        debuggeeWrapper.vmMirror.resume();
+    }
+
+    class EventReceiver extends Thread {
+        public void run() {
+            try {
+                event = debuggeeWrapper.vmMirror.receiveCertainEvent(JDWPConstants.EventKind.THREAD_START);
+            } catch (TestErrorException e) {
+                logWriter.println(e.toString());
+            }
+        }
+    }
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(HoldEventsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/IDSizesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/IDSizesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/IDSizesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/IDSizesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,81 @@
+/*
+ * 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 31.01.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.JDWPTestCase;
+
+
+/**
+ * JDWP Unit test for VirtualMachine.IDSizes command.
+ */
+public class IDSizesTest extends JDWPTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.SimpleHelloWorld";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.IDSizes command.
+     * <BR>At first the test starts HelloWorld debuggee.
+     * <BR> Then the test performs VirtualMachine.IDSizes command 
+     * and checks that all returned sizes are non-zero values.
+     */
+    public void testIDSizes001() {
+
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.IDSizesCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::IDSizes command");
+
+        int fieldIDSize = reply.getNextValueAsInt();
+        int methodIDSize = reply.getNextValueAsInt();
+        int objectIDSize = reply.getNextValueAsInt();
+        int referenceTypeIDSize = reply.getNextValueAsInt();
+        int frameIDSize = reply.getNextValueAsInt();
+        logWriter.println("fieldIDSize = " + fieldIDSize);
+        logWriter.println("methodIDSize = " + methodIDSize);
+        logWriter.println("objectIDSize = " + objectIDSize);
+        logWriter.println("referenceTypeIDSize = " + referenceTypeIDSize);
+        logWriter.println("frameIDSize = " + frameIDSize);
+
+        assertTrue("Invalid fieldIDSize: " + fieldIDSize, fieldIDSize > 0);
+        assertTrue("Invalid methodIDSize: " + methodIDSize, methodIDSize > 0);
+        assertTrue("Invalid objectIDSize: " + objectIDSize, objectIDSize > 0);
+        assertTrue("Invalid referenceTypeIDSize: " + referenceTypeIDSize, referenceTypeIDSize > 0);
+        assertTrue("Invalid frameIDSize: " + frameIDSize, frameIDSize > 0);
+
+        debuggeeWrapper.resume();
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(IDSizesTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineByteCode_Debuggee001
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineByteCode_Debuggee001?view=auto&rev=480141
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineByteCode_Debuggee001
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,66 @@
+/*
+ * 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 30.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class RedefineClassesDebuggee extends SyncDebuggee {
+    
+    static RedefineClassesDebuggee redefineClassesDebuggee;
+    static RedefineClass_Debuggee redefineClass_DebuggeeObject = null;
+
+    public void run() {
+        redefineClassesDebuggee = this;
+        
+        logWriter.println("--> Debuggee: RedefineClassesDebuggee: START");
+        logWriter.println("--> Debuggee: BEFORE redefine: RedefineClass_Debuggee.testMethod() = "
+            + RedefineClass_Debuggee.testMethod());
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        String testMethodResult = RedefineClass_Debuggee.testMethod();
+        logWriter.println("--> Debuggee: After redefine: RedefineClass_Debuggee.testMethod() = "
+                + testMethodResult);
+        synchronizer.sendMessage(testMethodResult);
+        logWriter.println("--> Debuggee: RedefineClassesDebuggee: FINISH");
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(RedefineClassesDebuggee.class);
+    }
+
+}
+
+// Next class will be redefined
+class RedefineClass_Debuggee {
+    
+    static String testMethod() {
+        return "testMethod_Result_Before_Redefine";
+        // return "testMethod_Result_After_Redefine";
+    }
+}   
+

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClassesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,308 @@
+/*
+ * 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.8 $
+ */
+
+/**
+ * Created on 30.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+
+
+import java.io.*;
+
+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.RedefineClasses command.
+ */
+public class RedefineClassesTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    static final int testStatusFailed = -1;
+    static final String thisCommandName = "VirtualMachine::RedefineClasses command";
+    static final String checkedClassSignature
+        = "Lorg/apache/harmony/jpda/tests/jdwp/VirtualMachine/RedefineClass_Debuggee;";
+    static final String byteCodeToRedefineFile = "RedefineByteCode_Debuggee001";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.RedefineClassesDebuggee";
+    }
+
+    File findNewClassByteCode() {
+        File foundFile = null;
+        String nameSeparator = File.separator;
+        String pathSeparator = File.pathSeparator;
+        String byteCodeFileNameSuffix = "org" + nameSeparator + "apache" + nameSeparator
+            + "harmony" + nameSeparator + "jpda" + nameSeparator + "tests" + nameSeparator
+            + "jdwp" + nameSeparator + "VirtualMachine"
+            + nameSeparator + byteCodeToRedefineFile;
+        String byteCodeFileName = null;
+        String classPaths = System.getProperty("java.class.path");
+        int begPos = 0;
+        int classPathsLength = classPaths.length();;
+
+        for (int i = 0; i <= classPathsLength; i++) {
+            if ( i == classPathsLength ) {
+                if ( begPos == i ) {
+                 break;   
+                }
+            } else {
+                if ( ! pathSeparator.equals(classPaths.substring(i,i+1))) {
+                    continue;
+                }
+                if ( begPos == i ) {
+                    begPos++;
+                    continue;
+                }
+            }
+            byteCodeFileName = classPaths.substring(begPos,i);
+            if ( ! nameSeparator.equals(classPaths.substring(i-1,i)) ) {
+                byteCodeFileName = byteCodeFileName + nameSeparator;
+            }
+            byteCodeFileName = byteCodeFileName + byteCodeFileNameSuffix;
+            foundFile = new File(byteCodeFileName);
+            if ( foundFile.exists() ) {
+                break;
+            }
+            foundFile = null;
+            begPos = i+1;
+        }
+       return foundFile;
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.RedefineClasses command.
+     * <BR>At first the test starts RedefineClassesDebuggee which invokes
+     * the 'testMethod()' of RedefineClass_Debuggee class and prints the string
+     * returned by this method before redefining.
+     * <BR> Then the test performs VirtualMachine.RedefineClasses command
+     * for RedefineClass_Debuggee class - the 'testMethod()' is redefined.
+     * Next, the debuggee invokes the 'testMethod()' again and it is expected
+     * that the method returns another resulting string.
+     * The test checks that this resulting string is expected string.
+     */
+    public void testRedefineClasses001() {
+        String thisTestName = "testClassObject001";
+        
+        //check capability, relevant for this test
+        logWriter.println("=> Check capability: canRedefineClasses");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canRedefineClasses;
+        if (!isCapability) {
+            logWriter.println("##WARNING: this VM doesn't possess capability: canRedefineClasses");
+            return;
+        }
+        
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        File newClassByteCodeFile = findNewClassByteCode();
+        if ( newClassByteCodeFile == null ) {
+            logWriter.println
+            ("===> Can NOT find out byte code file for redefine:");
+            logWriter.println
+            ("===> File name = " + byteCodeToRedefineFile);
+            logWriter.println
+            ("===> Test can NOT be run!");
+            logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+            return;
+        }
+
+        logWriter.println
+        ("\n=> Send VirtualMachine::ClassesBySignature command and and get checked class referenceTypeID...");
+        logWriter.println("=> checkedClassSignature = " + checkedClassSignature);
+        CommandPacket classesBySignatureCommand = new CommandPacket(
+            JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+            JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
+        classesBySignatureCommand.setNextValueAsString(checkedClassSignature);
+        
+        ReplyPacket classesBySignatureReply = debuggeeWrapper.vmMirror.performCommand(classesBySignatureCommand);
+        classesBySignatureCommand = null;
+
+        checkReplyPacket(classesBySignatureReply, "VirtualMachine::ClassesBySignature command");
+
+        int returnedClassesNumber = classesBySignatureReply.getNextValueAsInt();
+        logWriter.println("=> ReturnedClassesNumber = " + returnedClassesNumber);  
+        if ( returnedClassesNumber != 1 ) {
+            // Number of returned reference types - is NOt used here
+            printErrorAndFail("Unexpected number of classes is returned: " +
+                    returnedClassesNumber +
+                    ", Expected number = 1"); 
+        }
+
+        classesBySignatureReply.getNextValueAsByte();
+        // refTypeTag of class - is NOt used here
+
+        long refTypeID = classesBySignatureReply.getNextValueAsReferenceTypeID();
+        classesBySignatureReply = null;
+
+        logWriter.println("=> Checked class referenceTypeID = " + refTypeID);
+
+        logWriter.println("\n=> Preparing info for " + thisCommandName);
+        logWriter.println
+        ("=> File name with new class byte code to redefine = " + byteCodeToRedefineFile);
+        FileInputStream newClassByteCodeFileInputStream = null;
+        try {
+            newClassByteCodeFileInputStream = new FileInputStream(newClassByteCodeFile);
+        } catch (Throwable thrown) {
+            logWriter.println
+            ("===> Can NOT create FileInputStream for byte code file:");
+            logWriter.println("===> File name = " + byteCodeToRedefineFile);
+            logWriter.println("===> Exception is thrown: " + thrown);
+            logWriter.println("===> Test can NOT be run!");
+            logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+            return;
+        }
+        int newClassByteCodeSize = 0;
+        try {
+            newClassByteCodeSize = (int)newClassByteCodeFileInputStream.skip(Long.MAX_VALUE);
+        } catch (Throwable thrown) {
+            logWriter.println
+            ("===> Can NOT do FileInputStream.skip() to the end of file:");
+            logWriter.println("===> File name = " + byteCodeToRedefineFile);
+            logWriter.println("===> Exception is thrown: " + thrown);
+            logWriter.println("===> Test can NOT be run!");
+            logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+            return;
+        }
+        logWriter.println("=> newClassByteCodeSize = " + newClassByteCodeSize);
+        try {
+            newClassByteCodeFileInputStream.close();
+        } catch (Throwable thrown) {
+            logWriter.println
+            ("===> WARNING: Can NOT close FileInputStream for byte code file:");
+            logWriter.println("===> File name = " + byteCodeToRedefineFile);
+            logWriter.println("===> Exception is thrown: " + thrown);
+        }
+        newClassByteCodeFileInputStream = null;
+        
+        try {
+            newClassByteCodeFileInputStream = new FileInputStream(newClassByteCodeFile);
+        } catch (Throwable thrown) {
+            logWriter.println
+            ("===> Can NOT re-create FileInputStream for byte code file:");
+            logWriter.println("===> File name = " + byteCodeToRedefineFile);
+            logWriter.println("===> Exception is thrown: " + thrown);
+            logWriter.println("===> Test can NOT be run!");
+            logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+            return;
+        }
+
+        CommandPacket checkedCommand = new CommandPacket(
+            JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+            JDWPCommands.VirtualMachineCommandSet.RedefineClassesCommand);
+        checkedCommand.setNextValueAsInt(1); // number of classes to redefine
+        checkedCommand.setNextValueAsReferenceTypeID(refTypeID);
+        checkedCommand.setNextValueAsInt(newClassByteCodeSize);
+        int writtenBytes = 0;
+        int currentByte = 0;
+        while ( true ) {
+            try {
+                currentByte = newClassByteCodeFileInputStream.read();
+            } catch (Throwable thrown) {
+                logWriter.println
+                ("===> Can NOT read current byte from byte code file:");
+                logWriter.println("===> File name = " + byteCodeToRedefineFile);
+                logWriter.println("===> Byte number = " + writtenBytes);
+                logWriter.println("===> Exception is thrown: " + thrown);
+                logWriter.println("===> Test can NOT be run!");
+                logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+                return;
+            }
+            if ( currentByte == -1 ) { // EOF is reached
+               break;
+            }
+            checkedCommand.setNextValueAsByte((byte)currentByte);
+            writtenBytes++;
+        }
+        logWriter.println("=> Number of written bytes as new class file = " + writtenBytes);
+        if ( newClassByteCodeSize != writtenBytes ) {
+            logWriter.println("===> WARNING: Number of written bytes != newClassByteCodeSize");
+            logWriter.println("===> Test can NOT be run!");
+            logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+            return;
+        }
+        
+        logWriter.println("\n=> Send " + thisCommandName + " and check reply...");
+        
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+        checkedCommand = null;
+        int[] expectedErrors = {
+            JDWPConstants.Error.NOT_IMPLEMENTED,   
+        };
+        short errorCode = checkedReply.getErrorCode();
+        if ( errorCode != JDWPConstants.Error.NONE ) {
+            if ( errorCode != JDWPConstants.Error.UNSUPPORTED_VERSION ) {
+                finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+                printErrorAndFail(
+                    "## WARNING: A class file for redefine has a version number not supported by this VM" + 
+                    "\n## File name with byte code = " + byteCodeToRedefineFile +
+                    "\n## It should be re-created");
+            }
+            boolean expectedErr = false;
+            for (int i=0; i < expectedErrors.length; i++) {
+                if ( errorCode == expectedErrors[i] ) {
+                    expectedErr = true;
+                    break;
+                }
+            }
+            if ( expectedErr ) {
+                logWriter.println("=> " +  thisCommandName 
+                        + " returns expected ERROR = " + errorCode 
+                        + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+                logWriter.println
+                    ("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+                return;
+            } else {
+                finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+                printErrorAndFail(thisCommandName 
+                    + " returns unexpected ERROR = " + errorCode 
+                    + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+            }
+        }
+        logWriter.println("=> " +  thisCommandName + " returns reply without any error"); 
+
+        assertAllDataRead(checkedReply);
+
+        logWriter.println("\n=> Send Debuggee signal to continue and execute redefined testMethod");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        String testMethodResult = synchronizer.receiveMessage();
+        logWriter.println("=> Redefined testMethod result = \"" + testMethodResult + "\"");
+        if ( testMethodResult.equals("testMethod_Result_After_Redefine") ) {
+            logWriter.println("=> OK - it is expected result");
+        } else {
+            printErrorAndFail("it is NOT expected result" +
+                    "\n Expected result = \"testMethod_Result_After_Redefine\"");
+        }
+
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(RedefineClassesTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsDebuggee.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.3 $
+ */
+
+/**
+ * Created on 28.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.ThreadReference.ReleaseEventsTest</code>.
+ * This debuggee starts the tested thread <code>TESTED_THREAD</code>.
+ */
+public class ReleaseEventsDebuggee extends SyncDebuggee {
+
+    public static final String TESTED_THREAD = "TestedThread";
+    
+    static Object waitForStart = new Object();
+    static Object waitForFinish = new Object();
+
+    public void run() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        logWriter.println("wait for SGNL_CONTINUE to start thread");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        DebuggeeThread thrd = new DebuggeeThread(TESTED_THREAD,
+                logWriter, synchronizer); 
+        
+        synchronized(waitForStart){
+            logWriter.println("starting thread");
+            thrd.start();
+            try {
+                waitForStart.wait();
+            } catch (InterruptedException e) {
+                logWriter.println("" + e + " is cought");
+            }
+        }
+
+        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(ReleaseEventsDebuggee.waitForFinish){
+
+                synchronized(ReleaseEventsDebuggee.waitForStart){
+
+                    ReleaseEventsDebuggee.waitForStart.notifyAll();
+
+                    logWriter.println(getName() +  ": started");
+
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        runDebuggee(ReleaseEventsDebuggee.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Vitaly A. Provodin
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 28.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;
+
+
+/**
+ * This tests case exercises the JDWP command <code>VirtualMachine.ReleaseEvents</code>.
+ * After the test sends <code>HoldEvents</code>, the debuggee
+ * <code>org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsDebuggee</code> tries to start
+ * the tested thread <code>TESTED_THREAD</code>.
+ * 
+ * <p>The following statements are checked: 
+ * <ol>
+ *      <li><i>testReleaseEvents001</i>
+ *          It is expected the <code>THREAD_START</code> after sending
+ *          sending <code>ReleaseEvents</code>.
+ * 
+ * </ol>
+ */
+/**
+ * JDWP Unit test for VirtualMachine.ReleaseEvents command.
+ */
+public class ReleaseEventsTest extends JDWPSyncTestCase {
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsDebuggee";
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.ReleaseEvents command.
+     * <BR>At first the test starts ReleaseEventsDebuggee.
+     * <BR> Then the test sends request for TESTED_THREAD and
+     * performs VirtualMachine.HoldEvents command.
+     * <BR>Next, the test waits for debuggee to start the 'TESTED_THREAD'
+     * thread and performs VirtualMachine.ReleaseEvents command.
+     * <BR>After this the test expects that requested TESTED_THREAD event is sent to test.
+     */
+    public void testReleaseEvents001() {
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        debuggeeWrapper.vmMirror.setThreadStart();
+        
+        //send HoldEvents command
+        logWriter.println("send HoldEvents");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.HoldEventsCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::HoldEvents command");
+
+        logWriter.println("allow to start thread");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+        logWriter.println("send ReleaseEvents");
+        packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.ReleaseEventsCommand);
+        
+        reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        checkReplyPacket(reply, "VirtualMachine::ReleaseEvents command");
+
+        CommandPacket event = debuggeeWrapper.vmMirror.receiveCertainEvent(
+                JDWPConstants.EventKind.THREAD_START);
+        if (event != null) {
+            logWriter.println("expected event: "
+                    + JDWPConstants.EventKind.getName(JDWPConstants.EventKind.THREAD_START)
+                    + " was received");
+        } else {
+            logWriter.printError("no events were received");
+            fail("no events were received");
+        }
+        debuggeeWrapper.vmMirror.resume();
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ReleaseEventsTest.class);
+    }
+}

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

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ResumeDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ResumeDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ResumeDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ResumeDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,150 @@
+/*
+ * 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 20.06.2006
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class ResumeDebuggee extends SyncDebuggee {
+    public static final int THREAD_NUMBER_LIMIT = 10; 
+    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 thread groups...");
+
+        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/VirtualMachine/ResumeDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message