Пример #1
0
 @Test
 public void setNullOrEmpty() {
   Set<MetricType> orig = AwsSdkMetrics.getPredefinedMetrics();
   assertTrue(orig.size() > 0);
   AwsSdkMetrics.set(null);
   Set<MetricType> empty = AwsSdkMetrics.getPredefinedMetrics();
   assertTrue(empty.size() == 0);
   AwsSdkMetrics.set(null);
   Set<MetricType> stillEmpty = AwsSdkMetrics.getPredefinedMetrics();
   assertSame(empty, stillEmpty);
   AwsSdkMetrics.set(Collections.<MetricType>emptySet());
   Set<MetricType> empty3 = AwsSdkMetrics.getPredefinedMetrics();
   assertSame(empty, empty3);
   AwsSdkMetrics.set(orig);
 }
Пример #2
0
 @Test
 public void defaultMetricTypes() {
   // Default set of predefined metric types is not empty
   Set<MetricType> set = AwsSdkMetrics.getPredefinedMetrics();
   assertNotNull(set);
   assertTrue(set.size() > 0);
   // Clear out the default set of predefined metric types
   AwsSdkMetrics.set(Collections.<MetricType>emptyList());
   Set<MetricType> empty = AwsSdkMetrics.getPredefinedMetrics();
   assertNotNull(empty);
   assertTrue(empty.size() == 0);
   // Reconfigure the default set of predefined metric types back to the original
   AwsSdkMetrics.set(set);
   Set<MetricType> set2 = AwsSdkMetrics.getPredefinedMetrics();
   assertNotNull(set2);
   assertTrue(set2.size() > 0);
   // Not the same due to ensuring thread-safety
   assertNotSame(set, set2);
 }
Пример #3
0
 @Test
 public void addAndRemove() {
   Set<MetricType> orig = AwsSdkMetrics.getPredefinedMetrics();
   AwsSdkMetrics.set(null);
   // Test add and remove
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().isEmpty());
   AwsSdkMetrics.add(Field.ClientExecuteTime);
   assertFalse(AwsSdkMetrics.getPredefinedMetrics().isEmpty());
   AwsSdkMetrics.remove(Field.ClientExecuteTime);
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().isEmpty());
   // Test add more than one entry
   AwsSdkMetrics.add(Field.ClientExecuteTime);
   AwsSdkMetrics.add(Field.Exception);
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().size() == 2);
   AwsSdkMetrics.set(null);
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().isEmpty());
   // Test addAll
   AwsSdkMetrics.addAll(Arrays.asList(Field.Exception, Field.ClientExecuteTime));
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().size() == 2);
   AwsSdkMetrics.set(orig);
   assertTrue(AwsSdkMetrics.getPredefinedMetrics().size() == orig.size());
 }