0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6204469
0N/A * @summary Test that MBean*Info can be constructed with default descriptor
0N/A * @author Eamonn McManus
0N/A * @run clean DefaultDescriptorTest
0N/A * @run build DefaultDescriptorTest
0N/A * @run main DefaultDescriptorTest
0N/A */
0N/A
0N/Aimport java.lang.reflect.*;
0N/Aimport javax.management.*;
0N/Aimport javax.management.modelmbean.*;
0N/Aimport javax.management.openmbean.*;
0N/A
0N/Apublic class DefaultDescriptorTest {
0N/A public static void main(String[] args) throws Exception {
0N/A final Descriptor empty =
0N/A ImmutableDescriptor.EMPTY_DESCRIPTOR;
0N/A
0N/A final Class thisClass = DefaultDescriptorTest.class;
0N/A
0N/A final Method getWhatever = thisClass.getMethod("getWhatever");
0N/A final Method setWhatever = thisClass.getMethod("setWhatever",
0N/A int.class);
0N/A final Method doWhatever = thisClass.getMethod("doWhatever",
0N/A String.class);
0N/A
0N/A final Constructor<?> con = thisClass.getConstructor();
0N/A
0N/A final OpenMBeanParameterInfoSupport ombpi1 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.STRING);
0N/A final OpenMBeanParameterInfoSupport ombpi2 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.STRING,
0N/A (Descriptor) null);
0N/A final OpenMBeanParameterInfoSupport ombpi3 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.STRING,
0N/A empty);
0N/A final OpenMBeanParameterInfoSupport ombpi4 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.STRING,
0N/A "defaultString");
0N/A final OpenMBeanParameterInfoSupport ombpi5 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.INTEGER,
0N/A null, 3, 5);
0N/A final OpenMBeanParameterInfoSupport ombpi6 =
0N/A new OpenMBeanParameterInfoSupport("x", "y", SimpleType.LONG,
0N/A 53L, new Long[] {28L, 53L});
0N/A
0N/A final ModelMBeanInfoSupport mmbi1 =
0N/A new ModelMBeanInfoSupport("yo", "yo", null, null, null, null);
0N/A final ModelMBeanInfoSupport mmbi2 =
0N/A new ModelMBeanInfoSupport("yo", "yo", null, null, null, null,
0N/A (Descriptor) null);
0N/A// final ModelMBeanInfoSupport mmbi3 =
0N/A// new ModelMBeanInfoSupport("yo", "yo", null, null, null, null,
0N/A// empty);
0N/A // an empty descriptor is currently illegal for MMBIS
0N/A
0N/A final ModelMBeanAttributeInfo mmbai1 =
0N/A new ModelMBeanAttributeInfo("yo", "yo", getWhatever, setWhatever);
0N/A final ModelMBeanAttributeInfo mmbai2 =
0N/A new ModelMBeanAttributeInfo("yo", "yo", getWhatever, setWhatever,
0N/A (Descriptor) null);
0N/A final ModelMBeanAttributeInfo mmbai3 =
0N/A new ModelMBeanAttributeInfo("yo", "yo", "yo", true, true, false);
0N/A final ModelMBeanAttributeInfo mmbai4 =
0N/A new ModelMBeanAttributeInfo("yo", "yo", "yo", true, true, false,
0N/A (Descriptor) null);
0N/A
0N/A final ModelMBeanConstructorInfo mmbci1 =
0N/A new ModelMBeanConstructorInfo("yo", con);
0N/A final ModelMBeanConstructorInfo mmbci2 =
0N/A new ModelMBeanConstructorInfo("yo", con, (Descriptor) null);
0N/A final ModelMBeanConstructorInfo mmbci3 =
0N/A new ModelMBeanConstructorInfo("yo", "yo", null);
0N/A final ModelMBeanConstructorInfo mmbci4 =
0N/A new ModelMBeanConstructorInfo("yo", "yo", null, (Descriptor) null);
0N/A
0N/A final ModelMBeanNotificationInfo mmbni1 =
0N/A new ModelMBeanNotificationInfo(new String[] {"x.y.z"}, "yo", "yo");
0N/A final ModelMBeanNotificationInfo mmbni2 =
0N/A new ModelMBeanNotificationInfo(new String[] {"x.y.z"}, "yo", "yo",
0N/A (Descriptor) null);
0N/A
0N/A final ModelMBeanOperationInfo mmboi1 =
0N/A new ModelMBeanOperationInfo("yo", doWhatever);
0N/A final ModelMBeanOperationInfo mmboi2 =
0N/A new ModelMBeanOperationInfo("yo", doWhatever, (Descriptor) null);
0N/A final ModelMBeanOperationInfo mmboi3 =
0N/A new ModelMBeanOperationInfo("yo", "yo", null, "typo",
0N/A MBeanOperationInfo.ACTION);
0N/A final ModelMBeanOperationInfo mmboi4 =
0N/A new ModelMBeanOperationInfo("yo", "yo", null, "typo",
0N/A MBeanOperationInfo.ACTION,
0N/A (Descriptor) null);
0N/A
0N/A final DescriptorRead[] infos = {
0N/A new MBeanInfo("a.b.c", "blah", null, null, null, null),
0N/A new MBeanInfo("a.b.c", "blah", null, null, null, null,
0N/A (Descriptor) null),
0N/A new MBeanInfo("a.b.c", "blah", null, null, null, null,
0N/A empty),
0N/A
0N/A new MBeanAttributeInfo("blah", "blah", getWhatever, setWhatever),
0N/A// Following constructor deleted because Method has implicit Descriptor
0N/A// from annotations
0N/A// new MBeanAttributeInfo("blah", "blah", getWhatever, setWhatever,
0N/A// (Descriptor) null),
0N/A// new MBeanAttributeInfo("blah", "blah", getWhatever, setWhatever,
0N/A// empty),
0N/A
0N/A new MBeanAttributeInfo("blah", "a.b.c", "blah",
0N/A true, true, false),
0N/A new MBeanAttributeInfo("blah", "a.b.c", "blah",
0N/A true, true, false, (Descriptor) null),
0N/A new MBeanAttributeInfo("blah", "a.b.c", "blah",
0N/A true, true, false, empty),
0N/A
0N/A new MBeanConstructorInfo("blah", con),
0N/A// Following constructor deleted because Constructor has implicit Descriptor
0N/A// from annotations
0N/A// new MBeanConstructorInfo("blah", con, (Descriptor) null),
0N/A// new MBeanConstructorInfo("blah", con, empty),
0N/A
0N/A new MBeanConstructorInfo("blah", "blah", null),
0N/A new MBeanConstructorInfo("blah", "blah", null, (Descriptor) null),
0N/A new MBeanConstructorInfo("blah", "blah", null, empty),
0N/A
0N/A // this class should be abstract but isn't
0N/A new MBeanFeatureInfo("blah", "blah"),
0N/A new MBeanFeatureInfo("blah", "blah", (Descriptor) null),
0N/A new MBeanFeatureInfo("blah", "blah", empty),
0N/A
0N/A new MBeanNotificationInfo(new String[] {"a.b.c"}, "blah", "blah"),
0N/A new MBeanNotificationInfo(new String[] {"a.b.c"}, "blah", "blah",
0N/A (Descriptor) null),
0N/A new MBeanNotificationInfo(new String[] {"a.b.c"}, "blah", "blah",
0N/A empty),
0N/A
0N/A
0N/A new MBeanOperationInfo("blah", doWhatever),
0N/A// Following constructor deleted because Method has implicit Descriptor
0N/A// from annotations
0N/A// new MBeanOperationInfo("blah", doWhatever, (Descriptor) null),
0N/A// new MBeanOperationInfo("blah", doWhatever, empty),
0N/A
0N/A new MBeanOperationInfo("blah", "blah", null, "a.b.c",
0N/A MBeanOperationInfo.ACTION_INFO),
0N/A new MBeanOperationInfo("blah", "blah", null, "a.b.c",
0N/A MBeanOperationInfo.ACTION,
0N/A (Descriptor) null),
0N/A new MBeanOperationInfo("blah", "blah", null, "a.b.c",
0N/A MBeanOperationInfo.INFO,
0N/A empty),
0N/A
0N/A new MBeanParameterInfo("blah", "a.b.c", "blah"),
0N/A new MBeanParameterInfo("blah", "a.b.c", "blah", (Descriptor) null),
0N/A new MBeanParameterInfo("blah", "a.b.c", "blah", empty),
0N/A
0N/A new OpenMBeanInfoSupport("x", "y", null, null, null, null),
0N/A new OpenMBeanInfoSupport("x", "y", null, null, null, null,
0N/A (Descriptor) null),
0N/A new OpenMBeanInfoSupport("x", "y", null, null, null, null,
0N/A empty),
0N/A
0N/A ombpi1,
0N/A ombpi2,
0N/A ombpi3,
0N/A ombpi4,
0N/A ombpi5,
0N/A ombpi6,
0N/A
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.STRING,
0N/A true, true, false),
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.STRING,
0N/A true, true, false,
0N/A (Descriptor) null),
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.STRING,
0N/A true, true, false,
0N/A empty),
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.STRING,
0N/A true, true, false,
0N/A "defaultString"),
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.INTEGER,
0N/A true, true, false,
0N/A null, 3, 5),
0N/A new OpenMBeanAttributeInfoSupport("x", "y", SimpleType.LONG,
0N/A true, true, false,
0N/A 53L, new Long[] {28L, 53L}),
0N/A
0N/A new OpenMBeanConstructorInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }),
0N/A new OpenMBeanConstructorInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }, (Descriptor) null),
0N/A new OpenMBeanConstructorInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }, empty),
0N/A
0N/A new OpenMBeanOperationInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }, SimpleType.DATE,
0N/A MBeanOperationInfo.ACTION),
0N/A new OpenMBeanOperationInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }, SimpleType.DATE,
0N/A MBeanOperationInfo.ACTION,
0N/A (Descriptor) null),
0N/A new OpenMBeanOperationInfoSupport("x", "y",
0N/A new OpenMBeanParameterInfo[] {
0N/A ombpi1, ombpi2
0N/A }, SimpleType.DATE,
0N/A MBeanOperationInfo.ACTION,
0N/A empty),
0N/A
0N/A mmbi1,
0N/A mmbi2,
0N/A
0N/A new ModelMBeanInfoSupport(mmbi1),
0N/A new ModelMBeanInfoSupport(mmbi2),
0N/A
0N/A (DescriptorRead) mmbi1.clone(),
0N/A (DescriptorRead) mmbi2.clone(),
0N/A
0N/A mmbai1,
0N/A mmbai2,
0N/A mmbai3,
0N/A mmbai4,
0N/A
0N/A new ModelMBeanAttributeInfo(mmbai1),
0N/A new ModelMBeanAttributeInfo(mmbai2),
0N/A new ModelMBeanAttributeInfo(mmbai3),
0N/A new ModelMBeanAttributeInfo(mmbai4),
0N/A
0N/A (DescriptorRead) mmbai1.clone(),
0N/A (DescriptorRead) mmbai2.clone(),
0N/A (DescriptorRead) mmbai3.clone(),
0N/A (DescriptorRead) mmbai4.clone(),
0N/A
0N/A mmbci1,
0N/A mmbci2,
0N/A mmbci3,
0N/A mmbci4,
0N/A
0N/A // Oddly enough there's no public copy constructor for this class
0N/A
0N/A (DescriptorRead) mmbci1.clone(),
0N/A (DescriptorRead) mmbci2.clone(),
0N/A (DescriptorRead) mmbci3.clone(),
0N/A (DescriptorRead) mmbci4.clone(),
0N/A
0N/A mmbni1,
0N/A mmbni2,
0N/A
0N/A new ModelMBeanNotificationInfo(mmbni1),
0N/A new ModelMBeanNotificationInfo(mmbni2),
0N/A
0N/A (DescriptorRead) mmbni1.clone(),
0N/A (DescriptorRead) mmbni2.clone(),
0N/A
0N/A mmboi1,
0N/A mmboi2,
0N/A mmboi3,
0N/A mmboi4,
0N/A
0N/A new ModelMBeanOperationInfo(mmboi1),
0N/A new ModelMBeanOperationInfo(mmboi2),
0N/A new ModelMBeanOperationInfo(mmboi3),
0N/A new ModelMBeanOperationInfo(mmboi4),
0N/A
0N/A (DescriptorRead) mmboi1.clone(),
0N/A (DescriptorRead) mmboi2.clone(),
0N/A (DescriptorRead) mmboi3.clone(),
0N/A (DescriptorRead) mmboi4.clone(),
0N/A
0N/A };
0N/A
0N/A System.out.println("Testing that a default descriptor is always " +
0N/A "supplied");
0N/A for (DescriptorRead info : infos) {
0N/A System.out.println(info);
0N/A Descriptor d = info.getDescriptor();
0N/A if (d == null)
0N/A throw new Exception("getDescriptor returned null: " + info);
0N/A }
0N/A System.out.println("Test passed");
0N/A }
0N/A
0N/A public int getWhatever() {
0N/A return 0;
0N/A }
0N/A
0N/A public void setWhatever(int x) {
0N/A }
0N/A
0N/A public void doWhatever(String x) {
0N/A }
0N/A}