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 org. 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.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ASSUME_UNCHANGED
Constant |
| 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. |
| public static final int | CONTENT
Constant |
| public static final int | CONTENT_ID
Constant |
| public TestName | currentTest
The current test name. |
| private File | |
| public static final int | LENGTH
Constant |
| protected MockSystemReader | mockSystemReader
A |
| public static final int | MOD_TIME
Constant |
| pack-priv Random | |
| public static final int | SMUDGE
Constant |
| public TemporaryFolder | testRoot
Temporary test root directory for files created by tests. |
| private File | |
| private final Set | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addRepoToClose(Repository
the repository to be closed r)Adds a repository to the list of repositories which is closed at the end of the tests |
| private void | |
| private static HashMap | |
| protected FileRepository | Returns: the newly created bare repository, opened for access. The repository will not be closed intearDown(); the caller
is responsible for closing it.Creates a new empty bare repository. |
| protected FileRepository | Returns: the newly created repository, opened for access. The repository will not be closed intearDown(); the caller is
responsible for closing it.true to create a bare repository; false to make a repository
within its working directory bare)Creates a new empty repository. |
| public FileRepository | Returns: the newly created repository, opened for accesstrue to create a bare repository; false to make a repository
within its working directory bare, boolean auto close the repository in autoClose)tearDown()
Deprecated
use
createRepository(boolean) instead
Creates a new empty repository. |
| protected File | Returns: a unique directory for a testa subdirectory name)Creates a unique directory for a test |
| protected File | Returns: a unique path that does not exist.Allocates a new unique file path that does not exist. |
| protected File | Returns: a unique directory for a test repositorytrue for a bare repository; false for a repository with a
working directory bare)Creates a new unique directory for a test repository |
| protected FileRepository | Returns: the newly created repository, opened for access. The repository will not be closed intearDown(); the caller is
responsible for closing it.Creates a new empty repository within a new empty working directory. |
| protected List | |
| protected File | |
| private String | |
| public static String | Returns: a string encoding the index statethe repository the index state should be determined for repo, int a bitmask constructed out of the constants includedOptions)MOD_TIME,
SMUDGE, LENGTH, CONTENT_ID and
CONTENT controlling which info is present in the
resulting string.Represent the state of the index in one String. |
| private static String | |
| private static void | |
| protected String | |
| protected void | recursiveDelete(File
the recursively directory to delete, if present. dir)Recursively delete a directory, failing the test if the delete fails. |
| private static boolean | |
| private static void | |
| protected int | Returns: exit status code of the invoked hookrepository the script should see in GIT_DIR environment db, final File path of the hook script to execute, must be executable file
type on this platform hook, final String... arguments to pass to the hook script args)Run a hook script in the repository, returning the exit status. |
| public void | |
| public void | |
| protected void | |
| private static String[] | |
| protected File | |
| protected 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. |
| ASSUME_UNCHANGED | back to summary |
|---|---|
| public static final int ASSUME_UNCHANGED Constant | |
| author | back to summary |
|---|---|
| protected PersonIdent author A fake (but stable) identity for author fields in the test. | |
| committer | back to summary |
|---|---|
| protected PersonIdent committer A fake (but stable) identity for committer fields in the test. | |
| CONTENT | back to summary |
|---|---|
| public static final int CONTENT Constant | |
| CONTENT_ID | back to summary |
|---|---|
| public static final int CONTENT_ID Constant | |
| currentTest | back to summary |
|---|---|
| public TestName currentTest The current test name.
| |
| homeDir | back to summary |
|---|---|
| private File homeDir | |
| LENGTH | back to summary |
|---|---|
| public static final int LENGTH Constant | |
| mockSystemReader | back to summary |
|---|---|
| protected MockSystemReader mockSystemReader A
| |
| MOD_TIME | back to summary |
|---|---|
| public static final int MOD_TIME Constant | |
| rand | back to summary |
|---|---|
| pack-priv Random rand | |
| SMUDGE | back to summary |
|---|---|
| public static final int SMUDGE Constant | |
| testRoot | back to summary |
|---|---|
| public TemporaryFolder testRoot Temporary test root directory for files created by tests.
| |
| tmp | back to summary |
|---|---|
| private File tmp | |
| toClose | back to summary |
|---|---|
| private final Set<Repository> toClose | |
| useMMAP | back to summary |
|---|---|
| private static final boolean useMMAP | |
| LocalDiskRepositoryTestCase | back to summary |
|---|---|
| public LocalDiskRepositoryTestCase() | |
| addRepoToClose | back to summary |
|---|---|
| public void addRepoToClose(Repository r) Adds a repository to the list of repositories which is closed at the end of the tests
| |
| ceilTestDirectories | back to summary |
|---|---|
| private void ceilTestDirectories(List<File> ceilings) | |
| cloneEnv | back to summary |
|---|---|
| private static HashMap | |
| createBareRepository | back to summary |
|---|---|
| protected FileRepository createBareRepository() throws IOException Creates a new empty bare repository.
| |
| createRepository | back to summary |
|---|---|
| protected FileRepository createRepository(boolean bare) throws IOException Creates a new empty repository.
| |
| createRepository | back to summary |
|---|---|
| public FileRepository createRepository(boolean bare, boolean autoClose) throws IOException
Deprecated use Creates a new empty repository.
| |
| createTempDirectory | back to summary |
|---|---|
| protected File createTempDirectory(String name) throws IOException Creates a unique directory for a test
| |
| createTempFile | back to summary |
|---|---|
| protected File createTempFile() throws IOException Allocates a new unique file path that does not exist.
Unlike the standard This method is inherently unsafe due to a race condition between creating the name and the first use that reserves it.
| |
| createUniqueTestGitDir | back to summary |
|---|---|
| protected File createUniqueTestGitDir(boolean bare) throws IOException Creates a new unique directory for a test repository
| |
| createWorkRepository | back to summary |
|---|---|
| protected FileRepository createWorkRepository() throws IOException Creates a new empty repository within a new empty working directory.
| |
| getCeilings | back to summary |
|---|---|
| protected List Get list of ceiling directories | |
| getTemporaryDirectory | back to summary |
|---|---|
| protected File getTemporaryDirectory() Get temporary directory.
| |
| getTestName | back to summary |
|---|---|
| private String getTestName() | |
| indexState | back to summary |
|---|---|
| public static String indexState(Repository repo, int includedOptions) throws IOException Represent the state of the index in one String. This representation is useful when writing tests which do assertions on the state of the index. By default information about path, mode, stage (if different from 0) is included. A bitmask controls which additional info about modificationTimes, smudge state and length is included. The format of the returned string is described with this BNF: result = ( "[" path mode stage? time? smudge? length? sha1? content? "]" )* . mode = ", mode:" number . stage = ", stage:" number . time = ", time:t" timestamp-index . smudge = "" | ", smudged" . length = ", length:" number . sha1 = ", sha1:" hex-sha1 . content = ", content:" blob-data .'stage' is only presented when the stage is different from 0. All reported time stamps are mapped to strings like "t0", "t1", ... "tn". The smallest reported time-stamp will be called "t0". This allows to write assertions against the string although the concrete value of the time stamps is unknown.
| |
| makePath | back to summary |
|---|---|
| private static String makePath(List<?> objects) | |
| putPersonIdent | back to summary |
|---|---|
| private static void putPersonIdent(final Map<String, String> env, final String type, final PersonIdent who) | |
| read | back to summary |
|---|---|
| protected String read(File f) throws IOException Read a file's content
| |
| recursiveDelete | back to summary |
|---|---|
| protected void recursiveDelete(File dir) Recursively delete a directory, failing the test if the delete fails.
| |
| recursiveDelete | back to summary |
|---|---|
| private static boolean recursiveDelete(final File dir, boolean silent, boolean failOnError) | |
| reportDeleteFailure | back to summary |
|---|---|
| private static void reportDeleteFailure(boolean failOnError, File f, Exception cause) | |
| runHook | back to summary |
|---|---|
| protected int runHook(final Repository db, final File hook, final String... args) throws IOException, InterruptedException Run a hook script in the repository, returning the exit status.
| |
| setUp | back to summary |
|---|---|
| public void setUp() throws Exception Setup test | |
| tearDown | back to summary |
|---|---|
| public void tearDown() throws Exception Tear down the test | |
| tick | back to summary |
|---|---|
| protected void tick() | |
| toEnvArray | back to summary |
|---|---|
| private static String[] toEnvArray(Map<String, String> env) | |
| write | back to summary |
|---|---|
| protected File write(String body) throws IOException Create a string to a UTF-8 temporary file and return the path.
| |
| write | back to summary |
|---|---|
| protected void write(File f, String body) throws IOException Write a string as a UTF-8 file.
| |