comparison test/org/tmatesoft/hg/test/TestHistory.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents e51dd9a14b6f
children 31a89587eb04
comparison
equal deleted inserted replaced
422:5d1cc7366d04 423:9c9c442b5f2e
1 /* 1 /*
2 * Copyright (c) 2011 TMate Software Ltd 2 * Copyright (c) 2011-2012 TMate Software Ltd
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 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 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License. 6 * the Free Software Foundation; version 2 of the License.
7 * 7 *
111 // LogCommand does other way round, from oldest to newest, follewed by revisions of copy source, if any 111 // LogCommand does other way round, from oldest to newest, follewed by revisions of copy source, if any
112 // (apparently older than oldest of the copy target). Hence need to sort Java results according to rev numbers 112 // (apparently older than oldest of the copy target). Hence need to sort Java results according to rev numbers
113 final LinkedList<HgChangeset> sorted = new LinkedList<HgChangeset>(h.getChanges()); 113 final LinkedList<HgChangeset> sorted = new LinkedList<HgChangeset>(h.getChanges());
114 Collections.sort(sorted, new Comparator<HgChangeset>() { 114 Collections.sort(sorted, new Comparator<HgChangeset>() {
115 public int compare(HgChangeset cs1, HgChangeset cs2) { 115 public int compare(HgChangeset cs1, HgChangeset cs2) {
116 return cs1.getRevision() < cs2.getRevision() ? 1 : -1; 116 return cs1.getRevisionIndex() < cs2.getRevisionIndex() ? 1 : -1;
117 } 117 }
118 }); 118 });
119 report(what, sorted, false); 119 report(what, sorted, false);
120 } 120 }
121 121
135 if (!consoleResultItr.hasNext()) { 135 if (!consoleResultItr.hasNext()) {
136 errorCollector.addError(new AssertionError("Ran out of console results while there are still hg4j results")); 136 errorCollector.addError(new AssertionError("Ran out of console results while there are still hg4j results"));
137 break; 137 break;
138 } 138 }
139 Record cr = consoleResultItr.next(); 139 Record cr = consoleResultItr.next();
140 int x = cs.getRevision() == cr.changesetIndex ? 0x1 : 0; 140 int x = cs.getRevisionIndex() == cr.changesetIndex ? 0x1 : 0;
141 x |= cs.getDate().toString().equals(cr.date) ? 0x2 : 0; 141 x |= cs.getDate().toString().equals(cr.date) ? 0x2 : 0;
142 x |= cs.getNodeid().toString().equals(cr.changesetNodeid) ? 0x4 : 0; 142 x |= cs.getNodeid().toString().equals(cr.changesetNodeid) ? 0x4 : 0;
143 x |= cs.getUser().equals(cr.user) ? 0x8 : 0; 143 x |= cs.getUser().equals(cr.user) ? 0x8 : 0;
144 // need to do trim() on comment because command-line template does, and there are 144 // need to do trim() on comment because command-line template does, and there are
145 // repositories that have couple of newlines in the end of the comment (e.g. hello sample repo from the book) 145 // repositories that have couple of newlines in the end of the comment (e.g. hello sample repo from the book)
146 x |= cs.getComment().trim().equals(cr.description) ? 0x10 : 0; 146 x |= cs.getComment().trim().equals(cr.description) ? 0x10 : 0;
147 errorCollector.checkThat(String.format(what + ". Mismatch (0x%x) in %d hg4j rev comparing to %d cmdline's.", x, cs.getRevision(), cr.changesetIndex), x, equalTo(0x1f)); 147 errorCollector.checkThat(String.format(what + ". Mismatch (0x%x) in %d hg4j rev comparing to %d cmdline's.", x, cs.getRevisionIndex(), cr.changesetIndex), x, equalTo(0x1f));
148 consoleResultItr.remove(); 148 consoleResultItr.remove();
149 } 149 }
150 errorCollector.checkThat(what + ". Unprocessed results in console left (insufficient from hg4j)", consoleResultItr.hasNext(), equalTo(false)); 150 errorCollector.checkThat(what + ". Unprocessed results in console left (insufficient from hg4j)", consoleResultItr.hasNext(), equalTo(false));
151 } 151 }
152 152