@Test
  public void doStuff() throws Exception {
    DummyMetricCollector collector = new DummyMetricCollector();
    ConnectionFactory cf = new ConnectionFactoryBuilder()
      .setEnableMetrics(MetricType.DEBUG)
      .setMetricCollector(collector)
      .build();

    MemcachedClient client = new MemcachedClient(cf,
      AddrUtil.getAddresses(TestConfig.IPV4_ADDR + ":"
        + TestConfig.PORT_NUMBER));

    assertTrue(client.set("metrics:test", 0, "value").get());
    assertNotNull(client.get("metrics:test"));

    HashMap<String, Integer> metrics = collector.getMetrics();
    assertTrue(metrics.get("[MEM] Average Bytes written to OS per write") > 0);
    assertEquals(2, (long) metrics.get("[MEM] Response Rate: Success"));

    client.shutdown();
  }
Tests the initialization and measurement of Metrics.
src/test/java/net/spy/memcached/MetricsTest.java