Fix javadoc in org.eclipse.jgit.junit
Change-Id: I1107e6a82849ac329361baabb5c481d86ea6dc9e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
0b131b7312
commit
a90b75b47a
|
@ -44,12 +44,33 @@
|
|||
|
||||
import static java.lang.Boolean.valueOf;
|
||||
|
||||
/**
|
||||
* Assertion class
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
/**
|
||||
* Assert booleans are equal
|
||||
*
|
||||
* @param expect
|
||||
* expected value
|
||||
* @param actual
|
||||
* actual value
|
||||
*/
|
||||
public static void assertEquals(boolean expect, boolean actual) {
|
||||
org.junit.Assert.assertEquals(valueOf(expect), valueOf(actual));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert booleans are equal
|
||||
*
|
||||
* @param message
|
||||
* message
|
||||
* @param expect
|
||||
* expected value
|
||||
* @param actual
|
||||
* actual value
|
||||
*/
|
||||
public static void assertEquals(String message, boolean expect,
|
||||
boolean actual) {
|
||||
org.junit.Assert
|
||||
|
|
|
@ -64,13 +64,22 @@
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Abstract test util class
|
||||
*/
|
||||
public abstract class JGitTestUtil {
|
||||
/** Constant <code>CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"</code> */
|
||||
public static final String CLASSPATH_TO_RESOURCES = "org/eclipse/jgit/test/resources/";
|
||||
|
||||
private JGitTestUtil() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of current test by inspecting stack trace
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public static String getName() {
|
||||
GatherStackTrace stack;
|
||||
try {
|
||||
|
@ -109,6 +118,14 @@ private static class GatherStackTrace extends Exception {
|
|||
// Thrown above to collect the stack frame.
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert byte arrays are equal
|
||||
*
|
||||
* @param exp
|
||||
* expected value
|
||||
* @param act
|
||||
* actual value
|
||||
*/
|
||||
public static void assertEquals(byte[] exp, byte[] act) {
|
||||
Assert.assertEquals(s(exp), s(act));
|
||||
}
|
||||
|
@ -117,6 +134,12 @@ private static String s(byte[] raw) {
|
|||
return RawParseUtils.decode(raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get test resource file.
|
||||
*
|
||||
* @param fileName
|
||||
* @return the test resource file
|
||||
*/
|
||||
public static File getTestResourceFile(final String fileName) {
|
||||
if (fileName == null || fileName.length() <= 0) {
|
||||
return null;
|
||||
|
@ -145,6 +168,13 @@ public static File getTestResourceFile(final String fileName) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy test resource.
|
||||
*
|
||||
* @param name
|
||||
* @param dest
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copyTestResource(String name, File dest)
|
||||
throws IOException {
|
||||
URL url = cl().getResource(CLASSPATH_TO_RESOURCES + name);
|
||||
|
@ -169,6 +199,15 @@ private static ClassLoader cl() {
|
|||
return JGitTestUtil.class.getClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a trash file.
|
||||
*
|
||||
* @param db
|
||||
* @param name
|
||||
* @param data
|
||||
* @return the trash file
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File writeTrashFile(final Repository db,
|
||||
final String name, final String data) throws IOException {
|
||||
File path = new File(db.getWorkTree(), name);
|
||||
|
@ -176,6 +215,16 @@ public static File writeTrashFile(final Repository db,
|
|||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a trash file.
|
||||
*
|
||||
* @param db
|
||||
* @param subdir
|
||||
* @param name
|
||||
* @param data
|
||||
* @return the trash file
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File writeTrashFile(final Repository db,
|
||||
final String subdir,
|
||||
final String name, final String data) throws IOException {
|
||||
|
@ -224,17 +273,40 @@ public static String read(final File file) throws IOException {
|
|||
return new String(body, 0, body.length, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a file's content
|
||||
*
|
||||
* @param db
|
||||
* @param name
|
||||
* @return the content of the file
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String read(final Repository db, final String name)
|
||||
throws IOException {
|
||||
File file = new File(db.getWorkTree(), name);
|
||||
return read(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists
|
||||
*
|
||||
* @param db
|
||||
* @param name
|
||||
* name of the file
|
||||
* @return {@code true} if the file exists
|
||||
*/
|
||||
public static boolean check(final Repository db, final String name) {
|
||||
File file = new File(db.getWorkTree(), name);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a trash file.
|
||||
*
|
||||
* @param db
|
||||
* @param name
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void deleteTrashFile(final Repository db,
|
||||
final String name) throws IOException {
|
||||
File path = new File(db.getWorkTree(), name);
|
||||
|
@ -242,6 +314,8 @@ public static void deleteTrashFile(final Repository db,
|
|||
}
|
||||
|
||||
/**
|
||||
* Write a symbolic link
|
||||
*
|
||||
* @param db
|
||||
* the repository
|
||||
* @param link
|
||||
|
|
|
@ -82,8 +82,9 @@
|
|||
* A temporary directory is created for each test, allowing each test to use a
|
||||
* fresh environment. The temporary directory is cleaned up after the test ends.
|
||||
* <p>
|
||||
* Callers should not use {@link RepositoryCache} from within these tests as it
|
||||
* may wedge file descriptors open past the end of the test.
|
||||
* Callers should not use {@link org.eclipse.jgit.lib.RepositoryCache} from
|
||||
* within these tests as it may wedge file descriptors open past the end of the
|
||||
* test.
|
||||
* <p>
|
||||
* A system property {@code jgit.junit.usemmap} defines whether memory mapping
|
||||
* is used. Memory mapping has an effect on the file system, in that memory
|
||||
|
@ -112,6 +113,11 @@ public abstract class LocalDiskRepositoryTestCase {
|
|||
private final Set<Repository> toClose = new HashSet<>();
|
||||
private File tmp;
|
||||
|
||||
/**
|
||||
* Setup test
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tmp = File.createTempFile("jgit_test_", "_tmp");
|
||||
|
@ -142,10 +148,20 @@ public void setUp() throws Exception {
|
|||
c.install();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary directory.
|
||||
*
|
||||
* @return the temporary directory
|
||||
*/
|
||||
protected File getTemporaryDirectory() {
|
||||
return tmp.getAbsoluteFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of ceiling directories
|
||||
*
|
||||
* @return list of ceiling directories
|
||||
*/
|
||||
protected List<File> getCeilings() {
|
||||
return Collections.singletonList(getTemporaryDirectory());
|
||||
}
|
||||
|
@ -164,6 +180,11 @@ private static String makePath(List<?> objects) {
|
|||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down the test
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
RepositoryCache.clear();
|
||||
|
@ -185,7 +206,9 @@ public void tearDown() throws Exception {
|
|||
SystemReader.setInstance(null);
|
||||
}
|
||||
|
||||
/** Increment the {@link #author} and {@link #committer} times. */
|
||||
/**
|
||||
* Increment the {@link #author} and {@link #committer} times.
|
||||
*/
|
||||
protected void tick() {
|
||||
mockSystemReader.tick(5 * 60);
|
||||
final long now = mockSystemReader.getCurrentTime();
|
||||
|
@ -239,16 +262,22 @@ private static void reportDeleteFailure(boolean failOnError, File e) {
|
|||
System.err.println(msg);
|
||||
}
|
||||
|
||||
/** Constant <code>MOD_TIME=1</code> */
|
||||
public static final int MOD_TIME = 1;
|
||||
|
||||
/** Constant <code>SMUDGE=2</code> */
|
||||
public static final int SMUDGE = 2;
|
||||
|
||||
/** Constant <code>LENGTH=4</code> */
|
||||
public static final int LENGTH = 4;
|
||||
|
||||
/** Constant <code>CONTENT_ID=8</code> */
|
||||
public static final int CONTENT_ID = 8;
|
||||
|
||||
/** Constant <code>CONTENT=16</code> */
|
||||
public static final int CONTENT = 16;
|
||||
|
||||
/** Constant <code>ASSUME_UNCHANGED=32</code> */
|
||||
public static final int ASSUME_UNCHANGED = 32;
|
||||
|
||||
/**
|
||||
|
@ -279,7 +308,6 @@ private static void reportDeleteFailure(boolean failOnError, File e) {
|
|||
*
|
||||
* @param repo
|
||||
* the repository the index state should be determined for
|
||||
*
|
||||
* @param includedOptions
|
||||
* a bitmask constructed out of the constants {@link #MOD_TIME},
|
||||
* {@link #SMUDGE}, {@link #LENGTH}, {@link #CONTENT_ID} and
|
||||
|
@ -546,6 +574,14 @@ protected void write(final File f, final String body) throws IOException {
|
|||
JGitTestUtil.write(f, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a file's content
|
||||
*
|
||||
* @param f
|
||||
* the file
|
||||
* @return the content of the file
|
||||
* @throws IOException
|
||||
*/
|
||||
protected String read(final File f) throws IOException {
|
||||
return JGitTestUtil.read(f);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
import org.eclipse.jgit.util.time.ProposedTimestamp;
|
||||
|
||||
/**
|
||||
* Mock {@link SystemReader} for tests.
|
||||
* Mock {@link org.eclipse.jgit.util.SystemReader} for tests.
|
||||
*/
|
||||
public class MockSystemReader extends SystemReader {
|
||||
private final class MockConfig extends FileBasedConfig {
|
||||
|
@ -94,6 +94,9 @@ public boolean isOutdated() {
|
|||
|
||||
FileBasedConfig systemGitConfig;
|
||||
|
||||
/**
|
||||
* Constructor for <code>MockSystemReader</code>
|
||||
*/
|
||||
public MockSystemReader() {
|
||||
init(Constants.OS_USER_NAME_KEY);
|
||||
init(Constants.GIT_AUTHOR_NAME_KEY);
|
||||
|
@ -110,46 +113,62 @@ private void init(final String n) {
|
|||
setProperty(n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear properties
|
||||
*/
|
||||
public void clearProperties() {
|
||||
values.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public void setProperty(String key, String value) {
|
||||
values.put(key, value);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getenv(String variable) {
|
||||
return values.get(variable);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
return values.get(key);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FileBasedConfig openUserConfig(Config parent, FS fs) {
|
||||
assert parent == null || parent == systemGitConfig;
|
||||
return userGitConfig;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FileBasedConfig openSystemConfig(Config parent, FS fs) {
|
||||
assert parent == null;
|
||||
return systemGitConfig;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return "fake.host.example.com";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long getCurrentTime() {
|
||||
return now;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public MonotonicClock getClock() {
|
||||
return new MonotonicClock() {
|
||||
|
@ -182,26 +201,31 @@ public void tick(final int secDelta) {
|
|||
now += secDelta * 1000L;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getTimezone(long when) {
|
||||
return getTimeZone().getOffset(when) / (60 * 1000);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public TimeZone getTimeZone() {
|
||||
return TimeZone.getTimeZone("GMT-03:30");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.US;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SimpleDateFormat getSimpleDateFormat(String pattern) {
|
||||
return new SimpleDateFormat(pattern, getLocale());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle) {
|
||||
return DateFormat
|
||||
|
|
|
@ -46,8 +46,14 @@
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Interface enabling to run tests repeatedly
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ java.lang.annotation.ElementType.METHOD })
|
||||
public @interface Repeat {
|
||||
/**
|
||||
* Number of repetitions
|
||||
*/
|
||||
public abstract int n();
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
import org.junit.runners.model.Statement;
|
||||
|
||||
/**
|
||||
* {@link TestRule} which enables to run the same JUnit test repeatedly. Add
|
||||
* this rule to the test class
|
||||
* {@link org.junit.rules.TestRule} which enables to run the same JUnit test
|
||||
* repeatedly. Add this rule to the test class
|
||||
*
|
||||
* <pre>
|
||||
* public class MyTest {
|
||||
|
@ -118,6 +118,7 @@ public void evaluate() throws Throwable {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Statement apply(Statement statement, Description description) {
|
||||
Statement result = statement;
|
||||
|
|
|
@ -84,6 +84,13 @@
|
|||
* repositories and destroying them when the tests are finished.
|
||||
*/
|
||||
public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
|
||||
/**
|
||||
* Copy a file
|
||||
*
|
||||
* @param src
|
||||
* @param dst
|
||||
* @throws IOException
|
||||
*/
|
||||
protected static void copyFile(final File src, final File dst)
|
||||
throws IOException {
|
||||
final FileInputStream fis = new FileInputStream(src);
|
||||
|
@ -103,6 +110,14 @@ protected static void copyFile(final File src, final File dst)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a trash file
|
||||
*
|
||||
* @param name
|
||||
* @param data
|
||||
* @return the trash file
|
||||
* @throws IOException
|
||||
*/
|
||||
protected File writeTrashFile(final String name, final String data)
|
||||
throws IOException {
|
||||
return JGitTestUtil.writeTrashFile(db, name, data);
|
||||
|
@ -124,24 +139,62 @@ protected Path writeLink(final String link, final String target)
|
|||
return JGitTestUtil.writeLink(db, link, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a trash file
|
||||
*
|
||||
* @param subdir
|
||||
* @param name
|
||||
* @param data
|
||||
* @return the trash file
|
||||
* @throws IOException
|
||||
*/
|
||||
protected File writeTrashFile(final String subdir, final String name,
|
||||
final String data)
|
||||
throws IOException {
|
||||
return JGitTestUtil.writeTrashFile(db, subdir, name, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read content of a file
|
||||
*
|
||||
* @param name
|
||||
* @return the file's content
|
||||
* @throws IOException
|
||||
*/
|
||||
protected String read(final String name) throws IOException {
|
||||
return JGitTestUtil.read(db, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists
|
||||
*
|
||||
* @param name
|
||||
* file name
|
||||
* @return if the file exists
|
||||
*/
|
||||
protected boolean check(final String name) {
|
||||
return JGitTestUtil.check(db, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a trash file
|
||||
*
|
||||
* @param name
|
||||
* file name
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void deleteTrashFile(final String name) throws IOException {
|
||||
JGitTestUtil.deleteTrashFile(db, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check content of a file.
|
||||
*
|
||||
* @param f
|
||||
* @param checkData
|
||||
* expected content
|
||||
* @throws IOException
|
||||
*/
|
||||
protected static void checkFile(File f, final String checkData)
|
||||
throws IOException {
|
||||
Reader r = new InputStreamReader(new FileInputStream(f), "UTF-8");
|
||||
|
@ -161,6 +214,7 @@ protected static void checkFile(File f, final String checkData)
|
|||
/** Working directory of {@link #db}. */
|
||||
protected File trash;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -220,8 +274,8 @@ public String indexState(int includedOptions)
|
|||
* have an index which matches their prepared content.
|
||||
*
|
||||
* @param treeItr
|
||||
* a {@link FileTreeIterator} which determines which files should
|
||||
* go into the new index
|
||||
* a {@link org.eclipse.jgit.treewalk.FileTreeIterator} which
|
||||
* determines which files should go into the new index
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -261,13 +315,13 @@ protected void resetIndex(FileTreeIterator treeItr)
|
|||
*
|
||||
* @param l
|
||||
* the object to lookup
|
||||
* @param lookupTable
|
||||
* a table storing object-name mappings.
|
||||
* @param nameTemplate
|
||||
* the name for that object. Can contain "%n" which will be
|
||||
* replaced by a running number before used as a name. If the
|
||||
* lookup table already contains the object this parameter will
|
||||
* be ignored
|
||||
* @param lookupTable
|
||||
* a table storing object-name mappings.
|
||||
* @return a name of that object. Is not guaranteed to be unique. Use
|
||||
* nameTemplates containing "%n" to always have unique names
|
||||
*/
|
||||
|
@ -288,7 +342,7 @@ public static String lookup(Object l, String nameTemplate,
|
|||
* @param str
|
||||
* the string in which backslashes should be replaced
|
||||
* @return the resulting string with slashes
|
||||
* @since 4.2
|
||||
* @since 4.2
|
||||
*/
|
||||
public static String slashify(String str) {
|
||||
str = str.replace('\\', '/');
|
||||
|
@ -335,6 +389,13 @@ public static long fsTick(File lastFile) throws InterruptedException,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch
|
||||
*
|
||||
* @param objectId
|
||||
* @param branchName
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void createBranch(ObjectId objectId, String branchName)
|
||||
throws IOException {
|
||||
RefUpdate updateRef = db.updateRef(branchName);
|
||||
|
@ -342,6 +403,13 @@ protected void createBranch(ObjectId objectId, String branchName)
|
|||
updateRef.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout a branch
|
||||
*
|
||||
* @param branchName
|
||||
* @throws IllegalStateException
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void checkoutBranch(String branchName)
|
||||
throws IllegalStateException, IOException {
|
||||
try (RevWalk walk = new RevWalk(db)) {
|
||||
|
@ -429,15 +497,39 @@ else if (empty)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create <code>DirCacheEntry</code>
|
||||
*
|
||||
* @param path
|
||||
* @param mode
|
||||
* @return the DirCacheEntry
|
||||
*/
|
||||
protected DirCacheEntry createEntry(final String path, final FileMode mode) {
|
||||
return createEntry(path, mode, DirCacheEntry.STAGE_0, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create <code>DirCacheEntry</code>
|
||||
*
|
||||
* @param path
|
||||
* @param mode
|
||||
* @param content
|
||||
* @return the DirCacheEntry
|
||||
*/
|
||||
protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
||||
final String content) {
|
||||
return createEntry(path, mode, DirCacheEntry.STAGE_0, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create <code>DirCacheEntry</code>
|
||||
*
|
||||
* @param path
|
||||
* @param mode
|
||||
* @param stage
|
||||
* @param content
|
||||
* @return the DirCacheEntry
|
||||
*/
|
||||
protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
||||
final int stage, final String content) {
|
||||
final DirCacheEntry entry = new DirCacheEntry(path, stage);
|
||||
|
@ -449,6 +541,13 @@ protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
|||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert files are equal
|
||||
*
|
||||
* @param expected
|
||||
* @param actual
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void assertEqualsFile(File expected, File actual)
|
||||
throws IOException {
|
||||
assertEquals(expected.getCanonicalFile(), actual.getCanonicalFile());
|
||||
|
|
|
@ -47,30 +47,38 @@
|
|||
|
||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||
|
||||
/**
|
||||
* Strict work monitor
|
||||
*/
|
||||
public final class StrictWorkMonitor implements ProgressMonitor {
|
||||
private int lastWork, totalWork;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(int totalTasks) {
|
||||
// empty
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void beginTask(String title, int total) {
|
||||
this.totalWork = total;
|
||||
lastWork = 0;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void update(int completed) {
|
||||
lastWork += completed;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void endTask() {
|
||||
assertEquals("Units of work recorded", totalWork, lastWork);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
|
|
|
@ -114,12 +114,16 @@
|
|||
*/
|
||||
public class TestRepository<R extends Repository> {
|
||||
|
||||
/** Constant <code>AUTHOR="J. Author"</code> */
|
||||
public static final String AUTHOR = "J. Author";
|
||||
|
||||
/** Constant <code>AUTHOR_EMAIL="jauthor@example.com"</code> */
|
||||
public static final String AUTHOR_EMAIL = "jauthor@example.com";
|
||||
|
||||
/** Constant <code>COMMITTER="J. Committer"</code> */
|
||||
public static final String COMMITTER = "J. Committer";
|
||||
|
||||
/** Constant <code>COMMITTER_EMAIL="jcommitter@example.com"</code> */
|
||||
public static final String COMMITTER_EMAIL = "jcommitter@example.com";
|
||||
|
||||
private final PersonIdent defaultAuthor;
|
||||
|
@ -186,25 +190,38 @@ public TestRepository(R db, RevWalk rw, MockSystemReader reader)
|
|||
defaultCommitter = new PersonIdent(COMMITTER, COMMITTER_EMAIL, now, tz);
|
||||
}
|
||||
|
||||
/** @return the repository this helper class operates against. */
|
||||
/**
|
||||
* Get repository
|
||||
*
|
||||
* @return the repository this helper class operates against.
|
||||
*/
|
||||
public R getRepository() {
|
||||
return db;
|
||||
}
|
||||
|
||||
/** @return get the RevWalk pool all objects are allocated through. */
|
||||
/**
|
||||
* Get RevWalk
|
||||
*
|
||||
* @return get the RevWalk pool all objects are allocated through.
|
||||
*/
|
||||
public RevWalk getRevWalk() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Git API wrapper
|
||||
*
|
||||
* @return an API wrapper for the underlying repository. This wrapper does
|
||||
* not allocate any new resources and need not be closed (but closing
|
||||
* it is harmless). */
|
||||
* not allocate any new resources and need not be closed (but
|
||||
* closing it is harmless).
|
||||
*/
|
||||
public Git git() {
|
||||
return git;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date
|
||||
*
|
||||
* @return current date.
|
||||
* @since 4.2
|
||||
*/
|
||||
|
@ -212,7 +229,11 @@ public Date getDate() {
|
|||
return new Date(mockSystemReader.getCurrentTime());
|
||||
}
|
||||
|
||||
/** @return timezone used for default identities. */
|
||||
/**
|
||||
* Get timezone
|
||||
*
|
||||
* @return timezone used for default identities.
|
||||
*/
|
||||
public TimeZone getTimeZone() {
|
||||
return mockSystemReader.getTimeZone();
|
||||
}
|
||||
|
@ -424,7 +445,11 @@ public RevCommit commit(final int secDelta, final RevTree tree,
|
|||
return pool.lookupCommit(id);
|
||||
}
|
||||
|
||||
/** @return a new commit builder. */
|
||||
/**
|
||||
* Create commit builder
|
||||
*
|
||||
* @return a new commit builder.
|
||||
*/
|
||||
public CommitBuilder commit() {
|
||||
return new CommitBuilder();
|
||||
}
|
||||
|
@ -618,7 +643,7 @@ private static String normalizeRef(String ref) {
|
|||
|
||||
/**
|
||||
* Soft-reset HEAD to a detached state.
|
||||
* <p>
|
||||
*
|
||||
* @param id
|
||||
* ID of detached head.
|
||||
* @throws Exception
|
||||
|
@ -758,7 +783,8 @@ protected void writeFile(final String name, final byte[] bin)
|
|||
* Ensure the body of the given object has been parsed.
|
||||
*
|
||||
* @param <T>
|
||||
* type of object, e.g. {@link RevTag} or {@link RevCommit}.
|
||||
* type of object, e.g. {@link org.eclipse.jgit.revwalk.RevTag}
|
||||
* or {@link org.eclipse.jgit.revwalk.RevCommit}.
|
||||
* @param object
|
||||
* reference to the (possibly unparsed) object to force body
|
||||
* parsing of.
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
|
||||
package org.eclipse.jgit.junit;
|
||||
|
||||
/** Toy RNG to ensure we get predictable numbers during unit tests. */
|
||||
/**
|
||||
* Toy RNG to ensure we get predictable numbers during unit tests.
|
||||
*/
|
||||
public class TestRng {
|
||||
private int next;
|
||||
|
||||
|
@ -74,6 +76,8 @@ public byte[] nextBytes(final int cnt) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Next int
|
||||
*
|
||||
* @return the next random integer.
|
||||
*/
|
||||
public int nextInt() {
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
import org.eclipse.jgit.util.time.ProposedTimestamp;
|
||||
|
||||
/**
|
||||
* Fake {@link MonotonicClock} for testing code that uses Clock.
|
||||
* Fake {@link org.eclipse.jgit.util.time.MonotonicClock} for testing code that
|
||||
* uses Clock.
|
||||
*
|
||||
* @since 4.6
|
||||
*/
|
||||
|
@ -72,6 +73,7 @@ public void tick(long add, TimeUnit unit) {
|
|||
now += unit.toMillis(add);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ProposedTimestamp propose() {
|
||||
long t = now++;
|
||||
|
|
Loading…
Reference in New Issue