@Test
@SuppressWarnings("unchecked")
public void testSystemMemoryGauge() {

    ManualClock clock = new ManualClock();
    SystemMemoryGaugeSet systemMemoryGaugeSet = new SystemMemoryGaugeSet(
            "src/test/resources/proc_meminfo", 10, TimeUnit.MILLISECONDS, clock);
    Map<MetricName, Metric> metrics = systemMemoryGaugeSet.getMetrics();
    Assert.assertEquals(9, metrics.keySet().size());
    clock.addMillis(20);
    Gauge<Long> memTotal = (Gauge<Long>)metrics.get(MetricName.build("mem.total"));
    Gauge<Long> memFree = (Gauge<Long>)metrics.get(MetricName.build("mem.free"));
    Gauge<Long> memBuffers = (Gauge<Long>)metrics.get(MetricName.build("mem.buffers"));
    Gauge<Long> memCached = (Gauge<Long>)metrics.get(MetricName.build("mem.cached"));
    Gauge<Long> memUsed = (Gauge<Long>)metrics.get(MetricName.build("mem.used"));
    Gauge<Double> memUsedRatio = (Gauge<Double>)metrics.get(MetricName.build("mem.used_ratio"));
    Gauge<Long> memSwapTotal = (Gauge<Long>)metrics.get(MetricName.build("mem.swap.total"));
    Gauge<Long> memSwapUsed = (Gauge<Long>)metrics.get(MetricName.build("mem.swap.used"));
    Gauge<Long> memSwapFree = (Gauge<Long>)metrics.get(MetricName.build("mem.swap.free"));
    Assert.assertEquals(2053456L, memTotal.getValue().longValue());
    Assert.assertEquals(396264L, memFree.getValue().longValue());
    Assert.assertEquals(44280L, memBuffers.getValue().longValue());
    Assert.assertEquals(397836L, memCached.getValue().longValue());
    Assert.assertEquals(2053456L - 396264L - 44280L - 397836L, memUsed.getValue().longValue());
    Assert.assertEquals(1.0d * (2053456L - 396264L - 44280L - 397836L) / 2053456L,
            memUsedRatio.getValue().doubleValue(), 0.0001d);
    Assert.assertEquals(0L, memSwapTotal.getValue().longValue());
    Assert.assertEquals(0L, memSwapUsed.getValue().longValue());
    Assert.assertEquals(0L, memSwapFree.getValue().longValue());
}