1189N/A#!/bin/sh
1189N/A
1189N/A#
2362N/A# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1189N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1189N/A#
1189N/A# This code is free software; you can redistribute it and/or modify it
1189N/A# under the terms of the GNU General Public License version 2 only, as
1189N/A# published by the Free Software Foundation.
1189N/A#
1189N/A# This code is distributed in the hope that it will be useful, but WITHOUT
1189N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1189N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1189N/A# version 2 for more details (a copy is included in the LICENSE file that
1189N/A# accompanied this code).
1189N/A#
1189N/A# You should have received a copy of the GNU General Public License version
1189N/A# 2 along with this work; if not, write to the Free Software Foundation,
1189N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1189N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
1189N/A#
1189N/A
1189N/A
1189N/A# @test
1189N/A# @bug 6829503
1189N/A# @summary 1) Test Console and DeleteOnExitHook can be initialized
1189N/A# while shutdown is in progress
1189N/A# 2) Test if files that are added by the application shutdown
1189N/A# hook are deleted on exit during shutdown
1189N/A#
1189N/A# @build ShutdownHooks
1189N/A# @run shell ShutdownHooks.sh
1189N/A
1189N/Aif [ "${TESTJAVA}" = "" ]
1189N/Athen
1189N/A echo "TESTJAVA not set. Test cannot execute. Failed."
1189N/A exit 1
1189N/Afi
1189N/A
1189N/AFILENAME=fileToBeDeleted
1189N/Arm -f ${TESTCLASSES}/${FILENAME}
1189N/A
1189N/A# create the file to be deleted on exit
1189N/Aecho "testing shutdown" > ${TESTCLASSES}/${FILENAME}
1189N/A
1189N/A${TESTJAVA}/bin/java ${TESTVMOPTS} -classpath ${TESTCLASSES} ShutdownHooks ${TESTCLASSES} $FILENAME
1189N/Aif [ $? != 0 ] ; then
1189N/A echo "Test Failed"; exit 1
1189N/Afi
1189N/A
1189N/Aif [ -f ${TESTCLASSES}/${FILENAME} ]; then
1189N/A echo "Test Failed: ${TESTCLASSES}/${FILENAME} not deleted"; exit 2
1189N/Afi
1189N/Aecho "ShutdownHooks test passed.";