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 $PROVIDER $TESTVMOPTS -cp $CP Load $1" 2>&1
  75   if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  76 }
  77 
  78 # find one provider
  79 PROVIDER="-Djavax.accessibility.assistive_technologies=FooProvider"
  80 go
  81 
  82 # find two providers
  83 PROVIDER="-Djavax.accessibility.assistive_technologies=FooProvider,BarProvider"
  84 go
  85 
  86 #find provider, using security manager
  87 SECURITY_MANAGER="-Djava.security.manager -Djava.security.policy==$TESTSRC/accessibilityProvider.sp"
  88 go
  89 
  90 #fail if no provider
  91 PROVIDER="-Djavax.accessibility.assistive_technologies=NoProvider"
  92 go fail
  93 
  94 echo ''
  95 if [ $failures -gt 0 ];
  96   then echo "$failures case(s) failed";
  97   else echo "All cases passed"; fi
  98 exit $failures
  99