Package org.eclipse.jgit.junit
Class JGitTestUtil
java.lang.Object
org.eclipse.jgit.junit.JGitTestUtil
Abstract test util class
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ConstantCLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertEquals
(byte[] exp, byte[] act) Assert byte arrays are equalstatic boolean
check
(Repository db, String name) Check if file existsprivate static ClassLoader
cl()
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 tracestatic File
getTestResourceFile
(String fileName) Get test resource file.static String
Fully read a UTF-8 file and return as a string.static String
read
(Repository db, String name) Read a file's contentprivate static String
s
(byte[] raw) static void
Write a string as a UTF-8 file.static Path
writeLink
(Repository db, String link, String target) Write a symbolic linkstatic 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.
-
Field Details
-
CLASSPATH_TO_RESOURCES
ConstantCLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"
- See Also:
-
-
Constructor Details
-
JGitTestUtil
private JGitTestUtil()
-
-
Method Details
-
getName
Get name of current test by inspecting stack trace- Returns:
- the name
-
assertEquals
public static void assertEquals(byte[] exp, byte[] act) Assert byte arrays are equal- Parameters:
exp
- expected valueact
- actual value
-
s
-
getTestResourceFile
Get test resource file.- Parameters:
fileName
-- Returns:
- the test resource file
-
copyTestResource
Copy test resource.- Parameters:
name
-dest
-- Throws:
IOException
-
cl
-
writeTrashFile
Write a trash file.- Parameters:
db
-name
-data
-- Returns:
- the trash file
- Throws:
IOException
-
writeTrashFile
public static File writeTrashFile(Repository db, String subdir, String name, String data) throws IOException Write a trash file.- Parameters:
db
-subdir
-name
-data
-- Returns:
- the trash file
- Throws:
IOException
-
write
Write a string as a UTF-8 file.- Parameters:
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.- Throws:
IOException
- the file could not be written.
-
read
Fully read a UTF-8 file and return as a string.- Parameters:
file
- file to read the content of.- Returns:
- UTF-8 decoded content of the file, empty string if the file exists but has no content.
- Throws:
IOException
- the file does not exist, or could not be read.
-
read
Read a file's content- Parameters:
db
-name
-- Returns:
- the content of the file
- Throws:
IOException
-
check
Check if file exists- Parameters:
db
-name
- name of the file- Returns:
true
if the file exists
-
deleteTrashFile
Delete a trash file.- Parameters:
db
-name
-- Throws:
IOException
-
writeLink
Write a symbolic link- Parameters:
db
- the repositorylink
- the path of the symbolic link to createtarget
- the target of the symbolic link- Returns:
- the path to the symbolic link
- Throws:
Exception
- Since:
- 4.2
-
concat
public static byte[] concat(byte[]... b) Concatenate byte arrays.- Parameters:
b
- byte arrays to combine together.- Returns:
- a single byte array that contains all bytes copied from input byte arrays.
- Since:
- 4.9
-