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.5 $
022: */
023:
024: /**
025: * Created on 28.02.2005
026: */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
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.JDWPConstants;
031: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
032: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
033: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
034:
035: /**
036: * This tests case exercises the JDWP command <code>VirtualMachine.ReleaseEvents</code>.
037: * After the test sends <code>HoldEvents</code>, the debuggee
038: * <code>org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsDebuggee</code> tries to start
039: * the tested thread <code>TESTED_THREAD</code>.
040: *
041: * <p>The following statements are checked:
042: * <ol>
043: * <li><i>testReleaseEvents001</i>
044: * It is expected the <code>THREAD_START</code> after sending
045: * sending <code>ReleaseEvents</code>.
046: *
047: * </ol>
048: */
049: /**
050: * JDWP Unit test for VirtualMachine.ReleaseEvents command.
051: */
052: public class ReleaseEventsTest extends JDWPSyncTestCase {
053:
054: protected String getDebuggeeClassName() {
055: return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsDebuggee";
056: }
057:
058: /**
059: * This testcase exercises VirtualMachine.ReleaseEvents command.
060: * <BR>At first the test starts ReleaseEventsDebuggee.
061: * <BR> Then the test sends request for TESTED_THREAD and
062: * performs VirtualMachine.HoldEvents command.
063: * <BR>Next, the test waits for debuggee to start the 'TESTED_THREAD'
064: * thread and performs VirtualMachine.ReleaseEvents command.
065: * <BR>After this the test expects that requested TESTED_THREAD event is sent to test.
066: */
067: public void testReleaseEvents001() {
068: synchronizer
069: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
070:
071: debuggeeWrapper.vmMirror.setThreadStart();
072:
073: //send HoldEvents command
074: logWriter.println("send HoldEvents");
075: CommandPacket packet = new CommandPacket(
076: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
077: JDWPCommands.VirtualMachineCommandSet.HoldEventsCommand);
078:
079: ReplyPacket reply = debuggeeWrapper.vmMirror
080: .performCommand(packet);
081: checkReplyPacket(reply, "VirtualMachine::HoldEvents command");
082:
083: logWriter.println("allow to start thread");
084: synchronizer
085: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
086:
087: logWriter.println("send ReleaseEvents");
088: packet = new CommandPacket(
089: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
090: JDWPCommands.VirtualMachineCommandSet.ReleaseEventsCommand);
091:
092: reply = debuggeeWrapper.vmMirror.performCommand(packet);
093: checkReplyPacket(reply, "VirtualMachine::ReleaseEvents command");
094:
095: CommandPacket event = debuggeeWrapper.vmMirror
096: .receiveCertainEvent(JDWPConstants.EventKind.THREAD_START);
097: if (event != null) {
098: logWriter
099: .println("expected event: "
100: + JDWPConstants.EventKind
101: .getName(JDWPConstants.EventKind.THREAD_START)
102: + " was received");
103: } else {
104: logWriter.printError("no events were received");
105: fail("no events were received");
106: }
107: debuggeeWrapper.vmMirror.resume();
108: }
109:
110: public static void main(String[] args) {
111: junit.textui.TestRunner.run(ReleaseEventsTest.class);
112: }
113: }
|