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 Vitaly A. Provodin
021: * @version $Revision: 1.3 $
022: */
023:
024: /**
025: * Created on 25.02.2005
026: */package org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference;
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 ThreadGroupReference.Parent command.
036: */
037: public class ParentTest extends JDWPSyncTestCase {
038:
039: protected String getDebuggeeClassName() {
040: return "org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference.NameDebuggee";
041: }
042:
043: /**
044: * This testcase exercises ThreadGroupReference.Parent command.
045: * <BR>At first the test starts NameDebuggee.
046: * <BR> Then the test with help of the ThreadGroupReference.Parent command checks
047: * that the parent group of the group of the tested thread is group
048: * with name 'PARENT_GROUP'.
049: *
050: */
051: public void testParent001() {
052: logWriter.println("wait for SGNL_READY");
053: synchronizer
054: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
055:
056: // getting ID of the tested thread
057: CommandPacket packet;
058: long threadID = debuggeeWrapper.vmMirror
059: .getThreadID(NameDebuggee.TESTED_THREAD);
060:
061: long groupID;
062: String groupName;
063:
064: // getting the thread group ID
065: packet = new CommandPacket(
066: JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
067: JDWPCommands.ThreadReferenceCommandSet.ThreadGroupCommand);
068: packet.setNextValueAsThreadID(threadID);
069:
070: ReplyPacket reply = debuggeeWrapper.vmMirror
071: .performCommand(packet);
072: checkReplyPacket(reply, "ThreadReference::ThreadGroup command");
073:
074: groupID = reply.getNextValueAsThreadGroupID();
075:
076: packet = new CommandPacket(
077: JDWPCommands.ThreadGroupReferenceCommandSet.CommandSetID,
078: JDWPCommands.ThreadGroupReferenceCommandSet.ParentCommand);
079: packet.setNextValueAsThreadID(groupID);
080:
081: reply = debuggeeWrapper.vmMirror.performCommand(packet);
082: checkReplyPacket(reply, "ThreadGroupReference::Parent command");
083:
084: groupID = reply.getNextValueAsThreadGroupID();
085:
086: groupName = debuggeeWrapper.vmMirror
087: .getThreadGroupName(groupID);
088:
089: logWriter.println("\tgroupID=" + groupID + "; groupName="
090: + groupName);
091:
092: assertString(
093: "ThreadGroupReference::Parent command returned invalid group name,",
094: NameDebuggee.PARENT_GROUP, groupName);
095:
096: synchronizer
097: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
098: }
099:
100: public static void main(String[] args) {
101: junit.textui.TestRunner.run(ParentTest.class);
102: }
103: }
|