summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-12-29 16:51:12 -0800
committerAndreas Gampe <agampe@google.com>2015-12-30 09:49:21 -0800
commit47529c2d3caa987c1e8c6678e7eed1fc0c019b7c (patch)
tree7bbbee16d68da7879ed34c53fdd1890c2903e264
parent07346e19436b291fc3d16c7845527999c826a1ce (diff)
downloadapache-harmony-47529c2d3caa987c1e8c6678e7eed1fc0c019b7c.tar.gz
JDWP Tests: Make ClassLoaderTest more precise
Check the expectation that the debuggee class has a non-zero classloader, that is, not the boot classloader, while java.lang.Object has a zero classloader, that is, the boot classloader. Bug: 26349019 Change-Id: If224deabc8fc9c08f1bf7deb579f48f0893d6850
-rw-r--r--jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassLoaderTest.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassLoaderTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassLoaderTest.java
index 272968f..5d1aa7d 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassLoaderTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassLoaderTest.java
@@ -51,16 +51,32 @@ public class ClassLoaderTest extends JDWPSyncTestCase {
* <BR>The test starts HelloWorld debuggee, requests referenceTypeId
* for it by VirtualMachine.ClassesBySignature command, then
* performs ReferenceType.ClassLoader command and checks that command
- * returns reply with some classLoaderID without any ERROR
+ * returns reply with some non-zero classLoaderID without any ERROR
*/
public void testClassLoader001() {
- String thisTestName = "testClassLoader001";
+ classLoaderTest("testClassLoader001", debuggeeSignature, false);
+ }
+
+ /**
+ * Same as testClassLoader001, but expecting a zero classLoaderId for
+ * a boot classpath class.
+ * @see <a href="http://docs.oracle.com/javase/7/docs/platform/jpda/jdwp/jdwp-protocol.html#JDWP_ReferenceType_ClassLoader">ReferenceType.ClassLoader</a>
+ * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/jdwp-spec.html">Common Data Types</a>
+ */
+ public void testClassLoader002() {
+ classLoaderTest("testClassLoader002", "Ljava/lang/Object;", true);
+ }
+
+ /**
+ * Implementation of the tests, using the given parameters.
+ */
+ private void classLoaderTest(String thisTestName, String signature, boolean expectZero) {
logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
- long refTypeID = getClassIDBySignature(debuggeeSignature);
+ long refTypeID = getClassIDBySignature(signature);
- logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> Debuggee class = " + signature);
logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply for ERROR...");
@@ -74,6 +90,11 @@ public class ClassLoaderTest extends JDWPSyncTestCase {
checkReplyPacket(classLoaderReply, thisCommandName);
long returnedClassLoaderID = classLoaderReply.getNextValueAsObjectID();
+ if (expectZero) {
+ assertTrue("Should be boot classpath classloader", returnedClassLoaderID == 0);
+ } else {
+ assertTrue("Should not be boot classpath classloader", returnedClassLoaderID != 0);
+ }
logWriter.println("=> CHECK1: PASSED: Returned classLoaderID = " + returnedClassLoaderID);
assertAllDataRead(classLoaderReply);