1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /** 20 * @author Anatoly F. Bondarenko 21 */ 22 23 /** 24 * Created on 16.02.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.ReferenceType; 27 28 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; 29 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands; 30 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; 31 import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase; 32 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 33 34 35 /** 36 * JDWP Unit test for ReferenceType.SignatureWithGeneric command. 37 */ 38 public class SignatureWithGenericTest extends JDWPSyncTestCase { 39 40 static final int testStatusPassed = 0; 41 static final int testStatusFailed = -1; 42 static final String thisCommandName = "ReferenceType.SignatureWithGeneric command"; 43 static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee;"; 44 static final String debuggeeGenericSignature = ""; 45 46 @Override 47 protected String getDebuggeeClassName() { 48 return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.SignatureWithGenericDebuggee"; 49 } 50 51 /** 52 * This testcase exercises ReferenceType.SignatureWithGeneric command. 53 * <BR>The test starts SignatureWithGenericDebuggee class, requests referenceTypeId 54 * for this class by VirtualMachine.ClassesBySignature command, then 55 * performs ReferenceType.SignatureWithGeneric command and checks that returned 56 * both signature and generic signature are equal to expected signatures. 57 */ 58 public void testSignatureWithGeneric001() { 59 String thisTestName = "testSignatureWithGeneric001"; 60 logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START..."); 61 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 62 63 long refTypeID = getClassIDBySignature(debuggeeSignature); 64 65 logWriter.println("=> Debuggee class = " + getDebuggeeClassName()); 66 logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID); 67 logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply..."); 68 69 CommandPacket signatureWithGenericCommand = new CommandPacket( 70 JDWPCommands.ReferenceTypeCommandSet.CommandSetID, 71 JDWPCommands.ReferenceTypeCommandSet.SignatureWithGenericCommand); 72 signatureWithGenericCommand.setNextValueAsReferenceTypeID(refTypeID); 73 74 ReplyPacket signatureWithGenericReply = debuggeeWrapper.vmMirror.performCommand(signatureWithGenericCommand); 75 signatureWithGenericCommand = null; 76 checkReplyPacket(signatureWithGenericReply, thisCommandName); 77 78 String returnedSignature = signatureWithGenericReply.getNextValueAsString(); 79 String returnedGenericSignature = signatureWithGenericReply.getNextValueAsString(); 80 81 assertString(thisCommandName + " returned invalid signature,", 82 debuggeeSignature, returnedSignature); 83 assertString(thisCommandName + " returned invalid generic signature,", 84 debuggeeGenericSignature, returnedGenericSignature); 85 86 logWriter.println("=> CHECK1: PASSED: expected signatures are returned:"); 87 logWriter.println("=> Signature = " + returnedSignature); 88 logWriter.println("=> Generic signature = \"" + returnedGenericSignature + "\""); 89 90 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 91 logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH"); 92 93 assertAllDataRead(signatureWithGenericReply); 94 } 95 } 96