aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2017-12-17 19:50:13 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2017-12-17 20:21:54 +0100
commita90b75b47aff1c7139056352bf0145858ea3742c (patch)
treeff716f2f310e2b2ff52f60c308bc6a4cdb92a6b6 /org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
parent0b131b731263fbddebf1026a71a4bba8ce64574f (diff)
downloadjgit-a90b75b47aff1c7139056352bf0145858ea3742c.tar.gz
jgit-a90b75b47aff1c7139056352bf0145858ea3742c.zip
Fix javadoc in org.eclipse.jgit.junit
Change-Id: I1107e6a82849ac329361baabb5c481d86ea6dc9e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java109
1 files changed, 104 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
index c282df03bd..044f08072a 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
@@ -84,6 +84,13 @@ import org.junit.Before;
* 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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
}
}
+ /**
+ * 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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
/** Working directory of {@link #db}. */
protected File trash;
+ /** {@inheritDoc} */
@Override
@Before
public void setUp() throws Exception {
@@ -220,8 +274,8 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* 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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
*
* @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 abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
* @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 abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
}
}
+ /**
+ * 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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
}
}
+ /**
+ * 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 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
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());