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 VER=`uname -r`
  33 ARGS=""
  34 REGARGS=""
  35 
  36 case "$OS" in
  37   SunOS | Linux | Darwin | AIX )
  38     PS=":"
  39     FS="/"
  40     CHMOD="${FS}bin${FS}chmod"
  41     FILEURL="file:"
  42     ;;
  43   Windows* )
  44     PS=";"
  45     FS="\\"
  46     CHMOD="chmod"
  47     FILEURL="file:/"
  48     if [ "$VER" -eq "5" ]; then
  49         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
  50         REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000"
  51     fi
  52     ;;
  53   CYGWIN* )
  54     PS=";"
  55     FS="/"
  56     CHMOD="chmod"
  57     FILEURL="file:/"
  58     if [ "$VER" -eq "5" ]; then
  59         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
  60         REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000"
  61     fi
  62     ;;
  63   * )
  64     echo "Unrecognized system!"
  65     exit 1;
  66     ;;
  67 esac
  68 
  69 TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES}
  70 cp -r ${TESTSRC}${FS}* .
  71 ${CHMOD} -R u+w *
  72 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java
  73 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java
  74 
  75 mkdir rmi_tmp
  76 RMIREG_OUT=rmi.out
  77 #start rmiregistry without any local classes on classpath
  78 cd rmi_tmp
  79 # NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT
  80 ${TESTJAVA}${FS}bin${FS}rmiregistry ${REGARGS} -J-Djava.rmi.server.useCodebaseOnly=false \
  81     ${TESTTOOLVMOPTS} 60005 > ..${FS}${RMIREG_OUT} 2>&1 &
  82 RMIREG_PID=$!
  83 # allow some time to start
  84 sleep 3
  85 cd ..
  86 
  87 case "$OS" in
  88   CYGWIN* )
  89     CODEBASE=`cygpath -w $PWD`
  90     ;;
  91   * )
  92     CODEBASE=`pwd`
  93     ;;
  94 esac
  95 # trailing / after code base is important for rmi codebase property.
  96 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 &
  97 TEST_PID=$!
  98 #bulk of testcase - let it run for a while
  99 sleep 5
 100 
 101 #we're done, kill processes first
 102 kill -9 ${RMIREG_PID} ${TEST_PID}
 103 sleep 3
 104 
 105 echo "Test output : "
 106 
 107 cat OUT.TXT
 108 echo "=============="
 109 echo "rmiregistry output  : "
 110 cat ${RMIREG_OUT}
 111 echo "=============="
 112 
 113 grep "Server ready" OUT.TXT
 114 result1=$?
 115 grep "Test passed" OUT.TXT
 116 result2=$?
 117 
 118 if [ $result1 -eq 0  -a $result2 -eq 0 ]
 119 then
 120     echo "Passed"
 121     exitCode=0;
 122 else
 123     echo "Failed"
 124     exitCode=1
 125 fi
 126 rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp
 127 exit ${exitCode}
 128 
 129