AuthorizationTest.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:jdk8u-jdk 作者:
protected int doInvokeRequest(MBeanServerConnection mbsc,
                              ObjectName on,
                              boolean expectedException) {
    int errorCount = 0;

    try {
        Utils.debug(Utils.DEBUG_STANDARD,
            "ClientSide::doInvokeRequest: Invoke operations on the MBean") ;

        mbsc.invoke(on, "operation", null, null) ;

        if (expectedException) {
            System.out.println("ClientSide::doInvokeRequest: " +
                "(ERROR) Invoke did not fail with expected SecurityException");
            errorCount++;
        } else {
            System.out.println("ClientSide::doInvokeRequest: (OK) Invoke succeed") ;
        }
    } catch(Exception e) {
        Utils.printThrowable(e, true) ;
        if (expectedException) {
            if (e instanceof java.lang.SecurityException) {
                System.out.println("ClientSide::doInvokeRequest: " +
                    "(OK) Invoke failed with expected SecurityException") ;
            } else {
                System.out.println("ClientSide::doInvokeRequest: " +
                    " (ERROR) Invoke failed with " +
                    e.getClass() + " instead of expected SecurityException");
                errorCount++;
            }
        } else {
            System.out.println("ClientSide::doInvokeRequest: " +
                "(ERROR) Invoke failed");
            errorCount++;
        }
    }
    return errorCount;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号