public abstract class JGitTestUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
JGitTestUtil.GatherStackTrace |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASSPATH_TO_RESOURCES
Constant
CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/" |
Modifier | Constructor and Description |
---|---|
private |
JGitTestUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
assertEquals(byte[] exp,
byte[] act)
Assert byte arrays are equal
|
static boolean |
check(Repository db,
java.lang.String name)
Check if file exists
|
private static java.lang.ClassLoader |
cl() |
static byte[] |
concat(byte[]... b)
Concatenate byte arrays.
|
static void |
copyTestResource(java.lang.String name,
java.io.File dest)
Copy test resource.
|
static void |
deleteTrashFile(Repository db,
java.lang.String name)
Delete a trash file.
|
static java.lang.String |
getName()
Get name of current test by inspecting stack trace
|
static java.io.File |
getTestResourceFile(java.lang.String fileName)
Get test resource file.
|
static java.lang.String |
read(java.io.File file)
Fully read a UTF-8 file and return as a string.
|
static java.lang.String |
read(Repository db,
java.lang.String name)
Read a file's content
|
private static java.lang.String |
s(byte[] raw) |
static void |
write(java.io.File f,
java.lang.String body)
Write a string as a UTF-8 file.
|
static java.nio.file.Path |
writeLink(Repository db,
java.lang.String link,
java.lang.String target)
Write a symbolic link
|
static java.io.File |
writeTrashFile(Repository db,
java.lang.String name,
java.lang.String data)
Write a trash file.
|
static java.io.File |
writeTrashFile(Repository db,
java.lang.String subdir,
java.lang.String name,
java.lang.String data)
Write a trash file.
|
public static final java.lang.String CLASSPATH_TO_RESOURCES
CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"
public static java.lang.String getName()
public static void assertEquals(byte[] exp, byte[] act)
exp
- expected valueact
- actual valueprivate static java.lang.String s(byte[] raw)
public static java.io.File getTestResourceFile(java.lang.String fileName)
fileName
- public static void copyTestResource(java.lang.String name, java.io.File dest) throws java.io.IOException
name
- dest
- java.io.IOException
private static java.lang.ClassLoader cl()
public static java.io.File writeTrashFile(Repository db, java.lang.String name, java.lang.String data) throws java.io.IOException
db
- name
- data
- java.io.IOException
public static java.io.File writeTrashFile(Repository db, java.lang.String subdir, java.lang.String name, java.lang.String data) throws java.io.IOException
db
- subdir
- name
- data
- java.io.IOException
public static void write(java.io.File f, java.lang.String body) throws java.io.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.java.io.IOException
- the file could not be written.public static java.lang.String read(java.io.File file) throws java.io.IOException
file
- file to read the content of.java.io.IOException
- the file does not exist, or could not be read.public static java.lang.String read(Repository db, java.lang.String name) throws java.io.IOException
db
- name
- java.io.IOException
public static boolean check(Repository db, java.lang.String name)
db
- name
- name of the filetrue
if the file existspublic static void deleteTrashFile(Repository db, java.lang.String name) throws java.io.IOException
db
- name
- java.io.IOException
public static java.nio.file.Path writeLink(Repository db, java.lang.String link, java.lang.String target) throws java.lang.Exception
db
- the repositorylink
- the path of the symbolic link to createtarget
- the target of the symbolic linkjava.lang.Exception
public static byte[] concat(byte[]... b)
b
- byte arrays to combine together.