jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh
changeset 14013 10f55dd791e1
parent 11991 800d0ff7b043
child 14786 a9f61e0cbe61
equal deleted inserted replaced
14012:5eb69af39af2 14013:10f55dd791e1
    25 # @bug 7110104
    25 # @bug 7110104
    26 # @build JMXStartStopTest JMXStartStopDoSomething
    26 # @build JMXStartStopTest JMXStartStopDoSomething
    27 # @run shell JMXStartStopTest.sh --jtreg --no-compile
    27 # @run shell JMXStartStopTest.sh --jtreg --no-compile
    28 # @summary No word Failed expected in the test output
    28 # @summary No word Failed expected in the test output
    29 
    29 
    30 _verbose=no
       
    31 _server=no
    30 _server=no
    32 _jtreg=no
    31 _jtreg=no
    33 _compile=yes
    32 _compile=yes
    34 _testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13"
    33 _testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13"
    35 _port_one=50234
    34 _port_one=50234
    37 
    36 
    38 
    37 
    39 _testclasses=".classes"
    38 _testclasses=".classes"
    40 _testsrc=`pwd`
    39 _testsrc=`pwd`
    41 
    40 
    42 _logname=".classes/JMXStartStopTest_output.txt"
    41 _logname=".classes/output.txt"
    43 
    42 _lockFileName="JMXStartStop.lck"
    44 
    43 
    45 _compile(){
    44 _compile(){
    46 
    45 
    47     if [ ! -e ${_testclasses} ]
    46     if [ ! -e ${_testclasses} ]
    48     then
    47     then
    49 	  mkdir -p ${_testclasses} 
    48       mkdir -p ${_testclasses} 
    50     fi   
    49     fi   
    51 
    50 
    52     rm -f ${_testclasses}/JMXStartStopTest.class
    51     rm -f ${_testclasses}/JMXStartStopTest.class
    53 
    52 
    54     # Compile testcase
    53     # Compile testcase
    60       exit -1
    59       exit -1
    61     fi
    60     fi
    62 }
    61 }
    63 
    62 
    64 _app_start(){
    63 _app_start(){
    65 
       
    66   if [ "${_verbose}" = "yes" ]
       
    67   then
       
    68      echo "RUN: ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething "
       
    69   fi 
       
    70   ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething  >> ${_logname} 2>&1 &
    64   ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething  >> ${_logname} 2>&1 &
    71   sleep 1 
    65 
    72 
    66   npid=`_get_pid`
    73   pid=`_get_pid`
    67   if [ "${npid}" = "" ]
    74   if [ "x${pid}" = "x" ]
       
    75   then
    68   then
    76      echo "ERROR: Test app not started"
    69      echo "ERROR: Test app not started"
    77      exit -1
    70      if [ "${_jtreg}" = "yes" ]
       
    71      then
       
    72        exit -1
       
    73      fi  
    78   fi
    74   fi
    79 
       
    80 }
    75 }
    81 
    76 
    82 _get_pid(){
    77 _get_pid(){
    83     ${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"
    78     ${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"
    84 }
    79 }
    85 
    80 
    86 _app_stop(){
    81 _app_stop(){
    87     pid=`_get_pid`
    82   rm ${_lockFileName}
    88     if [ "x${pid}" != "x" ]
    83 
    89     then
    84   # wait until VM is actually shuts down
    90        kill $pid
    85   while true 
    91     fi
    86   do
    92 
    87     npid=`_get_pid`
    93     # Stop on first failed test under jtreg
    88     if [ "${npid}" = "" ] 
    94     if [ "x$1" = "xFailed" -a "${_jtreg}" = "yes" ]
    89     then
    95     then
    90       break
       
    91     fi
       
    92     sleep 1
       
    93   done 
       
    94 }
       
    95 
       
    96 _exit_on_jtreg(){
       
    97   # Stop on first failed test under jtreg
       
    98   if [ "${_jtreg}" = "yes" ]
       
    99   then
       
   100       _app_stop
    96       exit -1
   101       exit -1
    97     fi
   102   fi
    98 }
   103 }
    99    
   104 
   100 testme(){
   105 _testme(){
   101     ${TESTJAVA}/bin/java -cp ${_testclasses} JMXStartStopTest $*
   106   ${TESTJAVA}/bin/java -cp ${_testclasses} JMXStartStopTest $*
   102 }   
   107 }   
   103 
   108 
   104   
   109   
   105 _jcmd(){
   110 _jcmd(){
   106   if [ "${_verbose}" = "yes" ]
   111   ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* > /dev/null 2>/dev/null
   107   then
       
   108      echo "RUN: ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $*"
       
   109      ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* 
       
   110   else
       
   111      ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* > /dev/null 2>/dev/null
       
   112   fi
       
   113 } 
   112 } 
   114 
   113 
   115 _echo(){
   114 _echo(){
   116     echo "$*"
   115     echo "$*"
   117     echo "$*" >> ${_logname}
   116     echo "$*" >> ${_logname}
   120 # ============= TESTS ======================================
   119 # ============= TESTS ======================================
   121    
   120    
   122 test_01(){
   121 test_01(){
   123 # Run an app with JMX enabled stop it and 
   122 # Run an app with JMX enabled stop it and 
   124 # restart on other port
   123 # restart on other port
   125 		
   124         
   126     _echo "**** Test one ****"		
   125     _echo "**** Test one ****"      
   127 
   126 
   128     _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   127     _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   129                 -Dcom.sun.management.jmxremote.authenticate=false \
   128                 -Dcom.sun.management.jmxremote.authenticate=false \
   130 	        -Dcom.sun.management.jmxremote.ssl=false 
   129                 -Dcom.sun.management.jmxremote.ssl=false 
   131 
   130 
   132     res1=`testme $1`
   131     res1=`_testme $1`
   133 
   132 
   134     _jcmd ManagementAgent.stop
   133     _jcmd ManagementAgent.stop
   135 
   134 
   136     res2=`testme $1`
   135     res2=`_testme $1`
   137 
   136 
   138     _jcmd ManagementAgent.start jmxremote.port=$2
   137     _jcmd ManagementAgent.start jmxremote.port=$2
   139 
   138 
   140     res3=`testme $2`
   139     res3=`_testme $2`
   141 
       
   142 
   140 
   143     if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   141     if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   144     then
   142     then
   145 	_echo "Passed"
   143         _echo "Passed"
   146     else
   144     else
   147 	_echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}"
   145         _echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}"
   148     _app_stop "Failed"
   146         _exit_on_jtreg
   149     fi
   147     fi
   150 
   148 
   151     _app_stop
   149     _app_stop
   152 
       
   153 }  
   150 }  
   154    
   151    
   155 test_02(){
   152 test_02(){
   156 # Run an app without JMX enabled 
   153 # Run an app without JMX enabled 
   157 # start JMX by jcmd
   154 # start JMX by jcmd
   158 
   155 
   159 _echo "**** Test two ****"		
   156     _echo "**** Test two ****"      
   160 _app_start  
   157     _app_start  
   161 
   158 
   162 _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   159     _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   163 
   160 
   164 res1=`testme $1`
   161     res1=`_testme $1`
   165 
   162 
   166 if [ "${res1}" = "OK_CONN" ] 
   163     if [ "${res1}" = "OK_CONN" ] 
   167 then
   164     then
   168     _echo "Passed"
   165         _echo "Passed"
   169 else
   166     else
   170     _echo "Failed r1(OK):${res1}"
   167         _echo "Failed r1(OK):${res1}"
   171     _app_stop "Failed"
   168         _exit_on_jtreg
   172 fi
   169     fi
   173 
   170     _app_stop
   174 _app_stop
       
   175 
       
   176 }   
   171 }   
   177    
   172    
   178 test_03(){
   173 test_03(){
   179 # Run an app without JMX enabled 
   174 # Run an app without JMX enabled 
   180 # start JMX by jcmd on one port than on other one
   175 # start JMX by jcmd on one port than on other one
   181 
   176 
   182 _echo "**** Test three ****"		
   177     _echo "**** Test three ****"        
   183 _app_start  
   178     _app_start  
   184 
   179 
   185 _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   180     _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   186 
   181 
   187 # Second agent shouldn't start
   182 # Second agent shouldn't start
   188 _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   183     _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   189 
   184 
   190 # First agent should connect
   185 # First agent should connect
   191 res1=`testme $1`
   186     res1=`_testme $1`
   192 
   187 
   193 if [ "${res1}" = "OK_CONN" ] 
   188     if [ "${res1}" = "OK_CONN" ] 
   194 then
   189     then
   195     _echo "Passed $1"
   190         _echo "Passed $1"
   196 else
   191     else
   197     _echo "Failed r1(NO):${res1}"
   192         _echo "Failed r1(NO):${res1}"
   198     _app_stop "Failed"
   193         _exit_on_jtreg
   199 fi
   194     fi
   200 
   195 
   201 #Second agent shouldn't connect
   196 #Second agent shouldn't connect
   202 res1=`testme $2`
   197     res1=`_testme $2`
   203 
   198 
   204 if [ "${res1}" = "NO_CONN" ] 
   199     if [ "${res1}" = "NO_CONN" ] 
   205 then
   200     then
   206     _echo "Passed $2"
   201         _echo "Passed $2"
   207 else
   202     else
   208     _echo "Failed r1(OK):${res1}"
   203         _echo "Failed r1(OK):${res1}"
   209 fi
   204         _exit_on_jtreg
   210 
   205     fi
   211 _app_stop
   206 
       
   207     _app_stop
   212 }   
   208 }   
   213    
   209    
   214 test_04(){
   210 test_04(){
   215 # Run an app without JMX enabled 
   211 # Run an app without JMX enabled 
   216 # start JMX by jcmd on one port, specify rmi port explicitly
   212 # start JMX by jcmd on one port, specify rmi port explicitly
   217 
   213 
   218 _echo "**** Test four ****"		
   214     _echo "**** Test four ****"     
   219 _app_start  
   215     _app_start  
   220 
   216 
   221 _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   217     _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   222 
   218 
   223 # First agent should connect
   219 # First agent should connect
   224 res1=`testme $1 $2`
   220     res1=`_testme $1 $2`
   225 
   221 
   226 if [ "${res1}" = "OK_CONN" ] 
   222     if [ "${res1}" = "OK_CONN" ] 
   227 then
   223     then
   228     _echo "Passed $1 $2"
   224         _echo "Passed $1 $2"
   229 else
   225     else
   230     _echo "Failed r1(NO):${res1}"
   226         _echo "Failed r1(NO):${res1}"
   231     _app_stop "Failed"
   227         _exit_on_jtreg
   232 fi
   228     fi
   233 
   229 
   234 _app_stop
   230     _app_stop
   235 }   
   231 }   
   236 
   232 
   237 test_05(){
   233 test_05(){
   238 # Run an app without JMX enabled, it will enable local server
   234 # Run an app without JMX enabled, it will enable local server
   239 # but should leave remote server disabled  
   235 # but should leave remote server disabled  
   240 
   236 
   241 _echo "**** Test five ****"		
   237     _echo "**** Test five ****"     
   242 _app_start  
   238     _app_start  
   243 
   239 
   244 _jcmd ManagementAgent.start jmxremote=1 
   240     _jcmd ManagementAgent.start jmxremote=1 
   245 
   241 
   246 # First agent should connect
   242     # First agent should connect
   247 res1=`testme $1`
   243     res1=`_testme $1`
   248 
   244 
   249 if [ "${res1}" = "NO_CONN" ] 
   245     if [ "${res1}" = "NO_CONN" ] 
   250 then
   246     then
   251     _echo "Passed $1 $2"
   247         _echo "Passed $1 $2"
   252 else
   248     else
   253     _echo "Failed r1(OK):${res1}"
   249         _echo "Failed r1(OK):${res1}"
   254     _app_stop "Failed"
   250         _exit_on_jtreg
   255 fi
   251     fi
   256 
   252 
   257 _app_stop
   253     _app_stop
   258 }   
   254 }   
   259 
   255 
   260 test_06(){
   256 test_06(){
   261 # Run an app without JMX enabled 
   257 # Run an app without JMX enabled 
   262 # start JMX by jcmd on one port, specify rmi port explicitly
   258 # start JMX by jcmd on one port, specify rmi port explicitly
   263 # attempt to start it again
   259 # attempt to start it again
   264 # 1) with the same port 
   260 # 1) with the same port 
   265 # 2) with other port
   261 # 2) with other port
   266 # 3) attempt to stop it twice
   262 # 3) attempt to stop it twice
   267 # Check for valid messages in the output	
   263 # Check for valid messages in the output    
   268 
   264 
   269 _echo "**** Test six ****"		
   265     _echo "**** Test six ****"      
   270 _app_start  
   266     _app_start  
   271 
   267 
   272 _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   268     _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   273 
   269 
   274 # First agent should connect
   270     # First agent should connect
   275 res1=`testme $1 $2`
   271     res1=`_testme $1 $2`
   276 
   272 
   277 if [ "${res1}" = "OK_CONN" ] 
   273     if [ "${res1}" = "OK_CONN" ] 
   278 then
   274     then
   279     _echo "Passed $1 $2"
   275         _echo "Passed $1 $2"
   280 else
   276     else
   281     _echo "Failed r1(NO):${res1}"
   277         _echo "Failed r1(NO):${res1}"
   282     _app_stop "Failed"
   278         _exit_on_jtreg
   283 fi
   279     fi
   284 
   280 
   285 _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   281     _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
   286 
   282 
   287 _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   283     _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   288 
   284 
   289 _jcmd ManagementAgent.stop
   285     _jcmd ManagementAgent.stop
   290 
   286 
   291 _jcmd ManagementAgent.stop
   287     _jcmd ManagementAgent.stop
   292 
   288 
   293 _jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   289     _jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
   294 
   290 
   295 _app_stop
   291     _app_stop
   296 }   
   292 }   
   297 
   293 
   298 test_07(){
   294 test_07(){
   299 # Run an app without JMX enabled, but with some properties set 
   295 # Run an app without JMX enabled, but with some properties set 
   300 # in command line.
   296 # in command line.
   301 # make sure these properties overriden corectly 
   297 # make sure these properties overriden corectly 
   302 
   298 
   303 _echo "**** Test seven ****"		
   299     _echo "**** Test seven ****"        
   304 
   300 
   305 _app_start   -Dcom.sun.management.jmxremote.authenticate=false \
   301     _app_start   -Dcom.sun.management.jmxremote.authenticate=false \
   306              -Dcom.sun.management.jmxremote.ssl=true 
   302                  -Dcom.sun.management.jmxremote.ssl=true 
   307 
   303 
   308 res1=`testme $1`
   304     res1=`_testme $1`
   309 
   305 
   310 _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   306     _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   311 
   307 
   312 res2=`testme $2`
   308     res2=`_testme $2`
   313 
   309 
   314 
   310     if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
   315 if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
   311     then
   316 then
   312         echo "Passed"
   317    echo "Passed"
   313     else
   318 else
   314         _echo "Failed r1(NO):${res1} r2(OK):${res2}"
   319 	_echo "Failed r1(NO):${res1} r2(OK):${res2}"
   315         _exit_on_jtreg
   320     _app_stop "Failed"
   316     fi
   321 fi
   317 
   322 
   318     _app_stop
   323 _app_stop
       
   324 }   
   319 }   
   325 
   320 
   326 test_08(){
   321 test_08(){
   327 # Run an app with JMX enabled and with some properties set 
   322 # Run an app with JMX enabled and with some properties set 
   328 # in command line.
   323 # in command line.
   329 # stop JMX agent and then start it again with different property values
   324 # stop JMX agent and then start it again with different property values
   330 # make sure these properties overriden corectly 
   325 # make sure these properties overriden corectly 
   331 
   326 
   332 _echo "**** Test eight ****"		
   327     _echo "**** Test eight ****"        
   333 
   328 
   334 _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   329     _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   335 	    -Dcom.sun.management.jmxremote.authenticate=false \
   330                 -Dcom.sun.management.jmxremote.authenticate=false \
   336 	    -Dcom.sun.management.jmxremote.ssl=true 
   331                 -Dcom.sun.management.jmxremote.ssl=true 
   337 
   332 
   338 res1=`testme $1`
   333     res1=`_testme $1`
   339 
   334 
   340 _jcmd ManagementAgent.stop
   335     _jcmd ManagementAgent.stop
   341 
   336 
   342 res2=`testme $1`
   337     res2=`_testme $1`
   343 
   338 
   344 _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   339     _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
   345 
   340 
   346 res3=`testme $2`
   341     res3=`_testme $2`
   347 
   342 
   348 
   343     if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   349 if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   344     then
   350 then
   345         _echo "Passed"
   351     _echo "Passed"
   346     else
   352 else
   347         _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
   353     _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
   348         _exit_on_jtreg
   354     _app_stop "Failed"
   349     fi
   355 fi
       
   356  
   350  
   357 _app_stop
   351     _app_stop
   358 }   
   352 }   
   359 
   353 
   360 test_09(){
   354 test_09(){
   361 # Run an app with JMX enabled and with some properties set 
   355 # Run an app with JMX enabled and with some properties set 
   362 # in command line.
   356 # in command line.
   363 # stop JMX agent and then start it again with different property values
   357 # stop JMX agent and then start it again with different property values
   364 # specifing some property in management config file and some of them
   358 # specifing some property in management config file and some of them
   365 # in command line
   359 # in command line
   366 # make sure these properties overriden corectly 
   360 # make sure these properties overriden corectly 
   367 
   361 
   368 _echo "**** Test nine ****"		
   362     _echo "**** Test nine ****"     
   369 
   363 
   370 _app_start -Dcom.sun.management.config.file=${_testsrc}/management_cl.properties \
   364     _app_start -Dcom.sun.management.config.file=${_testsrc}/management_cl.properties \
   371            -Dcom.sun.management.jmxremote.authenticate=false 
   365                -Dcom.sun.management.jmxremote.authenticate=false 
   372 
   366 
   373 res1=`testme $1`
   367     res1=`_testme $1`
   374 
   368 
   375 _jcmd ManagementAgent.stop
   369     _jcmd ManagementAgent.stop
   376 
   370 
   377 res2=`testme $1`
   371     res2=`_testme $1`
   378 
   372 
   379 _jcmd ManagementAgent.start config.file=${_testsrc}/management_jcmd.properties \
   373     _jcmd ManagementAgent.start config.file=${_testsrc}/management_jcmd.properties \
   380        jmxremote.authenticate=false jmxremote.port=$2
   374                                 jmxremote.authenticate=false jmxremote.port=$2
   381 
   375 
   382 res3=`testme $2`
   376     res3=`_testme $2`
   383 
   377 
   384 if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   378     if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
   385 then
   379     then
   386     _echo "Passed"
   380         _echo "Passed"
   387 else
   381     else
   388     _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
   382         _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
   389     _app_stop "Failed"
   383         _exit_on_jtreg
   390 fi
   384     fi
   391  
   385  
   392 _app_stop
   386     _app_stop
   393 }   
   387 }   
   394 
   388 
   395 test_10(){
   389 test_10(){
   396 # Run an app with JMX enabled and with some properties set 
   390 # Run an app with JMX enabled and with some properties set 
   397 # in command line.
   391 # in command line.
   398 # stop JMX agent and then start it again with different property values
   392 # stop JMX agent and then start it again with different property values
   399 # stop JMX agent again and then start it without property value
   393 # stop JMX agent again and then start it without property value
   400 # make sure these properties overriden corectly 
   394 # make sure these properties overriden corectly 
   401 
   395 
   402 _echo "**** Test ten ****"		
   396     _echo "**** Test ten ****"      
   403 
   397 
   404 _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   398     _app_start  -Dcom.sun.management.jmxremote.port=$1 \
   405 	    -Dcom.sun.management.jmxremote.authenticate=false \
   399                 -Dcom.sun.management.jmxremote.authenticate=false \
   406 	    -Dcom.sun.management.jmxremote.ssl=true 
   400                 -Dcom.sun.management.jmxremote.ssl=true 
   407 
   401 
   408 res1=`testme $1`
   402     res1=`_testme $1`
   409 
   403 
   410 _jcmd ManagementAgent.stop
   404     _jcmd ManagementAgent.stop
   411 _jcmd ManagementAgent.start jmxremote.ssl=false jmxremote.port=$1
   405     _jcmd ManagementAgent.start jmxremote.ssl=false jmxremote.port=$1
   412 
   406 
   413 
   407 
   414 res2=`testme $1`
   408     res2=`_testme $1`
   415 
   409 
   416 _jcmd ManagementAgent.stop
   410     _jcmd ManagementAgent.stop
   417 _jcmd ManagementAgent.start jmxremote.port=$1
   411     _jcmd ManagementAgent.start jmxremote.port=$1
   418 
   412 
   419 res3=`testme $1`
   413     res3=`_testme $1`
   420 
   414 
   421 if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ] 
   415     if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ] 
   422 then
   416     then
   423     _echo "Passed"
   417         _echo "Passed"
   424 else
   418     else
   425     _echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}"
   419         _echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}"
   426     _app_stop "Failed"
   420         _exit_on_jtreg
   427 fi
   421     fi
   428  
   422  
   429 _app_stop
   423     _app_stop
   430 }   
   424 }   
   431 
   425 
   432 test_11(){
   426 test_11(){
   433 # Run an app with JMX enabled 
   427 # Run an app with JMX enabled 
   434 # stop remote agent 
   428 # stop remote agent 
   435 # make sure local agent is not affected
   429 # make sure local agent is not affected
   436 
   430 
   437 _echo "**** Test eleven ****"		
   431     _echo "**** Test eleven ****"       
   438 
   432 
   439 _app_start  -Dcom.sun.management.jmxremote.port=$2 \
   433     _app_start  -Dcom.sun.management.jmxremote.port=$2 \
   440 	    -Dcom.sun.management.jmxremote.authenticate=false \
   434                 -Dcom.sun.management.jmxremote.authenticate=false \
   441 	    -Dcom.sun.management.jmxremote.ssl=false 
   435                 -Dcom.sun.management.jmxremote.ssl=false 
   442 	  
   436       
   443 res1=`testme $2`
   437     res1=`_testme $2`
   444 
   438 
   445 _jcmd ManagementAgent.stop
   439     _jcmd ManagementAgent.stop
   446 
   440 
   447 pid=`${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"`
   441     pid=`${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"`
   448 res2=`testme local ${pid}`
   442     res2=`_testme local ${pid}`
   449 
   443 
   450 if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ] 
   444     if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ] 
   451 then
   445     then
   452     _echo "Passed"
   446         _echo "Passed"
   453 else
   447     else
   454     _echo "Failed r1(OK):${res1} r2(OK):${res2}"
   448         _echo "Failed r1(OK):${res1} r2(OK):${res2}"
   455     _app_stop "Failed"
   449         _exit_on_jtreg
   456 fi
   450     fi
   457  
   451  
   458 _app_stop
   452     _app_stop
   459 }   
   453 }   
   460 
   454 
   461 test_12(){
   455 test_12(){
   462 # Run an app with JMX disabled 
   456 # Run an app with JMX disabled 
   463 # start local agent only
   457 # start local agent only
   464 
   458 
   465 _echo "**** Test twelve ****"		
   459     _echo "**** Test twelve ****"       
   466 
   460 
   467 _app_start 
   461     _app_start 
   468 	  
   462       
   469 res1=`testme $1`
   463     res1=`_testme $1`
   470 
   464 
   471 _jcmd ManagementAgent.start_local
   465     _jcmd ManagementAgent.start_local
   472 
   466 
   473 pid=`_get_pid`
   467     pid=`_get_pid`
   474 if [ "x${pid}" = "x" ]
   468     if [ "x${pid}" = "x" ]
   475 then
   469     then
   476   res2="NO_CONN"
   470         res2="NO_CONN"
   477 else
   471     else
   478   res2=`testme local ${pid}`
   472         res2=`_testme local ${pid}`
   479 fi
   473     fi
   480 
   474 
   481 if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
   475     if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
   482 then
   476     then
   483     _echo "Passed"
   477         _echo "Passed"
   484 else
   478     else
   485     _echo "Failed r1(NO):${res1} r2(OK):${res2}"
   479         _echo "Failed r1(NO):${res1} r2(OK):${res2}"
   486     _app_stop "Failed"
   480         _exit_on_jtreg
   487 fi
   481     fi
   488  
   482  
   489 _app_stop
   483     _app_stop
   490 }   
   484 }   
   491 
   485 
   492 test_13(){
   486 test_13(){
   493 # Run an app with -javaagent make sure it works as expected - system properties are ignored
   487 # Run an app with -javaagent make sure it works as expected - system properties are ignored
   494 
   488 
   495 _echo "**** Test 13 ****"		
   489     _echo "**** Test thirteen ****"       
   496 
   490 			   
   497 AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
   491     AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
   498 if [ ! -f ${AGENT} ]
   492     if [ ! -f ${AGENT} ]
   499  then
   493     then
   500   AGENT="${TESTJAVA}/lib/management-agent.jar"
   494         AGENT="${TESTJAVA}/lib/management-agent.jar"
   501 fi
   495     fi
   502 
   496 
   503 _app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 
   497     _app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 
   504 	  
   498       
   505 res1=`testme $1`
   499     res1=`_testme $1`
   506 
   500 
   507 if [ "${res1}" = "NO_CONN" ] 
   501     if [ "${res1}" = "NO_CONN" ] 
   508 then
   502     then
   509     _echo "Passed"
   503         _echo "Passed"
   510 else
   504     else
   511     _echo "Failed r1(NO):${res1}"
   505         _echo "Failed r1(NO):${res1}"
   512     _app_stop "Failed"
   506         _exit_on_jtreg
   513 fi
   507     fi
   514  
   508  
   515 _app_stop
   509     _app_stop
   516 }   
   510 }   
   517 
   511 
   518 
       
   519 #============== Server tests =======================
       
   520 
       
   521 server_test_01(){
       
   522 		
       
   523     _echo "**** Server test one ****"		
       
   524 
       
   525     _app_start  -Dcom.sun.management.jmxremote.port=$1 \
       
   526                 -Dcom.sun.management.jmxremote.rmi.port=$2 \
       
   527                 -Dcom.sun.management.jmxremote.authenticate=false \
       
   528                 -Dcom.sun.management.jmxremote.ssl=false 
       
   529 
       
   530 }  
       
   531 
       
   532  
       
   533 # ============= MAIN =======================================
   512 # ============= MAIN =======================================
   534 
   513 
   535 if [ "x${TESTJAVA}" = "x" ]
   514 if [ "x${TESTJAVA}" = "x" ]
   536 then
   515 then
   537   echo "TESTJAVA env have to be set"
   516   echo "TESTJAVA env have to be set"
   540 
   519 
   541 if [ ! -x "${TESTJAVA}/bin/jcmd" ]
   520 if [ ! -x "${TESTJAVA}/bin/jcmd" ]
   542 then
   521 then
   543   echo "${TESTJAVA}/bin/jcmd"
   522   echo "${TESTJAVA}/bin/jcmd"
   544   echo "Doesn't exist or not an executable"
   523   echo "Doesn't exist or not an executable"
   545 
       
   546   if [ "${_verbose}" != "yes" ]
       
   547   then
       
   548     exit
       
   549   fi
       
   550 fi
   524 fi
   551 
   525 
   552 
   526 
   553 #------------------------------------------------------------------------------
   527 #------------------------------------------------------------------------------
   554 # reading parameters 
   528 # reading parameters 
   555 
   529 
   556 for parm in "$@"  
   530 for parm in "$@"  
   557 do
   531 do
   558    case $parm in
   532    case $parm in
   559   --verbose)      _verbose=yes  ;;
       
   560   --server)       _server=yes   ;;
       
   561   --jtreg)        _jtreg=yes    ;;
   533   --jtreg)        _jtreg=yes    ;;
   562   --no-compile)   _compile=no   ;;
   534   --no-compile)   _compile=no   ;;
   563   --testsuite=*)  _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   535   --testsuite=*)  _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   564   --port-one=*)   _port_one=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   536   --port-one=*)   _port_one=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   565   --port-two=*)   _port_two=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   537   --port-two=*)   _port_two=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
   582  _logname="JMXStartStopTest_output.txt"
   554  _logname="JMXStartStopTest_output.txt"
   583 fi
   555 fi
   584 
   556 
   585 rm -f ${_logname}
   557 rm -f ${_logname}
   586 
   558 
   587 # Start server mode tests
   559 # Local mode tests
   588 # All of them require manual cleanup
   560 for i in `echo ${_testsuite} | sed -e "s/,/ /g"`
   589 if [ "x${_server}" = "xyes" ]
   561 do
   590 then
       
   591   
       
   592  server_test_01 ${_port_one} ${_port_two}
       
   593 
       
   594 else
       
   595 
       
   596  # Local mode tests
       
   597  for i in `echo ${_testsuite} | sed -e "s/,/ /g"`
       
   598  do
       
   599   test_${i} ${_port_one} ${_port_two}
   562   test_${i} ${_port_one} ${_port_two}
   600  done
   563 done
   601 
   564 
   602 fi
   565 
   603