< prev index next >

test/javax/management/mxbean/ThreadMXBeanTest.java

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6305746
  27  * @summary Test that the null values returned by the ThreadMXBean work.
  28  * @author Eamonn McManus
  29  * @run clean ThreadMXBeanTest
  30  * @run build ThreadMXBeanTest
  31  * @run main ThreadMXBeanTest

  32  */
  33 
  34 import java.lang.management.*;
  35 import java.util.*;
  36 import javax.management.*;
  37 
  38 public class ThreadMXBeanTest {
  39     public static void main(String[] args) throws Exception {
  40         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
  41         ThreadMXBean tmb = ManagementFactory.getThreadMXBean();
  42         StandardMBean smb = new StandardMBean(tmb, ThreadMXBean.class, true);
  43         ObjectName on = new ObjectName("a:type=ThreadMXBean");
  44         mbs.registerMBean(smb, on);
  45         ThreadMXBean proxy = JMX.newMXBeanProxy(mbs, on, ThreadMXBean.class);
  46         long[] ids1 = proxy.getAllThreadIds();
  47 
  48         // Add some random ids to the list so we'll get back null ThreadInfo
  49         long[] ids2 = new long[ids1.length + 10];
  50         System.arraycopy(ids1, 0, ids2, 0, ids1.length);
  51         Random r = new Random();


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6305746
  27  * @summary Test that the null values returned by the ThreadMXBean work.
  28  * @author Eamonn McManus
  29  * @run clean ThreadMXBeanTest
  30  * @run build ThreadMXBeanTest
  31  * @run main ThreadMXBeanTest
  32  * @key randomness
  33  */
  34 
  35 import java.lang.management.*;
  36 import java.util.*;
  37 import javax.management.*;
  38 
  39 public class ThreadMXBeanTest {
  40     public static void main(String[] args) throws Exception {
  41         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
  42         ThreadMXBean tmb = ManagementFactory.getThreadMXBean();
  43         StandardMBean smb = new StandardMBean(tmb, ThreadMXBean.class, true);
  44         ObjectName on = new ObjectName("a:type=ThreadMXBean");
  45         mbs.registerMBean(smb, on);
  46         ThreadMXBean proxy = JMX.newMXBeanProxy(mbs, on, ThreadMXBean.class);
  47         long[] ids1 = proxy.getAllThreadIds();
  48 
  49         // Add some random ids to the list so we'll get back null ThreadInfo
  50         long[] ids2 = new long[ids1.length + 10];
  51         System.arraycopy(ids1, 0, ids2, 0, ids1.length);
  52         Random r = new Random();
< prev index next >