blob: d25fb25412856b9d45600b1e2bcbd48b35423b1e [file] [log] [blame]
package com.gemstone.gemfire.internal.cache;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import static org.junit.Assert.*;
import com.examples.snapshot.MyObject;
import com.gemstone.gemfire.cache.snapshot.SnapshotIterator;
import com.gemstone.gemfire.cache.snapshot.SnapshotReader;
public class SnapshotTestUtil {
public static <K,V> void checkSnapshotEntries(File dir, Map<K, V> expected, String diskStoreName, String regionName)
throws Exception {
final Map<K, V> testData = new HashMap<K, V>(expected);
String snapshot = "snapshot-" + diskStoreName + "-" + regionName + ".gfd";
SnapshotIterator<Integer, MyObject> iter = SnapshotReader.read(new File(dir, snapshot));
try {
while (iter.hasNext()) {
Entry<Integer, MyObject> entry = iter.next();
Object expectedVal = testData.remove(entry.getKey());
assertEquals(expectedVal, entry.getValue());
}
assertTrue(testData.isEmpty());
} finally {
iter.close();
}
}
}