public static <T extends MetricCollector> T getMetricCollector() { if (mc == null) { if (isDefaultMetricsEnabled()) enableDefaultMetrics(); } @SuppressWarnings("unchecked") T t = (T) (mc == null ? MetricCollector.NONE : mc); return t; }
@Test public void test() { // by default, it's disabled assertFalse(AwsSdkMetrics.isDefaultMetricsEnabled()); // won't be anble to enable unless the default impl library is on the classpath assertFalse(AwsSdkMetrics.enableDefaultMetrics()); assertFalse(AwsSdkMetrics.isDefaultMetricsEnabled()); assertSame(RequestMetricCollector.NONE, AwsSdkMetrics.getRequestMetricCollector()); assertFalse(AwsSdkMetrics.isDefaultMetricsEnabled()); // effectively no effect AwsSdkMetrics.disableMetrics(); assertFalse(AwsSdkMetrics.isDefaultMetricsEnabled()); }
@Override public boolean enableDefaultMetrics() { return AwsSdkMetrics.enableDefaultMetrics(); }
/** * By default the AWS SDK metric collection is disabled. Enabling it should fail unless the * necessary CloudWatch related jars are on the classpath. Therefore, this test is expected to * fail in enabling the default metric collection, but have absolutely no impact otherwise. */ @Test public void enableDefaultMetrics() { Assert.assertFalse(AwsSdkMetrics.enableDefaultMetrics()); }