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