@Test public void requireThatThreadLocalConsumersAreProvided() throws Exception { AtomicInteger cnt = new AtomicInteger(0); final MetricProvider metricProvider = MetricProviders.newInstance(MetricConsumerFactories.newCounter(cnt)); assertEquals(0, cnt.get()); metricProvider.get().add("foo", 6, null); assertEquals(1, cnt.get()); metricProvider.get().add("bar", 9, null); assertEquals(1, cnt.get()); ExecutorService executor = Executors.newSingleThreadExecutor(); assertTrue(executor.submit(new MetricTask(metricProvider)).get(60, TimeUnit.SECONDS)); assertEquals(2, cnt.get()); assertTrue(executor.submit(new MetricTask(metricProvider)).get(60, TimeUnit.SECONDS)); assertEquals(2, cnt.get()); }
@Override public Metric get() { return metric; }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); @Override Metric get(); @Override void deconstruct(); }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); @Override Metric get(); @Override void deconstruct();  }