15f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes/*
25f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * Licensed to the Apache Software Foundation (ASF) under one or more
35f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * contributor license agreements.  See the NOTICE file distributed with
45f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * this work for additional information regarding copyright ownership.
55f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * The ASF licenses this file to You under the Apache License, Version 2.0
65f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * (the "License"); you may not use this file except in compliance with
75f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * the License.  You may obtain a copy of the License at
85f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *
95f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *     http://www.apache.org/licenses/LICENSE-2.0
105f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *
115f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *  Unless required by applicable law or agreed to in writing, software
125f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *  distributed under the License is distributed on an "AS IS" BASIS,
135f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *
155f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *  See the License for the specific language governing permissions and
165f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes *  limitations under the License.
175f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes */
185f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
195f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes/**
205f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * @author Vitaly A. Provodin
215f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes */
225f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
235f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes/**
245f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * Created on 09.02.2005
255f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes */
265f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughespackage org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
275f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
285f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughesimport org.apache.harmony.jpda.tests.framework.TestErrorException;
295f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughesimport org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
305f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughesimport org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
315f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughesimport org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
325f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughesimport org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
335f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
345f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
355f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
365f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes/**
375f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes * JDWP Unit test for VirtualMachine.Dispose command.
385f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes */
395f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughespublic class DisposeTest extends JDWPSyncTestCase {
405f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
415f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes    protected String getDebuggeeClassName() {
425f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
435f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes    }
445f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
455f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes    /**
465f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     * This testcase exercises VirtualMachine.Dispose command.
475f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     * <BR>At first the test starts HelloWorld debuggee.
485f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     * <BR> Then the test performs VirtualMachine.Dispose command and checks that:
495f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     * <BR>&nbsp;&nbsp; - the reply on the Dispose command is received without any error;
505f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     * <BR>&nbsp;&nbsp; - next VirtualMachine.AllClasses command returns error;
515f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes     */
525f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes    public void testDispose001() {
535f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
545f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
555f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        CommandPacket packet = new CommandPacket(
565f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
575f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes                JDWPCommands.VirtualMachineCommandSet.DisposeCommand);
585f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
595f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        try {
605f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            debuggeeWrapper.vmMirror.performCommand(packet);
615f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        } catch (TestErrorException e) {
625f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            logWriter.printError("Unexpected exception " + e);
635f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            fail("Unexpected exception " + e);
645f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        }
655f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
665f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        packet = new CommandPacket(
675f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
685f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes                JDWPCommands.VirtualMachineCommandSet.AllClassesCommand);
695f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        try {
705f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            debuggeeWrapper.vmMirror.performCommand(packet);
715f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            fail("No exception has been thrown");
725f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        } catch (TestErrorException e) {
735f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes            logWriter.println("Expected exception " + e);
745f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        }
755f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes
765f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
775f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes    }
785f0a23683aa603d8c50b6dd071a565821b76067bElliott Hughes}
79