2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 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 0N/A * @summary Test that RequiredModelMBean.invoke will not invoke methods 0N/A * from the RequiredModelMBean class itself if they are not in the 0N/A * @author Eamonn McManus 0N/A * @run clean RequiredModelMBeanMethodTest 0N/A * @run build RequiredModelMBeanMethodTest 0N/A * @run main RequiredModelMBeanMethodTest 0N/A * We do the same test with a number of different operations: 0N/A * - A plain operation that is directed to the managed resource in the 0N/A * usual way. We give it some parameters so we can test that the 0N/A * class loading logic for signature parameters is reasonable. 0N/A * - An operation (removeNotificationListener) that is directed to the 0N/A * RequiredModelMBean itself. We use this particular operation because 0N/A * it will throw an exception, which allows us to check that it did in 0N/A * - An operation (load()) that has the same signature as a 0N/A * RequiredModelMBean operation but is directed to the resource 0N/A * because of a "class" field in the descriptor. 0N/A * - An operation (store()) that has the same signature as a 0N/A * RequiredModelMBean operation but is directed to the resource 0N/A * because of a "targetObject" field in the descriptor. 0N/A * In each case we check that the operation does not work if it is not 0N/A * in the ModelMBeanInfo, and does work if it is. 0N/A "descriptorType=operation",
0N/A "targetType=ObjectReference",
0N/A "descriptorType=operation",
0N/A "targetType=ObjectReference",
0N/A "descriptorType=operation",
0N/A "targetType=ObjectReference",
0N/A "descriptor directs methods to resource");
0N/A // Test the invoke("class.method") form 0N/A ".removeAttributeChangeNotificationListener",
0N/A " returned successfully but " +
0N/A // OK: there is no such listener 0N/A "removeAttributeChangeNotificationListener",
0N/A for (
int i =
0; i <
4; i++) {
0N/A " returned successfully but " +
0N/A // OK: there is no such listener 0N/A " worked but should not");
0N/A if (x !=
5 || y !=
this)
0N/A return "wrong params: " + x +
" " + y;