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