Top Description Inners Fields Constructors Methods
org.eclipse.jgit.junit

public abstract Class JGitTestUtil

extends Object
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8

Abstract test util class

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final String
CLASSPATH_TO_RESOURCES

Constant CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
assertEquals(byte[]
expected value
exp
,
byte[]
actual value
act
)

Assert byte arrays are equal

public static boolean

Returns:

true if the file exists
check
(Repository
the repository
db
,
String
name of the file
name
)

Check if file exists

private static ClassLoader
cl()

public static byte[]

Returns:

a single byte array that contains all bytes copied from input byte arrays.
concat
(byte[]...
byte arrays to combine together.
b
)

Concatenate byte arrays.

public static void
copyTestResource(String
resource name
name
,
File
destination file
dest
)

Copy test resource.

public static void
deleteTrashFile(final Repository
the repository
db
,
final String
file name
name
)

Delete a trash file.

public static String

Returns:

the name
getName
()

Get name of current test by inspecting stack trace

public static File

Returns:

the test resource file
getTestResourceFile
(String
file name
fileName
)

Get test resource file.

public static String

Returns:

UTF-8 decoded content of the file, empty string if the file exists but has no content.
read
(File
file to read the content of.
file
)

Fully read a UTF-8 file and return as a string.

public static String

Returns:

the content of the file
read
(Repository
the repository
db
,
String
file name
name
)

Read a file's content

private static String
s(byte[] raw)

public static void
write(File
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.
f
,
String
content to write to the file.
body
)

Write a string as a UTF-8 file.

public static File

Returns:

the trash file
writeTrashFile
(final Repository
the repository
db
,
final String
file name
name
,
final String
file content
data
)

Write a trash file.

public static File

Returns:

the trash file
writeTrashFile
(final Repository
the repository
db
,
final String
under working tree
subdir
,
final String
file name
name
,
final String
file content
data
)

Write a trash file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASSPATH_TO_RESOURCESback to summary
public static final String CLASSPATH_TO_RESOURCES

Constant CLASSPATH_TO_RESOURCES="org/eclipse/jgit/test/resources/"

Constructor Detail

JGitTestUtilback to summary
private JGitTestUtil()

Method Detail

assertEqualsback to summary
public static void assertEquals(byte[] exp, byte[] act)

Assert byte arrays are equal

Parameters
exp:byte[]

expected value

act:byte[]

actual value

checkback to summary
public static boolean check(Repository db, String name)

Check if file exists

Parameters
db:Repository

the repository

name:String

name of the file

Returns:boolean

true if the file exists

clback to summary
private static ClassLoader cl()
concatback to summary
public static byte[] concat(byte[]... b)

Concatenate byte arrays.

Parameters
b:byte[][]

byte arrays to combine together.

Returns:byte[]

a single byte array that contains all bytes copied from input byte arrays.

Since
4.9
copyTestResourceback to summary
public static void copyTestResource(String name, File dest) throws IOException

Copy test resource.

Parameters
name:String

resource name

dest:File

destination file

Exceptions
IOException:
if an IO error occurred
deleteTrashFileback to summary
public static void deleteTrashFile(final Repository db, final String name) throws IOException

Delete a trash file.

Parameters
db:Repository

the repository

name:String

file name

Exceptions
IOException:
if an IO error occurred
getNameback to summary
public static String getName()

Get name of current test by inspecting stack trace

Returns:String

the name

getTestResourceFileback to summary
public static File getTestResourceFile(String fileName)

Get test resource file.

Parameters
fileName:String

file name

Returns:File

the test resource file

readback to summary
public static String read(File file) throws IOException

Fully read a UTF-8 file and return as a string.

Parameters
file:File

file to read the content of.

Returns:String

UTF-8 decoded content of the file, empty string if the file exists but has no content.

Exceptions
IOException:
the file does not exist, or could not be read.
readback to summary
public static String read(Repository db, String name) throws IOException

Read a file's content

Parameters
db:Repository

the repository

name:String

file name

Returns:String

the content of the file

Exceptions
IOException:
if an IO error occurred
sback to summary
private static String s(byte[] raw)
writeback to summary
public static void write(File f, String body) throws IOException

Write a string as a UTF-8 file.

Parameters
f:File

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:String

content to write to the file.

Exceptions
IOException:
the file could not be written.
writeTrashFileback to summary
public static File writeTrashFile(final Repository db, final String name, final String data) throws IOException

Write a trash file.

Parameters
db:Repository

the repository

name:String

file name

data:String

file content

Returns:File

the trash file

Exceptions
IOException:
if an IO error occurred
writeTrashFileback to summary
public static File writeTrashFile(final Repository db, final String subdir, final String name, final String data) throws IOException

Write a trash file.

Parameters
db:Repository

the repository

subdir:String

under working tree

name:String

file name

data:String

file content

Returns:File

the trash file

Exceptions
IOException:
if an IO error occurred
org.eclipse.jgit.junit back to summary

private Class JGitTestUtil.GatherStackTrace

extends Exception
Class Inheritance
Annotations
@SuppressWarnings:serial

Constructor Summary

AccessConstructor and Description
private

Constructor Detail

GatherStackTraceback to summary
private GatherStackTrace()