01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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 Vitaly A. Provodin
21: * @version $Revision: 1.4 $
22: */
23:
24: /**
25: * Created on 25.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
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: * JDWP Unit test for ThreadGroupReference.Name command.
36: */
37: public class NameTest extends JDWPSyncTestCase {
38:
39: protected String getDebuggeeClassName() {
40: return "org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.NameDebuggee";
41: }
42:
43: /**
44: * This testcase exercises ThreadGroupReference.Name command.
45: * <BR>At first the test starts NameDebuggee.
46: * <BR> Then the test with help of the ThreadGroupReference.Name command checks
47: * that for the thread 'TESTED_THREAD' the group name is 'CHILD_GROUP'.
48: *
49: */
50: public void testName001() {
51: logWriter.println("wait for SGNL_READY");
52: synchronizer
53: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
54:
55: // getting ID of the tested thread
56: CommandPacket packet;
57: long threadID = debuggeeWrapper.vmMirror
58: .getThreadID(NameDebuggee.TESTED_THREAD);
59:
60: long groupID;
61: String groupName;
62:
63: // getting the thread group ID
64: packet = new CommandPacket(
65: JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
66: JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
67: packet.setNextValueAsThreadID(threadID);
68:
69: ReplyPacket reply = debuggeeWrapper.vmMirror
70: .performCommand(packet);
71: checkReplyPacket(reply, "ThreadReference::ThreadGroup command");
72:
73: groupID = reply.getNextValueAsThreadGroupID();
74: groupName = debuggeeWrapper.vmMirror
75: .getThreadGroupName(groupID);
76:
77: logWriter.println("\tthreadID=" + threadID + "; threadName="
78: + NameDebuggee.TESTED_THREAD + "; groupID=" + groupID
79: + "; groupName=" + groupName);
80:
81: assertString(
82: "ThreadReference::ThreadGroup command returned invalid group name,",
83: NameDebuggee.CHILD_GROUP, groupName);
84:
85: synchronizer
86: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
87: }
88:
89: public static void main(String[] args) {
90: junit.textui.TestRunner.run(NameTest.class);
91: }
92: }
|