# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
# @test
# @bug 7110104
# @build JMXStartStopTest JMXStartStopDoSomething
# @run shell JMXStartStopTest.sh --jtreg --no-compile
# @summary No word Failed expected in the test output
_testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13"
_port_one=50234
_port_two=50235
_testclasses=".classes"
_testsrc=`pwd`
if [ ! -e ${_testclasses} ]
then
mkdir -p ${_testclasses}
fi
# Compile testcase
if [ ! -e ${_testclasses}/JMXStartStopTest.class ]
then
echo "ERROR: Can't compile"
exit -1
fi
}
if [ "${_verbose}" = "yes" ]
then
fi
${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething >> ${_logname} 2>&1 &
sleep 1
if [ "x${pid}" = "x" ]
then
echo "ERROR: Test app not started"
exit -1
fi
}
}
if [ "x${pid}" != "x" ]
then
kill $pid
fi
# Stop on first failed test under jtreg
if [ "x$1" = "xFailed" -a "${_jtreg}" = "yes" ]
then
exit -1
fi
}
${TESTJAVA}/bin/java -cp ${_testclasses} JMXStartStopTest $*
}
if [ "${_verbose}" = "yes" ]
then
else
fi
}
echo "$*"
}
# ============= TESTS ======================================
# Run an app with JMX enabled stop it and
# restart on other port
if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}"
_app_stop "Failed"
fi
}
# Run an app without JMX enabled
# start JMX by jcmd
_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false
if [ "${res1}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(OK):${res1}"
_app_stop "Failed"
fi
}
# Run an app without JMX enabled
# start JMX by jcmd on one port than on other one
_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false
# Second agent shouldn't start
_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
# First agent should connect
if [ "${res1}" = "OK_CONN" ]
then
_echo "Passed $1"
else
_echo "Failed r1(NO):${res1}"
_app_stop "Failed"
fi
#Second agent shouldn't connect
if [ "${res1}" = "NO_CONN" ]
then
_echo "Passed $2"
else
_echo "Failed r1(OK):${res1}"
fi
}
# Run an app without JMX enabled
# start JMX by jcmd on one port, specify rmi port explicitly
_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
# First agent should connect
if [ "${res1}" = "OK_CONN" ]
then
_echo "Passed $1 $2"
else
_echo "Failed r1(NO):${res1}"
_app_stop "Failed"
fi
}
# Run an app without JMX enabled, it will enable local server
# but should leave remote server disabled
# First agent should connect
if [ "${res1}" = "NO_CONN" ]
then
_echo "Passed $1 $2"
else
_echo "Failed r1(OK):${res1}"
_app_stop "Failed"
fi
}
# Run an app without JMX enabled
# start JMX by jcmd on one port, specify rmi port explicitly
# attempt to start it again
# 1) with the same port
# 2) with other port
# 3) attempt to stop it twice
# Check for valid messages in the output
_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false
# First agent should connect
if [ "${res1}" = "OK_CONN" ]
then
_echo "Passed $1 $2"
else
_echo "Failed r1(NO):${res1}"
_app_stop "Failed"
fi
_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false
_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
_jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
}
# Run an app without JMX enabled, but with some properties set
# in command line.
# make sure these properties overriden corectly
_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ]
then
echo "Passed"
else
_echo "Failed r1(NO):${res1} r2(OK):${res2}"
_app_stop "Failed"
fi
}
# Run an app with JMX enabled and with some properties set
# in command line.
# stop JMX agent and then start it again with different property values
# make sure these properties overriden corectly
_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
_app_stop "Failed"
fi
}
# Run an app with JMX enabled and with some properties set
# in command line.
# stop JMX agent and then start it again with different property values
# specifing some property in management config file and some of them
# in command line
# make sure these properties overriden corectly
jmxremote.authenticate=false jmxremote.port=$2
if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
_app_stop "Failed"
fi
}
# Run an app with JMX enabled and with some properties set
# in command line.
# stop JMX agent and then start it again with different property values
# stop JMX agent again and then start it without property value
# make sure these properties overriden corectly
if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}"
_app_stop "Failed"
fi
}
# Run an app with JMX enabled
# stop remote agent
# make sure local agent is not affected
if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(OK):${res1} r2(OK):${res2}"
_app_stop "Failed"
fi
}
# Run an app with JMX disabled
# start local agent only
if [ "x${pid}" = "x" ]
then
res2="NO_CONN"
else
fi
if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(NO):${res1} r2(OK):${res2}"
_app_stop "Failed"
fi
}
# Run an app with -javaagent make sure it works as expected - system properties are ignored
AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
if [ ! -f ${AGENT} ]
then
AGENT="${TESTJAVA}/lib/management-agent.jar"
fi
_app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
if [ "${res1}" = "NO_CONN" ]
then
_echo "Passed"
else
_echo "Failed r1(NO):${res1}"
_app_stop "Failed"
fi
}
#============== Server tests =======================
}
# ============= MAIN =======================================
if [ "x${TESTJAVA}" = "x" ]
then
echo "TESTJAVA env have to be set"
exit
fi
then
echo "Doesn't exist or not an executable"
if [ "${_verbose}" != "yes" ]
then
exit
fi
fi
#------------------------------------------------------------------------------
# reading parameters
do
*)
echo "Undefined parameter $parm. Try --help for help"
exit
;;
esac
done
if [ ${_compile} = "yes" ]
then
fi
if [ ${_jtreg} = "yes" ]
then
fi
# Start server mode tests
# All of them require manual cleanup
if [ "x${_server}" = "xyes" ]
then
else
# Local mode tests
do
done
fi