Package org.eclipse.jgit.lib
Class CLIRepositoryTestCase
- java.lang.Object
-
- org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
-
- org.eclipse.jgit.lib.CLIRepositoryTestCase
-
public class CLIRepositoryTestCase extends LocalDiskRepositoryTestCase
-
-
Field Summary
Fields Modifier and Type Field Description protected RepositorydbTest repository, initialized for this test case.-
Fields inherited from class org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
ASSUME_UNCHANGED, author, committer, CONTENT, CONTENT_ID, LENGTH, mockSystemReader, MOD_TIME, SMUDGE
-
-
Constructor Summary
Constructors Constructor Description CLIRepositoryTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertArrayOfLinesEquals(String[] expected, String[] actual)protected voidassertStringArrayEquals(String expected, String[] actual)protected StringcmdString(String... cmds)static booleancontains(List<String> lines, String str)protected voiddeleteTrashFile(String name)protected StringescapeJava(String line)protected String[]execute(String... cmds)Executes specified git commands (with arguments), throws exception and stops execution on first command which output contains a 'fatal:' errorprotected String[]executeAndPrint(String... cmds)Execute the given commands and print the output to stdout.protected String[]executeAndPrintTestCode(String... cmds)Execute the given commands and print test code comparing expected and actual output.protected String[]executeUnchecked(String... cmds)Executes specified git commands (with arguments)protected Stringread(File file)Read a file's contentvoidsetUp()Setup testprotected StringshellQuote(File f)protected StringshellQuote(String s)static StringtoString(String... lines)static StringtoString(List<String> lines)protected PathwriteLink(String link, String target)protected FilewriteTrashFile(String name, String data)-
Methods inherited from class org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
addRepoToClose, createBareRepository, createRepository, createRepository, createTempDirectory, createTempFile, createUniqueTestGitDir, createWorkRepository, getCeilings, getTemporaryDirectory, indexState, recursiveDelete, runHook, tearDown, tick, write, write
-
-
-
-
Field Detail
-
db
protected Repository db
Test repository, initialized for this test case.
-
-
Method Detail
-
setUp
public void setUp() throws ExceptionDescription copied from class:LocalDiskRepositoryTestCaseSetup test- Overrides:
setUpin classLocalDiskRepositoryTestCase- Throws:
Exception
-
executeUnchecked
protected String[] executeUnchecked(String... cmds) throws Exception
Executes specified git commands (with arguments)- Parameters:
cmds- each string argument must be a valid git command line, e.g. "git branch -h"- Returns:
- command output
- Throws:
Exception
-
execute
protected String[] execute(String... cmds) throws Exception
Executes specified git commands (with arguments), throws exception and stops execution on first command which output contains a 'fatal:' error- Parameters:
cmds- each string argument must be a valid git command line, e.g. "git branch -h"- Returns:
- command output
- Throws:
Exception
-
writeLink
protected Path writeLink(String link, String target) throws Exception
- Parameters:
link- the path of the symbolic link to createtarget- the target of the symbolic link- Returns:
- the path to the symbolic link
- Throws:
Exception
-
writeTrashFile
protected File writeTrashFile(String name, String data) throws IOException
- Throws:
IOException
-
read
protected String read(File file) throws IOException
Description copied from class:LocalDiskRepositoryTestCaseRead a file's content- Overrides:
readin classLocalDiskRepositoryTestCase- Parameters:
file- the file- Returns:
- the content of the file
- Throws:
IOException
-
deleteTrashFile
protected void deleteTrashFile(String name) throws IOException
- Throws:
IOException
-
executeAndPrint
protected String[] executeAndPrint(String... cmds) throws Exception
Execute the given commands and print the output to stdout. Use this function instead of the normalexecute(String...)when preparing a test case: the command is executed and then its output is printed on stdout, thus making it easier to prepare the correct command and expected output for the test case.- Parameters:
cmds- The commands to execute- Returns:
- the result of the command, see
execute(String...) - Throws:
Exception
-
executeAndPrintTestCode
protected String[] executeAndPrintTestCode(String... cmds) throws Exception
Execute the given commands and print test code comparing expected and actual output. Use this function instead of the normalexecute(String...)when preparing a test case: the command is executed and test code is generated using the command output as a template of what is expected. The code generated is printed on stdout and can be pasted in the test case function.- Parameters:
cmds- The commands to execute- Returns:
- the result of the command, see
execute(String...) - Throws:
Exception
-
assertArrayOfLinesEquals
protected void assertArrayOfLinesEquals(String[] expected, String[] actual)
-
-