1 #
   2 # Copyright (c) 2011, 2012, 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 
  24 # @test
  25 # @bug 7102369 7094468 7100592
  26 # @library ../../testlibrary
  27 # @build TestLibrary
  28 # @summary remove java.rmi.server.codebase property parsing from registyimpl
  29 # @run shell readTest.sh
  30 
  31 OS=`uname -s`
  32 case "$OS" in
  33   SunOS | Linux | Darwin )
  34     PS=":"
  35     FS="/"
  36     FILEURL="file:"
  37     ;;
  38   Windows* )
  39     PS=";"
  40     FS="\\"
  41     FILEURL="file:/"
  42     ;;
  43   CYGWIN* )
  44     PS=";"
  45     FS="/"
  46     FILEURL="file:/"
  47     ;;
  48   * )
  49     echo "Unrecognized system!"
  50     exit 1;
  51     ;;
  52 esac
  53 
  54 TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES}
  55 cp -r ${TESTSRC}${FS}* .
  56 ${TESTJAVA}${FS}bin${FS}javac testPkg${FS}*java
  57 ${TESTJAVA}${FS}bin${FS}javac -cp $TEST_CLASSPATH readTest.java
  58 
  59 mkdir rmi_tmp
  60 RMIREG_OUT=rmi.out
  61 #start rmiregistry without any local classes on classpath
  62 cd rmi_tmp
  63 # NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT
  64 ${TESTJAVA}${FS}bin${FS}rmiregistry 64005 > ..${FS}${RMIREG_OUT} 2>&1 &
  65 RMIREG_PID=$!
  66 # allow some time to start
  67 sleep 3
  68 cd ..
  69 
  70 case "$OS" in
  71   CYGWIN* )
  72     CODEBASE=`cygpath -w $PWD`
  73     ;;
  74   * )
  75     CODEBASE=`pwd`
  76     ;;  
  77 esac
  78 # trailing / after code base is important for rmi codebase property.
  79 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 &
  80 TEST_PID=$!
  81 #bulk of testcase - let it run for a while
  82 sleep 5
  83 
  84 #we're done, kill processes first
  85 kill -9 ${RMIREG_PID} ${TEST_PID}
  86 sleep 3
  87 
  88 echo "Test output : "
  89 
  90 cat OUT.TXT
  91 echo "=============="
  92 echo "rmiregistry output  : "
  93 cat ${RMIREG_OUT}
  94 echo "=============="
  95 
  96 grep "Server ready" OUT.TXT
  97 result1=$?
  98 grep "Test passed" OUT.TXT
  99 result2=$?
 100 
 101 if [ $result1 -eq 0  -a $result2 -eq 0 ]
 102 then 
 103     echo "Passed"
 104     exitCode=0;
 105 else
 106     echo "Failed"
 107     exitCode=1
 108 fi
 109 rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp
 110 exit ${exitCode}    
 111 
 112