Mercurial > jhg
changeset 116:5d13dcaaff39
Test content of each and every revision
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 03 Feb 2011 23:37:21 +0100 |
parents | c0cc2535462c |
children | 6c0be854d149 |
files | test/org/tmatesoft/hg/test/TestByteChannel.java |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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); + } } }