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 package org.apache.harmony.jpda.tests.jdwp.ClassObjectReference;
20 
21 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
22 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
23 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
24 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
25 import org.apache.harmony.jpda.tests.jdwp.ClassObjectReference.AbstractReflectedTypeTestCase.TypeSignatureAndTag;
26 import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
27 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
28 
29 
30 /**
31  * JDWP unit test for ClassObjectReference.ReflectedType command.
32  */
33 
34 public class ReflectedType002Test extends AbstractReflectedTypeTestCase {
35 
36     /**
37      * Returns full name of debuggee class which is used by this test.
38      * @return full name of debuggee class.
39      */
getDebuggeeClassName()40     protected String getDebuggeeClassName() {
41         return ReflectedType002Debuggee.class.getName();
42     }
43 
44     /**
45      * This testcase exercises ClassObjectReference.ReflectedType command.
46      * <BR>Starts ReflectedType002Debuggee then checks the following array
47      * classes:
48      * <BR>&nbsp;&nbsp; - java/lang/Object[];
49      * <BR>&nbsp;&nbsp; - java/lang/String[];
50      * <BR>&nbsp;&nbsp; - java/lang/Runnable[];
51      * <BR>&nbsp;&nbsp; - char[];
52      * <BR>&nbsp;&nbsp;
53      * <BR>The following statements are checked:
54      * <BR>&nbsp;It is expected:
55      * <BR>&nbsp;&nbsp; - refTypeTag takes the TypeTag constant ARRAY
56      * <BR>&nbsp;&nbsp; - refTypeTag equals to refTypeTag returned by command
57      *  VirtualMachine.ClassesBySignature;
58      * <BR>&nbsp;&nbsp; - typeID equals to typeID returned by the JDWP command
59      * VirtualMachine.ClassesBySignature;
60      * <BR>&nbsp;&nbsp; - All data were read;
61      */
testReflectedType001()62     public void testReflectedType001() {
63         logWriter.println("==> testReflectedType001 START...");
64         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
65 
66         TypeSignatureAndTag[] array = new TypeSignatureAndTag[] {
67             new TypeSignatureAndTag("[Ljava/lang/Object;",
68                                     JDWPConstants.TypeTag.ARRAY),
69             new TypeSignatureAndTag("[Ljava/lang/String;",
70                                     JDWPConstants.TypeTag.ARRAY),
71             new TypeSignatureAndTag("[Ljava/lang/Runnable;",
72                                     JDWPConstants.TypeTag.ARRAY),
73             new TypeSignatureAndTag("[C", JDWPConstants.TypeTag.ARRAY)
74         };
75 
76         runReflectedTypeTest(array);
77 
78         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
79     }
80 }
81