You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/11/28 18:49:31 UTC
svn commit: r480141 [21/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...
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/ReplyErrorCodeException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/ReplyErrorCodeException.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/ReplyErrorCodeException.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/ReplyErrorCodeException.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,63 @@
+/*
+ * 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.03.2005
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp.exceptions;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+
+
+/**
+ * This exception is thrown if reply packet with error code is received.
+ */
+public class ReplyErrorCodeException extends TestErrorException {
+
+ /**
+ * Serialization id.
+ */
+ private static final long serialVersionUID = -5114602978946240494L;
+
+ private int errorCode;
+
+ /**
+ * Creates new instance of this exception.
+ *
+ * @param errorCode error code of received reply packet
+ */
+ public ReplyErrorCodeException(int errorCode) {
+ super("Error " + errorCode + ": " + JDWPConstants.Error.getName(errorCode));
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * Returns error code provided for this exception.
+ *
+ * @return error code
+ */
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/ReplyErrorCodeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/TimeoutException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/TimeoutException.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/TimeoutException.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/TimeoutException.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,59 @@
+/*
+ * 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 16.03.2005
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp.exceptions;
+
+import java.io.IOException;
+
+/**
+ * This exception is thrown if reading packet form JDWP connection is timed out.
+ */
+public class TimeoutException extends IOException {
+
+ /**
+ * Serialization id.
+ */
+ private static final long serialVersionUID = -6288034406488650881L;
+
+ private boolean wasConnectionClosed = false;
+
+ /**
+ * Create new exception instance.
+ * @param connectionClosed is true if connection was normally closed
+ * before timeout exceeded
+ */
+ public TimeoutException(boolean connectionClosed) {
+ super(connectionClosed ? "Connection was closed" : "Timeout was exceeded");
+ this.wasConnectionClosed = connectionClosed;
+ }
+
+ /**
+ * Returns true if connection was normally closed before timeout exceeded.
+ * @return true or false
+ */
+ public boolean isConnectionClosed() {
+ return wasConnectionClosed;
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/exceptions/TimeoutException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee.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 Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 09.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * Common debuggee of JDWP unit tests for JDWP ArrayReference command set:
+ * GetValuesTest, LengthTest, SetValuesTest.
+ *
+ */
+public class ArrayReferenceDebuggee extends SyncDebuggee {
+
+ static int[] intArray = new int[10];
+ static String[] strArray = new String[8];
+ static Integer intField = new Integer(-1);
+
+ static Thread[] threadArray = { new Thread() };
+ static ThreadGroup[] threadGroupArray = { new ThreadGroup("name") };
+ static Class[] classArray = { ArrayReferenceDebuggee.class };
+ static ClassLoader[] ClassLoaderArray = { ArrayReferenceDebuggee.class.getClassLoader() };
+ static MyThread[] myThreadArray = { new MyThread() };
+ static Object[][] objectArrayArray = { threadArray };
+
+ static long[] longArray = new long[10];
+ static byte[] byteArray = new byte[10];
+
+ static {
+ for (int i=0; i<intArray.length; i++) {
+ intArray[i] = i;
+ byteArray[i] = (byte)i;
+ longArray[i] = i;
+ }
+
+ for (int i=0; i<strArray.length; i++) {
+ strArray[i] = ""+i;
+ }
+ }
+
+ public void run() {
+ logWriter.println("-- ArrayReferenceDebuggee: STARTED ...");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("-- ArrayReferenceDebuggee: FINISHing ...");
+ }
+
+ /**
+ * Starts ArrayReferenceDebuggee with help of runDebuggee() method
+ * from <A HREF="../../share/Debuggee.html">Debuggee</A> super class.
+ *
+ */
+ public static void main(String [] args) {
+ runDebuggee(ArrayReferenceDebuggee.class);
+ }
+
+}
+
+class MyThread extends Thread {}
+
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/GetValuesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/GetValuesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/GetValuesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/GetValuesTest.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 Anton V. Karnachuk
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 09.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.ArrayRegion;
+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.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP unit test for ArrayReference.GetValues command.
+ */
+
+public class GetValuesTest extends JDWPArrayReferenceTestCase {
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(GetValuesTest.class);
+ }
+
+ /**
+ * This testcase exercises ArrayReference.GetValues command.
+ * <BR>Starts <A HREF="ArrayReferenceDebuggee.html">ArrayReferenceDebuggee</A>.
+ * <BR>Receives fields with ReferenceType.fields command,
+ * receives values with ArrayReference.GetValues then checks them.
+ */
+ public void testGetValues001() throws UnsupportedEncodingException {
+ logWriter.println("==> GetValuesTest.testGetValues001 started...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String debuggeeSig = "Lorg/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee;";
+
+ // obtain classID
+ long classID = getClassIDBySignature(debuggeeSig);
+
+ // obtain fields
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.FieldsCommand);
+ packet.setNextValueAsReferenceTypeID(classID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::Fields command");
+
+ int declared = reply.getNextValueAsInt();
+ for (int i = 0; i < declared; i++) {
+ long fieldID = reply.getNextValueAsFieldID();
+ String name = reply.getNextValueAsString();
+ reply.getNextValueAsString();
+ reply.getNextValueAsInt();
+
+ if (name.equals("threadArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'threadArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.THREAD_TAG, false);
+ }
+ if (name.equals("threadGroupArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'threadGroupArray...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.THREAD_GROUP_TAG, false);
+ }
+ if (name.equals("classArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'classArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.CLASS_OBJECT_TAG, false);
+ }
+ if (name.equals("ClassLoaderArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'ClassLoaderArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.CLASS_LOADER_TAG, false);
+ }
+ if (name.equals("myThreadArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'myThreadArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.THREAD_TAG, false);
+ }
+ if (name.equals("objectArrayArray")) {
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'objectArrayArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 1,
+ 1, JDWPConstants.Tag.ARRAY_TAG, JDWPConstants.Tag.ARRAY_TAG, false);
+ }
+ if (name.equals("intArray")) {
+ // int[] intArray = new int[10]
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'int[] intArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 10,
+ 4, JDWPConstants.Tag.INT_TAG, JDWPConstants.Tag.INT_TAG, true);
+ }
+ if (name.equals("strArray")) {
+ // String[] strArray = new String[8]
+ logWriter.println
+ ("\n==> testGetValues001: check for array field: 'String[] strArray'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.NONE, 8,
+ 4, JDWPConstants.Tag.OBJECT_TAG, JDWPConstants.Tag.STRING_TAG, true);
+ }
+ if (name.equals("intField")) {
+ // Integer intField = new Integer(-1)
+ logWriter.println
+ ("\n==> testGetValues001: check for non-array field: 'Integer intField = new Integer(-1)'...");
+ checkArrayValues(classID, fieldID, JDWPConstants.Error.INVALID_ARRAY, 0,
+ 4, (byte)0, (byte)0, false);
+ }
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ private void checkArrayValues(long classID, long fieldID, int error, int length,
+ int checksNumber, byte expectedArrayTag, byte expectedElementTag, boolean checkValues)
+ throws UnsupportedEncodingException {
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ // set referenceTypeID
+ packet.setNextValueAsReferenceTypeID(classID);
+ // repeat 1 time
+ packet.setNextValueAsInt(1);
+ // set fieldID
+ packet.setNextValueAsFieldID(fieldID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::GetValues command");
+
+ assertEquals("ReferenceType::GetValues command returned invalid int value,", reply.getNextValueAsInt(), 1);
+ Value value = reply.getNextValueAsValue();
+ long arrayID = value.getLongValue();
+ logWriter.println("==> testGetValues001: checked arrayID = " + arrayID);
+
+ logWriter.println("==> testGetValues001: checkArrayRegion: arrayID = " + arrayID
+ + "; Expected error = " + error + "(" + JDWPConstants.Error.getName(error) + ")"
+ + "; firstIndex = 0; length = " + length);
+ checkArrayRegion
+ (arrayID, error, 0, length, expectedArrayTag, expectedElementTag, checkValues);
+ logWriter.println("==> PASSED!");
+
+ if ( checksNumber > 1 ) {
+ logWriter.println("==> testGetValues001: checkArrayRegion: arrayID = " + arrayID
+ + "; Expected error = " + error+ "(" + JDWPConstants.Error.getName(error) + ")"
+ + "; firstIndex = 1; length = " + (length-1));
+ checkArrayRegion
+ (arrayID, error, 1, length-1, expectedArrayTag, expectedElementTag, checkValues);
+ logWriter.println("==> PASSED!");
+
+ logWriter.println("==> testGetValues001: checkArrayRegion: arrayID = " + arrayID
+ + "; Expected error = " + error+ "(" + JDWPConstants.Error.getName(error) + ")"
+ + "; firstIndex = 0; length = " + (length-1));
+ checkArrayRegion
+ (arrayID, error, 0, length-1, expectedArrayTag, expectedElementTag, checkValues);
+ logWriter.println("==> PASSED!");
+
+ logWriter.println("==> testGetValues001: checkArrayRegion: arrayID = " + arrayID
+ + "; Expected error = " + error+ "(" + JDWPConstants.Error.getName(error) + ")"
+ + "; firstIndex = " + (length-1) + " length = 1");
+ checkArrayRegion
+ (arrayID, error, length-1, 1, expectedArrayTag, expectedElementTag, checkValues);
+ logWriter.println("==> PASSED!");
+ }
+ }
+
+ private void checkArrayRegion(long arrayID, int error, int firstIndex, int length,
+ byte expectedArrayTag, byte expectedElementTag, boolean checkValues)
+ throws UnsupportedEncodingException {
+
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.GetValuesCommand);
+ packet.setNextValueAsArrayID(arrayID);
+ packet.setNextValueAsInt(firstIndex);
+ packet.setNextValueAsInt(length);
+
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayReference::GetValues command", error);
+
+ if (reply.getErrorCode() == JDWPConstants.Error.NONE) {
+ // do not check values for non-array fields
+ ArrayRegion region = reply.getNextValueAsArrayRegion();
+ //System.err.println("length="+region.length);
+ byte arrayTag = region.getTag();
+ logWriter.println("==> arrayTag = " + arrayTag
+ + "(" + JDWPConstants.Tag.getName(arrayTag) + ")");
+ logWriter.println("==> arrayLength = "+region.getLength());
+ Value value_0 = region.getValue(0);
+ byte elementTag = value_0.getTag();
+ logWriter.println("==> elementTag = " + elementTag
+ + "(" + JDWPConstants.Tag.getName(elementTag) + ")");
+
+ assertEquals("ArrayReference::GetValues returned invalid array tag,",
+ expectedArrayTag, arrayTag,
+ JDWPConstants.Tag.getName(expectedArrayTag),
+ JDWPConstants.Tag.getName(arrayTag));
+ assertEquals("ArrayReference::GetValues returned invalid array length,",
+ length, region.getLength());
+ assertEquals("ArrayReference::GetValues returned invalid element tag",
+ expectedElementTag, elementTag,
+ JDWPConstants.Tag.getName(expectedElementTag),
+ JDWPConstants.Tag.getName(elementTag));
+
+ if (checkValues) {
+ for (int i = 0; i < region.getLength(); i++) {
+ Value value = region.getValue(i);
+ if (value.getTag() == JDWPConstants.Tag.INT_TAG) {
+ assertEquals("ArrayReference::GetValues returned invalid value on index:<" + i + ">,",
+ value.getIntValue(), i + firstIndex);
+ }
+ else if (value.getTag() == JDWPConstants.Tag.STRING_TAG) {
+ long stringID = value.getLongValue();
+ String s = getStringValue(stringID);
+ assertEquals("ArrayReference::GetValues returned invalid value on index:<" + i + ">,",
+ Integer.parseInt(s), i + firstIndex);
+ }
+ }
+ }
+ }
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/GetValuesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/JDWPArrayReferenceTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/JDWPArrayReferenceTestCase.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/JDWPArrayReferenceTestCase.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/JDWPArrayReferenceTestCase.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 09.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+
+class JDWPArrayReferenceTestCase extends JDWPSyncTestCase {
+
+ /**
+ * Returns full name of debuggee class which is used by
+ * all testcases in this test.
+ * @return full name of debuggee class.
+ */
+ protected String getDebuggeeClassName() {
+ return ArrayReferenceDebuggee.class.getName();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/JDWPArrayReferenceTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/LengthTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/LengthTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/LengthTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/LengthTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 09.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import java.io.UnsupportedEncodingException;
+
+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.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP unit test for ArrayReference.Length command.
+ *
+ */
+
+public class LengthTest extends JDWPArrayReferenceTestCase {
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(LengthTest.class);
+ }
+
+ /**
+ * This testcase exercises ArrayReference.Length command.
+ * <BR>Starts <A HREF="ArrayReferenceDebuggee.html">ArrayReferenceDebuggee</A>.
+ * <BR>Receives fields with ReferenceType.fields command,
+ * checks length with ArrayReference.Length command.
+ */
+ public void testLength001() throws UnsupportedEncodingException {
+ logWriter.println("testLength001 started");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // obtain classID
+ long classID = getClassIDBySignature("Lorg/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee;");
+
+ // obtain fields
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.FieldsCommand);
+ packet.setNextValueAsReferenceTypeID(classID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::Fields command");
+
+ int declared = reply.getNextValueAsInt();
+ for (int i = 0; i < declared; i++) {
+ long fieldID = reply.getNextValueAsFieldID();
+ reply.getNextValueAsString();
+ reply.getNextValueAsString();
+ reply.getNextValueAsInt();
+
+ switch (i) {
+ case 0:
+ // int[] intArray = new int[10]
+ checkArrayLength(classID, fieldID, JDWPConstants.Error.NONE, 10);
+ break;
+ case 1:
+ // String[] strArray = new String[8]
+ checkArrayLength(classID, fieldID, JDWPConstants.Error.NONE, 8);
+ break;
+ case 2:
+ // Integer intField = new Integer(-1)
+ checkArrayLength(classID, fieldID, JDWPConstants.Error.INVALID_ARRAY, 0);
+ break;
+ }
+ }
+
+ logWriter.println("test PASSED!");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ private void checkArrayLength(long classID, long fieldID, int error, int length) {
+ //System.err.println("classID="+classID);
+ //System.err.println("fieldID="+fieldID);
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ packet.setNextValueAsReferenceTypeID(classID);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsFieldID(fieldID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::GetValues command");
+
+ int values = reply.getNextValueAsInt();
+ assertEquals("ReferenceType::GetValues returned invalid number of values,", 1, values);
+
+ Value value = reply.getNextValueAsValue();
+ //System.err.println("value="+value);
+ long arrayID = value.getLongValue();
+ logWriter.println("arrayID = " + arrayID);
+
+ packet = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.LengthCommand);
+ packet.setNextValueAsArrayID(arrayID);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayReference::Length command", error);
+
+ if (reply.getErrorCode() == JDWPConstants.Error.NONE) {
+ // do not check length for non-array fields
+ int returnedLength = reply.getNextValueAsInt();
+ assertEquals("ArrayReference::Length returned invalid length,",
+ length, returnedLength);
+ }
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/LengthTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Debuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,79 @@
+/*
+ * 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 13.07.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * Debuggee for JDWP SetValues002Test unit test which
+ * exercises ArrayReference.SetValues command.
+ */
+public class SetValues002Debuggee extends SyncDebuggee {
+
+ static String passedStatus = "PASSED";
+ static String failedStatus = "FAILED";
+ static String status = passedStatus;
+
+ static SetValues002Debuggee objectArrayField[]; // JDWP_TAG_ARRAY = 91
+
+ public void run() {
+ logWriter.println("--> Debuggee: SetValues002Debuggee: START");
+
+ objectArrayField = new SetValues002Debuggee[1];
+ objectArrayField[0] = new SetValues002Debuggee();
+
+ logWriter.println("\n--> Debuggee: SetValues002Debuggee: Before ObjectReference::SetValues command:");
+ logWriter.println("--> objectArrayField[0] value = " + objectArrayField[0]);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("\n--> Debuggee: SetValues002Debuggee: After ObjectReference::SetValues command:");
+ logWriter.println("--> objectArrayField[0] value = " + objectArrayField[0]);
+ if ( objectArrayField[0] != null ) {
+ logWriter.println("##> Debuggee: FAILURE: Unexpected value");
+ logWriter.println("##> Expected value = " + null);
+ status = failedStatus;
+ } else {
+ logWriter.println("--> Debuggee: OK. Expected value");
+ }
+
+ logWriter.println("--> Debuggee: Send check status for SetValues002Test...\n");
+ synchronizer.sendMessage(status);
+
+ logWriter.println("--> Debuggee: SetValues002Debuggee: FINISH");
+ }
+
+ /**
+ * Starts SetValues002Debuggee with help of runDebuggee() method
+ * from <A HREF="../../share/Debuggee.html">Debuggee</A> super class.
+ *
+ */
+ 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/ArrayReference/SetValues002Debuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,156 @@
+/*
+ * 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.5 $
+ */
+
+/**
+ * Created on 13.07.2005
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+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 ArrayReference.SetValues command with specific values.
+ */
+public class SetValues002Test extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ArrayReference::SetValues command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Debuggee;";
+
+ /**
+ * Returns full name of debuggee class which is used by this test.
+ * @return full name of debuggee class.
+ */
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ArrayReference.SetValues002Debuggee";
+ }
+
+ /**
+ * This testcase exercises ArrayReference.SetValues command for
+ * array of elements of referenceType with value=null.
+ * <BR>The test expects array element should be set by null value.
+ */
+ public void testSetValues002() {
+ String thisTestName = "testSetValues002";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ 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 checkedFieldNames[] = {
+ "objectArrayField",
+ };
+ long checkedFieldIDs[] = checkFields(refTypeID, checkedFieldNames);
+
+ logWriter.println("=> Send ReferenceType::GetValues command and get ArrayID 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();
+ assertEquals("ReferenceType::GetValues returned invalid number of values,",
+ 1, returnedValuesNumber);
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+
+ Value checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checked object= " + checkedObjectFieldTag
+ + "(" + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+
+ assertEquals("ReferenceType::GetValues returned invalid object field tag,",
+ JDWPConstants.Tag.ARRAY_TAG, checkedObjectFieldTag,
+ JDWPConstants.Tag.getName(JDWPConstants.Tag.ARRAY_TAG),
+ JDWPConstants.Tag.getName(checkedObjectFieldTag));
+
+ long checkedObjectID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned checked ArrayID = " + checkedObjectID);
+ logWriter.println("=> CHECK: send " + thisCommandName
+ + " for this ArrayID for element of referenceType with null values...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.SetValuesCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObjectID);
+ checkedCommand.setNextValueAsInt(0); // first index
+ checkedCommand.setNextValueAsInt(1); // elements' number
+ checkedCommand.setNextValueAsObjectID(0); // null value
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, "ArrayReference::SetValues command");
+
+ logWriter.println("=> Wait for Debuggee's status about check for set field...");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ boolean debuggeeStatus = synchronizer.receiveMessage("PASSED");
+ if (!debuggeeStatus) {
+ logWriter.println("## " + thisTestName + ": Debuggee returned status FAILED");
+ //logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FAILED");
+ fail("Debuggee returned status FAILED");
+ } else {
+ logWriter.println("=> " + thisTestName + ": Debuggee returned status PASSED");
+ }
+
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": OK.");
+ }
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SetValues002Test.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValues002Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValuesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValuesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValuesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValuesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 09.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.ArrayRegion;
+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.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP unit test for ArrayReference.SetValues command.
+ *
+ */
+
+public class SetValuesTest extends JDWPArrayReferenceTestCase {
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SetValuesTest.class);
+ }
+
+ /**
+ * This testcase exercises ArrayReference.SetValues command.
+ * <BR>Starts <A HREF="ArrayReferenceDebuggee.html">ArrayReferenceDebuggee</A>.
+ * <BR>Receives fields with ReferenceType.fields command,
+ * sets values with ArrayReference.SetValues then checks changes.
+ */
+ public void testSetValues001() {
+ logWriter.println("testLength001 started");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // obtain classID
+ long classID = getClassIDBySignature("Lorg/apache/harmony/jpda/tests/jdwp/ArrayReference/ArrayReferenceDebuggee;");
+
+ // obtain fields
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.FieldsCommand);
+ packet.setNextValueAsReferenceTypeID(classID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::Fields command");
+
+ int declared = reply.getNextValueAsInt();
+ for (int i = 0; i < declared; i++) {
+ long fieldID = reply.getNextValueAsFieldID();
+ String name = reply.getNextValueAsString();
+ reply.getNextValueAsString();
+ reply.getNextValueAsInt();
+
+ if (name.equals("intArray")) {
+ ArrayRegion valuesRegion = new ArrayRegion(
+ JDWPConstants.Tag.INT_TAG, 10);
+ for (int j = 0; j < valuesRegion.getLength(); j++) {
+ valuesRegion.setValue(j, new Value(-j));
+ }
+ checkArrayValues(valuesRegion, classID, fieldID);
+ } else if (name.equals("longArray")) {
+ ArrayRegion valuesRegion = new ArrayRegion(
+ JDWPConstants.Tag.LONG_TAG, 10);
+ for (int j = 0; j < valuesRegion.getLength(); j++) {
+ valuesRegion.setValue(j, new Value((long)-j));
+ }
+ checkArrayValues(valuesRegion, classID, fieldID);
+ } else if (name.equals("byteArray")) {
+ ArrayRegion valuesRegion = new ArrayRegion(
+ JDWPConstants.Tag.BYTE_TAG, 10);
+ for (int j = 0; j < valuesRegion.getLength(); j++) {
+ valuesRegion.setValue(j, new Value((byte)-j));
+ }
+ checkArrayValues(valuesRegion, classID, fieldID);
+ }
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ private void checkArrayValues(ArrayRegion valuesRegion, long classID,
+ long fieldID) {
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ packet.setNextValueAsReferenceTypeID(classID);
+ packet.setNextValueAsInt(1);
+ packet.setNextValueAsFieldID(fieldID);
+
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::GetValues command");
+
+ assertEquals("GetValuesCommand returned invalid number of values,", 1, reply.getNextValueAsInt());
+ Value value = reply.getNextValueAsValue();
+ //System.err.println("value="+value);
+ long arrayID = value.getLongValue();
+ int length = valuesRegion.getLength();
+
+ checkArrayRegion(valuesRegion, arrayID, 0, length);
+ }
+
+ private void checkArrayRegion(ArrayRegion valuesRegion, long arrayID,
+ int firstIndex, int length) {
+ // set values
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.SetValuesCommand);
+ packet.setNextValueAsArrayID(arrayID);
+ packet.setNextValueAsInt(firstIndex);
+ packet.setNextValueAsInt(length);
+ for (int i = 0; i < length; i++) {
+ packet.setNextValueAsUntaggedValue(valuesRegion.getValue(i));
+ }
+ packet.setNextValueAsInt(length);
+
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayReference::SetValues command");
+
+ // get values
+ packet = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.GetValuesCommand);
+ packet.setNextValueAsArrayID(arrayID);
+ packet.setNextValueAsInt(firstIndex);
+ packet.setNextValueAsInt(length);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayReference::GetValues command");
+
+ // do not check values for non-array fields
+ ArrayRegion region = reply.getNextValueAsArrayRegion();
+ assertEquals("Invalud returned array length,", length, region.getLength());
+ for (int i = 0; i < region.getLength(); i++) {
+ Value value = region.getValue(i);
+ logWriter.println(value.toString());
+ assertEquals("ArrayReference::GetValues returned invalid value on index:<" + i + ">",
+ value, valuesRegion.getValue(i));
+ }
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayReference/SetValuesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,62 @@
+/*
+ * 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, Aleksander V. Budniy
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 31.01.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * Debuggee for JDWP NewInstanceTest unit test which
+ * exercises ArrayType.NewInstance command.
+ */
+public class NewInstanceDebuggee extends SyncDebuggee {
+
+ public void run() {
+ String[] checkString = {"line1"};
+ int[] checkInt = {1};
+ int[][] ia = { { 123 }, { 23, 34 }, { 2, 4, 6, 8 } };
+ checkClass[] clazz = {new checkClass()};
+ checkClass[][] ca = {{new checkClass()}, {new checkClass()}};
+ logWriter.println("-> array of classes "+ clazz[0].name + " is created");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("-> Hello World");
+ logWriter.println("DUMP{" + checkString + checkInt + ia + ca + "}");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * Starts NewInstanceDebuggee with help of runDebuggee() method
+ * from <A HREF="../../share/Debuggee.html">Debuggee</A> super class.
+ *
+ */
+ public static void main(String [] args) {
+ runDebuggee(NewInstanceDebuggee.class);
+ }
+}
+
+class checkClass {
+ public String name = "checkClass";
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,143 @@
+/*
+ * 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 10.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ArrayType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP unit test for ArrayType.NewInstance command.
+ */
+
+public class NewInstanceTest extends JDWPSyncTestCase {
+
+ /**
+ * Returns full name of debuggee class which is used by this test.
+ * @return full name of debuggee class.
+ */
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ArrayType.NewInstanceDebuggee";
+ }
+
+ /**
+ * This testcase exercises ArrayType.NewInstance command.
+ * <BR>Starts <A HREF="../share/debuggee/HelloWorld.html">HelloWorld</A> debuggee.
+ * <BR>Creates new instance of array by ArrayType.NewInstance command,
+ * check it length by ArrayReference.Length command.
+ */
+ public void testNewInstance001() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ String[] testedArrayRefs = {
+ "[Lorg/apache/harmony/jpda/tests/jdwp/ArrayType/checkClass;",
+ "[Ljava/lang/String;",
+ "[I",
+ "[[Lorg/apache/harmony/jpda/tests/jdwp/ArrayType/checkClass;",
+ "[[Ljava/lang/String;",
+ "[[I"
+ };
+ for (int i = 0; i < testedArrayRefs.length; i++) {
+ logWriter.println("Checking reference " + testedArrayRefs[i]);
+
+ // Get referenceTypeID
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
+ packet.setNextValueAsString(testedArrayRefs[i]);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "VirtualMachine::ClassesBySignature command");
+
+ int classes = reply.getNextValueAsInt();
+ if (classes <= 0) {
+ logWriter.println("## WARNING: class " + testedArrayRefs[i]+ " is not loadded ");
+ continue;
+ }
+
+ byte refInitTypeTag = reply.getNextValueAsByte();
+ long typeArrayID = reply.getNextValueAsReferenceTypeID();
+ int status = reply.getNextValueAsInt();
+
+ assertEquals("VirtualMachine::ClassesBySignature returned invalid TypeTag,",
+ JDWPConstants.TypeTag.ARRAY, refInitTypeTag,
+ JDWPConstants.TypeTag.getName(JDWPConstants.TypeTag.ARRAY),
+ JDWPConstants.TypeTag.getName(refInitTypeTag));
+
+ logWriter.println(" VirtualMachine.ClassesBySignature: classes="
+ + classes + " refTypeTag=" + refInitTypeTag + " typeID= "
+ + typeArrayID + " status=" + status);
+
+ // Make NewInstance
+ packet = new CommandPacket(
+ JDWPCommands.ArrayTypeCommandSet.CommandSetID,
+ JDWPCommands.ArrayTypeCommandSet.NewInstanceCommand);
+ packet.setNextValueAsReferenceTypeID(typeArrayID);
+ packet.setNextValueAsInt(10);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayType::NewInstance command");
+
+ TaggedObject newArray = reply.getNextValueAsTaggedObject();
+ assertAllDataRead(reply);
+ assertNotNull("ArrayType::NewInstance returned null newArray", newArray);
+
+ logWriter.println("ArrayType.NewInstance: newArray.tag="
+ + newArray.tag + " newArray.objectID=" + newArray.objectID);
+
+ if (newArray.tag != JDWPConstants.Tag.ARRAY_TAG) {
+ logWriter.println("##FAILURE: typeTag is not ARRAY_TAG");
+ fail("Returned tag " + JDWPConstants.Tag.getName(newArray.tag)
+ + "(" + newArray.tag + ") is not ARRAY_TAG");
+ }
+
+ // Let's check array length
+ packet = new CommandPacket(
+ JDWPCommands.ArrayReferenceCommandSet.CommandSetID,
+ JDWPCommands.ArrayReferenceCommandSet.LengthCommand);
+ packet.setNextValueAsObjectID(newArray.objectID);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ArrayReference::Length command");
+
+ int arrayLength = reply.getNextValueAsInt();
+ logWriter.println("ArrayReference.Length: arrayLength=" + arrayLength);
+ assertEquals("ArrayReference::Length command returned ivalid array length,",
+ 10, arrayLength);
+ assertAllDataRead(reply);
+ }
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(NewInstanceTest.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ArrayType/NewInstanceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassLoaderReference/VisibleClassesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassLoaderReference/VisibleClassesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassLoaderReference/VisibleClassesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassLoaderReference/VisibleClassesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Viacheslav G. Rybalov
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 05.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ClassLoaderReference;
+
+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 ClassLoaderReference.VisibleClasses command.
+ */
+public class VisibleClassesTest extends JDWPSyncTestCase {
+
+ /**
+ * Returns full name of debuggee class which is used by this test.
+ * @return full name of debuggee class.
+ */
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+ }
+
+ /**
+ * This testcase exercises ClassLoaderReference.VisibleClasses command.
+ * <BR>Starts <A HREF="../share/debuggee/HelloWorld.html">HelloWorld</A> debuggee.
+ * <BR>Then the following statements are checked:
+ * <BR>It is expected:
+ * <BR> - number of reference types has non-zero value;
+ * <BR> - refTypeTag takes one of the TypeTag constants: CLASS, INTERFACE, ARRAY;
+ * <BR> - All data were read;
+ */
+ public void testVisibleClasses001() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ClassLoaderReferenceCommandSet.CommandSetID,
+ JDWPCommands.ClassLoaderReferenceCommandSet.VisibleClassesCommand);
+ packet.setNextValueAsClassLoaderID(0);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ClassLoaderReference::VisibleClasses command");
+
+ byte refTypeTag;
+ String refTypeTagName;
+ long typeID;
+ String msgLine;
+
+ int classes = reply.getNextValueAsInt();
+ logWriter.println("Number of reference types = " + classes);
+ assertTrue("Invalid returned number of reference types = " + classes, classes > 0);
+
+ int printBound_1 = classes;
+ int printBound_2 = 0;
+ if (classes > 50) {
+ printBound_1 = 5;
+ printBound_2 = classes - 5;
+ }
+ for (int i = 0; i < classes; i++) {
+ refTypeTag = reply.getNextValueAsByte();
+ refTypeTagName = JDWPConstants.TypeTag.getName(refTypeTag);
+ msgLine = "" + i + ". refTypeTag = " + refTypeTagName + "(" + refTypeTag + ")";
+ typeID = reply.getNextValueAsReferenceTypeID();
+ msgLine = msgLine + "; referenceTypeID = " + typeID;
+ if ( (i < printBound_1) || (i >= printBound_2) ) {
+ logWriter.println(msgLine);
+ if ( i == (printBound_1 - 1) ) {
+ logWriter.println("...\n...\n...");
+ }
+ }
+ assertTrue("Unexpected reference TagType:<" + refTypeTag + "(" + refTypeTagName + ")>",
+ refTypeTag == JDWPConstants.TypeTag.ARRAY
+ || refTypeTag == JDWPConstants.TypeTag.CLASS
+ || refTypeTag == JDWPConstants.TypeTag.INTERFACE);
+ }
+
+ assertAllDataRead(reply);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(VisibleClassesTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassLoaderReference/VisibleClassesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassObjectReference/ReflectedTypeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassObjectReference/ReflectedTypeTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassObjectReference/ReflectedTypeTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassObjectReference/ReflectedTypeTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,192 @@
+/*
+ * 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 05.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ClassObjectReference;
+
+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 ClassObjectReference.ReflectedType command.
+ */
+
+public class ReflectedTypeTest extends JDWPSyncTestCase {
+
+ /**
+ * Returns full name of debuggee class which is used by this test.
+ * @return full name of debuggee class.
+ */
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+ }
+
+ /**
+ * This testcase exercises ClassObjectReference.ReflectedType command.
+ * <BR>Starts <A HREF="../share/debuggee/HelloWorld.html">HelloWorld</A> debuggee.
+ * <BR>Then checks the following four classes:
+ * <BR> - java/lang/Object;
+ * <BR> - java/lang/String;
+ * <BR> - java/lang/Runnable;
+ * <BR> - HelloWorld.
+ * <BR>
+ * <BR>The following statements are checked:
+ * <BR> It is expected:
+ * <BR> - refTypeTag takes one of the TypeTag constants: CLASS, INTERFACE;
+ * <BR> - refTypeTag equals to refTypeTag returned by command
+ * VirtualMachine.ClassesBySignature;
+ * <BR> - typeID equals to typeID returned by the JDWP command
+ * VirtualMachine.ClassesBySignature;
+ * <BR> - All data were read;
+ */
+ public void testReflectedType001() {
+ logWriter.println("==> testReflectedType001 START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String[] testedClasses = {
+ "java/lang/Object",
+ "java/lang/String",
+ "java/lang/Runnable",
+ "org/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld",
+ };
+
+ byte expectedRefTypeTags[] = {
+ JDWPConstants.TypeTag.CLASS,
+ JDWPConstants.TypeTag.CLASS,
+ JDWPConstants.TypeTag.INTERFACE,
+ JDWPConstants.TypeTag.CLASS,
+ };
+
+ for (int i = 0; i < testedClasses.length; i++) {
+ logWriter.println("\n==> Checked class: " + testedClasses[i]);
+
+ // Get referenceTypeID
+ logWriter.println
+ ("==> Send VirtualMachine::ClassesBySignature command for checked class...");
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
+ packet.setNextValueAsString("L" + testedClasses[i] + ";");
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "VirtualMachine::ClassesBySignature command");
+
+ int classes = reply.getNextValueAsInt();
+ logWriter.println("==> Number of returned classes = " + classes);
+ //this class may be loaded only once
+ byte refInitTypeTag = 0;
+ long typeInitID = 0;
+ int status = 0;
+
+ for (int j = 0; j < classes; j++) {
+ refInitTypeTag = reply.getNextValueAsByte();
+ typeInitID = reply.getNextValueAsReferenceTypeID();
+ status = reply.getNextValueAsInt();
+ logWriter.println("==> refTypeId["+j+"] = " + typeInitID);
+ logWriter.println("==> refTypeTag["+j+"] = " + refInitTypeTag + "("
+ + JDWPConstants.TypeTag.getName(refInitTypeTag) + ")");
+ logWriter.println("==> classStatus["+j+"] = " + status + "("
+ + JDWPConstants.ClassStatus.getName(status) + ")");
+
+ String classSignature = debuggeeWrapper.vmMirror.getClassSignature(typeInitID);
+ logWriter.println("==> classSignature["+j+"] = " + classSignature);
+
+ packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.ClassLoaderCommand);
+ packet.setNextValueAsReferenceTypeID(typeInitID);
+ ReplyPacket reply2 = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::ClassLoader command");
+
+ long classLoaderID = reply2.getNextValueAsObjectID();
+ logWriter.println("==> classLoaderID["+j+"] = " + classLoaderID);
+
+ if (classLoaderID != 0) {
+ String classLoaderSignature = getObjectSignature(classLoaderID);
+ logWriter.println("==> classLoaderSignature["+j+"] = " + classLoaderSignature);
+ } else {
+ logWriter.println("==> classLoader is system class loader");
+ }
+ }
+
+ assertEquals("VirtualMachine::ClassesBySignature returned invalid number of classes,",
+ 1, classes);
+ assertEquals("VirtualMachine::ClassesBySignature returned invalid TypeTag,",
+ expectedRefTypeTags[i], refInitTypeTag,
+ JDWPConstants.TypeTag.getName(expectedRefTypeTags[i]),
+ JDWPConstants.TypeTag.getName(refInitTypeTag));
+
+ // Get ClassObject
+ logWriter.println
+ ("==> Send ReferenceType::ClassObject command for checked class...");
+ packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.ClassObjectCommand);
+ packet.setNextValueAsReferenceTypeID(typeInitID);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ReferenceType::ClassObject command");
+
+ long classObject = reply.getNextValueAsClassObjectID();
+ assertAllDataRead(reply);
+ logWriter.println("==> classObjectID=" + classObject);
+
+ // Get ReflectedType
+ logWriter.println
+ ("==> Send ClassObjectReference::ReflectedType command for classObjectID...");
+ packet = new CommandPacket(
+ JDWPCommands.ClassObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ClassObjectReferenceCommandSet.ReflectedTypeCommand);
+ packet.setNextValueAsObjectID(classObject);
+ reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "ClassObjectReference::ReflectedType command");
+
+ byte refTypeTag = reply.getNextValueAsByte();
+ long typeID = reply.getNextValueAsReferenceTypeID();
+ logWriter.println("==> reflectedTypeId = " + typeID);
+ logWriter.println("==> reflectedTypeTag = " + refTypeTag
+ + "(" + JDWPConstants.TypeTag.getName(refTypeTag) + ")");
+
+ assertEquals("ClassObjectReference::ReflectedType returned invalid reflected TypeTag,",
+ expectedRefTypeTags[i], refTypeTag,
+ JDWPConstants.TypeTag.getName(expectedRefTypeTags[i]),
+ JDWPConstants.TypeTag.getName(refTypeTag));
+ assertEquals("ClassObjectReference::ReflectedType returned invalid reflected typeID,",
+ typeInitID, typeID);
+ assertAllDataRead(reply);
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * Starts this test by junit.textui.TestRunner.run() method.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ReflectedTypeTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassObjectReference/ReflectedTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassType/ClassTypeDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassType/ClassTypeDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassType/ClassTypeDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassType/ClassTypeDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ClassType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * Common debuggee of some JDWP unit tests for JDWP ClassType command set.
+ */
+public class ClassTypeDebuggee extends SyncDebuggee {
+
+ static boolean f_def_bool = false;
+ private static boolean f_pri_bool = false;
+ protected static boolean f_pro_bool = false;
+ public static boolean f_pub_bool = false;
+
+ static final boolean ff_def_bool = false;
+ private static final boolean ff_pri_bool = false;
+ protected static final boolean ff_pro_bool = false;
+ public static final boolean ff_pub_bool = false;
+
+ public static byte f_pub_byte;
+ public static char f_pub_char;
+ public static float f_pub_float = 254.5f;
+ public static double f_pub_double;
+ public static int f_pub_int;
+ public static long f_pub_long;
+ public static short f_pub_short;
+ public static boolean f_pub_boolean;
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("ClassTypeDebuggee started");
+ logWriter.println("DUMP{" + f_pri_bool + ff_pri_bool + "}");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("ClassTypeDebuggee done");
+ }
+
+ /**
+ * Starts ClassTypeDebuggee with help of runDebuggee() method
+ * from <A HREF="../../share/Debuggee.html">Debuggee</A> super class.
+ *
+ */
+ public static void main(String [] args) {
+ runDebuggee(ClassTypeDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ClassType/ClassTypeDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native