8199375: [TESTBUG] Open source vm testbase monitoring tests

Reviewed-by: kvn, ihse, sspitsyn
This commit is contained in:
Igor Ignatyev 2018-05-02 16:43:56 -07:00
parent c555679d4f
commit 47bc94b60e
594 changed files with 41275 additions and 2 deletions

View File

@ -59,8 +59,18 @@ VM_SHARE_INCLUDES := \
-I$(VM_TESTBASE_DIR)/nsk/share/native \
-I$(VM_TESTBASE_DIR)/nsk/share/jni
NSK_MONITORING_INCLUDES := \
-I$(VM_TESTBASE_DIR)/nsk/share/native \
-I$(VM_TESTBASE_DIR)/nsk/share/jni
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libDeadlock := $(NSK_MONITORING_INCLUDES)
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libRecursiveMonitoringThread := $(NSK_MONITORING_INCLUDES)
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libLockingThreads := $(NSK_MONITORING_INCLUDES)
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libStackTraceController := $(NSK_MONITORING_INCLUDES)
################################################################################
# Platform specific setup

View File

@ -94,3 +94,19 @@ serviceability/sa/sadebugd/SADebugDTest.java 8163805 generic-all
compiler/c2/Test8007294.java 8194310 generic-all Java EE Module Removal
compiler/c2/Test6852078.java 8194310 generic-all Java EE Module Removal
#############################################################################
# :vmTestbase_*
#############################################################################
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java 8198668 generic-all
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java 8198668 generic-all
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all
#############################################################################

View File

@ -317,3 +317,274 @@ hotspot_rest_runtime = \
-:tier1_runtime_appcds_exclude \
-:hotspot_nmt \
-:hotspot_tier2_runtime_platform_agnostic
# Stress tests against information provided by VM via JMX
vmTestbase_nsk_monitoring = \
vmTestbase/nsk/monitoring
vmTestbase_nsk_monitoring_quick = \
vmTestbase/nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryNotificationInfo/from/from001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryNotificationInfo/getCount/getcount001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsage/getusage005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdSupported/issupported005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdSupported/issupported005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/resetPeakUsage/reset005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setCollectionUsageThreshold/setthreshold005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold002/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold003/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold004/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryPoolMBean/setUsageThreshold/setthreshold005/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryUsage/MemoryUsage/memoryusage001/TestDescription.java \
vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isCurrentThreadCpuTimeSupported/curthcputime005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadContentionMonitoringSupported/thcontmonitor005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/isThreadCpuTimeSupported/thcputime005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/resetPeakThreadCount/reset005/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel002/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel003/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel004/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel005/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel002/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel003/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel004/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel005/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername002/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername003/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername004/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername005/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames002/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames003/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames004/TestDescription.java \
vmTestbase/nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames005/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount002/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount003/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount004/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount005/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime002/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime003/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime004/TestDescription.java \
vmTestbase/nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime005/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean001/RuntimeMXBean001.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean002/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean003/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean004/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean005/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean006/RuntimeMXBean006.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean007/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean008/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean009/TestDescription.java \
vmTestbase/nsk/monitoring/RuntimeMXBean/RuntimeMXBean010/TestDescription.java \
vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java \
vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java \
vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java \
vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java \
vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/TimedWaitingThread/TimedWaitingThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread001/RunningThread001.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/RunningThread/RunningThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SleepingThread/SleepingThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/WaitingThread/WaitingThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/BlockedThread/BlockedThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NativeBlockedThread/NativeBlockedThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/NewThread/NewThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/FinishedThread/FinishedThread005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/LockingThreads/LockingThreads005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/SynchronizerLockingThreads/SynchronizerLockingThreads005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock003/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock004/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock005/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/NativeDeadlock001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizerDeadlock001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/SynchronizedMethodDeadlock001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/MixedDeadlock001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/baseBehaviorTest_proxy_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/illegalArgumentsTest_proxy_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/allocatedMemorySupportedTest_proxy_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/baseBehaviorTest_proxy_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_directly_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_default_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_server_custom_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_default_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/doubleAllocationTest_proxy_custom_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_array/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_directly_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_default_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_server_custom_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_default_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/equalThreadsTest_proxy_custom_string/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/illegalArgumentsTest_proxy_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_directly/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_server_custom/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_default/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/noAllocationTest_proxy_custom/TestDescription.java

View File

@ -0,0 +1,116 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* CompilationMBean.isCompilationTimeMonitoringSupported()
* method returns true. The test performs directly access to management
* metrics within the same JVM.
* Note, that the test is correct ONLY against Sun's Hotspot VM. This
* feature is optional and the method may return either true, or false.
* However, Sun's implementation must always return true.
* The test passes, if the JVM has no compilation system, for example the
* test is invoked with -Xint option.
* COMMENT
* Fixed the bug:
* 4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/timeout=300 nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
*/
package nsk.monitoring.CompilationMXBean.comptimemon001;
import java.io.*;
import nsk.share.test.*;
import nsk.share.TestFailure;
import nsk.monitoring.share.*;
import java.lang.management.*;
public class comptimemon001 extends MonitoringTestBase implements Initializable {
private CompilationMXBean compilation;
private int iterations = 30;
public void initialize() {
if (monitoringFactory.hasCompilationMXBean())
compilation = monitoringFactory.getCompilationMXBean();
}
public boolean testCompilationTimeMonitoringSupported() {
if (compilation == null) {
// The JVM has no compilation system, for example the test is
// invoked with -Xint option
log.info("The JVM has no compilation system.");
return false;
} else if (!compilation.isCompilationTimeMonitoringSupported()) {
// Check the method is... for the specified way of access to MBeans
log.error("Monitoring of compilation time is not supported.\n");
setFailed(true);
return false;
}
return true;
}
private void testCompilationTimeOne() {
long sleepTime = LocalRandom.randomPauseTime();
long startTime = compilation.getTotalCompilationTime();
if (startTime < 0)
throw new TestFailure("getTotalCompilationTime < 0: " + startTime);
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw new TestFailure("Sleep was interrupted.");
}
long finishTime = compilation.getTotalCompilationTime();
if (finishTime < 0)
throw new TestFailure("getTotalCompilationTime < 0: " + finishTime);
if (finishTime < startTime)
throw new TestFailure("getTotalCompilationTime before sleep: " + startTime
+ " > getTotalCompilationTime after sleep: " + finishTime);
}
public void testCompilationTime() {
for (int i = 0; i < iterations; ++i)
testCompilationTimeOne();
}
public void run() {
if (!testCompilationTimeMonitoringSupported())
return;
testCompilationTime();
}
public static void main(String[] args) {
Monitoring.runTest(new comptimemon001(), args);
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* CompilationMBean.isCompilationTimeMonitoringSupported()
* method returns true. The test performs access to management metrics
* through default MBeanServer.
* Note, that the test is correct ONLY against Sun's Hotspot VM. This
* feature is optional and the method may return either true, or false.
* However, Sun's implementation must always return true.
* The test passes, if the JVM has no compilation system, for example the
* test is invoked with -Xint option.
* COMMENTS
* Fixed the bug:
* 4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/timeout=300
* nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
* -testMode=server
*/

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* CompilationMBean.isCompilationTimeMonitoringSupported()
* method returns true. The test performs access to management metrics
* through custom MBeanServer (developed and saved in
* $TESTBASE/src/nsk/monitoring/share).
* Note, that the test is correct ONLY against Sun's Hotspot VM. This
* feature is optional and the method may return either true, or false.
* However, Sun's implementation must always return true.
* The test passes, if the JVM has no compilation system, for example the
* test is invoked with -Xint option.
* COMMENTS
* Fixed the bug:
* 4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/timeout=300
* nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* CompilationMBean.isCompilationTimeMonitoringSupported()
* method returns true. The test performs access to management metrics
* through default MBeanServer proxy.
* Note, that the test is correct ONLY against Sun's Hotspot VM. This
* feature is optional and the method may return either true, or false.
* However, Sun's implementation must always return true.
* The test passes, if the JVM has no compilation system, for example the
* test is invoked with -Xint option.
* COMMENTS
* Fixed the bug:
* 4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/timeout=300
* nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
* -testMode=proxy
*/

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/CompilationMXBean/comptimemon005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* CompilationMBean.isCompilationTimeMonitoringSupported()
* method returns true. The test performs access to management metrics
* through custom MBeanServer proxy (developed and saved in
* $TESTBASE/src/nsk/monitoring/share).
* Note, that the test is correct ONLY against Sun's Hotspot VM. This
* feature is optional and the method may return either true, or false.
* However, Sun's implementation must always return true.
* The test passes, if the JVM has no compilation system, for example the
* test is invoked with -Xint option.
* COMMENTS
* Fixed the bug:
* 4953476 TEST_BUG: The spec is updated accoring to 4944573 and 4947536
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/timeout=300
* nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,142 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters001.
* VM Testbase keywords: [monitoring]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=directly
*/
package nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001;
import java.util.List;
import java.lang.management.*;
import nsk.share.TestFailure;
import nsk.share.test.*;
import nsk.monitoring.share.*;
import nsk.share.gc.Algorithms;
import nsk.share.runner.RunParams;
import nsk.share.runner.RunParamsAware;
/**
* Test counters from GarbageCollectorMXBean.
*
* In this test, we do some operations on heap and check that total
* counters from all GarbageCollectorBeans do not decrease and actually
* increase in some situations.
*
* This also checks that counters increase after MemoryMXBean.gc().
*
* Note: we assume that System.gc() increases collection count and
* time. It may be false with -XX:+DisableExplicitGC.
*/
public class CollectionCounters001 extends MonitoringTestBase implements RunParamsAware, Initializable {
private List<GarbageCollectorMXBean> gcBeans;
private MemoryMXBean memory;
Stresser stresser;
RunParams runParams;
private long collectionCount;
private long collectionTime;
private long collectionCountOld;
private long collectionTimeOld;
public void initialize() {
gcBeans = monitoringFactory.getGarbageCollectorMXBeans();
memory = monitoringFactory.getMemoryMXBean();
}
private void runOne(ExecutionController stresser) {
updateCounters();
validate();
Algorithms.eatMemory(stresser);
if(stresser.continueExecution()) {
updateCounters();
validateNonTrivial();
System.gc();
updateCounters();
validateNonTrivial();
memory.gc();
updateCounters();
validateNonTrivial();
}
}
public void run() {
stresser = new Stresser(runParams.getStressOptions());
stresser.start(runParams.getIterations());
while (stresser.iteration()) {
runOne(stresser);
}
}
private void validate() {
if (collectionCount < 0)
throw new TestFailure("collectionCount negative: " + collectionCount);
if (collectionTime < 0)
throw new TestFailure("collectionTime negative: " + collectionTime);
if (collectionCount < collectionCountOld)
throw new TestFailure("collectionCount decreased: " + collectionCount + " -> " + collectionCountOld);
if (collectionTime < collectionTimeOld)
throw new TestFailure("collectionTime decreased: " + collectionTime + " -> " + collectionTimeOld);
}
private void validateNonTrivial() {
if (collectionCount < 0)
throw new TestFailure("collectionCount negative: " + collectionCount);
if (collectionTime < 0)
throw new TestFailure("collectionTime negative: " + collectionTime);
if (collectionCount <= collectionCountOld)
throw new TestFailure("collectionCount not increased: " + collectionCount + " -> " + collectionCountOld);
if (collectionTime < collectionTimeOld)
throw new TestFailure("collection time became smaller: " + collectionTime + " -> " + collectionTimeOld);
}
private void updateCounters() {
collectionCountOld = collectionCount;
collectionTimeOld = collectionTime;
collectionCount = 0;
collectionTime = 0;
for (GarbageCollectorMXBean gcBean : gcBeans) {
collectionCount += gcBean.getCollectionCount();
collectionTime += gcBean.getCollectionTime();
}
}
public static void main(String[] args) {
Monitoring.runTest(new CollectionCounters001(), args);
}
@Override
public void setRunParams(RunParams runParams) {
this.runParams = runParams;
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters002.
* VM Testbase keywords: [monitoring]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters003.
* VM Testbase keywords: [monitoring]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters004.
* VM Testbase keywords: [monitoring]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters005.
* VM Testbase keywords: [monitoring]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.GarbageCollectorMXBean.getCollectionCount;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getcollectioncount001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
// Test case 1. check that
// getCollectionCount() does not throw unexpected exceptions
System.gc();
System.gc();
System.gc();
GarbageCollectorMonitor gcMonitor =
Monitor.getGarbageCollectorMonitor(log, argumentHandler);
Object[] pool = gcMonitor.getGarbageCollectorMXBeans();
for (int i=0; i<pool.length; i++) {
String beanName = "";
long collectionCount = gcMonitor.getCollectionCount(pool[i]);
if (pool[i] instanceof javax.management.ObjectName) {
beanName = ((javax.management.ObjectName)pool[i]).toString();
} else {
beanName = ((java.lang.management.GarbageCollectorMXBean)
pool[i]).getName();
}
log.display(beanName+": getCollectionCount() = "+collectionCount);
if (collectionCount < -1) {
// value can be non-negative or -1 if if the collection count
// is undefined for this collector.
log.complain("FAILURE 1.");
log.complain("getCollectionCount() returns unexpected value: " +
collectionCount);
testFailed = true;
}
}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionCount()
* This method returns the total number of collections that have occurred
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
*/

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionCount()
* This method returns the total number of collections that have occurred
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionCount()
* This method returns the total number of collections that have occurred
* Access to metrics is provided in following way: custom MBeanServer.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionCount()
* This method returns the total number of collections that have occurred
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionCount/getcollectioncount005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionCount()
* This method returns the total number of collections that have occurred
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionCount.getcollectioncount001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.GarbageCollectorMXBean.getCollectionTime;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getcollectiontime001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
// Test case 1. check that
// getCollectionTime() does not throw unexpected exceptions
System.gc();
System.gc();
System.gc();
GarbageCollectorMonitor gcMonitor = Monitor.getGarbageCollectorMonitor(
log,
argumentHandler);
Object[] pool = gcMonitor.getGarbageCollectorMXBeans();
for (int i=0; i<pool.length; i++) {
String beanName = "";
long collectionTime = gcMonitor.getCollectionTime(pool[i]);
if (pool[i] instanceof javax.management.ObjectName) {
beanName = ((javax.management.ObjectName)pool[i]).toString();
} else {
beanName = ((java.lang.management.GarbageCollectorMXBean)
pool[i]).getName();
}
log.display(beanName+": getCollectionTime() = "+collectionTime);
if (collectionTime < -1) {
// value can be non-negative or -1 if if the collection elapsed
// time is undefined for this collector.
log.complain("FAILURE 1.");
log.complain("getCollectionTime() returns unexpected value: " +
collectionTime);
testFailed = true;
}
}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionTime()
* This method returns the approximate accumulated collection elapsed time
* in milliseconds
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionTime()
* This method returns the approximate accumulated collection elapsed time
* in milliseconds
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionTime()
* This method returns the approximate accumulated collection elapsed time
* in milliseconds
* Access to metrics is provided in following way: custom MBeanServer.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionTime()
* This method returns the approximate accumulated collection elapsed time
* in milliseconds
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/getCollectionTime/getcollectiontime005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.GarbageCollectorMXBean
* Method: getCollectionTime()
* This method returns the approximate accumulated collection elapsed time
* in milliseconds
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. Returns the total number of collections that have occurred.
* 2. This method returns -1 if the collection count is undefined for this
* collector.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.GarbageCollectorMXBean.getCollectionTime.getcollectiontime001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,193 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LockTest/LockTest001.
* VM Testbase keywords: [monitoring, vm6]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LockTest.LockTest001.LockTest001
*/
package nsk.monitoring.LockTest.LockTest001;
import java.lang.management.ThreadInfo;
import java.lang.management.ManagementFactory;
import nsk.share.TestFailure;
public class LockTest001
{
private Object syncObj = new Object();
public LockTest001()
{ }
public void test()
{
int localVar0, localVar1, localVar2, localVar3, localVar4, localVar5, localVar6, localVar7, localVar8, localVar9;
int localVar10, localVar11, localVar12, localVar13, localVar14, localVar15, localVar16, localVar17, localVar18, localVar19;
int localVar20, localVar21, localVar22, localVar23, localVar24, localVar25, localVar26, localVar27, localVar28, localVar29;
int localVar30, localVar31, localVar32, localVar33, localVar34, localVar35, localVar36, localVar37, localVar38, localVar39;
int localVar40, localVar41, localVar42, localVar43, localVar44, localVar45, localVar46, localVar47, localVar48, localVar49;
String threadName = Thread.currentThread().getName();
System.out.println(threadName + ": Entering test()");
synchronized (syncObj)
{
int n = 0;
for (int i = 0; i < 10000000; i++)
n += i;
logMonitors((n & 1) >>> (n & 1));
} // end sync
logMonitors(1);
synchronized (syncObj)
{
logMonitors(2);
}
logMonitors(3);
System.out.println(threadName + ": Leaving test()");
return;
}
public static void logMonitors(int n)
{
String threadName = Thread.currentThread().getName();
java.lang.management.MonitorInfo[] monitors = java.lang.management.ManagementFactory.getThreadMXBean()
.getThreadInfo(new long[] { Thread.currentThread().getId() }, true, true)[0].getLockedMonitors();
System.out.println(threadName + ": Checkpoint #" + n + ", number of monitors: " + monitors.length);
if ((n == 3) && (monitors.length > 0))
System.out.println(threadName + ": MONITOR HELD AFTER EXITING SYNCHRONIZED BLOCK!");
for (int i = 0; i < monitors.length; i++)
{
java.lang.management.MonitorInfo monitor = monitors[i];
System.out.println(threadName + ": MonitorInfo[" + i + "]=" + monitor.toString() + ", StackDepth=" + monitor.getLockedStackDepth()
+ ", frame=" + ((monitor.getLockedStackFrame() == null) ? "No Frame" : monitor.getLockedStackFrame().toString()));
}
return;
}
public static void main(String[] argv)
{
LockTest001 lt = new LockTest001();
RunLockTest rlt = new RunLockTest(lt, 10000);
Thread t = new Thread(rlt);
System.out.println("main: About to start first thread: " + t.getName());
t.start();
synchronized (rlt)
{
while (!rlt.finishedTest)
{
try
{ rlt.wait(); }
catch (Exception e)
{ }
}
}
rlt = new RunLockTest(lt, 0);
t = new Thread(rlt);
System.out.println("main: About to start second thread: " + t.getName());
t.start();
// amount of time to wait for the thread. In case of buggy behavior, the thread will hang forever.
// but long enough to complete test on busy boxes
long endTime = System.currentTimeMillis() + 5 * 60 * 1000;
boolean isError = true;
while (System.currentTimeMillis() < endTime)
{
if (t.getState() == Thread.State.TERMINATED)
{
isError = false;
break;
}
try
{ Thread.currentThread().sleep(1000); }
catch (Exception e)
{ }
ThreadInfo[] tis = ManagementFactory.getThreadMXBean().getThreadInfo(new long[] { t.getId() }, true, true);
if (tis.length == 0)
System.out.println("Unable to find the thread " + t.getName());
else
{
ThreadInfo ti = tis[0];
if (ti == null)
System.out.println("Unable to get info for thread: " + t.getName());
else
System.out.println(t.getName() + " state: " + ti.getThreadState().toString() +
", LockName: " + ti.getLockName() + ", LockOwnerName: " + ti.getLockOwnerName());
}
}
if (!isError)
System.out.println("TEST PASSED");
else
throw new TestFailure("TEST FAILED");
return;
}
public static class RunLockTest implements Runnable
{
public LockTest001 lt;
public boolean finishedTest = false;
public long sleepLength;
public RunLockTest(LockTest001 _lt, long _sleepLength)
{
lt = _lt;
sleepLength = _sleepLength;
}
public void run()
{
lt.test();
synchronized (this)
{
finishedTest = true;
this.notify();
}
if (sleepLength > 0)
{
try
{ Thread.currentThread().sleep(sleepLength); }
catch (Exception e)
{ }
}
System.out.println(Thread.currentThread().getName() + ": exiting");
return;
}
}
}

View File

@ -0,0 +1,180 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LockTest/LockTest002.
* VM Testbase keywords: [monitoring, vm6]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LockTest.LockTest002.LockTest002
*/
package nsk.monitoring.LockTest.LockTest002;
import java.lang.management.ThreadInfo;
import java.lang.management.ManagementFactory;
import nsk.share.TestFailure;
public class LockTest002
{
private Object syncObj = new Object();
public LockTest002()
{ }
public synchronized void test()
{
int localVar0, localVar1, localVar2, localVar3, localVar4, localVar5, localVar6, localVar7, localVar8, localVar9;
int localVar10, localVar11, localVar12, localVar13, localVar14, localVar15, localVar16, localVar17, localVar18, localVar19;
int localVar20, localVar21, localVar22, localVar23, localVar24, localVar25, localVar26, localVar27, localVar28, localVar29;
int localVar30, localVar31, localVar32, localVar33, localVar34, localVar35, localVar36, localVar37, localVar38, localVar39;
int localVar40, localVar41, localVar42, localVar43, localVar44, localVar45, localVar46, localVar47, localVar48, localVar49;
String threadName = Thread.currentThread().getName();
System.out.println(threadName + ": Entering test()");
int n = 0;
for (int i = 0; i < 10000000; i++)
n += i;
System.out.println(threadName + ": Leaving test(), n=" + n);
return;
}
public static void logMonitors()
{
String threadName = Thread.currentThread().getName();
java.lang.management.MonitorInfo[] monitors = java.lang.management.ManagementFactory.getThreadMXBean()
.getThreadInfo(new long[] { Thread.currentThread().getId() }, true, true)[0].getLockedMonitors();
System.out.println(threadName + ": Number of monitors: " + monitors.length);
for (int i = 0; i < monitors.length; i++)
{
java.lang.management.MonitorInfo monitor = monitors[i];
System.out.println(threadName + ": MonitorInfo[" + i + "]=" + monitor.toString() + ", StackDepth=" + monitor.getLockedStackDepth()
+ ", frame=" + ((monitor.getLockedStackFrame() == null) ? "No Frame" : monitor.getLockedStackFrame().toString()));
}
return;
}
public static void main(String[] argv)
{
LockTest002 lt = new LockTest002();
RunLockTest rlt = new RunLockTest(lt, 10000);
Thread t = new Thread(rlt);
System.out.println("main: About to start first thread: " + t.getName());
t.start();
synchronized (rlt)
{
while (!rlt.finishedTest)
{
try
{ rlt.wait(); }
catch (Exception e)
{ }
}
}
rlt = new RunLockTest(lt, 0);
t = new Thread(rlt);
System.out.println("main: About to start second thread: " + t.getName());
t.start();
// amount of time to wait for the thread. In case of buggy behavior, the thread will hang forever.
// but long enough to complete test on busy boxes
long endTime = System.currentTimeMillis() + 5 * 60 * 1000;
boolean isError = true;
while (System.currentTimeMillis() < endTime)
{
if (t.getState() == Thread.State.TERMINATED)
{
isError = false;
break;
}
try
{ Thread.currentThread().sleep(1000); }
catch (Exception e)
{ }
ThreadInfo[] tis = ManagementFactory.getThreadMXBean().getThreadInfo(new long[] { t.getId() }, true, true);
if (tis.length == 0)
System.out.println("Unable to find the thread " + t.getName());
else
{
ThreadInfo ti = tis[0];
if (ti == null)
System.out.println("Unable to get info for thread: " + t.getName());
else
System.out.println(t.getName() + " state: " + ti.getThreadState().toString() +
", LockName: " + ti.getLockName() + ", LockOwnerName: " + ti.getLockOwnerName());
}
}
if (!isError)
System.out.println("TEST PASSED");
else
throw new TestFailure("TEST FAILED");
return;
}
public static class RunLockTest implements Runnable
{
public LockTest002 lt;
public boolean finishedTest = false;
public long sleepLength;
public RunLockTest(LockTest002 _lt, long _sleepLength)
{
lt = _lt;
sleepLength = _sleepLength;
}
public void run()
{
logMonitors();
lt.test();
logMonitors();
synchronized (this)
{
finishedTest = true;
this.notify();
}
if (sleepLength > 0)
{
try
{ Thread.currentThread().sleep(sleepLength); }
catch (Exception e)
{ }
}
System.out.println(Thread.currentThread().getName() + ": exiting");
return;
}
}
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.LoggingMXBean.getLoggerLevel;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
import java.util.logging.*;
public class getloggerlevel001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
private static final Level[] LogLevels = new Level[] {
Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
};
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
argumentHandler);
// Test case 1. check that
// it returns the name of the log level associated with the specified
// logger
String testLog1Name = getloggerlevel001.class.getName();
Logger testLog1 = Logger.getLogger(testLog1Name);
for (int i=0; i<LogLevels.length; i++) {
testLog1.setLevel(LogLevels[i]);
String mxbeanLevel = loggingMonitor.getLoggerLevel(testLog1Name);
if (! LogLevels[i].toString().equals(mxbeanLevel)) {
testFailed = true;
log.complain("Failure 1.");
log.complain("LogLevels[i] = "+LogLevels[i].toString());
log.complain("loggingMXBean.getLoggerLevel() method returns "
+ "unexpected value");
}
}
// Test case 2. check
// if the specified logger does not exist, null is returned
if (loggingMonitor.getLoggerLevel("no such logger") != null) {
testFailed = true;
log.complain("Failure 2.");
log.complain("loggingMXBean.getLoggerLevel(\"no such logger\") does "
+ "not return null");
}
// A Logger object created with the call Logger.getLogger(testLogName),
// stores it in a method local and expects it to be alive in the method scope
// after it is not used anymore.
// The java.util.logging.LogManager which is used by loggingMonitor stores a WeakReference to
// the Logger object being created into a Hashtable.
// The WeakReference becomes stale after a GC event, so the tests
// are not able to retrieve the expected info about the parent logger
// using the child logger name.
//
// So this synchronized block is needed to guarantee that testLog1 will still be alive
// when loggingMonitor.getLoggerLevel is invoked
synchronized (testLog1) {
// Test case 3. check
// if the Level of the specified logger is null, an empty string will
// be returned.
testLog1.setLevel(null);
String returnedLevel = loggingMonitor.getLoggerLevel(testLog1Name);
if (returnedLevel == null || !returnedLevel.equals("")) {
testFailed = true;
log.complain("Failure 3.");
log.complain("Level of the specified logger is null, but returned "
+ "string was not empty: "+returnedLevel);
}
}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerLevel(String loggerName)
* This method first finds the logger of the given name and then returns
* the name of the log level
* by calling: Logger.getLevel().getName()
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. it returns the name of the log level associated with the specified
* logger
* 2. if the specified logger does not exist, null is returned
* 3. if the Level of the specified logger is null, which means that this
* logger's effective level
* is inherited from its parent, an empty string will be returned
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
*/

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerLevel(String loggerName)
* This method first finds the logger of the given name and then returns
* the name of the log level
* by calling: Logger.getLevel().getName()
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. it returns the name of the log level associated with the specified
* logger
* 2. if the specified logger does not exist, null is returned
* 3. if the Level of the specified logger is null, which means that this
* logger's effective level
* is inherited from its parent, an empty string will be returned
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerLevel(String loggerName)
* This method first finds the logger of the given name and then returns
* the name of the log level
* by calling: Logger.getLevel().getName()
* Access to metrics is provided in following way: custom MBeanServer.
* The test checks that
* 1. it returns the name of the log level associated with the specified
* logger
* 2. if the specified logger does not exist, null is returned
* 3. if the Level of the specified logger is null, which means that this
* logger's effective level
* is inherited from its parent, an empty string will be returned
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerLevel(String loggerName)
* This method first finds the logger of the given name and then returns
* the name of the log level
* by calling: Logger.getLevel().getName()
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. it returns the name of the log level associated with the specified
* logger
* 2. if the specified logger does not exist, null is returned
* 3. if the Level of the specified logger is null, which means that this
* logger's effective level
* is inherited from its parent, an empty string will be returned
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerLevel/getloggerlevel005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerLevel(String loggerName)
* This method first finds the logger of the given name and then returns
* the name of the log level
* by calling: Logger.getLevel().getName()
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. it returns the name of the log level associated with the specified
* logger
* 2. if the specified logger does not exist, null is returned
* 3. if the Level of the specified logger is null, which means that this
* logger's effective level
* is inherited from its parent, an empty string will be returned
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerLevel.getloggerlevel001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,134 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.LoggingMXBean.getLoggerNames;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
import java.util.*;
import java.util.logging.*;
import javax.management.*;
public class getloggernames001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
private static final Level[] LogLevels = new Level[] {
Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
};
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
argumentHandler);
// Test case 1. check that
// This method calls LogManager.getLoggerNames() and returns a
// list of the logger names
// create logger
String testLog1Name = getloggernames001.class.getName();
Logger testLog1 = Logger.getLogger(testLog1Name);
Enumeration loggerNamesEn = LogManager.getLogManager().getLoggerNames();
List loggerMXBeanNamesList = loggingMonitor.getLoggerNames();
// check that all elements from loggerNamesEn contain in
// loggerMXBeanNamesList
while (loggerNamesEn.hasMoreElements()) {
Object loggerName = loggerNamesEn.nextElement();
//log.display("loggerName="+loggerName);
boolean isInvolved = false;
for (int i=0; i<loggerMXBeanNamesList.size(); i++) {
Object loggerMXBeanName = loggerMXBeanNamesList.get(i);
if ( loggerName.equals(loggerMXBeanName) ) {
isInvolved = true;
break;
}
}
if (! isInvolved) {
log.complain("FAILURE 1.");
log.complain("LoggingMonitor.getLoggerNames() does not return "
+ "the next logger name: "+loggerName);
testFailed = true;
}
}
// check that all elements from loggerMXBeanNamesList contain in
// loggerNamesEn
loggerNamesEn = LogManager.getLogManager().getLoggerNames();
for (int i=0; i<loggerMXBeanNamesList.size(); i++) {
Object loggerMXBeanName = loggerMXBeanNamesList.get(i);
//log.display("loggerMXBeanName="+loggerMXBeanName);
boolean isInvolved = false;
while (loggerNamesEn.hasMoreElements()) {
Object loggerName = loggerNamesEn.nextElement();
if ( loggerName.equals(loggerMXBeanName) ) {
isInvolved = true;
break;
}
}
if (! isInvolved) {
log.complain("FAILURE 2.");
log.complain("LoggingMonitor.getLoggerNames() does not return "
+ "unknown logger name: "+loggerMXBeanName);
testFailed = true;
}
}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerNames()
* Returns the list of currently registered loggers
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. This method calls LogManager.getLoggerNames() and returns a
* list of the logger names.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
*/

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerNames()
* Returns the list of currently registered loggers
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. This method calls LogManager.getLoggerNames() and returns a
* list of the logger names.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerNames()
* Returns the list of currently registered loggers
* Access to metrics is provided in following way: custom MBeanServer.
* The test checks that
* 1. This method calls LogManager.getLoggerNames() and returns a
* list of the logger names.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerNames()
* Returns the list of currently registered loggers
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. This method calls LogManager.getLoggerNames() and returns a
* list of the logger names.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getLoggerNames/getloggernames005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getLoggerNames()
* Returns the list of currently registered loggers
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. This method calls LogManager.getLoggerNames() and returns a
* list of the logger names.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getLoggerNames.getloggernames001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.LoggingMXBean.getParentLoggerName;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
import java.util.logging.*;
public class getparentloggername001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
LoggingMonitor loggingMonitor = Monitor.getLoggingMonitor(log,
argumentHandler);
// Test case 1. check that
// it returns the name of the parent for the specified logger
String testLogName = getparentloggername001.class.getName()+".child";
String testLogParentName = getparentloggername001.class.getName();
Logger testLog = Logger.getLogger(testLogName);
Logger testLogParent = Logger.getLogger(testLogParentName);
// This synchronized block guarantees that testLog will still be alive
// when loggingMonitor is getting an information about logger
synchronized (testLog) {
synchronized (testLogParent) {
String mxbeanParentName = loggingMonitor.getParentLoggerName(
testLogName);
if (! testLogParentName.equals(mxbeanParentName)) {
testFailed = true;
log.complain("Failure 1.");
log.complain("loggingMXBean.getParentLoggerName() returns "
+ "unexpected name of parent logger");
log.complain("Parent name is "+testLogParentName+", obtained name "
+"is "+mxbeanParentName);
}
// Test case 2. check
// if the specified logger does not exist, null is returned
if (loggingMonitor.getParentLoggerName("no such logger") != null) {
testFailed = true;
log.complain("Failure 2.");
log.complain("loggingMXBean.getParentLoggerName(\"no such logger\") "
+ "does not return null");
}
// Test case 3. check
// if the specified logger is the root Logger in the namespace, the
// result will be an empty string.
String parentName = loggingMonitor.getParentLoggerName(
testLogParentName);
if (parentName == null || !parentName.equals("")) {
testFailed = true;
log.complain("Failure 3.");
log.complain("The specified logger was the root Logger in the "
+ "namespace, but returned string is not empty: "+parentName);
}
}}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getParentLoggerName(String loggerName)
* Returns the name of the parent for the specified logger.
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. it returns the name of the parent for the specified logger
* 2. if the specified logger does not exist, null is returned
* 3. if the specified logger is the root Logger in the namespace, the
* result will be an empty string
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getParentLoggerName(String loggerName)
* Returns the name of the parent for the specified logger.
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. it returns the name of the parent for the specified logger
* 2. if the specified logger does not exist, null is returned
* 3. if the specified logger is the root Logger in the namespace, the
* result will be an empty string
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getParentLoggerName(String loggerName)
* Returns the name of the parent for the specified logger.
* Access to metrics is provided in following way: custom MBeanServer.
* The test checks that
* 1. it returns the name of the parent for the specified logger
* 2. if the specified logger does not exist, null is returned
* 3. if the specified logger is the root Logger in the namespace, the
* result will be an empty string
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getParentLoggerName(String loggerName)
* Returns the name of the parent for the specified logger.
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. it returns the name of the parent for the specified logger
* 2. if the specified logger does not exist, null is returned
* 3. if the specified logger is the root Logger in the namespace, the
* result will be an empty string
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/getParentLoggerName/getparentloggername005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: getParentLoggerName(String loggerName)
* Returns the name of the parent for the specified logger.
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. it returns the name of the parent for the specified logger
* 2. if the specified logger does not exist, null is returned
* 3. if the specified logger is the root Logger in the namespace, the
* result will be an empty string
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.getParentLoggerName.getparentloggername001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,94 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.LoggingMXBean.setLoggerLevel;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import nsk.monitoring.share.*;
import java.util.logging.*;
public class setloggerlevel001 {
private static boolean testFailed = false;
public static void main(String[] args) {
System.exit(Consts.JCK_STATUS_BASE + run(args, System.out));
}
private static Log log;
private static final Level[] LogLevels = new Level[] {
Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
};
static int run(String[] args, PrintStream out) {
ArgumentHandler argumentHandler = new ArgumentHandler(args);
log = new Log(out, argumentHandler);
LoggingMXBean loggingMXBean = LogManager.getLoggingMXBean();
// Test case 1. check that
// if the levelName is not null, the level of the specified
// logger is set to the parsed Level matching the levelName
String testLog1Name = setloggerlevel001.class.getName();
Logger testLog1 = Logger.getLogger(testLog1Name);
for (int i=0; i<LogLevels.length; i++) {
loggingMXBean.setLoggerLevel(testLog1Name, LogLevels[i].toString());
if (! LogLevels[i].equals(testLog1.getLevel())) {
testFailed = true;
log.complain("Failure 1.");
log.complain("LogLevels[i] = "+LogLevels[i].toString());
log.complain("testLog1.getLevel() = "+testLog1.getLevel());
log.complain("loggingMXBean.setLoggerLevel() failed");
}
}
// Test case 2. check
// if the levelName is null, the level of the specified logger is set
// to null
loggingMXBean.setLoggerLevel(testLog1Name, null);
if (testLog1.getLevel() != null) {
testFailed = true;
log.complain("Failure 2.");
log.complain("Level of the specified logger was not set to null: "+
testLog1.getLevel());
}
if (testFailed)
log.complain("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: setLoggerLevel(java.lang.String loggerName,
* java.lang.String levelName)
* sets the specified logger to the specified new level
* Access to metrics is provided in following way: directly.
* The test checks that
* 1. if the levelName is not null, the level of the specified
* logger is set to the parsed Level matching the levelName
* 2. if the levelName is null, the level of the specified logger
* is set to null
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: setLoggerLevel(java.lang.String loggerName,
* java.lang.String levelName)
* sets the specified logger to the specified new level
* Access to metrics is provided in following way: default MBeanServer.
* The test checks that
* 1. if the levelName is not null, the level of the specified
* logger is set to the parsed Level matching the levelName
* 2. if the levelName is null, the level of the specified logger
* is set to null
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
* -testMode=server
* -MBeanServer=default
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: setLoggerLevel(java.lang.String loggerName,
* java.lang.String levelName)
* sets the specified logger to the specified new level
* Access to metrics is provided in following way: custom MBean.
* The test checks that
* 1. if the levelName is not null, the level of the specified
* logger is set to the parsed Level matching the levelName
* 2. if the levelName is null, the level of the specified logger
* is set to null
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: setLoggerLevel(java.lang.String loggerName,
* java.lang.String levelName)
* sets the specified logger to the specified new level
* Access to metrics is provided in following way: default MBeanServer
* through proxy.
* The test checks that
* 1. if the levelName is not null, the level of the specified
* logger is set to the parsed Level matching the levelName
* 2. if the levelName is null, the level of the specified logger
* is set to null
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
* -testMode=proxy
* -MBeanServer=default
*/

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/LoggingMXBean/setLoggerLevel/setloggerlevel005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Interface: java.util.logging.LoggingMXBean
* Method: setLoggerLevel(java.lang.String loggerName,
* java.lang.String levelName)
* sets the specified logger to the specified new level
* Access to metrics is provided in following way: custom MBeanServer
* through proxy.
* The test checks that
* 1. if the levelName is not null, the level of the specified
* logger is set to the parsed Level matching the levelName
* 2. if the levelName is null, the level of the specified logger
* is set to null
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.LoggingMXBean.setLoggerLevel.setloggerlevel001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryNotificationInfo.MemoryNotificationInfo;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
public class info001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
test("name", mu, 1, out, "if correct parameters are passed.");
test("", mu, 1, out, "if empty pool name is passed.");
test(null, mu, 1, out, "if null pool name is passed.");
test("name", null, 1, out, "if null MemoryUsage is passed.");
test("name", mu, -2, out, "if negative count is passed.");
test("name", mu, 0, out, "if zero count is passed.");
test("name", mu, Long.MAX_VALUE, out, "if Long.MAX_VALUE, count is "
+ "passed.");
test("name", mu, Long.MIN_VALUE, out, "if Long.MIN_VALUE, count is "
+ "passed.");
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
private static void test(String name, MemoryUsage usage, long count,
PrintStream out, String message) {
MemoryNotificationInfo info;
try {
info = new MemoryNotificationInfo(name, usage, count);
if ((name == null) || (usage == null)) {
out.println("NullPointerException was not thrown, " + message);
testFailed = true;
}
} catch (NullPointerException e) {
if ((name != null) && (usage != null)) {
out.println("Unexpected NullPointerException, " + message);
e.printStackTrace(out);
testFailed = true;
}
} catch (Exception e) {
out.println("Exception, " + message);
e.printStackTrace(out);
testFailed = true;
}
} // test()
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/MemoryNotificationInfo/info001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that constructor
* MemoryNotificationInfo()
* does not throw any exception for various sets of arguments:
* 1. correct set of arguments;
* 2. empty pool name;
* 3. negative count;
* 4. zero count;
* 5. Long.MAX_VALUE as count;
* 6. Long.MIN_VALUE as count.
* NullpointerException is expected for the following sets of arguments:
* 1. null pool name;
* 2. null MemoryUsage;
* COMMENT
* Fixed the bug:
* 5013995 null pointer exception in MM nsk test todata001.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryNotificationInfo.MemoryNotificationInfo.info001
*/

View File

@ -0,0 +1,201 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryNotificationInfo.from;
import java.lang.management.*;
import javax.management.*;
import javax.management.openmbean.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.SynchronousQueue;
import nsk.share.*;
import nsk.share.gc.Algorithms;
import nsk.share.gc.Memory;
import nsk.share.gc.gp.GarbageUtils;
import nsk.monitoring.share.*;
import nsk.share.test.Stresser;
public class from001 {
private static boolean testFailed = false;
public static void main(String[] args) {
ArgumentHandler argHandler = new ArgumentHandler(args);
Log log = new Log(System.out, argHandler);
log.display("MemoryNotificationInfo/from/from001/from001.java test started.");
MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
MBeanServer mbs = Monitor.getMBeanServer();
// 1. Check null CompositeData - null must be returned
MemoryNotificationInfo result = MemoryNotificationInfo.from(null);
if (result != null) {
log.complain("FAILURE 1.");
log.complain("MemoryNotificationInfo.from(null) returned " + result
+ ", expected: null.");
testFailed = true;
}
log.display("null CompositeData check passed.");
// 2. Check CompositeData that doest not represnt
// MemoryNotificationInfo - IllegalArgumentException must be thrown
ObjectName mbeanObjectName = null;
CompositeData cdata = null;
try {
mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
cdata = (CompositeData )mbs.getAttribute(mbeanObjectName,
"HeapMemoryUsage");
} catch (Exception e) {
log.complain("Unexpected exception " + e);
e.printStackTrace(log.getOutStream());
testFailed = true;
}
try {
result = MemoryNotificationInfo.from(cdata);
log.complain("FAILURE 2.");
log.complain("MemoryNotificationInfo.from(CompositeData) returned "
+ result + ", expected: IllegalArgumentException.");
testFailed = true;
} catch (IllegalArgumentException e) {
// Expected: CompositeData doest not represnt MemoryNotificationInfo
}
log.display("check for CompositeData doest not represnt MemoryNotificationInfo passed.");
// 3. Check correct CompositeData
Object poolObject = null;
try {
mbeanObjectName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
mbs.addNotificationListener(mbeanObjectName, new from001Listener(),
null, null);
List<?> pools = monitor.getMemoryPoolMBeans();
if (pools.isEmpty()) {
log.complain("No Memory Pool Beans found. Test case will hang/fail.");
testFailed = true;
}
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
if (monitor.isUsageThresholdSupported(pool)) {
if (monitor.getType(pool).equals(MemoryType.HEAP)) {
poolObject = pool;
monitor.setUsageThreshold(pool, 1);
log.display("Usage threshold set for pool :" + poolObject);
break;
}
}
}
} catch (Exception e) {
log.complain("Unexpected exception " + e);
e.printStackTrace(log.getOutStream());
testFailed = true;
}
if (testFailed) {
throw new TestFailure("TEST FAILED. See log.");
}
// eat memory just to emmit notification
Stresser stresser = new Stresser(args) {
@Override
public boolean continueExecution() {
return from001Listener.data.get() == null
&& super.continueExecution();
}
};
stresser.start(0);// we use timeout, not iterations
GarbageUtils.eatMemory(stresser);
boolean messageNotRecieved = true;
while(messageNotRecieved) {
try {
from001Listener.queue.take();
messageNotRecieved = false;
} catch (InterruptedException e) {
messageNotRecieved = true;
}
}
result = MemoryNotificationInfo.from(from001Listener.data.get());
try {
ObjectName poolObjectName = new ObjectName(monitor.getName(poolObject));
ObjectName resultObjectName = new ObjectName(
ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE +
",name=" + result.getPoolName());
log.display("poolObjectName : " + poolObjectName +
" resultObjectName : " + resultObjectName);
if (!poolObjectName.equals(resultObjectName)) {
log.complain("FAILURE 3.");
log.complain("Wrong pool name : " + resultObjectName +
", expected : " + poolObjectName);
testFailed = true;
}
} catch (Exception e) {
log.complain("Unexpected exception " + e);
e.printStackTrace(log.getOutStream());
testFailed = true;
}
if (testFailed) {
throw new TestFailure("TEST FAILED. See log.");
}
log.display("Test passed.");
}
}
class from001Listener implements NotificationListener {
static AtomicReference<CompositeData> data = new AtomicReference<CompositeData>();
static SynchronousQueue<Object> queue = new SynchronousQueue<Object>();
public void handleNotification(Notification notification, Object handback) {
if (data.get() != null)
return;
data.set((CompositeData) notification.getUserData());
boolean messageNotSent = true;
while(messageNotSent){
try {
queue.put(new Object());
messageNotSent = false;
} catch(InterruptedException e) {
messageNotSent = true;
}
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/from/from001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryNotificationInfo.from(CompositeData)
* returns correct results:
* 1. null, if CompositeData is null;
* 2. trows IllegalArgumentException, if CompositeData doest not represnt
* MemoryNotificationInfo;
* 3. correct MemoryNotificationInfo object, if CompositeData is correst (i.e
* all attributes of the CompositeData must have correct values: pool name,
* count; init, used, committed, max (from MemoryUsage).
* COMMENT
* Updated according to:
* 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* -XX:-UseGCOverheadLimit
* nsk.monitoring.MemoryNotificationInfo.from.from001
* -testMode=server
*/

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryNotificationInfo.getCount;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
public class getcount001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
// Check positive count
MemoryNotificationInfo mn
= new MemoryNotificationInfo("poolName", mu, 1);
long count = mn.getCount();
if (count != 1) {
out.println("FAILURE 1.");
out.println("Wrong count: " + count + ", expected: 1");
testFailed = true;
}
// Check negative count
mn = new MemoryNotificationInfo("poolName", mu, -1);
count = mn.getCount();
if (count != -1) {
out.println("FAILURE 2.");
out.println("Wrong count: " + count + ", expected: -1");
testFailed = true;
}
// Check zero count
mn = new MemoryNotificationInfo("poolName", mu, -2);
mn = new MemoryNotificationInfo("poolName", mu, 0);
count = mn.getCount();
if (count != 0) {
out.println("FAILURE 3.");
out.println("Wrong count: " + count + ", expected: 0");
testFailed = true;
}
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getCount/getcount001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryNotificationInfo.getCount()
* returns correct values, if
* 1. count is positive;
* 2. count is negative;
* 3. count is zero.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryNotificationInfo.getCount.getcount001
*/

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryNotificationInfo.getPoolName;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
public class getpoolname001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
MemoryUsage mu = new MemoryUsage(1, 2, 3, 4);
// Check not-empty string
MemoryNotificationInfo mn
= new MemoryNotificationInfo("poolName", mu, 1);
String name = mn.getPoolName();
if (!"poolName".equals(name)) {
out.println("FAILURE 1.");
out.println("Wrong pool name: \"" + name + "\", expected: "
+ "\"poolName\"");
testFailed = true;
}
// Check empty string
mn = new MemoryNotificationInfo("", mu, 1);
name = mn.getPoolName();
if (!"".equals(name)) {
out.println("FAILURE 2.");
out.println("Wrong pool name: \"" + name + "\", expected: \"\"");
testFailed = true;
}
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getPoolName/getpoolname001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryNotificationInfo.getPoolName()
* returns correct values, if
* 1. pool name is not-empty string;
* 2. pool name is empty string;
* COMMENT
* Fixed the bug:
* 5013995 null pointer exception in MM nsk test todata001.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryNotificationInfo.getPoolName.getpoolname001
*/

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryNotificationInfo.getUsage;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
public class getusage001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
// Check not-null object
MemoryUsage expectedUsage = new MemoryUsage(1, 2, 3, 4);
MemoryNotificationInfo mn
= new MemoryNotificationInfo("poolName", expectedUsage, 1);
MemoryUsage realUsage = mn.getUsage();
long committed = realUsage.getCommitted();
long init = realUsage.getInit();
long max = realUsage.getMax();
long used = realUsage.getUsed();
String s = realUsage.toString();
if (committed != 3) {
out.println("FAILURE 1.");
out.println("Wrong committed value: " + committed + ", expected: "
+ "3");
testFailed = true;
}
if (init != 1) {
out.println("FAILURE 2.");
out.println("Wrong init value: " + init + ", expected: 1");
testFailed = true;
}
if (max != 4) {
out.println("FAILURE 3.");
out.println("Wrong max value: " + max + ", expected: 4");
testFailed = true;
}
if (used != 2) {
out.println("FAILURE 4.");
out.println("Wrong used value: " + used + ", expected: 2");
testFailed = true;
}
if (!expectedUsage.toString().equals(s)) {
out.println("FAILURE 5.");
out.println("Wrong toString() value: \"" + s + "\", expected: \""
+ expectedUsage.toString() + "\"");
testFailed = true;
}
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryNotificationInfo/getUsage/getusage001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryNotificationInfo.getUsage()
* returns correct MemoryUsage object - the same that was passed to the
* MemoryNotificationInfo() constructor. The test checks
* 1. not-null MemoryUsage;
* COMMENT
* Fixed the bug:
* 5013995 null pointer exception in MM nsk test todata001.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryNotificationInfo.getUsage.getusage001
*/

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getCollectionUsage;
import java.io.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getusage001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
try {
monitor.getCollectionUsage(pool);
} catch (Exception e) {
log.complain("Unexpected exception " + e);
e.printStackTrace(log.getOutStream());
testFailed = true;
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsage()
* does not throw any exception.
* The test implements direct access to the metrics.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
*/

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsage()
* does not throw any exception.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001 -testMode=server
*/

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsage()
* does not throw any exception.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage004.
* VM Testbase keywords: [quick, monitoring, quarantine]
* VM Testbase comments: JDK-8016181
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsage()
* does not throw any exception.
* The test implements access to the metrics via default for MBean server
* proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001 -testMode=proxy
*/

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsage/getusage005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsage()
* does not throw any exception.
* The test implements access to the metrics via custom MBean server
* proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsage.getusage001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,137 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold;
import java.io.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getthreshold001 {
private static boolean testFailed = false;
private static MemoryMonitor monitor;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
log.display(i + " pool " + monitor.getName(pool));
boolean isSupported = monitor.isCollectionThresholdSupported(pool);
if (isSupported) {
log.display(" supports collection usage thresholds");
// Test three values for the threshold
long max = monitor.getUsage(pool).getMax();
long used = monitor.getUsage(pool).getUsed();
// max value can be -1, so take an absolute value
test(monitor, pool, Math.abs(max), log);
test(monitor, pool, 0, log);
test(monitor, pool, used, log);
} else {
log.display(" does not support collection usage thresholds");
// UnsupportedOperationException is expected
try {
long threshold = monitor.getCollectionThreshold(pool);
log.complain("Threshold " + threshold + " is returned "
+ "instead of UnsupportedOperationException "
+ "in pool " + monitor.getName(pool));
testFailed = true;
} catch (Exception e) {
Throwable unwrapped = unwrap(e);
if (unwrapped instanceof UnsupportedOperationException) {
log.display(" UnsupportedOperationException is "
+ "thrown");
} else {
log.complain("Incorrect execption " + unwrapped
+ " is thrown, "
+ "UnsupportedOperationException is "
+ "expected in pool "
+ monitor.getName(pool));
unwrapped.printStackTrace(log.getOutStream());
testFailed = true;
}
} // try
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
private static void test(MemoryMonitor monitor, Object pool,
long threshold, Log log) {
log.display(" setting threshold " + threshold);
try {
monitor.setCollectionThreshold(pool, threshold);
} catch (Exception e) {
log.complain("Unexpected exception " + e + " in pool "
+ monitor.getName(pool));
e.printStackTrace(log.getOutStream());
testFailed = true;
return;
}
log.display(" threshold " + threshold + " is set");
long result = monitor.getCollectionThreshold(pool);
if (threshold != result) {
log.complain("Threshold value is " + result + " in pool "
+ monitor.getName(pool) + ", " + threshold
+ " expected");
testFailed = true;
}
log.display(" threshold " + threshold + " is read");
} // test()
static Throwable unwrap(Throwable throwable) {
Throwable unwrapped, t = throwable;
do {
unwrapped = t;
if (unwrapped instanceof UnsupportedOperationException) {
break;
}
t = unwrapped.getCause();
} while (t != null);
return unwrapped;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports collection usage thresholds. Three values are
* tested:
* - 0;
* - used value for the pool;
* - max value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* collection usage thresholds.
* The test implements direct access to the metrics.
* COMMENT
* Fixed the bug:
* 5035038 Chain of JMX exceptions impact on monitoring tests
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports collection usage thresholds. Three values are
* tested:
* - 0;
* - used value for the pool;
* - max value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* collection usage thresholds.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
* -testMode=server
*/

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports collection usage thresholds. Three values are
* tested:
* - 0;
* - used value for the pool;
* - max value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* collection usage thresholds.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports collection usage thresholds. Three values are
* tested:
* - 0;
* - used value for the pool;
* - max value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* collection usage thresholds.
* The test implements access to the metrics via default MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
* -testMode=proxy
*/

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThreshold/getthreshold005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports collection usage thresholds. Three values are
* tested:
* - 0;
* - used value for the pool;
* - max value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* collection usage thresholds.
* The test implements access to the metrics via custom MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThreshold.getthreshold001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount;
import java.io.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getcount001 {
private static boolean testFailed = false;
static MemoryMonitor monitor;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
log.display(i + " pool " + monitor.getName(pool));
boolean isSupported = monitor.isCollectionThresholdSupported(pool);
if (isSupported) {
// Check that the method returns non-negative count
log.display(" supports collection usage thresholds");
long count = monitor.getCollectionThresholdCount(pool);
if (count < 0) {
log.complain("Threshold count is less than zero: " + count
+ " in pool " + monitor.getName(pool));
testFailed = true;
} else
log.display(" getUsageThresholdCount() returned " + count);
} else {
// UnsupportedOperationException is expected
log.display(" does not support collection usage thresholds");
try {
long count = monitor.getCollectionThresholdCount(pool);
log.complain("Threshold ount " + count + " is returned "
+ "instead of UnsupportedOperationException in "
+ "pool " + monitor.getName(pool));
testFailed = true;
} catch (Exception e) {
Throwable unwrapped = unwrap(e);
if (unwrapped instanceof UnsupportedOperationException)
log.display(" UnsupportedOperationException is "
+ "thrown");
else {
log.complain("Incorrect execption " + unwrapped
+ " is thrown, "
+ "UnsupportedOperationException is "
+ "expected");
unwrapped.printStackTrace(log.getOutStream());
testFailed = true;
}
} // try
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
static Throwable unwrap(Throwable throwable) {
Throwable unwrapped, t = throwable;
do {
unwrapped = t;
if (unwrapped instanceof UnsupportedOperationException) {
break;
}
t = unwrapped.getCause();
} while (t != null);
return unwrapped;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThresholdCount()
* 1. returns not-negative value, if collection usage thresholds are supported;
* 2. throws UnsupportedOperationException, if collection usage thresholds are
* not supported.
* The test implements direct access to the metrics.
* COMMENT
* Fixed the bug:
* 5035038 Chain of JMX exceptions impact on monitoring tests
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
*/

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThresholdCount()
* 1. returns not-negative value, if collection usage thresholds are supported;
* 2. throws UnsupportedOperationException, if collection usage thresholds are
* not supported.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
* -testMode=server
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThresholdCount()
* 1. returns not-negative value, if collection usage thresholds are supported;
* 2. throws UnsupportedOperationException, if collection usage thresholds are
* not supported.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThresholdCount()
* 1. returns not-negative value, if collection usage thresholds are supported;
* 2. throws UnsupportedOperationException, if collection usage thresholds are
* not supported.
* The test implements access to the metrics via default MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
* -testMode=proxy
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getCollectionUsageThresholdCount/getcount005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getCollectionUsageThresholdCount()
* 1. returns not-negative value, if collection usage thresholds are supported;
* 2. throws UnsupportedOperationException, if collection usage thresholds are
* not supported.
* The test implements access to the metrics via custom MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getCollectionUsageThresholdCount.getcount001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getPeakUsage;
import java.io.*;
import java.lang.management.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getpeak001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
MemoryUsage usage = null;
for (int i = 0; i < pools.size(); i++) {
byte[] b = new byte[10 * 1024]; // Eat 10K
Object pool = pools.get(i);
// No exceptions should be thrown
try {
usage = monitor.getPeakUsage(pool);
log.display(i + " " + monitor.getName(pool) + ": " + usage);
} catch (Throwable t) {
if (t instanceof ThreadDeath)
throw (ThreadDeath) t;
log.complain("Unexpected exception in pool "
+ monitor.getName(pool));
t.printStackTrace(log.getOutStream());
testFailed = true;
continue;
}
boolean isValid = monitor.isValid(pool);
if (isValid) {
if (usage == null) {
log.complain("getPeakUsage() returned null for the valid "
+ "pool " + monitor.getName(pool));
testFailed = true;
}
} else {
if (usage != null) {
log.complain("getPeakUsage() returned not-null: " + usage
+ " for invalid pool " + monitor.getName(pool));
testFailed = true;
}
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getPeakUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements direct access to the metrics.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
*/

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getPeakUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001 -testMode=server
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getPeakUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getPeakUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via default MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001 -testMode=proxy
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getPeakUsage/getpeak005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getPeakUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via custom MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getPeakUsage.getpeak001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getUsage;
import java.io.*;
import java.lang.management.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getusage001 {
private static boolean testFailed = false;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
MemoryUsage usage = null;
for (int i = 0; i < pools.size(); i++) {
byte[] b = new byte[10 * 1024]; // Eat 10K
Object pool = pools.get(i);
// No exceptions should be thrown
try {
usage = monitor.getUsage(pool);
log.display(i + " " + monitor.getName(pool) + ": " + usage);
} catch (Throwable t) {
if (t instanceof ThreadDeath)
throw (ThreadDeath) t;
log.complain("Unexpected exception in pool "
+ monitor.getName(pool));
t.printStackTrace(log.getOutStream());
testFailed = true;
continue;
}
boolean isValid = monitor.isValid(pool);
if (isValid) {
if (usage == null) {
log.complain("getPeakUsage() returned null for the valid "
+ "pool " + monitor.getName(pool));
testFailed = true;
}
} else {
if (usage != null) {
log.complain("getPeakUsage() returned not-null: " + usage
+ " for invalid pool " + monitor.getName(pool));
testFailed = true;
}
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements direct access to the metrics.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
*/

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001 -testMode=server
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via default MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsage.getusage001 -testMode=proxy
*/

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsage/getusage005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsage()
* 1. does not throw any exceptions;
* 2. returns null, if the pool is invalid, and not-null MemoryUsage object,
* if the pool is valid.
* The test implements access to the metrics via custom MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsage.getusage001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getUsageThreshold;
import java.io.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getthreshold001 {
private static boolean testFailed = false;
static MemoryMonitor monitor;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
log.display(i + " pool " + monitor.getName(pool));
boolean isSupported = monitor.isUsageThresholdSupported(pool);
if (isSupported) {
log.display(" supports usage thresholds");
// Test three values for the threshold
long max = monitor.getUsage(pool).getMax();
long used = monitor.getUsage(pool).getUsed();
// max value can be -1, so take an absolute value
test(monitor, pool, Math.abs(max), log);
test(monitor, pool, 0, log);
test(monitor, pool, used, log);
} else {
log.display(" does not support usage thresholds");
// UnsupportedOperationException is expected
try {
long threshold = monitor.getUsageThreshold(pool);
log.complain("Threshold " + threshold + " is returned "
+ "instead of UnsupportedOperationException "
+ "in pool " + monitor.getName(pool));
testFailed = true;
} catch (Exception e) {
Throwable unwrapped = unwrap(e);
if (unwrapped instanceof UnsupportedOperationException) {
log.display(" UnsupportedOperationException is "
+ "thrown");
} else {
log.complain("Incorrect execption " + unwrapped
+ " is thrown, "
+ "UnsupportedOperationException is "
+ "expected in pool "
+ monitor.getName(pool));
unwrapped.printStackTrace(log.getOutStream());
testFailed = true;
}
} // try
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
private static void test(MemoryMonitor monitor, Object pool,
long threshold, Log log) {
log.display(" setting threshold " + threshold);
try {
monitor.setUsageThreshold(pool, threshold);
} catch (Exception e) {
log.complain("Unexpected exception " + e);
e.printStackTrace(log.getOutStream());
testFailed = true;
return;
}
log.display(" threshold " + threshold + " is set");
long result = monitor.getUsageThreshold(pool);
if (threshold != result) {
log.complain("Threshold value is " + result + " in pool "
+ monitor.getName(pool) + ", " + threshold
+ " expected");
testFailed = true;
}
log.display(" threshold " + threshold + " is read");
} // test()
static Throwable unwrap(Throwable throwable) {
Throwable unwrapped, t = throwable;
do {
unwrapped = t;
if (unwrapped instanceof UnsupportedOperationException) {
break;
}
t = unwrapped.getCause();
} while (t != null);
return unwrapped;
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports usage thresholds. The tested values of the
* threshold are:
* - 0;
* - max value for the pool;
* - used value for the pool.
* 2. throws UnsupportedOperationException, if the pool does not support
* usage thresholds.
* The test implements direct access to the metrics.
* COMMENT
* Fixed the bug
* 4989235 TEST: The spec is updated accoring to 4982289, 4985742
* Fixed the bug:
* 5035038 Chain of JMX exceptions impact on monitoring tests
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports usage thresholds. The tested values of the
* threshold are:
* - 0;
* - max value for the pool;
* - used value for the pool.
* 2. returns -1, if the pool does not support usage thresholds.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
* -testMode=server
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold003.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports usage thresholds. The tested values of the
* threshold are:
* - 0;
* - max value for the pool;
* - used value for the pool.
* 2. returns -1, if the pool does not support usage thresholds.
* The test implements access to the metrics via custom MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
* -testMode=server
* -MBeanServer=custom
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold004.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports usage thresholds. The tested values of the
* threshold are:
* - 0;
* - max value for the pool;
* - used value for the pool.
* 2. returns -1, if the pool does not support usage thresholds.
* The test implements access to the metrics via default MBean server
* proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
* -testMode=proxy
*/

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThreshold/getthreshold005.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThreshold()
* 1. returns the correct threshold value that was just set to the pool,
* if the pool supports usage thresholds. The tested values of the
* threshold are:
* - 0;
* - max value for the pool;
* - used value for the pool.
* 2. returns -1, if the pool does not support usage thresholds.
* The test implements access to the metrics via custom MBean server proxy.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsageThreshold.getthreshold001
* -testMode=proxy
* -MBeanServer=custom
*/

View File

@ -0,0 +1,110 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount;
import java.io.*;
import java.util.*;
import nsk.share.*;
import nsk.monitoring.share.*;
public class getcount001 {
private static boolean testFailed = false;
static MemoryMonitor monitor;
public static void main(String[] argv) {
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
}
public static int run(String[] argv, PrintStream out) {
ArgumentHandler argHandler = new ArgumentHandler(argv);
Log log = new Log(out, argHandler);
monitor = Monitor.getMemoryMonitor(log, argHandler);
List pools = monitor.getMemoryPoolMBeans();
for (int i = 0; i < pools.size(); i++) {
Object pool = pools.get(i);
log.display(i + " pool " + monitor.getName(pool));
boolean isSupported = monitor.isUsageThresholdSupported(pool);
if (isSupported) {
log.display(" supports usage thresholds");
long count = monitor.getUsageThresholdCount(pool);
if (count < 0) {
log.complain("Threshold count is less than zero: " + count
+ " in pool " + monitor.getName(pool));
testFailed = true;
} else
log.display(" getUsageThresholdCount() returned " + count);
} else {
// UnsupportedOperationException is expected
log.display(" does not support usage thresholds");
try {
monitor.getUsageThresholdCount(pool);
log.complain("UnsupportedOperationException is not thrown "
+ "in pool " + monitor.getName(pool));
testFailed = true;
} catch (Exception e) {
Throwable unwrapped = unwrap(e);
if (unwrapped instanceof UnsupportedOperationException)
log.display(" UnsupportedOperationException is "
+ "thrown");
else {
log.complain(" Incorrect execption " + unwrapped
+ " is thrown, "
+ "UnsupportedOperationException is "
+ "expected");
unwrapped.printStackTrace(log.getOutStream());
testFailed = true;
}
} // try
}
} // for i
if (testFailed)
out.println("TEST FAILED");
return (testFailed) ? Consts.TEST_FAILED : Consts.TEST_PASSED;
}
static Throwable unwrap(Throwable throwable) {
Throwable unwrapped, t = throwable;
do {
unwrapped = t;
if (unwrapped instanceof UnsupportedOperationException) {
break;
}
t = unwrapped.getCause();
} while (t != null);
return unwrapped;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThresholdCount()
* 1. returns not-negative value, if usage thresholds are supported;
* 2. throws UnsupportedOperationException, if usage thresholds are not
* supported.
* The test implements direct access to the metrics.
* COMMENT
* Fixed the bug:
* 5035038 Chain of JMX exceptions impact on monitoring tests
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
*/

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase nsk/monitoring/MemoryPoolMBean/getUsageThresholdCount/getcount002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* MemoryPoolMBean.getUsageThresholdCount()
* 1. returns not-negative value, if usage thresholds are supported;
* 2. throws UnsupportedOperationException, if usage thresholds are not
* supported.
* The test implements access to the metrics via default MBean server.
* COMMENT
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm
* nsk.monitoring.MemoryPoolMBean.getUsageThresholdCount.getcount001
* -testMode=server
*/

Some files were not shown because too many files have changed in this diff Show More