/*
* 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 4954062
* @summary Test that a custom ModelMBean implementation can have custom
* targetType values in its ModelMBeanOperationInfo descriptors.
* @author Eamonn McManus
* @run clean ExoticTargetTypeTest
* @run build ExoticTargetTypeTest
* @run main ExoticTargetTypeTest
*/
import javax.management.*;
public class ExoticTargetTypeTest {
" a nonstandard targetType provided that the " +
"ModelMBean understands it");
boolean ok = true;
final Descriptor noddyDescr =
new DescriptorSupport(new String[] {
"name=noddy",
"descriptorType=operation",
"role=operation",
"targetType=noddy",
});
final ModelMBeanOperationInfo opInfo =
new ModelMBeanOperationInfo("noddy",
"noddy description",
new MBeanParameterInfo[0],
"void",
final ModelMBeanInfo mmbInfo =
"Noddy ModelMBean description",
new ModelMBeanOperationInfo[] {opInfo},
null);
"ModelMBeanOperationInfo...");
try {
if (exoticMMB.noddyCalled)
else {
"not invoke method?!");
ok = false;
}
} catch (Exception e) {
ok = false;
}
"ModelMBeanOperationInfo...");
// RequiredModelMBean's constructor could legitimately throw
// an exception here because of the nonstandard descriptor.
// If some day it does, we will have to update this test.
try {
ok = false;
} catch (MBeanException e) {
if (cause instanceof InvalidTargetObjectTypeException) {
"InvalidTargetObjectTypeException: " +
cause.getMessage());
} else {
"wrong cause: " + cause);
ok = false;
}
} catch (Exception e) {
ok = false;
}
if (ok)
else {
}
}
try {
} finally {
}
}
super();
}
throws MBeanException, ReflectionException {
noddyCalled = true;
return null;
} else
}
private boolean noddyCalled;
}
}