RuntimeExceptionTest.java 文件源码

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

项目:infobip-open-jdk-8 作者:
/**
 * Update the string and check for notifications
 */
public int stringMonitorNotification() throws Exception {

    StringMonitor stringMonitor = new StringMonitor();
    try {
        // Create a new StringMonitor MBean and add it to the MBeanServer.
        //
        echo(">>> CREATE a new StringMonitor MBean");
        ObjectName stringMonitorName = new ObjectName(
                        domain + ":type=" + StringMonitor.class.getName());
        server.registerMBean(stringMonitor, stringMonitorName);

        echo(">>> ADD a listener to the StringMonitor");
        stringMonitor.addNotificationListener(this, null, null);

        //
        // MANAGEMENT OF A STANDARD MBEAN
        //

        echo(">>> SET the attributes of the StringMonitor:");

        stringMonitor.addObservedObject(obsObjName);
        echo("\tATTRIBUTE \"ObservedObject\"    = " + obsObjName);

        stringMonitor.setObservedAttribute("StringAttribute");
        echo("\tATTRIBUTE \"ObservedAttribute\" = StringAttribute");

        stringMonitor.setNotifyMatch(false);
        echo("\tATTRIBUTE \"NotifyMatch\"       = false");

        stringMonitor.setNotifyDiffer(false);
        echo("\tATTRIBUTE \"NotifyDiffer\"      = false");

        stringMonitor.setStringToCompare("dummy");
        echo("\tATTRIBUTE \"StringToCompare\"   = \"dummy\"");

        int granularityperiod = 500;
        stringMonitor.setGranularityPeriod(granularityperiod);
        echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);

        echo(">>> START the StringMonitor");
        stringMonitor.start();

        // Check if notification was received
        //
        doWait();
        if (messageReceived) {
            echo("\tOK: StringMonitor got RUNTIME_ERROR notification!");
        } else {
            echo("\tKO: StringMonitor did not get " +
                 "RUNTIME_ERROR notification!");
            return 1;
        }
    } finally {
        messageReceived = false;
        if (stringMonitor != null)
            stringMonitor.stop();
    }

    return 0;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号