comparison 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
comparison
equal deleted inserted replaced
114:46291ec605a0 115:c0cc2535462c
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@svnkit.com
16 */
17 package org.tmatesoft.hg.test;
18
19 import java.util.Arrays;
20
21 import org.junit.Assert;
22 import org.tmatesoft.hg.core.CatCommand;
23 import org.tmatesoft.hg.core.RepositoryFacade;
24 import org.tmatesoft.hg.internal.ByteArrayChannel;
25 import org.tmatesoft.hg.repo.HgDataFile;
26 import org.tmatesoft.hg.repo.HgRepository;
27
28 /**
29 *
30 * @author Artem Tikhomirov
31 * @author TMate Software Ltd.
32 */
33 public class TestByteChannel {
34
35 public static void main(String[] args) throws Exception {
36 RepositoryFacade rf = new RepositoryFacade();
37 rf.init();
38 HgDataFile file = rf.getRepository().getFileNode("COPYING");
39 int rev = HgRepository.TIP;
40 byte[] oldAccess = file.content(rev);
41 ByteArrayChannel ch = new ByteArrayChannel();
42 file.content(rev, ch);
43 byte[] newAccess = ch.toArray();
44 Assert.assertArrayEquals(oldAccess, newAccess);
45 //CatCommand cmd = rf.createCatCommand();
46 }
47 }