Path: blob/master/test/jdk/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh
41153 views
#1# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 8081729 814031425# @summary Test external plugin as classpath jar and as a modular jar.26# Test both cases with and without a security manager.2728set -e2930exception=03132if [ -z "$TESTJAVA" ]; then33if [ $# -lt 1 ]; then echo "No Java path specified. Exiting."; fi34if [ $# -lt 1 ]; then exit 1; fi35TESTJAVA="$1"; shift36COMPILEJAVA="${TESTJAVA}"37TESTSRC="`pwd`"38TESTCLASSES="`pwd`"39fi4041JAVAC="$COMPILEJAVA/bin/javac"42JAR="$COMPILEJAVA/bin/jar"43JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}"4445TESTDIR="$TESTCLASSES/classes"46PLUGINDIR="$TESTCLASSES/classes"47mkdir -p $TESTDIR48$JAVAC -d $TESTDIR `find $TESTSRC/src/simptest -name "*.java"`4950# compile the plugin java sources and services file into a temp location.5152mkdir -p $TESTCLASSES/tmpdir/simp53cp -r $TESTSRC/src/simp/META-INF $TESTCLASSES/tmpdir54$JAVAC -d $TESTCLASSES/tmpdir `find $TESTSRC/src/simp -name "*.java"`5556# create modular jar file (inc. module-info.java) from the class files.57mkdir -p $PLUGINDIR58$JAR cf $PLUGINDIR/simp.jar -C $TESTCLASSES/tmpdir META-INF/services \59-C $TESTCLASSES/tmpdir module-info.class -C $TESTCLASSES/tmpdir simp6061OS=`uname -s`62case "$OS" in63Windows_* | CYGWIN* )64CPSEP=";"65;;66* )67CPSEP=":"68;;69esac7071# expect to find SimpReader via jar on classpath.72# Will be treated as a regular jar.73echo "Test classpath jar .. "74$JAVA -cp ${TESTDIR}${CPSEP}${PLUGINDIR}/simp.jar simptest.TestSIMPPlugin75if [ $? -ne 0 ]; then76exception=177echo "Classpath test failed: exception thrown!"78fi79echo "Test classpath jar with security manager .."80$JAVA -Djava.security.manager -cp .${CPSEP}${TESTDIR}${CPSEP}${PLUGINDIR}/simp.jar simptest.TestSIMPPlugin81if [ $? -ne 0 ]; then82exception=183echo "Classpath + SecurityManager test failed: exception thrown!"84fi8586# expect to find SimpReader on module path87echo "Test modular jar .. "88$JAVA --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin8990if [ $? -ne 0 ]; then91exception=192echo "modular jar test failed: exception thrown!"93fi9495echo "Test modular jar with security manager .."96$JAVA -Djava.security.manager --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin97if [ $? -ne 0 ]; then98exception=199echo "modular jar with security manager test failed: exception thrown!"100fi101102if [ $exception -ne 0 ]; then103echo "TEST FAILED"104exit 1105fi106exit 0107108109