public abstract class JGitTestUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CLASSPATH_TO_RESOURCES
Constant
CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/" |
Modifier and Type | Method and Description |
---|---|
static void |
assertEquals(byte[] exp,
byte[] act)
Assert byte arrays are equal
|
static boolean |
check(Repository db,
String name)
Check if file exists
|
static byte[] |
concat(byte[]... b)
Concatenate byte arrays.
|
static void |
copyTestResource(String name,
File dest)
Copy test resource.
|
static void |
deleteTrashFile(Repository db,
String name)
Delete a trash file.
|
static String |
getName()
Get name of current test by inspecting stack trace
|
static File |
getTestResourceFile(String fileName)
Get test resource file.
|
static String |
read(File file)
Fully read a UTF-8 file and return as a string.
|
static String |
read(Repository db,
String name)
Read a file's content
|
static void |
write(File f,
String body)
Write a string as a UTF-8 file.
|
static Path |
writeLink(Repository db,
String link,
String target)
Write a symbolic link
|
static File |
writeTrashFile(Repository db,
String name,
String data)
Write a trash file.
|
static File |
writeTrashFile(Repository db,
String subdir,
String name,
String data)
Write a trash file.
|
public static final String CLASSPATH_TO_RESOURCES
CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"
public static String getName()
public static void assertEquals(byte[] exp, byte[] act)
exp
- expected valueact
- actual valuepublic static File getTestResourceFile(String fileName)
fileName
- public static void copyTestResource(String name, File dest) throws IOException
name
- dest
- IOException
public static File writeTrashFile(Repository db, String name, String data) throws IOException
db
- name
- data
- IOException
public static File writeTrashFile(Repository db, String subdir, String name, String data) throws IOException
db
- subdir
- name
- data
- IOException
public static void write(File f, String body) throws IOException
f
- file to write the string to. Caller is responsible for making
sure it is in the trash directory or will otherwise be cleaned
up at the end of the test. If the parent directory does not
exist, the missing parent directories are automatically
created.body
- content to write to the file.IOException
- the file could not be written.public static String read(File file) throws IOException
file
- file to read the content of.IOException
- the file does not exist, or could not be read.public static String read(Repository db, String name) throws IOException
db
- name
- IOException
public static boolean check(Repository db, String name)
db
- name
- name of the filetrue
if the file existspublic static void deleteTrashFile(Repository db, String name) throws IOException
db
- name
- IOException
public static Path writeLink(Repository db, String link, String target) throws Exception
db
- the repositorylink
- the path of the symbolic link to createtarget
- the target of the symbolic linkException
public static byte[] concat(byte[]... b)
b
- byte arrays to combine together.Copyright © 2018 Eclipse JGit Project. All rights reserved.