Mercurial > hg4j
diff test/org/tmatesoft/hg/test/TestByteChannel.java @ 115:c0cc2535462c
Introduced channels to pipeline (and easily filter) data streams
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 03 Feb 2011 23:32:08 +0100 |
parents | |
children | 5d13dcaaff39 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/org/tmatesoft/hg/test/TestByteChannel.java Thu Feb 03 23:32:08 2011 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2011 TMate Software Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For information on how to redistribute this software under + * the terms of a license other than GNU General Public License + * contact TMate Software at support@svnkit.com + */ +package org.tmatesoft.hg.test; + +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; + +/** + * + * @author Artem Tikhomirov + * @author TMate Software Ltd. + */ +public class TestByteChannel { + + public static void main(String[] args) throws Exception { + RepositoryFacade rf = new RepositoryFacade(); + rf.init(); + HgDataFile file = rf.getRepository().getFileNode("COPYING"); + int rev = HgRepository.TIP; + 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(); + } +}