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 [30/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...
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,213 @@
+/*
+ * 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.4 $
+ */
+
+/**
+ * Created on 18.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.Methods command.
+ */
+public class MethodsTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.Methods command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.MethodsDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.Methods command.
+ * <BR>The test starts MethodsDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.Methods command and checks that returned
+ * list of methods corresponds to expected list of methods with expected attributes.
+ */
+ public void testMethods001() {
+ String thisTestName = "testMethods001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ int testStatus = testStatusPassed;
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+ logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+ CommandPacket methodsCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.MethodsCommand);
+ methodsCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket methodsReply = debuggeeWrapper.vmMirror.performCommand(methodsCommand);
+ methodsCommand = null;
+ checkReplyPacket(methodsReply, thisCommandName);
+
+ int returnedMethodsNumber = methodsReply.getNextValueAsInt();
+ logWriter.println("=> Returned methods number = " + returnedMethodsNumber);
+
+ String methodNames[] = {
+ "staticTestMethod",
+ "objectTestMethod",
+ "run",
+ "main",
+ "<init>"
+ };
+
+ String methodSignatures[] = {
+ "(J)I",
+ "(Ljava/lang/Object;)Ljava/lang/Object;",
+ "()V",
+ "([Ljava/lang/String;)V",
+ "()V"
+ };
+
+ int methodModifiers[] = {
+ 0x8,
+ 0x0,
+ 0x1,
+ 0x9,
+ 0x1
+ };
+
+ boolean methodFound[] = {
+ false,
+ false,
+ false,
+ false,
+ false
+ };
+ int expectedMetodsNumber = methodNames.length;
+ int methodSyntheticFlag = 0xf0000000;
+ String failMessage = "";
+
+ logWriter.println("=> CHECK for all expected methods...");
+ for (int i = 0; i < returnedMethodsNumber; i++) {
+ long returnedMethodID = methodsReply.getNextValueAsMethodID();
+ String returnedMethodName = methodsReply.getNextValueAsString();
+ String returnedMethodSignature = methodsReply.getNextValueAsString();
+ int returnedMethodModifiers = methodsReply.getNextValueAsInt();
+ logWriter.println("\n=> Method ID = " + returnedMethodID);
+ logWriter.println("=> Method name = " + returnedMethodName);
+ logWriter.println("=> Method signature = " + returnedMethodSignature);
+ logWriter.println("=> Method modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ if ( (returnedMethodModifiers & methodSyntheticFlag) == methodSyntheticFlag ) {
+ continue; // do not check synthetic methods
+ }
+ int k = 0;
+ for (; k < expectedMetodsNumber; k++) {
+ if ( ! methodNames[k].equals(returnedMethodName)) {
+ continue;
+ }
+ if ( methodFound[k] ) {
+ logWriter.println("\n## FAILURE: The method is found out repeatedly in the list");
+ logWriter.println("## Method name = " + returnedMethodName);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "The method '" + returnedMethodName +
+ "' is found repeatedly in the list;\n";
+ break;
+ }
+ methodFound[k] = true;
+ if ( ! methodSignatures[k].equals(returnedMethodSignature) ) {
+ logWriter.println("\n## FAILURE: Unexpected method signature is returned:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println("## Expected signature = " + methodSignatures[k]);
+ logWriter.println("## Returned signature = " + returnedMethodSignature);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected signature is returned for method: " +
+ returnedMethodName +
+ ", Expected: " + methodSignatures[k] +
+ ", Returned: " + returnedMethodSignature + ";\n";
+ }
+ if ( methodModifiers[k] != returnedMethodModifiers ) {
+ logWriter.println("\n## FAILURE: Unexpected method modifiers are returned:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println
+ ("## Expected modifiers = 0x" + Integer.toHexString(methodModifiers[k]));
+ logWriter.println
+ ("## Returned modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected modifiers are returned for method: " +
+ returnedMethodName +
+ ", Expected: 0x" + Integer.toHexString(methodModifiers[k]) +
+ ", Returned: 0x" + Integer.toHexString(returnedMethodModifiers) + ";\n";
+ }
+ break;
+ }
+ if ( k == expectedMetodsNumber ) {
+ // returned method is not found out in the list of expected methods
+ logWriter.println("\n## FAILURE: It is found out unexpected returned method:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println("## Method signature = " + returnedMethodSignature);
+ logWriter.println
+ ("## Method modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected returned method is found:" +
+ ", name = " + returnedMethodName +
+ ", signature = " + returnedMethodSignature +
+ ", modifiers = 0x" + Integer.toHexString(returnedMethodModifiers) + ";\n";
+ }
+ }
+ for (int k=0; k < expectedMetodsNumber; k++) {
+ if ( ! methodFound[k] ) {
+ logWriter.println
+ ("\n## FAILURE: Expected method is NOT found out in the list of retuned methods:");
+ logWriter.println("## Method name = " + methodNames[k]);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Expected method is NOT found in the list of retuned methods:" +
+ " name = " + methodNames[k];
+ }
+ }
+ if ( testStatus == testStatusPassed ) {
+ logWriter.println
+ ("=> CHECK PASSED: All expected methods are found out and have expected attributes");
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ if (testStatus == testStatusFailed) {
+ fail(failMessage);
+ }
+ assertAllDataRead(methodsReply);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(MethodsTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,51 @@
+/*
+ * 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 18.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class MethodsWithGenericDebuggee extends SyncDebuggee {
+
+ static boolean staticTestMethod(double doubleParam) {
+ return true;
+ }
+
+ Object objectTestMethod(java.util.Collection stringCollection) {
+ return null;
+ }
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: MethodsWithGenericDebuggee...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(MethodsWithGenericDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,243 @@
+/*
+ * 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.4 $
+ */
+
+/**
+ * Created on 18.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.MethodsWithGeneric command.
+ */
+public class MethodsWithGenericTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.MethodsWithGeneric command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.MethodsWithGenericDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.ClassObject command.
+ * <BR>The test starts MethodsWithGenericDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.MethodsWithGeneric command and checks that returned
+ * list of methods corresponds to expected list of methods with expected attributes.
+ */
+ public void testMethodsWithGeneric001() {
+ String thisTestName = "testMethodsWithGeneric001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ int testStatus = testStatusPassed;
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+ logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+ CommandPacket methodsWithGenericCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.MethodsWithGenericCommand);
+ methodsWithGenericCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket methodsWithGenericReply = debuggeeWrapper.vmMirror.performCommand(methodsWithGenericCommand);
+ methodsWithGenericCommand = null;
+ checkReplyPacket(methodsWithGenericReply, thisCommandName);
+
+ int returnedMethodsNumber = methodsWithGenericReply.getNextValueAsInt();
+ logWriter.println("=> Returned methods number = " + returnedMethodsNumber);
+
+ String methodNames[] = {
+ "staticTestMethod",
+ "objectTestMethod",
+ "run",
+ "main",
+ "<init>"
+ };
+
+ String methodSignatures[] = {
+ "(D)Z",
+ "(Ljava/util/Collection;)Ljava/lang/Object;",
+ "()V",
+ "([Ljava/lang/String;)V",
+ "()V"
+ };
+
+ String methodGenericSignatures[] = {
+ "",
+ "",
+ "",
+ "",
+ ""
+ };
+
+ int methodModifiers[] = {
+ 0x8, // ACC_STATIC flag
+ 0x0,
+ 0x1, // ACC_PUBLIC flag
+ 0x9, // ACC_STATIC | ACC_PUBLIC flags
+ 0x1 // ACC_PUBLIC flag
+ };
+
+ boolean methodFound[] = {
+ false,
+ false,
+ false,
+ false,
+ false
+ };
+ int expectedMetodsNumber = methodNames.length;
+ int methodSyntheticFlag = 0xf0000000;
+
+ logWriter.println("=> CHECK for all expected methods...");
+ for (int i = 0; i < returnedMethodsNumber; i++) {
+ long returnedMethodID = methodsWithGenericReply.getNextValueAsMethodID();
+ String returnedMethodName = methodsWithGenericReply.getNextValueAsString();
+ String returnedMethodSignature = methodsWithGenericReply.getNextValueAsString();
+ String returnedGenericSignature = methodsWithGenericReply.getNextValueAsString();
+ int returnedMethodModifiers = methodsWithGenericReply.getNextValueAsInt();
+ logWriter.println("\n=> Method ID = " + returnedMethodID);
+ logWriter.println("=> Method name = " + returnedMethodName);
+ logWriter.println("=> Method signature = \"" + returnedMethodSignature + "\"");
+ logWriter.println("=> Method generic signature = \"" + returnedGenericSignature + "\"");
+ logWriter.println("=> Method modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ if ( (returnedMethodModifiers & methodSyntheticFlag) == methodSyntheticFlag ) {
+ continue; // do not check synthetic methods
+ }
+ int k = 0;
+ for (; k < expectedMetodsNumber; k++) {
+ if ( ! methodNames[k].equals(returnedMethodName)) {
+ continue;
+ }
+ if ( methodFound[k] ) {
+ logWriter.println("\n## FAILURE: The method is found out repeatedly in the list");
+ logWriter.println("## Method name = " + returnedMethodName);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "The method is found repeatedly in the list: " +
+ returnedMethodName + ";\n";
+ break;
+ }
+ methodFound[k] = true;
+ if ( ! methodSignatures[k].equals(returnedMethodSignature) ) {
+ logWriter.println("\n## FAILURE: Unexpected method signature is returned:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println("## Expected signature = " + methodSignatures[k]);
+ logWriter.println("## Returned signature = " + returnedMethodSignature);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected method signature is returned:" +
+ ", Method = " + returnedMethodName +
+ ", Expected = " + methodSignatures[k] +
+ ", Returned = " + returnedMethodSignature + ";\n";
+ }
+ if ( ! methodGenericSignatures[k].equals(returnedGenericSignature) ) {
+ logWriter.println("\n## FAILURE: Unexpected method generic signature is returned:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println
+ ("## Expected generic signature = " + methodGenericSignatures[k]);
+ logWriter.println
+ ("## Returned generic signature = " + returnedGenericSignature);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected method generic signature is returned:" +
+ ", Method = " + returnedMethodName +
+ ", Expected = " + methodGenericSignatures[k] +
+ ", Returned = " + returnedGenericSignature + ";\n";
+ }
+ if ( methodModifiers[k] != returnedMethodModifiers ) {
+ logWriter.println("\n## FAILURE: Unexpected method modifiers are returned:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println
+ ("## Expected modifiers = 0x" + Integer.toHexString(methodModifiers[k]));
+ logWriter.println
+ ("## Returned modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected method modifiers are returned:" +
+ ", Method name = " + returnedMethodName +
+ ", Expected modifiers = 0x" + Integer.toHexString(methodModifiers[k]) +
+ ", Returned modifiers = 0x" + Integer.toHexString(returnedMethodModifiers) + ";\n";
+ }
+ break;
+ }
+ if ( k == expectedMetodsNumber ) {
+ // returned method is not found out in the list of expected methos
+ logWriter.println("\n## FAILURE: It is found out unexpected returned method:");
+ logWriter.println("## Method name = " + returnedMethodName);
+ logWriter.println("## Method signature = " + returnedMethodSignature);
+ logWriter.println("## Method generic signature = " + returnedGenericSignature);
+ logWriter.println
+ ("## Method modifiers = 0x" + Integer.toHexString(returnedMethodModifiers));
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Unexpected method has been found: " +
+ ", name = " + returnedMethodName +
+ ", signature = " + returnedMethodSignature +
+ ", generic signature = " + returnedGenericSignature +
+ ", modifiers = 0x" + Integer.toHexString(returnedMethodModifiers) + ";\n";
+ }
+ }
+
+ for (int k=0; k < expectedMetodsNumber; k++) {
+ if ( ! methodFound[k] ) {
+ logWriter.println
+ ("\n## FAILURE: Expected method is NOT found out in the list of retuned methods:");
+ logWriter.println("## Method name = " + methodNames[k]);
+ testStatus = testStatusFailed;
+ failMessage = failMessage +
+ "Expected method is NOT found in the list of retuned methods: " +
+ " name = " + methodNames[k];
+ }
+ }
+
+ if (testStatus == testStatusPassed) {
+ logWriter.println
+ ("=> CHECK PASSED: All expected methods are found out and have expected attributes");
+ }
+
+ assertAllDataRead(methodsWithGenericReply);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+ if (testStatus == testStatusFailed) {
+ fail(failMessage);
+ }
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(MethodsWithGenericTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/MethodsWithGenericTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ModifiersTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ModifiersTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ModifiersTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ModifiersTest.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 Anatoly F. Bondarenko
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 17.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.Modifiers command.
+ */
+public class ModifiersTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.Modifiers command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.Modifiers command.
+ * <BR>The test starts HelloWorld debuggee, requests referenceTypeId
+ * for it by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.Modifiers command and checks that returned
+ * Modifiers contain expected flags: ACC_PUBLIC, ACC_SUPER;
+ * but do NOT contain flags: ACC_FINAL, ACC_INTERFACE, ACC_ABSTRACT
+ */
+ public void testModifiers001() {
+ String thisTestName = "testModifiers001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+ logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply...");
+
+ CommandPacket modifiersCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.ModifiersCommand);
+ modifiersCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket modifiersReply = debuggeeWrapper.vmMirror.performCommand(modifiersCommand);
+ modifiersCommand = null;
+ checkReplyPacket(modifiersReply, thisCommandName);
+
+ int returnedModifiers = modifiersReply.getNextValueAsInt();
+/*
+ * The value of the access_flags item is a mask of modifiers used with class and
+ * interface declarations. The access_flags modifiers are:
+ * Flag Name Value Meaning Used By
+ * ACC_PUBLIC 0x0001 Is public; may be accessed from outside its package. Class, interface
+ * ACC_FINAL 0x0010 Is final; no subclasses allowed. Class
+ * ACC_SUPER 0x0020 Treat superclass methods specially in invokespecial. Class, interface
+ * ACC_INTERFACE 0x0200 Is an interface. Interface
+ * ACC_ABSTRACT 0x0400 Is abstract; may not be instantiated. Class, interface
+ */
+ logWriter.println("=> Returned modifiers = 0x" + Integer.toHexString(returnedModifiers));
+
+ int publicFlag = 0x0001; // expected
+ int finalFlag = 0x0010; // unexpected
+ int superFlag = 0x0020; // expected
+ int interfaceFlag = 0x0200; // unexpected
+ int abstractFlag = 0x0400; // unexpected
+
+ if ( (returnedModifiers & publicFlag) == 0 ) {
+ logWriter.println
+ ("## CHECK1: FAILURE: Returned modifiers do NOT contain expected ACC_PUBLIC flag(0x0001)");
+ failMessage = failMessage +
+ "Returned modifiers do NOT contain expected ACC_PUBLIC flag(0x0001);\n";
+ }
+ if ( (returnedModifiers & superFlag) == 0 ) {
+ logWriter.println
+ ("## CHECK1: FAILURE: Returned modifiers do NOT contain expected ACC_SUPER flag(0x0020)");
+ failMessage = failMessage +
+ "Returned modifiers do NOT contain expected ACC_SUPER flag(0x0020);\n";
+ }
+ if ( (returnedModifiers & finalFlag) != 0 ) {
+ logWriter.println
+ ("## CHECK1: FAILURE: Returned modifiers contain unexpected ACC_FINAL flag(0x0010)");
+ failMessage = failMessage +
+ "Returned modifiers contain unexpected ACC_FINAL flag(0x0010);\n";
+ }
+ if ( (returnedModifiers & interfaceFlag) != 0 ) {
+ logWriter.println
+ ("## CHECK1: FAILURE: Returned modifiers contain unexpected ACC_INTERFACE flag(0x0200)");
+ failMessage = failMessage +
+ "Returned modifiers contain unexpected ACC_INTERFACE flag(0x0200);\n";
+ }
+ if ( (returnedModifiers & abstractFlag) != 0 ) {
+ logWriter.println
+ ("## CHECK1: FAILURE: Returned modifiers contain unexpected ACC_ABSTRACT flag(0x0400)");
+ failMessage = failMessage +
+ "Returned modifiers contain unexpected ACC_ABSTRACT flag(0x0400);\n";
+ }
+
+ logWriter.println
+ ("=> CHECK1: PASSED: expected modifiers are returned: ACC_PUBLIC flag(0x0001), ACC_SUPER flag(0x0020)");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+ if (failMessage.length() > 0) {
+ fail(failMessage);
+ }
+
+ assertAllDataRead(modifiersReply);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ModifiersTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ModifiersTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,73 @@
+/*
+ * 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 21.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class NestedTypesDebuggee extends SyncDebuggee {
+
+ static interface StatInterf_1 {
+ static interface StatInterf_1_1 {
+ }
+ }
+
+ static class StatClass_1 {
+ static class StatClass_1_1 {
+ }
+ StatClass_1_1 statClass_1_2_obj = new StatClass_1_1();
+ }
+
+ class NonStatClass_1 implements StatInterf_1 {
+ class NonStatClass_1_1 implements StatInterf_1_1 {
+ }
+ NonStatClass_1_1 nonStatClass_1_2_obj = new NonStatClass_1_1();
+ }
+
+ void method_1() {
+ Object obj1 = new Object() {
+ };
+ logWriter.println("--> Debuggee: DUMP{" + obj1 + "}");
+ }
+
+ public void run() {
+ logWriter.println("--> Debuggee: NestedTypesDebuggee: START");
+ StatClass_1 stat_Class_1_Obj = new StatClass_1();
+ NonStatClass_1 nonStat_Class_1_Obj = new NonStatClass_1();
+ method_1();
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("--> Debuggee: DUMP{" +
+ stat_Class_1_Obj + nonStat_Class_1_Obj + "}");
+ logWriter.println("--> Debuggee: NestedTypesDebuggee: FINISH");
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(NestedTypesDebuggee.class);
+ }
+
+}
+
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,183 @@
+/*
+ * 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 21.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+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 ReferenceType.NestedTypes command.
+ */
+public class NestedTypesTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.NestedTypes command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.NestedTypesDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.NestedTypes command.
+ * The test starts NestedTypesDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.NestedTypes command and checks that returned
+ * list of nested classes corresponds to expected list.
+ */
+ public void testNestedTypes001() {
+ String thisTestName = "testNestedTypes001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ String failMessage = "";
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+ logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.NestedTypesCommand);
+ checkedCommand.setNextValueAsReferenceTypeID(refTypeID);
+ ReplyPacket checkedReply =
+ debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, thisCommandName);
+
+ int returnedNestedTypesNumber = checkedReply.getNextValueAsInt();
+ logWriter.println("=> Returned nested types number = " + returnedNestedTypesNumber);
+
+ String nestedTypeSignatures[] = {
+ "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee$StatInterf_1;",
+ "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee$StatClass_1;",
+ "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesDebuggee$NonStatClass_1;",
+ };
+
+ byte nestedTypeTags[] = {
+ JDWPConstants.TypeTag.INTERFACE,
+ JDWPConstants.TypeTag.CLASS,
+ JDWPConstants.TypeTag.CLASS,
+ };
+
+ boolean nestedTypeFound[] = {
+ false,
+ false,
+ false,
+ };
+
+ int expectedNestedTypesNumber = nestedTypeSignatures.length;
+
+ logWriter.println("=> CHECK for all returned NestedTypes...");
+ for (int i = 0; i < returnedNestedTypesNumber; i++) {
+ logWriter.println("\n=> Check for returned nested type[" + i + "] ...");
+ byte returnedRefTypeTag = checkedReply.getNextValueAsByte();
+ logWriter.println("=> RefTypeTag of nested type = " + returnedRefTypeTag + "("
+ + JDWPConstants.TypeTag.getName(returnedRefTypeTag) + ")");
+ long returnedRefTypeID = checkedReply.getNextValueAsReferenceTypeID();
+ logWriter.println("=> RefTypeID of nested type = " + returnedRefTypeID);
+ logWriter.println("=> Get signature for nested type...");
+ CommandPacket signatureCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ signatureCommand.setNextValueAsReferenceTypeID(returnedRefTypeID);
+ ReplyPacket signatureReply =
+ debuggeeWrapper.vmMirror.performCommand(signatureCommand);
+ signatureCommand = null;
+ checkReplyPacket(signatureReply, "ReferenceType::Signature command");
+
+ String returnedSignature = signatureReply.getNextValueAsString();
+ signatureReply = null;
+ logWriter.println("=> Signature of nested type = " + returnedSignature);
+
+ int k = 0;
+ for (; k < expectedNestedTypesNumber; k++) {
+ if ( ! nestedTypeSignatures[k].equals(returnedSignature)) {
+ continue;
+ }
+ if ( nestedTypeFound[k] ) {
+ logWriter.println("\n## FAILURE: This nested type is found out repeatedly in the list");
+ failMessage = failMessage +
+ "This nested type is found repeatedly in the list;\n";
+ break;
+ }
+ nestedTypeFound[k] = true;
+ if ( nestedTypeTags[k] != returnedRefTypeTag ) {
+ logWriter.println("\n## FAILURE: Unexpected RefTypeTag is returned:");
+ logWriter.println("## Expected RefTypeTag = " + nestedTypeTags[k] + "("
+ + JDWPConstants.TypeTag.getName(nestedTypeTags[k]) + ")");
+ failMessage = failMessage +
+ "Unexpected RefTypeTag is returned:" +
+ returnedRefTypeTag + "(" +
+ JDWPConstants.TypeTag.getName(returnedRefTypeTag) + ")" +
+ ", Expected: " + nestedTypeTags[k] + "(" +
+ JDWPConstants.TypeTag.getName(nestedTypeTags[k]) + ");\n";
+ }
+ break;
+ }
+ if ( k == expectedNestedTypesNumber ) {
+ // returned nested type is not found out in the list of expected nested types
+ logWriter.println("\n## FAILURE: It is unexpected nested type");
+ failMessage = failMessage +
+ "It is unexpected nested type;\n";
+ }
+ }
+
+ for (int k=0; k < expectedNestedTypesNumber; k++) {
+ if ( ! nestedTypeFound[k] ) {
+ logWriter.println
+ ("\n## FAILURE: Expected nested type is NOT found out in the returned list:");
+ logWriter.println("=> Signature of nested type = " + nestedTypeSignatures[k]);
+ failMessage = failMessage +
+ "Expected nested type is NOT found in the returned list: " + nestedTypeSignatures[k];
+ }
+ }
+
+ finalSyncMessage = JPDADebuggeeSynchronizer.SGNL_CONTINUE;
+ if (failMessage.length() > 0) {
+ fail(failMessage);
+ }
+ assertAllDataRead(checkedReply);
+ finalSyncMessage = null;
+
+ logWriter.println
+ ("\n=> CHECK PASSED: All expected nested types are found out and have expected attributes");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("\n==> " + thisTestName + " for " + thisCommandName + ": OK.");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(NestedTypesTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/NestedTypesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,55 @@
+/*
+ * 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 16.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class Signature002Debuggee extends SyncDebuggee {
+
+ static Object checkedObject;
+
+
+ public void run() {
+ logWriter.println("--> Debuggee: Signature002Debuggee: START");
+
+ checkedObject = new Object();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("--> Debuggee: Signature002Debuggee: FINISH");
+
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(Signature002Debuggee.class);
+ }
+
+}
+
+
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,215 @@
+/*
+ * 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.7 $
+ */
+
+/**
+ * Created on 04.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+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 ReferenceType..Signature command with incorrect ReferenceTypeIDs.
+ */
+public class Signature002Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ReferenceType.Signature command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.Signature002Debuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.Signature command with incorrect ReferenceTypeIDs.
+ * <BR>The test starts >Signature002Debuggee class, gets objectID
+ * as value of static field of this class which (field) represents checked object.
+ * Then the test performs three variants of ReferenceType.Signature commands
+ * and checks that commands return:
+ * <BR> - JDWP_ERROR_INVALID_CLASS, if objectID is passed as ReferenceTypeID;
+ * <BR> - JDWP_ERROR_INVALID_OBJECT, if fieldID is passed as ReferenceTypeID;
+ * <BR> - JDWP_ERROR_INVALID_OBJECT, if unknown ID is passed as ReferenceTypeID;
+ */
+ public void testSignature002() {
+ String thisTestName = "testSignature002";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ finalSyncMessage = "TO_FINISH";
+
+ long debuggeeRefTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + debuggeeRefTypeID);
+
+ long checkedFieldID = checkField(debuggeeRefTypeID, "checkedObject");
+
+ 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(debuggeeRefTypeID);
+ 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);
+ if ( returnedValuesNumber != 1 ) {
+ logWriter.println
+ ("\n## FAILURE: ReferenceType::GetValues command returned unexpected number of values:");
+ logWriter.println("## Expected number = 1");
+ logWriter.println("## Returned number = " + returnedValuesNumber);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ synchronizer.sendMessage("TO_FINISH");
+ assertEquals("ReferenceType::GetValues command returned unexpected 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) + ")");
+ if ( checkedObjectFieldTag != JDWPConstants.Tag.OBJECT_TAG ) {
+ finalSyncMessage = "TO_FINISH";
+ printErrorAndFail(
+ "ReferenceType::GetValues command returned unexpected tag: " +
+ checkedObjectFieldTag + "(" +
+ JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")" +
+ ", Expected tag = " + JDWPConstants.Tag.OBJECT_TAG + "(OBJECT_TAG)");
+ }
+
+ long checkedObjectID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned checked ObjectID = " + checkedObjectID);
+
+ logWriter.println
+ ("\n=> CHECK: send " + thisCommandName + " for checked ObjectID: INVALID_CLASS is expected...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ checkedCommand.setNextValueAsReferenceTypeID(checkedObjectID);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+
+ short errorCode = checkedReply.getErrorCode();
+ if ( errorCode != JDWPConstants.Error.NONE ) {
+ if ( errorCode != JDWPConstants.Error.INVALID_CLASS ) {
+ logWriter.println("## CHECK: FAILURE: " + thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ fail(thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ } else {
+ logWriter.println("=> CHECK PASSED: Expected error (INVALID_CLASS) is returned");
+ }
+ } else {
+ logWriter.println
+ ("\n## FAILURE: " + thisCommandName + " does NOT return expected error - INVALID_CLASS");
+ fail(thisCommandName + " does NOT return expected error - INVALID_CLASS");
+ }
+
+ logWriter.println
+ ("\n=> CHECK: send " + thisCommandName + " for checked fieldID: INVALID_OBJECT is expected...");
+
+ checkedCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ checkedCommand.setNextValueAsReferenceTypeID(checkedFieldID);
+
+ checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+
+ errorCode = checkedReply.getErrorCode();
+ if ( errorCode != JDWPConstants.Error.NONE ) {
+ if ( errorCode != JDWPConstants.Error.INVALID_OBJECT ) {
+ logWriter.println("## CHECK: FAILURE: " + thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ fail(thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ } else {
+ logWriter.println("=> CHECK PASSED: Expected error (INVALID_OBJECT) is returned");
+ }
+ } else {
+ logWriter.println
+ ("\n## FAILURE: " + thisCommandName + " does NOT return expected error - INVALID_OBJECT");
+ fail(thisCommandName + " does NOT return expected error - INVALID_OBJECT");
+ }
+
+ logWriter.println
+ ("\n=> CHECK: send " + thisCommandName + " for unknown ID: INVALID_OBJECT is expected...");
+
+ long unknownID = debuggeeRefTypeID + 10;
+ if ( unknownID == checkedFieldID ) {
+ unknownID = unknownID + 100;
+ }
+ logWriter.println("=> unknown ID = " + unknownID);
+ checkedCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ checkedCommand.setNextValueAsReferenceTypeID(unknownID);
+
+ checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+
+ errorCode = checkedReply.getErrorCode();
+ if ( errorCode != JDWPConstants.Error.NONE ) {
+ if ( errorCode != JDWPConstants.Error.INVALID_OBJECT ) {
+ logWriter.println("## CHECK: FAILURE: " + thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ fail(thisCommandName
+ + " returns unexpected ERROR = " + errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ } else {
+ logWriter.println("=> CHECK PASSED: Expected error (INVALID_OBJECT) is returned");
+ }
+ } else {
+ logWriter.println
+ ("\n## FAILURE: " + thisCommandName + " does NOT return expected error - INVALID_OBJECT");
+ fail(thisCommandName + " does NOT return expected error - INVALID_OBJECT");
+ }
+
+ finalSyncMessage = null;
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("\n==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(Signature002Test.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,95 @@
+/*
+ * 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 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.Signature command.
+ */
+public class SignatureTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.Signature command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.Signature command.
+ * <BR>The test starts HelloWorld debuggee, requests referenceTypeId
+ * for it by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.Signature command and checks that returned
+ * signature is equal to expected signature:
+ * <BR>'Lorg/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld;'
+ */
+ public void testSignature001() {
+ String thisTestName = "testSignature001";
+ 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);
+ logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply...");
+
+ CommandPacket signatureCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
+ signatureCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket signatureReply = debuggeeWrapper.vmMirror.performCommand(signatureCommand);
+ signatureCommand = null;
+ checkReplyPacket(signatureReply, thisCommandName);
+
+ String returnedSignature = signatureReply.getNextValueAsString();
+
+ if ( ! debuggeeSignature.equals(returnedSignature) ) {
+ printErrorAndFail(thisCommandName + " returned invalid signature" +
+ ", Expected = " + debuggeeSignature +
+ ", Returned = " + returnedSignature);
+ } else {
+ logWriter.println("=> CHECK1: PASSED: expected signature is returned = "
+ + returnedSignature);
+ }
+ assertAllDataRead(signatureReply);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SignatureTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,43 @@
+/*
+ * 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 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class SignatureWithGenericDebuggee extends SyncDebuggee {
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: SignatureWithGenericDebuggee...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(SignatureWithGenericDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 16.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for ReferenceType.SignatureWithGeneric command.
+ */
+public class SignatureWithGenericTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.SignatureWithGeneric command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee;";
+ static final String debuggeeGenericSignature = "";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.SignatureWithGenericDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.SignatureWithGeneric command.
+ * <BR>The test starts SignatureWithGenericDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.SignatureWithGeneric command and checks that returned
+ * both signature and generic signature are equal to expected signatures.
+ */
+ public void testSignatureWithGeneric001() {
+ String thisTestName = "testSignatureWithGeneric001";
+ 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);
+ logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply...");
+
+ CommandPacket signatureWithGenericCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SignatureWithGenericCommand);
+ signatureWithGenericCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket signatureWithGenericReply = debuggeeWrapper.vmMirror.performCommand(signatureWithGenericCommand);
+ signatureWithGenericCommand = null;
+ checkReplyPacket(signatureWithGenericReply, thisCommandName);
+
+ String returnedSignature = signatureWithGenericReply.getNextValueAsString();
+ String returnedGenericSignature = signatureWithGenericReply.getNextValueAsString();
+
+ assertString(thisCommandName + " returned invalid signature,",
+ debuggeeSignature, returnedSignature);
+ assertString(thisCommandName + " returned invalid generic signature,",
+ debuggeeGenericSignature, returnedGenericSignature);
+
+ logWriter.println("=> CHECK1: PASSED: expected signatures are returned:");
+ logWriter.println("=> Signature = " + returnedSignature);
+ logWriter.println("=> Generic signature = \"" + returnedGenericSignature + "\"");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+ assertAllDataRead(signatureWithGenericReply);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SignatureWithGenericTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,43 @@
+/*
+ * 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 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class SourceDebugExtensionDebuggee extends SyncDebuggee {
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: SourceDebugExtensionDebuggee...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(SourceDebugExtensionDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anatoly F. Bondarenko
+ * @version $Revision: 1.7 $
+ */
+
+/**
+ * Created on 24.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+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 ReferenceType.SourceDebugExtension command.
+ */
+public class SourceDebugExtensionTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "ReferenceType.SourceDebugExtension command";
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.SourceDebugExtensionDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.SourceDebugExtension command.
+ * <BR>The test starts SourceDebugExtensionDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.SourceDebugExtension command and checks that
+ * no any unexpected ERROR is returned.
+ */
+ public void testSourceDebugExtension001() {
+ String thisTestName = "testSourceDebugExtension001";
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canGetSourceDebugExtension");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetSourceDebugExtension;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canGetSourceDebugExtension");
+ return;
+ }
+
+ 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);
+ logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.SourceDebugExtensionCommand);
+ checkedCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+
+ short errorCode = checkedReply.getErrorCode();
+
+ switch ( errorCode ) {
+ case JDWPConstants.Error.NONE:
+ logWriter.println("=> No any ERROR is returned");
+ String SourceDebugExtension = checkedReply.getNextValueAsString();
+ logWriter.println("=> Returned SourceDebugExtension = " + SourceDebugExtension);
+ break;
+ case JDWPConstants.Error.NOT_IMPLEMENTED:
+ logWriter.println("=> ERROR is returned: "+ errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ logWriter.println("=> It is possible ERROR");
+ break;
+ case JDWPConstants.Error.ABSENT_INFORMATION:
+ logWriter.println("=> ERROR is returned: "+ errorCode
+ + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ logWriter.println("=> It is possible ERROR");
+ break;
+ default:
+ logWriter.println("\n## FAILURE: " + thisCommandName + " returns unexpected ERROR = "
+ + errorCode + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ fail(thisCommandName + " returns unexpected ERROR = "
+ + errorCode + "(" + JDWPConstants.Error.getName(errorCode) + ")");
+ }
+
+ assertAllDataRead(checkedReply);
+
+ logWriter.println("=> CHECK PASSED: No any unexpected ERROR is returned");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SourceDebugExtensionTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceDebugExtensionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,43 @@
+/*
+ * 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 21.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class SourceFileDebuggee extends SyncDebuggee {
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: SourceFileDebuggee...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(SourceFileDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/ReferenceType/SourceFileDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native