1 #
   2 # Copyright 2008-2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20 # CA 95054 USA or visit www.sun.com if you need additional information or
  21 # have any questions.
  22 #
  23 
  24 # @test
  25 # @bug 4313887
  26 # @summary Unit test for walkFileTree method
  27 # @build CreateFileTree PrintFileTree SkipSiblings TerminateWalk
  28 # @run shell walk_file_tree.sh
  29 
  30 # if TESTJAVA isn't set then we assume an interactive run.
  31 
  32 if [ -z "$TESTJAVA" ]; then
  33     TESTSRC=.
  34     TESTCLASSES=.
  35     JAVA=java
  36 else
  37     JAVA="${TESTJAVA}/bin/java"
  38 fi
  39 
  40 OS=`uname -s`
  41 case "$OS" in
  42     Windows_* )
  43         echo "This test does not run on Windows" 
  44         exit 0
  45         ;;
  46     * )
  47         CLASSPATH=${TESTCLASSES}:${TESTSRC}
  48         ;;
  49 esac
  50 export CLASSPATH
  51 
  52 # create the file tree
  53 ROOT=`$JAVA CreateFileTree`
  54 if [ $? != 0 ]; then exit 1; fi
  55 
  56 failures=0
  57 
  58 # print the file tree and compare output with find(1)
  59 $JAVA PrintFileTree "$ROOT" > out1
  60 find "$ROOT" > out2
  61 diff out1 out2
  62 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  63 
  64 # repeat test following links (use -follow instead of -L
  65 # to allow running on older systems)
  66 $JAVA PrintFileTree -L "$ROOT" > out1
  67 find "$ROOT" -follow > out2
  68 diff out1 out2
  69 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  70 
  71 # test SKIP_SIBLINGS
  72 $JAVA SkipSiblings "$ROOT"
  73 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  74 
  75 # test TERMINATE
  76 $JAVA TerminateWalk "$ROOT"
  77 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  78 
  79 # clean-up
  80 rm -r "$ROOT"
  81 
  82 echo ''
  83 if [ $failures -gt 0 ];
  84   then echo "$failures test(s) failed";
  85   else echo "Test passed"; fi
  86 exit $failures