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

    String data0 = "Active connections: 1\n" +
            "server accepts handled requests request_time\n" +
            " 65355 65355 56195 37545\n" +
            "ssl new reused(SID+ticket)\n" +
            " 0 0\n" +
            "Reading: 0 Writing: 1 Waiting: 0\n" +
            "SSL_Requests: 0 SSL_Handshake: 0 SSL_Handshake_Time: 0";
    String data1 = "Active connections: 1\n" +
            "server accepts handled requests request_time\n" +
            " 2 3 4 5\n" +
            "ssl new reused(SID+ticket)\n" +
            " 0 0\n" +
            "Reading: 1 Writing: 2 Waiting: 3\n" +
            "SSL_Requests: 0 SSL_Handshake: 0 SSL_Handshake_Time: 0";
    ManualClock clock = new ManualClock();
    TestNginxGaugeSet nginxGaugeSet = new TestNginxGaugeSet(clock);
    Map<MetricName, Metric> metrics = nginxGaugeSet.getMetrics();
    Assert.assertEquals(8, metrics.keySet().size());
    clock.addMillis(1000);
    nginxGaugeSet.setData(data0);
    Gauge<Double> connAccepted = (Gauge<Double>)metrics.get(MetricName.build("conn.accepted"));
    Gauge<Double> connHandled = (Gauge<Double>)metrics.get(MetricName.build("conn.handled"));
    Gauge<Double> reqQps = (Gauge<Double>)metrics.get(MetricName.build("request.qps"));
    Gauge<Double> reqAvgRt = (Gauge<Double>)metrics.get(MetricName.build("request.avg_rt"));
    Gauge<Long> connActive = (Gauge<Long>)metrics.get(MetricName.build("conn.active"));
    Gauge<Long> connReading = (Gauge<Long>)metrics.get(MetricName.build("conn.reading"));
    Gauge<Long> connWriting = (Gauge<Long>)metrics.get(MetricName.build("conn.writing"));
    Gauge<Long> connWaiting = (Gauge<Long>)metrics.get(MetricName.build("conn.waiting"));
    Assert.assertEquals(0.0d, connAccepted.getValue(), 0.0001d);
    clock.addMillis(1000);
    nginxGaugeSet.setData(data1);
    Assert.assertEquals(Constants.NOT_AVAILABLE, connAccepted.getValue(), 0.0001d);
    Assert.assertEquals(Constants.NOT_AVAILABLE, connHandled.getValue(), 0.0001d);
    Assert.assertEquals(Constants.NOT_AVAILABLE, reqQps.getValue(), 0.0001d);
    Assert.assertEquals(Constants.NOT_AVAILABLE, reqAvgRt.getValue(), 0.0001d);
    Assert.assertEquals(1L, connActive.getValue().longValue());
    Assert.assertEquals(1L, connReading.getValue().longValue());
    Assert.assertEquals(2L, connWriting.getValue().longValue());
    Assert.assertEquals(3L, connWaiting.getValue().longValue());
}