diff test/org/tmatesoft/hg/test/TestClone.java @ 202:706bcc7cfee4

Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 26 Apr 2011 02:50:06 +0200
parents a736f42ed75b
children 883f1efbcf27
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestClone.java	Thu Apr 21 19:16:45 2011 +0200
+++ b/test/org/tmatesoft/hg/test/TestClone.java	Tue Apr 26 02:50:06 2011 +0200
@@ -22,8 +22,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import junit.framework.Assert;
-
+import org.hamcrest.CoreMatchers;
 import org.junit.Rule;
 import org.tmatesoft.hg.core.HgCloneCommand;
 import org.tmatesoft.hg.repo.HgRemoteRepository;
@@ -38,9 +37,10 @@
 	@Rule
 	public ErrorCollectorExt errorCollector = new ErrorCollectorExt();
 
-	public static void main(String[] args) throws Exception {
+	public static void main(String[] args) throws Throwable {
 		TestClone t = new TestClone();
 		t.testSimpleClone();
+		t.errorCollector.verify();
 	}
 
 	public TestClone() {
@@ -48,7 +48,7 @@
 	
 	public void testSimpleClone() throws Exception {
 		int x = 0;
-		final File tempDir = new File(System.getProperty("java.io.tmpdir"));
+		final File tempDir = Configuration.get().getTempDir();
 		for (HgRemoteRepository hgRemote : Configuration.get().allRemote()) {
 			HgCloneCommand cmd = new HgCloneCommand();
 			cmd.source(hgRemote);
@@ -63,21 +63,16 @@
 	}
 
 	private void verify(HgRemoteRepository hgRemote, File dest) throws Exception {
-		OutputParser noop = new OutputParser() {
-			public void parse(CharSequence seq) {
-				// no-op
-			}
-		};
-		ExecHelper eh = new ExecHelper(noop, dest);
+		ExecHelper eh = new ExecHelper(new OutputParser.Stub(), dest);
 		eh.run("hg", "verify");
-		Assert.assertEquals(0, eh.getExitValue());
+		errorCollector.checkThat("Verify", eh.getExitValue(), CoreMatchers.equalTo(0));
 		eh.run("hg", "out", hgRemote.getLocation());
-		Assert.assertEquals(1, eh.getExitValue());
+		errorCollector.checkThat("Outgoing", eh.getExitValue(), CoreMatchers.equalTo(1));
 		eh.run("hg", "in", hgRemote.getLocation());
-		Assert.assertEquals(1, eh.getExitValue());
+		errorCollector.checkThat("Incoming", eh.getExitValue(), CoreMatchers.equalTo(1));
 	}
 
-	private static void rmdir(File dest) throws IOException {
+	static void rmdir(File dest) throws IOException {
 		LinkedList<File> queue = new LinkedList<File>();
 		queue.addAll(Arrays.asList(dest.listFiles()));
 		while (!queue.isEmpty()) {