@Test
public void testSyncSnapshotTimeStampChecking() throws Exception {

  initData(source);
  initData(target);
  dfs.allowSnapshot(source);
  dfs.allowSnapshot(target);
  dfs.createSnapshot(source, "s2");
  dfs.createSnapshot(target, "s1");
  // Sleep one second to make snapshot s1 created later than s2
  Thread.sleep(1000);
  dfs.createSnapshot(source, "s1");
  boolean threwException = false;
  try {
    DistCpSync distCpSync = new DistCpSync(context, conf);
    // do the sync
    distCpSync.sync();
  } catch (HadoopIllegalArgumentException e) {
    threwException = true;
    GenericTestUtils.assertExceptionContains(
        "Snapshot s2 should be newer than s1", e);
  }
  Assert.assertTrue(threwException);
}