@Test
public void testDisableWriteToFile() throws InterruptedException {

    IMetricManager metricManager = MetricManager.getIMetricManager();
    metricManager.clear();
    RollingFileAppender fileAppender = mock(RollingFileAppender.class);
    BinAppender binAppender = mock(BinAppender.class);
    // 设置全局的report时间间隔是3秒
    MetricsCollectPeriodConfig config = new MetricsCollectPeriodConfig(3);
    // 设置CRITICAL的report时间间隔为1秒
    config.configPeriod(MetricLevel.CRITICAL, 1);
    StructMetricManagerReporter reporter = new StructMetricManagerReporter(metricManager, binAppender, fileAppender,
            Clock.defaultClock(), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, MetricFilter.ALL,
            config, new HashMap<String, String>(), new JsonMetricFormat(), CollectLevel.CLASSIFIER);
    long period = 1;
    try {
        reporter.start(period, TimeUnit.SECONDS);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Counter c = MetricManager.getCounter("struct", MetricName.build("AAA")
            .tagged("hi", null).level(MetricLevel.CRITICAL));
    c.inc(10000);
    TimeUnit.MILLISECONDS.sleep(2200);
    verify(fileAppender, times(0)).append((byte[]) any());
}