Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestCatCommand.java @ 479:59b7c817bc4d
Methods from Main graduated as tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 12 Jul 2012 20:02:49 +0200 |
parents | |
children | b286222158be |
comparison
equal
deleted
inserted
replaced
478:e74580e24feb | 479:59b7c817bc4d |
---|---|
1 /* | |
2 * Copyright (c) 2012 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@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.test; | |
18 | |
19 import static org.junit.Assert.*; | |
20 | |
21 import org.junit.Test; | |
22 import org.tmatesoft.hg.core.HgCatCommand; | |
23 import org.tmatesoft.hg.core.HgChangesetFileSneaker; | |
24 import org.tmatesoft.hg.core.Nodeid; | |
25 import org.tmatesoft.hg.internal.ByteArrayChannel; | |
26 import org.tmatesoft.hg.repo.HgLookup; | |
27 import org.tmatesoft.hg.repo.HgRepository; | |
28 import org.tmatesoft.hg.util.Path; | |
29 | |
30 /** | |
31 * | |
32 * @author Artem Tikhomirov | |
33 * @author TMate Software Ltd. | |
34 */ | |
35 public class TestCatCommand { | |
36 | |
37 private final HgRepository repo; | |
38 | |
39 public TestCatCommand() throws Exception { | |
40 repo = new HgLookup().detectFromWorkingDir(); | |
41 } | |
42 | |
43 @Test | |
44 public void testCatAtCsetRevision() throws Exception { | |
45 HgCatCommand cmd = new HgCatCommand(repo); | |
46 final Path file = Path.create("src/org/tmatesoft/hg/internal/RevlogStream.java"); | |
47 cmd.file(file); | |
48 final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554"); | |
49 cmd.changeset(cset); | |
50 final ByteArrayChannel sink = new ByteArrayChannel(); | |
51 cmd.execute(sink); | |
52 final int result1 = sink.toArray().length; | |
53 HgChangesetFileSneaker i = new HgChangesetFileSneaker(repo); | |
54 boolean result = i.changeset(cset).checkExists(file); | |
55 assertFalse(result); | |
56 assertFalse(i.exists()); | |
57 result = i.followRenames(true).checkExists(file); | |
58 assertTrue(result); | |
59 assertTrue(i.exists()); | |
60 HgCatCommand cmd2 = new HgCatCommand(repo).revision(i.getFileRevision()); | |
61 final ByteArrayChannel sink2 = new ByteArrayChannel(); | |
62 cmd2.execute(sink2); | |
63 final int result2 = sink2.toArray().length; | |
64 assertEquals(result1, result2); | |
65 } | |
66 | |
67 } |