|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.junit.LocalDiskRepositoryTestCase
public abstract class LocalDiskRepositoryTestCase
JUnit TestCase with specialized support for temporary local repository.
A temporary directory is created for each test, allowing each test to use a fresh environment. The temporary directory is cleaned up after the test ends.
Callers should not use RepositoryCache
from within these tests as it
may wedge file descriptors open past the end of the test.
A system property jgit.junit.usemmap
defines whether memory mapping
is used. Memory mapping has an effect on the file system, in that memory
mapped files in Java cannot be deleted as long as the mapped arrays have not
been reclaimed by the garbage collector. The programmer cannot control this
with precision, so temporary files may hang around longer than desired during
a test, or tests may fail altogether if there is insufficient file
descriptors or address space for the test process.
Field Summary | |
---|---|
protected PersonIdent |
author
A fake (but stable) identity for author fields in the test. |
protected PersonIdent |
committer
A fake (but stable) identity for committer fields in the test. |
Constructor Summary | |
---|---|
LocalDiskRepositoryTestCase()
|
Method Summary | |
---|---|
void |
addRepoToClose(Repository r)
Adds a repository to the list of repositories which is closed at the end of the tests |
protected FileRepository |
createBareRepository()
Creates a new empty bare repository. |
protected java.io.File |
createTempDirectory(java.lang.String name)
Creates a unique directory for a test |
protected java.io.File |
createTempFile()
|
protected java.io.File |
createUniqueTestGitDir(boolean bare)
Creates a new unique directory for a test repository |
protected FileRepository |
createWorkRepository()
Creates a new empty repository within a new empty working directory. |
protected java.util.List<java.io.File> |
getCeilings()
|
protected java.lang.String |
read(java.io.File f)
Fully read a UTF-8 file and return as a string. |
protected void |
recursiveDelete(java.io.File dir)
Recursively delete a directory, failing the test if the delete fails. |
protected int |
runHook(Repository db,
java.io.File hook,
java.lang.String... args)
Run a hook script in the repository, returning the exit status. |
void |
setUp()
|
void |
tearDown()
|
protected void |
tick()
Increment the author and committer times. |
protected void |
write(java.io.File f,
java.lang.String body)
Write a string as a UTF-8 file. |
protected java.io.File |
write(java.lang.String body)
Create a string to a UTF-8 temporary file and return the path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PersonIdent author
protected PersonIdent committer
Constructor Detail |
---|
public LocalDiskRepositoryTestCase()
Method Detail |
---|
public void setUp() throws java.lang.Exception
java.lang.Exception
protected java.util.List<java.io.File> getCeilings()
public void tearDown() throws java.lang.Exception
java.lang.Exception
protected void tick()
author
and committer
times.
protected void recursiveDelete(java.io.File dir)
dir
- the recursively directory to delete, if present.protected FileRepository createBareRepository() throws java.io.IOException
java.io.IOException
- the repository could not be created in the temporary areaprotected FileRepository createWorkRepository() throws java.io.IOException
java.io.IOException
- the repository could not be created in the temporary areapublic void addRepoToClose(Repository r)
r
- the repository to be closedprotected java.io.File createTempDirectory(java.lang.String name) throws java.io.IOException
name
- a subdirectory
java.io.IOException
protected java.io.File createUniqueTestGitDir(boolean bare) throws java.io.IOException
bare
- true for a bare repository; false for a repository with a
working directory
java.io.IOException
protected java.io.File createTempFile() throws java.io.IOException
java.io.IOException
protected int runHook(Repository db, java.io.File hook, java.lang.String... args) throws java.io.IOException, java.lang.InterruptedException
db
- repository the script should see in GIT_DIR environmenthook
- path of the hook script to execute, must be executable file
type on this platformargs
- arguments to pass to the hook script
java.io.IOException
- the hook could not be executed
java.lang.InterruptedException
- the caller was interrupted before the hook completedprotected java.io.File write(java.lang.String body) throws java.io.IOException
body
- complete content to write to the file. If the file should end
with a trailing LF, the string should end with an LF.
java.io.IOException
- the file could not be written.protected 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.protected java.lang.String read(java.io.File f) throws java.io.IOException
f
- file to read the content of.
java.io.IOException
- the file does not exist, or could not be read.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |