# HG changeset patch # User Artem Tikhomirov # Date 1296772641 -3600 # Node ID 5d13dcaaff3988ed3d720e633f27be0185ad0c22 # Parent c0cc2535462c08b8162adbf0dc188a0017a45d3b Test content of each and every revision diff -r c0cc2535462c -r 5d13dcaaff39 test/org/tmatesoft/hg/test/TestByteChannel.java --- a/test/org/tmatesoft/hg/test/TestByteChannel.java Thu Feb 03 23:32:08 2011 +0100 +++ b/test/org/tmatesoft/hg/test/TestByteChannel.java Thu Feb 03 23:37:21 2011 +0100 @@ -19,11 +19,9 @@ import java.util.Arrays; import org.junit.Assert; -import org.tmatesoft.hg.core.CatCommand; import org.tmatesoft.hg.core.RepositoryFacade; import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.repo.HgDataFile; -import org.tmatesoft.hg.repo.HgRepository; /** * @@ -35,13 +33,24 @@ public static void main(String[] args) throws Exception { RepositoryFacade rf = new RepositoryFacade(); rf.init(); - HgDataFile file = rf.getRepository().getFileNode("COPYING"); - int rev = HgRepository.TIP; + HgDataFile file = rf.getRepository().getFileNode("TODO"); + for (int i = file.getRevisionCount() - 1; i >= 0; i--) { + System.out.print("Content for revision:" + i); + compareContent(file, i); + System.out.println(" OK"); + } + //CatCommand cmd = rf.createCatCommand(); + } + + private static void compareContent(HgDataFile file, int rev) throws Exception { byte[] oldAccess = file.content(rev); ByteArrayChannel ch = new ByteArrayChannel(); file.content(rev, ch); byte[] newAccess = ch.toArray(); Assert.assertArrayEquals(oldAccess, newAccess); - //CatCommand cmd = rf.createCatCommand(); + // don't trust anyone (even JUnit) + if (!Arrays.equals(oldAccess, newAccess)) { + throw new RuntimeException("Failed:" + rev); + } } }