Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 28.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ObjectReference.GetValues command .
+ */
+public class GetValuesTest extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ObjectReference::GetValues command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ObjectReference.GetValuesDebuggee";
+ }
+
+ /**
+ * This test exercises ObjectReference.GetValues command.
+ * <BR>The test starts GetValuesDebuggee class, gets objectID
+ * as value of static field of this class which (field) represents checked object.
+ * Then for this objectID test executes ObjectReference::GetValues command for special
+ * set of fieldIDs and checks that command returns expected jdwpTags for all checked
+ * fields and expected values for primitive fields.
+ */
+ public void testGetValues001() {
+ String thisTestName = "testGetValues001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+
+ String checkedFieldNames[] = {
+ "getValuesDebuggeeObject",
+
+ "intField",
+ "longField",
+ "objectField",
+ "stringArrayField",
+ "objectArrayField",
+ "threadField",
+ "threadGroupField",
+ "classField",
+ "classLoaderField",
+ "stringField",
+ };
+ long checkedFieldIDs[] = checkFields(refTypeID, checkedFieldNames);
+ int checkedFieldsNumber = checkedFieldNames.length;
+
+ logWriter.println
+ ("=> Send ReferenceType::GetValues command and and get ObjectID to check...");
+
+ CommandPacket getValuesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
+ getValuesCommand.setNextValueAsInt(1);
+ getValuesCommand.setNextValueAsFieldID(checkedFieldIDs[0]);
+
+ ReplyPacket getValuesReply = debuggeeWrapper.vmMirror.performCommand(getValuesCommand);
+ getValuesCommand = null;
+ checkReplyPacket(getValuesReply, "ReferenceType::GetValues command");
+
+ int returnedValuesNumber = getValuesReply.getNextValueAsInt();
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+ assertEquals("Invalid number of values,", 1, returnedValuesNumber);
+
+ Value checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checked object= " + checkedObjectFieldTag
+ + "(" + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+ assertEquals("Invalid value tag for checked object,", JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(checkedObjectFieldTag));
+
+ long checkedObjectID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned checked ObjectID = " + checkedObjectID);
+ logWriter.println("=> CHECK: send " + thisCommandName + " for this ObjectID and check reply...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.GetValuesCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObjectID);
+ checkedCommand.setNextValueAsInt(checkedFieldsNumber-1);
+ int fieldIndex = 1; // !!!
+ for (; fieldIndex < checkedFieldsNumber; fieldIndex++) {
+ checkedCommand.setNextValueAsFieldID(checkedFieldIDs[fieldIndex]);
+ }
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ returnedValuesNumber = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+ assertEquals("Invalid number of values,", checkedFieldsNumber - 1, returnedValuesNumber);
+
+ byte expectedFieldTags[] = {
+ 0, // dummy
+ JDWPConstants.Tag.INT_TAG,
+ JDWPConstants.Tag.LONG_TAG,
+ JDWPConstants.Tag.OBJECT_TAG,
+ JDWPConstants.Tag.ARRAY_TAG,
+ JDWPConstants.Tag.ARRAY_TAG,
+ JDWPConstants.Tag.THREAD_TAG,
+ JDWPConstants.Tag.THREAD_GROUP_TAG,
+ JDWPConstants.Tag.CLASS_OBJECT_TAG,
+ JDWPConstants.Tag.CLASS_LOADER_TAG,
+ JDWPConstants.Tag.STRING_TAG,
+ };
+
+ logWriter.println("=> CHECK for returned values...");
+ fieldIndex = 1; // !!!
+ for (; fieldIndex < checkedFieldsNumber; fieldIndex++) {
+ Value fieldValue = checkedReply.getNextValueAsValue();
+ byte fieldTag = fieldValue.getTag();
+ logWriter.println
+ ("\n=> Check for returned value for field: " + checkedFieldNames[fieldIndex] + " ...");
+ logWriter.println("=> Returned value tag = " + fieldTag
+ + "(" + JDWPConstants.Tag.getName(fieldTag) + ")");
+
+ assertEquals("Invalid value tag is returned,", expectedFieldTags[fieldIndex], fieldTag
+ , JDWPConstants.Tag.getName(expectedFieldTags[fieldIndex])
+ , JDWPConstants.Tag.getName(fieldTag));
+
+ switch ( fieldTag ) {
+ case JDWPConstants.Tag.INT_TAG:
+ int intValue = fieldValue.getIntValue();
+ logWriter.println("=> Returned value = " + intValue);
+ // here expected value = 9999 (staticIntField)
+ int expectedIntValue = 9999;
+ assertEquals("Invalid int value,", expectedIntValue, intValue);
+ break;
+ case JDWPConstants.Tag.LONG_TAG:
+ long longValue = fieldValue.getLongValue();
+ logWriter.println("=> Returned value = " + longValue);
+ // here expected value = 999999 (staticLongField)
+ long expectedLongValue = 999999;
+ assertEquals("Invalid long value,", expectedLongValue, longValue);
+ break;
+ case JDWPConstants.Tag.STRING_TAG:
+ case JDWPConstants.Tag.OBJECT_TAG:
+ case JDWPConstants.Tag.ARRAY_TAG:
+ case JDWPConstants.Tag.THREAD_TAG:
+ case JDWPConstants.Tag.THREAD_GROUP_TAG:
+ case JDWPConstants.Tag.CLASS_OBJECT_TAG:
+ case JDWPConstants.Tag.CLASS_LOADER_TAG:
+ long objectIDValue = fieldValue.getLongValue();
+ logWriter.println("=> ObjectId value = " + objectIDValue);
+ break;
+ }
+ }
+
+ assertAllDataRead(checkedReply);
+
+ logWriter.println
+ ("=> CHECK PASSED: All expected field values are got and have expected attributes");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(GetValuesTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/GetValuesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,395 @@
+/*
+ * 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 Viacheslav G. Rybalov
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 15.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * Unit test for NewInstance command.
+ * Runs <code>InvokeMethodDebuggee</code>, creates NewInstance of testClass2:
+ * Case 1: with options
+ * Case 2: without options
+ *
+ * Then invokes it's testMethod3:
+ * Case 1: with and without exceptions
+ * Case 2: nonvirtual child method without exception and nonvirtual super method without exception
+ */
+
+/**
+ * JDWP unit test for ObjectReference.InvokeMethod command.
+ */
+public class InvokeMethodTest extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.InvokeMethodDebuggee";
+ }
+
+ protected int setEventRequest() {
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.EventRequestCommandSet.CommandSetID,
+ JDWPCommands.EventRequestCommandSet.SetCommand);
+ packet.setNextValueAsByte(JDWPConstants.EventKind.METHOD_ENTRY);
+ packet.setNextValueAsByte(JDWPConstants.SuspendPolicy.ALL);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsByte((byte) 5);
+ packet.setNextValueAsString("*.InvokeMethodDebuggee");
+
+ logWriter.println("\nSend EventRequest::Set command...");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "EventRequest::Set command");
+
+ int requestID = reply.getNextValueAsInt();
+ logWriter.println(" EventRequest.Set: requestID=" + requestID);
+ assertTrue(reply.isAllDataRead());
+ return requestID;
+ }
+
+ protected long waitEvent(int requestID) {
+ long targetThreadID = 0;
+
+ CommandPacket event = debuggeeWrapper.vmMirror
+ .receiveCertainEvent(JDWPConstants.EventKind.METHOD_ENTRY);
+ byte suspendPolicy = event.getNextValueAsByte();
+ int events = event.getNextValueAsInt();
+ logWriter.println(" EVENT_THREAD event: suspendPolicy=" + suspendPolicy
+ + " events=" + events);
+ for (int i = 0; i < events; i++) {
+ byte eventKind = event.getNextValueAsByte();
+ int newRequestID = event.getNextValueAsInt();
+ long threadID = event.getNextValueAsThreadID();
+ //Location location =
+ event.getNextValueAsLocation();
+ logWriter.println(" EVENT_THREAD event " + i + ": eventKind="
+ + eventKind + " requestID=" + newRequestID + " threadID="
+ + threadID);
+ if (newRequestID == requestID) {
+ targetThreadID = threadID;
+ }
+ }
+ assertAllDataRead(event);
+ assertTrue("targetThreadID must be != 0", targetThreadID != 0);
+ return targetThreadID;
+ }
+
+ protected void clearEvent(int requestID) {
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.EventRequestCommandSet.CommandSetID,
+ JDWPCommands.EventRequestCommandSet.ClearCommand);
+ packet.setNextValueAsByte(JDWPConstants.EventKind.METHOD_ENTRY);
+ packet.setNextValueAsInt(requestID);
+ logWriter.println("\nSend EventRequest::Clear command...");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "EventRequest::Clear command");
+ assertAllDataRead(reply);
+ }
+
+ protected TaggedObject makeNewInstance(long typeID, long threadID,
+ long constructorID, int testNumber) {
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ClassTypeCommandSet.CommandSetID,
+ JDWPCommands.ClassTypeCommandSet.NewInstanceCommand);
+ packet.setNextValueAsClassID(typeID);
+ packet.setNextValueAsThreadID(threadID);
+ packet.setNextValueAsMethodID(constructorID);
+ if ( testNumber == 1 ) {
+ packet.setNextValueAsInt(1); // number of parameters
+ packet.setNextValueAsValue(new Value(false));
+ }
+ if ( testNumber == 2 ) {
+ packet.setNextValueAsInt(0); // number of parameters
+ }
+ packet.setNextValueAsInt(0);
+ logWriter.println("\nSend ClassType.NewInstance");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ClassType::NewInstance command");
+
+ TaggedObject newObject = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ClassType.NewInstance: newObject.tag="
+ + newObject.tag + " newObject.objectID=" + newObject.objectID);
+
+ TaggedObject exception = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ClassType.NewInstance: exception.tag="
+ + exception.tag + " exception.objectID=" + exception.objectID);
+
+ assertTrue("newObject must be != null", newObject != null);
+ assertTrue("newObject.objectID must be != 0", newObject.objectID != 0);
+ assertEquals("Invalid object tag,", JDWPConstants.Tag.OBJECT_TAG, newObject.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(newObject.tag));
+
+ assertTrue("exception must be != null", exception != null);
+ assertTrue("exception.objectID must be == 0", exception.objectID == 0);
+ assertEquals("Invalid exception.tag,", JDWPConstants.Tag.OBJECT_TAG, exception.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(exception.tag));
+
+ assertAllDataRead(reply);
+ return newObject;
+ }
+
+ /**
+ * This testcase exercises ObjectReference.InvokeMethod command.
+ * <BR>At first the test starts debuggee.
+ * <BR>Then does the following checks:
+ * <BR> - send ObjectReference.InvokeMethod command for method,
+ * which should not throw any Exception, and checks,
+ * that returned value is int value and returned
+ * exception object is null;
+ * <BR> - send ObjectReference.InvokeMethod command for method,
+ * which should throw some Exception, and checks, that
+ * returned exception object is not null and has expected attributes;
+ */
+ public void testInvokeMethod001() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Get referenceTypeID
+ String classSig = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/testClass2;";
+ long typeID = getReferenceTypeID(classSig);
+
+ // Get methodIDs
+ long targetMethodID = getMethodID(typeID, "testMethod3");
+ long targetConstructorID = getMethodID(typeID, "<init>");
+
+ // Set EventRequest
+ int requestID = setEventRequest();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // Wait event
+ long targetThreadID = waitEvent(requestID);
+
+ // Let's clear event request
+ clearEvent(requestID);
+
+ // Make NewInstance
+ TaggedObject newObject = makeNewInstance(typeID, targetThreadID,
+ targetConstructorID, 1 /* test number */);
+
+ // Make InvokeMethod without exception
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.InvokeMethodCommand);
+ packet.setNextValueAsObjectID(newObject.objectID);
+ packet.setNextValueAsThreadID(targetThreadID);
+ packet.setNextValueAsClassID(typeID);
+ packet.setNextValueAsMethodID(targetMethodID);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsValue(new Value(false));
+ packet.setNextValueAsInt(0);
+ logWriter.println("\nSend ObjectReference.InvokeMethod without exception...");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ObjectReference::InvokeMethod command");
+
+ Value returnValue = reply.getNextValueAsValue();
+ logWriter.println(" ObjectReference.InvokeMethod: returnValue.getIntValue()="
+ + returnValue.getIntValue());
+
+ TaggedObject exception = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ObjectReference.InvokeMethod: exception.tag="
+ + exception.tag + " exception.objectID=" + exception.objectID);
+
+ assertTrue("returnValue must be != null", returnValue != null);
+ assertEquals("Invalid returned value,", 345, returnValue.getIntValue());
+
+ assertTrue("exception must be != null", exception != null);
+ assertTrue("exception.objectID must be == 0", exception.objectID == 0);
+ assertEquals("invalid exception.tag,", JDWPConstants.Tag.OBJECT_TAG, exception.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(exception.tag));
+
+ assertAllDataRead(reply);
+
+ // Make InvokeMethod with exception
+ packet = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.InvokeMethodCommand);
+ packet.setNextValueAsObjectID(newObject.objectID);
+ packet.setNextValueAsThreadID(targetThreadID);
+ packet.setNextValueAsClassID(typeID);
+ packet.setNextValueAsMethodID(targetMethodID);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsValue(new Value(true));
+ packet.setNextValueAsInt(0);
+ logWriter.println("\nSend ObjectReference.InvokeMethod with exception...");
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ObjectReference::InvokeMethod command");
+
+ returnValue = reply.getNextValueAsValue();
+ logWriter.println(" ObjectReference.InvokeMethod: returnValue.getIntValue()="
+ + returnValue.getIntValue());
+
+ exception = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ObjectReference.InvokeMethod: exception.tag="
+ + exception.tag + " exception.objectID=" + exception.objectID);
+
+ assertTrue("exception must be != null", exception != null);
+ assertTrue("exception.objectID must be != 0", exception.objectID != 0);
+ assertEquals("Invalid exception.tag", JDWPConstants.Tag.OBJECT_TAG, exception.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(exception.tag));
+
+ assertAllDataRead(reply);
+
+ // Let's resume application
+ resumeDebuggee();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * This testcase exercises ObjectReference.InvokeMethod command with INVOKE_NONVIRTUAL InvokeOption.
+ * <BR>At first the test starts debuggee.
+ * <BR>Then does the following checks:
+ * <BR> - send ObjectReference.InvokeMethod command for nonvirtual
+ * child method (from subclass), which should not throw any Exception, and checks,
+ * that returned value is expected int value and returned
+ * exception object is null;
+ * <BR> - send ObjectReference.InvokeMethod command for nonvirtual
+ * super method (from super class), which should not throw any Exception, and checks,
+ * that returned value is expected int value and returned
+ * exception object is null;
+ */
+ public void testInvokeMethod002() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Get referenceTypeID of super class
+ String classSig = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/testClass2;";
+ long typeIDSuper = getReferenceTypeID(classSig);
+
+ // Get referenceTypeID of child class
+ classSig = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/testClass3;";
+ long typeIDChild = getReferenceTypeID(classSig);
+
+ // Get methodID
+ long targetMethodIDSuper = getMethodID(typeIDSuper, "testMethod3");
+ long targetMethodIDChild = getMethodID(typeIDChild, "testMethod3");
+ long targetConstructorID = getMethodID(typeIDChild, "<init>");
+
+ // Set EventRequest
+ int requestID = setEventRequest();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // Wait event
+ long targetThreadID = waitEvent(requestID);
+
+ // Let's clear event request
+ clearEvent(requestID);
+
+ // Make NewInstance
+ TaggedObject newObject = makeNewInstance(typeIDChild, targetThreadID,
+ targetConstructorID, 2 /* test number */);
+
+ // Make InvokeMethod: nonvirtual child method without exception
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.InvokeMethodCommand);
+ packet.setNextValueAsObjectID(newObject.objectID);
+ packet.setNextValueAsThreadID(targetThreadID);
+ packet.setNextValueAsClassID(typeIDChild);
+ packet.setNextValueAsMethodID(targetMethodIDChild);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsValue(new Value(false));
+ packet.setNextValueAsInt(JDWPConstants.InvokeOptions.INVOKE_NONVIRTUAL);
+ logWriter.println
+ ("\nSend ObjectReference.InvokeMethod:: nonvirtual child method without exception...");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ObjectReference::InvokeMethod command");
+
+ Value returnValue = reply.getNextValueAsValue();
+ logWriter.println(" ObjectReference.InvokeMethod: returnValue.getIntValue()="
+ + returnValue.getIntValue());
+
+ TaggedObject exception = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ObjectReference.InvokeMethod: exception.tag="
+ + exception.tag + " exception.objectID=" + exception.objectID);
+
+ assertTrue("returnValue must be != null", returnValue != null);
+ assertEquals("Invalid value,", 456, returnValue.getIntValue());
+
+ assertTrue("exception must be != null", exception != null);
+ assertTrue("exception.objectID must be == 0", exception.objectID == 0);
+ assertEquals("Invalid exception.tag", JDWPConstants.Tag.OBJECT_TAG, exception.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(exception.tag));
+
+ assertAllDataRead(reply);
+
+ // Make InvokeMethod: nonvirtual super method without exception
+ packet = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.InvokeMethodCommand);
+ packet.setNextValueAsObjectID(newObject.objectID);
+ packet.setNextValueAsThreadID(targetThreadID);
+ packet.setNextValueAsClassID(typeIDSuper);
+ packet.setNextValueAsMethodID(targetMethodIDSuper);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsValue(new Value(false));
+ packet.setNextValueAsInt(JDWPConstants.InvokeOptions.INVOKE_NONVIRTUAL);
+ logWriter.println
+ ("\nSend ObjectReference.InvokeMethod: nonvirtual super method without exception...");
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ObjectReference::InvokeMethod command");
+
+ returnValue = reply.getNextValueAsValue();
+ logWriter.println(" ObjectReference.InvokeMethod: returnValue.getIntValue()="
+ + returnValue.getIntValue());
+
+ exception = reply.getNextValueAsTaggedObject();
+ logWriter.println(" ObjectReference.InvokeMethod: exception.tag="
+ + exception.tag + " exception.objectID=" + exception.objectID);
+
+ assertTrue("returnValue must be != null", returnValue != null);
+ assertEquals("Invalid value,", 345, returnValue.getIntValue());
+
+ assertTrue("exception must be != null", exception != null);
+ assertTrue("exception.objectID must be == 0" ,exception.objectID == 0);
+ assertEquals("Invalid exception.tag", JDWPConstants.Tag.OBJECT_TAG, exception.tag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(exception.tag));
+
+ assertAllDataRead(reply);
+
+ // Let's resume application
+ resumeDebuggee();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(InvokeMethodTest.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,134 @@
+/*
+ * 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 04.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class IsCollectedDebuggee extends SyncDebuggee {
+
+ static IsCollectedObject001_01 checkedObject_01;
+ static boolean checkedObject_01_Finalized = false;
+ static IsCollectedObject001_02 checkedObject_02;
+ static boolean checkedObject_02_Finalized = false;
+ static IsCollectedObject001_03 checkedObject_03;
+ static boolean checkedObject_03_Finalized = false;
+
+ public void run() {
+ logWriter.println("--> Debuggee: IsCollectedDebuggee: START");
+
+ checkedObject_01 = new IsCollectedObject001_01();
+ checkedObject_02 = new IsCollectedObject001_02();
+ checkedObject_03 = new IsCollectedObject001_03();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ String messageFromTest = synchronizer.receiveMessage();
+ if ( messageFromTest.equals("TO_FINISH")) {
+ logWriter.println("--> Debuggee: IsCollectedDebuggee: FINISH");
+ return;
+ }
+
+ checkedObject_01 = null;
+ checkedObject_02 = null;
+ checkedObject_03 = null;
+ long[][] longArray;
+ int i = 0;
+ try {
+ longArray = new long[1000000][];
+ int arraysNumberLimit = 7; // max - longArray.length
+ logWriter.println
+ ("--> Debuggee: memory depletion - creating 'long[1000000]' arrays (" + arraysNumberLimit + ")...");
+ for (; i < arraysNumberLimit; i++) {
+ longArray[i] = new long[1000000];
+ }
+ } catch ( OutOfMemoryError outOfMem ) {
+ logWriter.println("--> Debuggee: OutOfMemoryError!!!");
+ // logWriter.println("--> Debuggee: i = " + i);
+ }
+ longArray = null;
+ System.gc();
+ logWriter.println("--> Debuggee: AFTER System.gc():");
+ logWriter.println("--> Debuggee: checkedObject_01 = " +
+ checkedObject_01);
+ logWriter.println("--> Debuggee: checkedObject_01_UNLOADed = " +
+ checkedObject_01_Finalized);
+ logWriter.println("--> Debuggee: checkedObject_02 = " +
+ checkedObject_02);
+ logWriter.println("--> Debuggee: checkedObject_02_UNLOADed = " +
+ checkedObject_02_Finalized);
+ logWriter.println("--> Debuggee: checkedObject_03 = " +
+ checkedObject_03);
+ logWriter.println("--> Debuggee: checkedObject_03_UNLOADed = " +
+ checkedObject_03_Finalized);
+
+ String messageForTest = null;
+ if ( checkedObject_01_Finalized ) {
+ if ( checkedObject_02_Finalized ) {
+ messageForTest = "checkedObject_01 is UNLOADed; checkedObject_02 is UNLOADed;";
+ } else {
+ messageForTest = "checkedObject_01 is UNLOADed; checkedObject_02 is NOT UNLOADed;";
+ }
+ } else {
+ if ( checkedObject_02_Finalized ) {
+ messageForTest = "checkedObject_01 is NOT UNLOADed; checkedObject_02 is UNLOADed;";
+ } else {
+ messageForTest = "checkedObject_01 is NOT UNLOADed; checkedObject_02 is NOT UNLOADed;";
+ }
+ }
+ logWriter.println("--> Debuggee: Send to test message: \"" + messageForTest + "\"");
+ synchronizer.sendMessage(messageForTest);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("--> Debuggee: IsCollectedDebuggee: FINISH");
+
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(IsCollectedDebuggee.class);
+ }
+
+}
+
+class IsCollectedObject001_01 {
+ protected void finalize() throws Throwable {
+ IsCollectedDebuggee.checkedObject_01_Finalized = true;
+ super.finalize();
+ }
+}
+
+class IsCollectedObject001_02 {
+ protected void finalize() throws Throwable {
+ IsCollectedDebuggee.checkedObject_02_Finalized = true;
+ super.finalize();
+ }
+}
+
+class IsCollectedObject001_03 {
+ protected void finalize() throws Throwable {
+ IsCollectedDebuggee.checkedObject_03_Finalized = true;
+ super.finalize();
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 05.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ObjectReference.IsCollected command.
+ */
+public class IsCollectedTest extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ObjectReference.IsCollected command";
+
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ObjectReference.IsCollectedDebuggee";
+ }
+
+ /**
+ * This test exercises ObjectReference.IsCollected command.
+ * <BR>The test starts IsCollectedDebuggee class, gets two
+ * objectIDs as value of static fields of this class which (fields)
+ * represent two checked objects. Then for the first objectID test executes
+ * ObjectReference.DisableCollection command. After that Debuggee tries to
+ * unload checked objects. Then the test executes
+ * ObjectReference.IsCollected commands for both checked objects and checks
+ * replies.
+ */
+ public void testIsCollected001() {
+ String thisTestName = "testIsCollected001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ finalSyncMessage = "TO_FINISH";
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = "
+ + refTypeID);
+
+ String checkedFieldNames[] = { "checkedObject_01", "checkedObject_02", };
+ long checkedFieldIDs[] = checkFields(refTypeID, checkedFieldNames);
+ long checkedField_01ID = checkedFieldIDs[0];
+ long checkedField_02ID = checkedFieldIDs[1];
+
+ logWriter
+ .println("=> Send ReferenceType::GetValues command for received fieldIDs and get ObjectIDs to check...");
+
+ CommandPacket getValuesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
+ getValuesCommand.setNextValueAsInt(2);
+ getValuesCommand.setNextValueAsFieldID(checkedField_01ID);
+ getValuesCommand.setNextValueAsFieldID(checkedField_02ID);
+
+ ReplyPacket getValuesReply = debuggeeWrapper.vmMirror
+ .performCommand(getValuesCommand);
+ getValuesCommand = null;
+ checkReplyPacket(getValuesReply, "ReferenceType::GetValues command");
+
+ int returnedValuesNumber = getValuesReply.getNextValueAsInt();
+ logWriter
+ .println("=> Returned values number = " + returnedValuesNumber);
+ assertEquals("Invalid number of values,", 2, returnedValuesNumber);
+
+ Value checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checkedObject_01 = "
+ + checkedObjectFieldTag + "("
+ + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+ assertEquals("Invalid value tag for checkedObject_01",
+ JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag,
+ JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG),
+ JDWPConstants.Tag.getName(checkedObjectFieldTag));
+
+ long checkedObject_01ID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned ObjectID for checkedObject_01 = "
+ + checkedObject_01ID);
+
+ checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checkedObject_02 = "
+ + checkedObjectFieldTag + "("
+ + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+ assertEquals("Invalid value tag for checkedObject_02",
+ JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag,
+ JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG),
+ JDWPConstants.Tag.getName(checkedObjectFieldTag));
+
+ long checkedObject_02ID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned ObjectID for checkedObject_02 = "
+ + checkedObject_02ID);
+
+ logWriter
+ .println("\n=> Send ObjectReference::DisableCollection command for checkedObject_01...");
+
+ CommandPacket disableCollectionCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.DisableCollectionCommand);
+ disableCollectionCommand.setNextValueAsObjectID(checkedObject_01ID);
+
+ ReplyPacket disableCollectionReply = debuggeeWrapper.vmMirror
+ .performCommand(disableCollectionCommand);
+ disableCollectionCommand = null;
+ checkReplyPacket(disableCollectionReply,
+ "ObjectReference::DisableCollection command");
+
+ logWriter
+ .println("=> Send to Debuggee signal to continue and try to unload checked objects...");
+ finalSyncMessage = null;
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ String messageFromDebuggee = synchronizer.receiveMessage();
+ logWriter.println("\n=> Received message from Debuggee = \""
+ + messageFromDebuggee + "\"");
+
+ logWriter.println("\n=> Send " + thisCommandName
+ + " for checkedObject_01 and check reply...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.IsCollectedCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObject_01ID);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror
+ .performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ boolean checkedObject_01_IsCollected = checkedReply
+ .getNextValueAsBoolean();
+ logWriter.println("=> IsCollected for checkedObject_01 = "
+ + checkedObject_01_IsCollected);
+
+ if (messageFromDebuggee.indexOf("checkedObject_01 is UNLOADed;") != -1) {
+ if (!checkedObject_01_IsCollected) {
+ logWriter
+ .println("## FAILURE: Unexpected result for checkedObject_01 of "
+ + thisCommandName + ":");
+ logWriter
+ .println("## checkedObject_01 is UNLOADed so IsCollected must be 'true'");
+ failMessage = failMessage +
+ "Unexpected result for checkedObject_01 of "
+ + thisCommandName + "\n";
+ }
+ } else {
+ if (checkedObject_01_IsCollected) {
+ logWriter
+ .println("## FAILURE: Unexpected result for checkedObject_01 of "
+ + thisCommandName + ":");
+ logWriter
+ .println("## checkedObject_01 is NOT UNLOADed so IsCollected must be 'false'");
+ failMessage = failMessage +
+ "Unexpected result for checkedObject_01 of "
+ + thisCommandName + "\n";
+ }
+ }
+
+ logWriter.println("=> PASSED for checkedObject_01");
+
+ logWriter.println("\n=> Send " + thisCommandName
+ + " for checkedObject_02 and check reply...");
+
+ checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.IsCollectedCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObject_02ID);
+
+ checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ boolean checkedObject_02_IsCollected = checkedReply
+ .getNextValueAsBoolean();
+ logWriter.println("=> IsCollected for checkedObject_02 = "
+ + checkedObject_02_IsCollected);
+
+ if (messageFromDebuggee.indexOf("checkedObject_02 is UNLOADed;") != -1) {
+ if (!checkedObject_02_IsCollected) {
+ logWriter
+ .println("## FAILURE: Unexpected result for checkedObject_02 of "
+ + thisCommandName + ":");
+ logWriter
+ .println("## checkedObject_02 is UNLOADed so IsCollected must be 'true'");
+ failMessage = failMessage +
+ "Unexpected result for checkedObject_02 of "
+ + thisCommandName + "\n";
+ }
+ } else {
+ if (checkedObject_02_IsCollected) {
+ logWriter
+ .println("## FAILURE: Unexpected result for checkedObject_02 of "
+ + thisCommandName + ":");
+ logWriter
+ .println("## checkedObject_02 is NOT UNLOADed so IsCollected must be 'false'");
+ failMessage = failMessage +
+ "Unexpected result for checkedObject_02 of "
+ + thisCommandName + "\n";
+ }
+ }
+
+ logWriter.println("=> PASSED for checkedObject_02");
+ logWriter.println("=> Send to Debuggee signal to funish ...");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": FINISH");
+
+ if (failMessage.length() > 0) {
+ fail(failMessage);
+ }
+
+ assertAllDataRead(checkedReply);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(IsCollectedTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/IsCollectedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,57 @@
+/*
+ * 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 03.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class MonitorInfoDebuggee extends SyncDebuggee {
+
+ static Object lockObject;
+
+ public void run() {
+ logWriter.println("--> Debuggee: MonitorInfoDebuggee: START");
+ lockObject = new Object();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String messageFromTest = synchronizer.receiveMessage();
+ if ( messageFromTest.equals("TO_FINISH") ) {
+ logWriter.println("--> Debuggee: MonitorInfoDebuggee: FINISH");
+ return;
+ }
+ synchronized (lockObject) {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+ logWriter.println("--> Debuggee: MonitorInfoDebuggee: FINISH");
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(MonitorInfoDebuggee.class);
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,278 @@
+/*
+ * 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.9 $
+ */
+
+/**
+ * Created on 03.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ObjectReference.MonitorInfo command.
+ */
+public class MonitorInfoTest extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ObjectReference.MonitorInfo command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ObjectReference.MonitorInfoDebuggee";
+ }
+
+ /**
+ * This test exercises ObjectReference.MonitorInfo command.
+ * <BR>The test starts MonitorInfoDebuggee class, gets objectID
+ * as value of static field of this class which (field) represents checked object.
+ * Then for this objectID test executes ObjectReference.MonitorInfo command for
+ * checked object and checks that command returns the expected monitor info:
+ * <BR>monitorOwnerThreadID = 0, monitorEntryCount = 0, monitorWaiters = 0
+ * <BR>Then test waits for Debuggee to continue and to enter in synchronized block
+ * and again executes ObjectReference.MonitorInfo for checked object.
+ * Then test checks that expected results are received:
+ * <BR>monitorOwnerThreadID = 'not null', monitorEntryCount = 1, monitorWaiters = 0
+ */
+ public void testMonitorInfo001() {
+ String thisTestName = "testMonitorInfo001";
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canGetMonitorInfo");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetMonitorInfo;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canGetMonitorInfo");
+ return;
+ }
+
+
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ finalSyncMessage = "TO_FINISH";
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+
+ long checkedFieldID = checkField(refTypeID, "lockObject");
+
+ logWriter.println
+ ("=> Send ReferenceType::GetValues command for received fieldID and get ObjectID to check...");
+
+ CommandPacket getValuesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
+ getValuesCommand.setNextValueAsInt(1);
+ getValuesCommand.setNextValueAsFieldID(checkedFieldID);
+
+ ReplyPacket getValuesReply = debuggeeWrapper.vmMirror.performCommand(getValuesCommand);
+ getValuesCommand = null;
+ checkReplyPacket(getValuesReply, "ReferenceType::GetValues command");
+
+ int returnedValuesNumber = getValuesReply.getNextValueAsInt();
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+ assertEquals("Invalid number of values returned by ReferenceType::GetValues command,", 1, returnedValuesNumber);
+
+ Value checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checked object= " + checkedObjectFieldTag
+ + "(" + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+ assertEquals("Invalid value tag for checked object,", JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag
+ , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
+ , JDWPConstants.Tag.getName(checkedObjectFieldTag));
+
+ long checkedObjectID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned checked ObjectID = " + checkedObjectID);
+
+ logWriter.println("=> Send VirtualMachine::Suspend command...");
+
+ CommandPacket suspendCommand = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.SuspendCommand);
+
+ ReplyPacket suspendReply = debuggeeWrapper.vmMirror.performCommand(suspendCommand);
+ suspendCommand = null;
+ checkReplyPacket(suspendReply, "VirtualMachine::Suspend command");
+
+ logWriter.println
+ ("\n=> CHECK 1: send " + thisCommandName + " for checked ObjectID and check reply...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.MonitorInfoCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObjectID);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+
+ short errorCode = checkedReply.getErrorCode();
+ if ( errorCode == JDWPConstants.Error.NOT_IMPLEMENTED ) {
+ // it is possible case
+ logWriter.println("=> " + thisCommandName + " returns ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ logWriter.println("=> It is possible case - CHECK 1 PASSED");
+ logWriter.println("=> Send to Debuggee signal to funish ...");
+ synchronizer.sendMessage("TO_FINISH");
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ } else {
+ checkReplyPacket(checkedReply, thisCommandName);
+ }
+
+ long monitorOwnerThreadID = checkedReply.getNextValueAsThreadID();
+ logWriter.println("=> Returned monitorOwnerThreadID = " + monitorOwnerThreadID);
+ if ( monitorOwnerThreadID != 0) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorOwnerThreadID:" +
+ monitorOwnerThreadID);
+ logWriter.println("## Expected monitorOwnerThreadID = 0");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorOwnerThreadID: " +
+ monitorOwnerThreadID +
+ ", Expected: 0\n";
+ }
+
+ int monitorEntryCount = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned monitorEntryCount = " + monitorEntryCount);
+ if ( monitorEntryCount != 0) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorEntryCount:");
+ logWriter.println("## Expected monitorEntryCount = 0");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorEntryCount:" +
+ monitorEntryCount +
+ ", expected: 0\n";
+ }
+
+ int monitorWaiters = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned monitorWaiters = " + monitorWaiters);
+ if ( monitorWaiters != 0) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorWaiters:");
+ logWriter.println("## Expected monitorWaiters = 0");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorWaiters:" +
+ monitorWaiters +
+ ", expected: 0\n";
+ }
+
+ assertAllDataRead(checkedReply);
+ logWriter.println("=> CHECK 1: PASSED - expected monitor info is received");
+ checkedReply = null;
+
+ logWriter.println("\n=> Send VirtualMachine::Resume command ...");
+
+ resumeDebuggee();
+
+ logWriter.println("=> Send to Debuggee signal to continue and to enter in synchronized block ...");
+ finalSyncMessage = null;
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("=> Send VirtualMachine::Suspend command...");
+
+ suspendCommand = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.SuspendCommand);
+
+ suspendReply = debuggeeWrapper.vmMirror.performCommand(suspendCommand);
+ suspendCommand = null;
+ checkReplyPacket(suspendReply, "VirtualMachine::Suspend command");
+
+ logWriter.println
+ ("\n=> CHECK 2: send " + thisCommandName + " for checked ObjectID when it is locked...");
+
+ checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.MonitorInfoCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObjectID);
+
+ checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ monitorOwnerThreadID = checkedReply.getNextValueAsThreadID();
+ logWriter.println("=> Returned monitorOwnerThreadID = " + monitorOwnerThreadID);
+ if ( monitorOwnerThreadID == 0) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorOwnerThreadID:");
+ logWriter.println("## Expected monitorOwnerThreadID = 'not null'");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorOwnerThreadID: 0" +
+ ", Expected monitorOwnerThreadID: 'not null'\n";
+ }
+
+ monitorEntryCount = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned monitorEntryCount = " + monitorEntryCount);
+ if ( monitorEntryCount != 1) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorEntryCount:" +
+ monitorEntryCount);
+ logWriter.println("## Expected monitorEntryCount = 1");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorEntryCount: " +
+ monitorEntryCount +
+ ", expected: 1\n";
+ }
+
+ monitorWaiters = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned monitorWaiters = " + monitorWaiters);
+ if ( monitorWaiters != 0) {
+ logWriter.println
+ ("## FAILURE: " + thisCommandName + " returns unexpected monitorWaiters:" +
+ monitorWaiters);
+ logWriter.println("## Expected monitorWaiters = 0");
+ failMessage = failMessage +
+ thisCommandName + " returns unexpected monitorWaiters: " +
+ monitorWaiters +
+ ", expected: 0\n";
+ }
+
+ logWriter.println("=> CHECK 2: PASSED - expected monitor info is received");
+ logWriter.println("\n=> Send VirtualMachine::Resume command ...");
+
+ resumeDebuggee();
+
+ logWriter.println("=> Send to Debuggee signal to funish ...");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+ assertAllDataRead(checkedReply);
+
+ if (failMessage.length() > 0) {
+ fail(failMessage);
+ }
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(MonitorInfoTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/MonitorInfoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,56 @@
+/*
+ * 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 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class ReferenceTypeDebuggee extends SyncDebuggee {
+
+ static Class_ReferenceType001 class_ReferenceType001Object;
+ static ReferenceTypeDebuggee[] referenceTypeDebuggeeArray;
+ static String[] stringArrayField;
+ static String stringField = "stringField";
+
+ public void run() {
+ logWriter.println("--> Debuggee: ReferenceTypeDebuggee: START");
+ class_ReferenceType001Object = new Class_ReferenceType001();
+ referenceTypeDebuggeeArray = new ReferenceTypeDebuggee[1];
+ referenceTypeDebuggeeArray[0] = new ReferenceTypeDebuggee();
+ stringArrayField = new String[1];
+ stringArrayField[0] = "stringArrayField";
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("--> Debuggee: ReferenceTypeDebuggee: FINISH");
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(ReferenceTypeDebuggee.class);
+ }
+
+}
+
+class Class_ReferenceType001 {}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeTest.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 Anatoly F. Bondarenko
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 25.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ObjectReference.ReferenceType command.
+ */
+public class ReferenceTypeTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ObjectReference.ReferenceType command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ObjectReference.ReferenceTypeDebuggee";
+ }
+
+ /**
+ * This test exercises ObjectReference.ReferenceType command.
+ * <BR>The test starts ReferenceTypeDebuggee class, gets objectIDs
+ * as values of some static fields of this class and then for each objectID
+ * executes ObjectReference.ReferenceType command and checks
+ * that command returns expected refTypeTags and returned Reference Types have
+ * expected signatures.
+ */
+ public void testReferenceType001() {
+ String thisTestName = "testReferenceType001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ int testStatus = testStatusPassed;
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ CommandPacket classesBySignatureCommand = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
+ classesBySignatureCommand.setNextValueAsString(debuggeeSignature);
+
+ ReplyPacket classesBySignatureReply = debuggeeWrapper.vmMirror.performCommand(classesBySignatureCommand);
+ classesBySignatureCommand = null;
+
+ checkReplyPacket(classesBySignatureReply, "VirtualMachine::ClassesBySignature command");
+
+ classesBySignatureReply.getNextValueAsInt();
+ // Number of returned reference types - is NOt used here
+
+ classesBySignatureReply.getNextValueAsByte();
+ // refTypeTag of class - is NOt used here
+
+ long refTypeID = classesBySignatureReply.getNextValueAsReferenceTypeID();
+ classesBySignatureReply = null;
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+
+ String neededFieldNames[] = {
+ "class_ReferenceType001Object",
+ "referenceTypeDebuggeeArray",
+ "stringArrayField",
+ "stringField",
+ };
+
+ long neededFieldIDs[] = checkFields(refTypeID, neededFieldNames);
+ int neededFieldsNumber = neededFieldNames.length;
+
+ logWriter.println
+ ("=> Send ReferenceType::GetValues command and and get ObjectIDs to check...");
+ CommandPacket getValuesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
+ getValuesCommand.setNextValueAsInt(neededFieldsNumber);
+ for (int k=0; k < neededFieldsNumber; k++) {
+ getValuesCommand.setNextValueAsFieldID(neededFieldIDs[k]);
+ }
+
+ ReplyPacket getValuesReply = debuggeeWrapper.vmMirror.performCommand(getValuesCommand);
+ getValuesCommand = null;
+ checkReplyPacket(getValuesReply, "ReferenceType::GetValues command");
+
+ int returnedValuesNumber = getValuesReply.getNextValueAsInt();
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+ if ( returnedValuesNumber != neededFieldsNumber ) {
+ logWriter.println
+ ("\n## FAILURE: ReferenceType::GetValues command returned unexpected number of values:");
+ logWriter.println("## Expected number = " + neededFieldsNumber);
+ logWriter.println("## Returned number = " + returnedValuesNumber);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ assertTrue(false);
+ }
+ logWriter.println("=> Check for returned objectIDs...");
+ byte expectedFieldTags[] = {
+ JDWPConstants.Tag.OBJECT_TAG,
+ JDWPConstants.Tag.ARRAY_TAG,
+ JDWPConstants.Tag.ARRAY_TAG,
+ JDWPConstants.Tag.STRING_TAG,
+ };
+ String expectedSignatures[] = {
+ "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/Class_ReferenceType001;",
+ "[Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeDebuggee;",
+ "[Ljava/lang/String;",
+ "Ljava/lang/String;",
+ };
+ byte expectedRefTypeTags[] = {
+ JDWPConstants.TypeTag.CLASS,
+ JDWPConstants.TypeTag.ARRAY,
+ JDWPConstants.TypeTag.ARRAY,
+ JDWPConstants.TypeTag.CLASS,
+ };
+ ReplyPacket checkedReply = null;
+ for (int k=0; k < neededFieldsNumber; k++) {
+ Value fieldValue = getValuesReply.getNextValueAsValue();
+ byte fieldTag = fieldValue.getTag();
+ logWriter.println("\n=> Returned value for field: " + neededFieldNames[k] + ":");
+ logWriter.println("=> Value tag = " + fieldTag + "(" + JDWPConstants.Tag.getName(fieldTag) + ")");
+ if ( fieldTag != expectedFieldTags[k] ) {
+ logWriter.println
+ ("\n## FAILURE: ReferenceType::GetValues command returned unexpected value tag ");
+ logWriter.println
+ ("## Expected tag = " + expectedFieldTags[k]);
+ assertTrue(false);
+ }
+ long objectIdValue = fieldValue.getLongValue();
+ logWriter.println("=> objectId = " + objectIdValue);
+ logWriter.println("=> CHECK: send " + thisCommandName + " for this objectID and check reply...");
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.ReferenceTypeCommand);
+ checkedCommand.setNextValueAsObjectID(objectIdValue);
+
+ checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ byte refTypeTag = checkedReply.getNextValueAsByte();
+ long objectRefTypeID = checkedReply.getNextValueAsReferenceTypeID();
+ logWriter.println("=> Returned refTypeTag = " + refTypeTag
+ + "(" + JDWPConstants.TypeTag.getName(refTypeTag) + ")");
+ if ( refTypeTag != expectedRefTypeTags[k] ) {
+ logWriter.println
+ ("\n## FAILURE: " + thisCommandName + " returned unexpected refTypeTag:");
+ logWriter.println("## Expected refTypeTag = " + expectedRefTypeTags[k]
+ + "(" + JDWPConstants.TypeTag.getName(expectedRefTypeTags[k]) + ")");
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ thisCommandName + " returned unexpected refTypeTag: " +
+ refTypeTag + "(" + JDWPConstants.TypeTag.getName(refTypeTag) + ")" +
+ ", Expected: " + expectedRefTypeTags[k] +
+ "(" + JDWPConstants.TypeTag.getName(expectedRefTypeTags[k]) + ")\n";
+ }
+ logWriter.println("=> ReferenceTypeID for this objectID = " + objectRefTypeID);
+ logWriter.println("=> Get signature for returned ReferenceTypeID...");
+ CommandPacket signatureCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ signatureCommand.setNextValueAsReferenceTypeID(objectRefTypeID);
+
+ ReplyPacket signatureReply = debuggeeWrapper.vmMirror.performCommand(signatureCommand);
+ signatureCommand = null;
+ checkReplyPacket(signatureReply, "ReferenceType::Signature command");
+
+ String returnedSignature = signatureReply.getNextValueAsString();
+ logWriter.println("=> Returned Signature = " + returnedSignature);
+
+ if ( ! expectedSignatures[k].equals(returnedSignature) ) {
+ logWriter.println("\n## FAILURE: Unexpected signature is returned:");
+ logWriter.println("## Expected signature = " + expectedSignatures[k]);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected signature is returned: " + returnedSignature +
+ ", Expected: " + expectedSignatures[k] + "\n";
+ }
+ }
+
+ if ( testStatus == testStatusPassed ) {
+ logWriter.println
+ ("\n=> CHECK PASSED: All expected reference types are got and have expected attributes");
+ }
+
+ assertAllDataRead(checkedReply);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ if (failMessage.length() > 0) {
+ fail(failMessage);
+ }
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ReferenceTypeTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferenceTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/SetValues002Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/SetValues002Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/SetValues002Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/SetValues002Debuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,60 @@
+/*
+ * 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 17.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class SetValues002Debuggee extends SyncDebuggee {
+
+ static SetValues002Debuggee setValues002DebuggeeObject;
+
+ SetValues002Debuggee objectField;
+
+ public void run() {
+ logWriter.println("--> Debuggee: SetValues002Debuggee: START");
+ setValues002DebuggeeObject = new SetValues002Debuggee();
+
+ logWriter.println("\n--> Debuggee: SetValues002Debuggee: Before ObjectReference::SetValues command:");
+ logWriter.println("--> objectField value = " + setValues002DebuggeeObject.objectField);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("\n--> Debuggee: SetValues002Debuggee: After ObjectReference::SetValues command:");
+ logWriter.println("--> objectField value = " + setValues002DebuggeeObject.objectField);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: SetValues002Debuggee: FINISH");
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(SetValues002Debuggee.class);
+ }
+
+}
+
+
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ObjectReference/SetValues002Debuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
|