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 Viacheslav G. Rybalov 21 */ 22 23 /** 24 * Created on 05.03.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.ClassObjectReference; 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.JDWPConstants; 31 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; 32 import org.apache.harmony.jpda.tests.jdwp.ClassObjectReference.AbstractReflectedTypeTestCase.TypeSignatureAndTag; 33 import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase; 34 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 35 36 37 /** 38 * JDWP unit test for ClassObjectReference.ReflectedType command. 39 */ 40 41 public class ReflectedTypeTest extends AbstractReflectedTypeTestCase { 42 43 private static final String DEBUGGEE_CLASS_NAME = 44 "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld"; 45 46 /** 47 * Returns full name of debuggee class which is used by this test. 48 * @return full name of debuggee class. 49 */ getDebuggeeClassName()50 protected String getDebuggeeClassName() { 51 return DEBUGGEE_CLASS_NAME; 52 } 53 54 /** 55 * This testcase exercises ClassObjectReference.ReflectedType command. 56 * <BR>Starts <A HREF="../share/debuggee/HelloWorld.html">HelloWorld</A> debuggee. 57 * <BR>Then checks the following four classes: 58 * <BR> - java/lang/Object; 59 * <BR> - java/lang/String; 60 * <BR> - java/lang/Runnable; 61 * <BR> - HelloWorld. 62 * <BR> 63 * <BR>The following statements are checked: 64 * <BR> It is expected: 65 * <BR> - refTypeTag takes one of the TypeTag constants: CLASS, INTERFACE; 66 * <BR> - refTypeTag equals to refTypeTag returned by command 67 * VirtualMachine.ClassesBySignature; 68 * <BR> - typeID equals to typeID returned by the JDWP command 69 * VirtualMachine.ClassesBySignature; 70 * <BR> - All data were read; 71 */ testReflectedType001()72 public void testReflectedType001() { 73 logWriter.println("==> testReflectedType001 START..."); 74 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 75 76 // Builds debuggee class signature string. 77 String debuggeeClassSignature = 78 "L" + DEBUGGEE_CLASS_NAME.replace('.', '/') + ";"; 79 80 TypeSignatureAndTag[] array = new TypeSignatureAndTag[] { 81 new TypeSignatureAndTag("Ljava/lang/Object;", 82 JDWPConstants.TypeTag.CLASS), 83 new TypeSignatureAndTag("Ljava/lang/String;", 84 JDWPConstants.TypeTag.CLASS), 85 new TypeSignatureAndTag("Ljava/lang/Runnable;", 86 JDWPConstants.TypeTag.INTERFACE), 87 new TypeSignatureAndTag(debuggeeClassSignature, 88 JDWPConstants.TypeTag.CLASS) 89 }; 90 91 runReflectedTypeTest(array); 92 93 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 94 } 95 } 96