Path: blob/master/test/jdk/javax/accessibility/AccessibilityProvider/basic.sh
41152 views
#1# Copyright (c) 2015, 2020, 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#22# @test23# @key headful24# @bug 8055160 821600825# @summary Unit test for javax.accessibility.AccessibilitySPI26#27# @build Load FooProvider BarProvider UnusedProvider28# @run shell basic.sh2930# Command-line usage: sh basic.sh /path/to/build3132if [ -z "$TESTJAVA" ]; then33if [ $# -lt 1 ]; then exit 1; fi34TESTJAVA="$1"35TESTSRC=`pwd`36TESTCLASSES="`pwd`"37fi3839JAVA="$TESTJAVA/bin/java"4041OS=`uname -s`42case "$OS" in43Darwin | AIX )44FS='/'45SEP=':' ;;46Linux )47FS='/'48SEP=':' ;;49* )50FS='\\'51SEP='\;' ;;52esac5354TESTD=x.test55rm -rf $TESTD56mkdir -p $TESTD5758mv $TESTCLASSES/FooProvider.class $TESTD59mv $TESTCLASSES/BarProvider.class $TESTD60mv $TESTCLASSES/UnusedProvider.class $TESTD61mkdir -p $TESTD/META-INF/services62echo FooProvider >$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider63echo BarProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider64echo UnusedProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider656667failures=06869go() {70CP="$TESTCLASSES$SEP$TESTD"71echo ''72sh -xc "$JAVA $SECURITY_MANAGER -Djavax.accessibility.assistive_technologies=$PROVIDER1$COMMA$PROVIDER2 -cp $CP Load $1 $2 $3" 2>&173if [ $? != 0 ]; then failures=`expr $failures + 1`; fi74}7576# find one provider77PROVIDER1="FooProvider"78go pass $PROVIDER17980# start using security manager81SECURITY_MANAGER="-Djava.security.manager -Djava.security.policy=$TESTSRC/accessibilityProvider.sp"8283# find one provider (with security manager)84go pass $PROVIDER185SECURITY_MANAGER=8687# fail if no provider found88PROVIDER1="NoProvider"89go fail $PROVIDER19091# pass if none provider found92PROVIDER1=93go pass $PROVIDER19495PROVIDER1=" "96go pass $PROVIDER19798# setup for two providers99COMMA=","100101# find two providers, both exist102PROVIDER1="FooProvider"103PROVIDER2="BarProvider"104go pass $PROVIDER1 $PROVIDER2105106# find two providers, where second one doesn't exist107PROVIDER1="FooProvider"108PROVIDER2="NoProvider"109go fail $PROVIDER1 $PROVIDER2110111# find two providers, where first one doesn't exist112PROVIDER1="NoProvider"113PROVIDER2="BarProvider"114go fail $PROVIDER1 $PROVIDER2115116echo ''117if [ $failures -gt 0 ];118then echo "$failures case(s) failed";119else echo "All cases passed"; fi120exit $failures121122123124