Change-Id: I8575797127fc96abea8af56f019ca39f5897486f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>tags/v4.2.0.201601211800-r
FileUtils.delete(path); | FileUtils.delete(path); | ||||
} | } | ||||
/** | |||||
* @param db | |||||
* the repository | |||||
* @param link | |||||
* the path of the symbolic link to create | |||||
* @param target | |||||
* the target of the symbolic link | |||||
* @return the path to the symbolic link | |||||
* @throws Exception | |||||
* @since 4.2 | |||||
*/ | |||||
public static Path writeLink(Repository db, String link, | public static Path writeLink(Repository db, String link, | ||||
String target) throws Exception { | String target) throws Exception { | ||||
return FileUtils.createSymLink(new File(db.getWorkTree(), link), | return FileUtils.createSymLink(new File(db.getWorkTree(), link), |
/** A fake (but stable) identity for committer fields in the test. */ | /** A fake (but stable) identity for committer fields in the test. */ | ||||
protected PersonIdent committer; | protected PersonIdent committer; | ||||
/** A {@link SystemReader} used to coordinate time, envars, etc. */ | |||||
/** | |||||
* A {@link SystemReader} used to coordinate time, envars, etc. | |||||
* @since 4.2 | |||||
*/ | |||||
protected MockSystemReader mockSystemReader; | protected MockSystemReader mockSystemReader; | ||||
private final List<Repository> toClose = new ArrayList<Repository>(); | private final List<Repository> toClose = new ArrayList<Repository>(); |
* | * | ||||
* @param secDelta | * @param secDelta | ||||
* number of seconds to add to the current time. | * number of seconds to add to the current time. | ||||
* @since 4.2 | |||||
*/ | */ | ||||
public void tick(final int secDelta) { | public void tick(final int secDelta) { | ||||
now += secDelta * 1000L; | now += secDelta * 1000L; |
return JGitTestUtil.writeTrashFile(db, name, data); | return JGitTestUtil.writeTrashFile(db, name, data); | ||||
} | } | ||||
/** | |||||
* Create a symbolic link | |||||
* | |||||
* @param link | |||||
* the path of the symbolic link to create | |||||
* @param target | |||||
* the target of the symbolic link | |||||
* @return the path to the symbolic link | |||||
* @throws Exception | |||||
* @since 4.2 | |||||
*/ | |||||
protected Path writeLink(final String link, final String target) | protected Path writeLink(final String link, final String target) | ||||
throws Exception { | throws Exception { | ||||
return JGitTestUtil.writeLink(db, link, target); | return JGitTestUtil.writeLink(db, link, target); |
* the MockSystemReader to use for clock and other system | * the MockSystemReader to use for clock and other system | ||||
* operations. | * operations. | ||||
* @throws IOException | * @throws IOException | ||||
* @since 4.2 | |||||
*/ | */ | ||||
public TestRepository(R db, RevWalk rw, MockSystemReader reader) | public TestRepository(R db, RevWalk rw, MockSystemReader reader) | ||||
throws IOException { | throws IOException { | ||||
return git; | return git; | ||||
} | } | ||||
/** @return current date. */ | |||||
/** | |||||
* @return current date. | |||||
* @since 4.2 | |||||
*/ | |||||
public Date getDate() { | public Date getDate() { | ||||
return new Date(mockSystemReader.getCurrentTime()); | return new Date(mockSystemReader.getCurrentTime()); | ||||
} | } |
* Create a symbolic link | * Create a symbolic link | ||||
* | * | ||||
* @param path | * @param path | ||||
* the path of the symbolic link to create | |||||
* @param target | * @param target | ||||
* @return path to the created link | |||||
* the target of the symbolic link | |||||
* @return the path to the symbolic link | |||||
* @throws IOException | * @throws IOException | ||||
* @since 4.2 | * @since 4.2 | ||||
*/ | */ |