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 09.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
27:
28: import org.apache.harmony.jpda.tests.framework.TestErrorException;
29: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
30: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
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 VirtualMachine.Dispose command.
36: */
37: public class DisposeTest extends JDWPSyncTestCase {
38:
39: protected String getDebuggeeClassName() {
40: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
41: }
42:
43: /**
44: * This testcase exercises VirtualMachine.Dispose command.
45: * <BR>At first the test starts HelloWorld debuggee.
46: * <BR> Then the test performs VirtualMachine.Dispose command and checks that:
47: * <BR> - the reply on the Dispose command is received without any error;
48: * <BR> - next VirtualMachine.AllClasses command returns error;
49: */
50: public void testDispose001() {
51: synchronizer
52: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
53:
54: CommandPacket packet = new CommandPacket(
55: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
56: JDWPCommands.VirtualMachineCommandSet.DisposeCommand);
57:
58: try {
59: debuggeeWrapper.vmMirror.performCommand(packet);
60: } catch (TestErrorException e) {
61: logWriter.printError("Unexpected exception " + e);
62: fail("Unexpected exception " + e);
63: }
64:
65: packet = new CommandPacket(
66: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
67: JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
68: try {
69: debuggeeWrapper.vmMirror.performCommand(packet);
70: fail("No exception has been thrown");
71: } catch (TestErrorException e) {
72: logWriter.println("Expected exception " + e);
73: }
74:
75: synchronizer
76: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
77: }
78:
79: public static void main(String[] args) {
80: junit.textui.TestRunner.run(DisposeTest.class);
81: }
82: }
|