001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Anatoly F. Bondarenko
021: * @version $Revision: 1.5 $
022: */
023:
024: /**
025: * Created on 16.02.2005
026: */package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
027:
028: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
030: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
031: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
032: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
033:
034: /**
035: * JDWP Unit test for ReferenceType.SignatureWithGeneric command.
036: */
037: public class SignatureWithGenericTest extends JDWPSyncTestCase {
038:
039: static final int testStatusPassed = 0;
040: static final int testStatusFailed = -1;
041: static final String this CommandName = "ReferenceType.SignatureWithGeneric command";
042: static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/SignatureWithGenericDebuggee;";
043: static final String debuggeeGenericSignature = "";
044:
045: protected String getDebuggeeClassName() {
046: return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.SignatureWithGenericDebuggee";
047: }
048:
049: /**
050: * This testcase exercises ReferenceType.SignatureWithGeneric command.
051: * <BR>The test starts SignatureWithGenericDebuggee class, requests referenceTypeId
052: * for this class by VirtualMachine.ClassesBySignature command, then
053: * performs ReferenceType.SignatureWithGeneric command and checks that returned
054: * both signature and generic signature are equal to expected signatures.
055: */
056: public void testSignatureWithGeneric001() {
057: String this TestName = "testSignatureWithGeneric001";
058: logWriter.println("==> " + this TestName + " for "
059: + this CommandName + ": START...");
060: synchronizer
061: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
062:
063: long refTypeID = getClassIDBySignature(debuggeeSignature);
064:
065: logWriter.println("=> Debuggee class = "
066: + getDebuggeeClassName());
067: logWriter.println("=> referenceTypeID for Debuggee class = "
068: + refTypeID);
069: logWriter.println("=> CHECK1: send " + this CommandName
070: + " and check reply...");
071:
072: CommandPacket signatureWithGenericCommand = new CommandPacket(
073: JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
074: JDWPCommands.ReferenceTypeCommandSet.SignatureWithGenericCommand);
075: signatureWithGenericCommand
076: .setNextValueAsReferenceTypeID(refTypeID);
077:
078: ReplyPacket signatureWithGenericReply = debuggeeWrapper.vmMirror
079: .performCommand(signatureWithGenericCommand);
080: signatureWithGenericCommand = null;
081: checkReplyPacket(signatureWithGenericReply, this CommandName);
082:
083: String returnedSignature = signatureWithGenericReply
084: .getNextValueAsString();
085: String returnedGenericSignature = signatureWithGenericReply
086: .getNextValueAsString();
087:
088: assertString(this CommandName + " returned invalid signature,",
089: debuggeeSignature, returnedSignature);
090: assertString(this CommandName
091: + " returned invalid generic signature,",
092: debuggeeGenericSignature, returnedGenericSignature);
093:
094: logWriter
095: .println("=> CHECK1: PASSED: expected signatures are returned:");
096: logWriter.println("=> Signature = " + returnedSignature);
097: logWriter.println("=> Generic signature = \""
098: + returnedGenericSignature + "\"");
099:
100: synchronizer
101: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
102: logWriter.println("==> " + this TestName + " for "
103: + this CommandName + ": FINISH");
104:
105: assertAllDataRead(signatureWithGenericReply);
106: }
107:
108: public static void main(String[] args) {
109: junit.textui.TestRunner.run(SignatureWithGenericTest.class);
110: }
111: }
|