1 # 2 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 # @test 24 # @bug 8055160 25 # @summary Unit test for javax.accessibility.AccessibilitySPI 26 # 27 # @build Load FooProvider 28 # @build Load BarProvider 29 # @build Load UnusedProvider 30 # @run shell basic.sh 31 # 32 # Command-line usage: sh basic.sh /path/to/build 33 34 if [ -z "$TESTJAVA" ]; then 35 if [ $# -lt 1 ]; then exit 1; fi 36 TESTJAVA="$1" 37 TESTSRC=`pwd` 38 TESTCLASSES="`pwd`" 39 fi 40 41 JAVA="$TESTJAVA/bin/java" 42 43 OS=`uname -s` 44 case "$OS" in 45 SunOS | Darwin | AIX ) 46 FS='/' 47 SEP=':' ;; 48 Linux ) 49 FS='/' 50 SEP=':' ;; 51 * ) 52 FS='\\' 53 SEP='\;' ;; 54 esac 55 56 TESTD=x.test 57 rm -rf $TESTD 58 mkdir -p $TESTD 59 60 mv $TESTCLASSES/FooProvider.class $TESTD 61 mv $TESTCLASSES/BarProvider.class $TESTD 62 mv $TESTCLASSES/UnusedProvider.class $TESTD 63 mkdir -p $TESTD/META-INF/services 64 echo FooProvider >$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider 65 echo BarProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider 66 echo UnusedProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider 67 68 69 failures=0 70 71 go() { 72 echo '' 73 CP="$TESTCLASSES$SEP$TESTD" 74 sh -xc "'$JAVA' $SECURITY_MANAGER -Djavax.accessibility.assistive_technologies=$PROVIDER1$COMMA$PROVIDER2 $TESTVMOPTS -cp $CP Load $1 $2 $3" 2>&1 75 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 76 } 77 78 # find one provider 79 PROVIDER1="FooProvider" 80 go pass $PROVIDER1 81 82 # start using security manager 83 SECURITY_MANAGER="-Djava.security.manager -Djava.security.policy=$TESTSRC/accessibilityProvider.sp" 84 85 # find one provider (with security manager) 86 go pass $PROVIDER1 87 SECURITY_MANAGER= 88 89 # fail if no provider found 90 PROVIDER1="NoProvider" 91 go fail $PROVIDER1 92 93 # setup for two providers 94 COMMA="," 95 96 # find two providers, both exist 97 PROVIDER1="FooProvider" 98 PROVIDER2="BarProvider" 99 go pass $PROVIDER1 $PROVIDER2 100 101 # find two providers, where second one doesn't exist 102 PROVIDER1="FooProvider" 103 PROVIDER2="NoProvider" 104 go fail $PROVIDER1 $PROVIDER2 105 106 # find two providers, where first one doesn't exist 107 PROVIDER1="NoProvider" 108 PROVIDER2="BarProvider" 109 go fail $PROVIDER1 $PROVIDER2 110 111 echo '' 112 if [ $failures -gt 0 ]; 113 then echo "$failures case(s) failed"; 114 else echo "All cases passed"; fi 115 exit $failures 116