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* | CYGWIN* )
  39     PS=";"
  40     FS="\\"
  41     FILEURL="file:/"
  42     ;;
  43   * )
  44     echo "Unrecognized system!"
  45     exit 1;
  46     ;;
  47 esac
  48 
  49 TEST_CLASSPATH=.:$TESTCLASSES
  50 cp -r ${TESTSRC}${FS}* .
  51 ${TESTJAVA}${FS}bin${FS}javac testPkg${FS}*java
  52 ${TESTJAVA}${FS}bin${FS}javac -cp $TEST_CLASSPATH readTest.java
  53 
  54 mkdir rmi_tmp
  55 RMIREG_OUT=rmi.out
  56 #start rmiregistry without any local classes on classpath
  57 cd rmi_tmp
  58 # NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT
  59 ${TESTJAVA}${FS}bin${FS}rmiregistry 64005 > ..${FS}${RMIREG_OUT} 2>&1 &
  60 RMIREG_PID=$!
  61 # allow some time to start
  62 sleep 3
  63 cd ..
  64 
  65 # trailing / after code base is important for rmi codebase property.
  66 ${TESTJAVA}${FS}bin${FS}java -cp $TEST_CLASSPATH -Djava.rmi.server.codebase=${FILEURL}`pwd`/ readTest > OUT.TXT 2>&1 &
  67 TEST_PID=$!
  68 #bulk of testcase - let it run for a while
  69 sleep 5
  70 
  71 #we're done, kill processes first
  72 kill -9 ${RMIREG_PID} ${TEST_PID}
  73 sleep 3
  74 
  75 echo "Test output : "
  76 
  77 cat OUT.TXT
  78 echo "=============="
  79 echo "rmiregistry output  : "
  80 cat ${RMIREG_OUT}
  81 echo "=============="
  82 
  83 grep "Server ready" OUT.TXT
  84 result1=$?
  85 grep "Test passed" OUT.TXT
  86 result2=$?
  87 
  88 if [ $result1 -eq 0  -a $result2 -eq 0 ]
  89 then 
  90     echo "Passed"
  91     exitCode=0;
  92 else
  93     echo "Failed"
  94     exitCode=1
  95 fi
  96 rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp
  97 exit ${exitCode}    
  98 
  99