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 /**
20  * @author Vitaly A. Provodin
21  */
22 
23 /**
24  * Created on 09.02.2005
25  */
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 
36 /**
37  * JDWP Unit test for VirtualMachine.Dispose command.
38  */
39 public class DisposeTest extends JDWPSyncTestCase {
40 
getDebuggeeClassName()41     protected String getDebuggeeClassName() {
42         return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
43     }
44 
45     /**
46      * This testcase exercises VirtualMachine.Dispose command.
47      * <BR>At first the test starts HelloWorld debuggee.
48      * <BR> Then the test performs VirtualMachine.Dispose command and checks that:
49      * <BR>&nbsp;&nbsp; - the reply on the Dispose command is received without any error;
50      * <BR>&nbsp;&nbsp; - next VirtualMachine.AllClasses command returns error;
51      */
testDispose001()52     public void testDispose001() {
53         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
54 
55         CommandPacket packet = new CommandPacket(
56                 JDWPCommands.VirtualMachineCommandSet.CommandSetID,
57                 JDWPCommands.VirtualMachineCommandSet.DisposeCommand);
58 
59         try {
60             debuggeeWrapper.vmMirror.performCommand(packet);
61         } catch (TestErrorException e) {
62             logWriter.printError("Unexpected exception " + e);
63             fail("Unexpected exception " + e);
64         }
65 
66         packet = new CommandPacket(
67                 JDWPCommands.VirtualMachineCommandSet.CommandSetID,
68                 JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
69         try {
70             debuggeeWrapper.vmMirror.performCommand(packet);
71             fail("No exception has been thrown");
72         } catch (TestErrorException e) {
73             logWriter.println("Expected exception " + e);
74         }
75 
76         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
77     }
78 }
79