/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5042004
* @summary Check that MBeans with the same class have identical MBeanInfo
* unless they are NotificationBroadcasters
* @author Eamonn McManus
* @run clean IdenticalMBeanInfoTest
* @run build IdenticalMBeanInfoTest
* @run main IdenticalMBeanInfoTest
*/
import javax.management.*;
/* What we test here is not required by the spec. It is an
optimization that can save a considerable amount of memory when
there are many MBeans of the same type. There is no reason why two
Standard MBeans of the same type should have different MBeanInfo
objects, unless they are NotificationBroadcasters and return
different arrays from getNotificationInfo(). Note that two MBeans
that share the same MBean interface but are of different classes
cannot have the same MBeanInfo because the MBeanInfo includes the
implementation class name. */
public class IdenticalMBeanInfoTest {
public static interface WhatsitMBean {
public int getReadOnly();
public int getReadWrite();
public void setReadWrite(int x);
public int op(int x, int y);
}
public Whatsit() {}
public void setReadWrite(int x) {}
}
}
implements BroadcasterMBean, NotificationBroadcaster {
Object h) {}
return new MBeanNotificationInfo[] {
"something",
"a something")
};
}
}
fail("Two MBeans of the same class should have identical " +
"MBeanInfo");
}
if (true)
else
fail("Plain Standard MBean should have identical MBeanInfo " +
"to StandardMBean(...) with same class as resource");
}
fail("Two MBeans of the same class should NOT have identical " +
"MBeanInfo if they are NotificationBroadcasters and "+
"do not return the same MBeanNotificationInfo[]");
}
return;
}
}
}
}