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 Repository
db
Test 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 void
assertArrayOfLinesEquals(java.lang.String[] expected, java.lang.String[] actual)
protected void
assertStringArrayEquals(java.lang.String expected, java.lang.String[] actual)
protected java.lang.String
cmdString(java.lang.String... cmds)
static boolean
contains(java.util.List<java.lang.String> lines, java.lang.String str)
protected void
deleteTrashFile(java.lang.String name)
protected java.lang.String
escapeJava(java.lang.String line)
protected java.lang.String[]
execute(java.lang.String... cmds)
Executes specified git commands (with arguments), throws exception and stops execution on first command which output contains a 'fatal:' errorprotected java.lang.String[]
executeAndPrint(java.lang.String... cmds)
Execute the given commands and print the output to stdout.protected java.lang.String[]
executeAndPrintTestCode(java.lang.String... cmds)
Execute the given commands and print test code comparing expected and actual output.protected java.lang.String[]
executeUnchecked(java.lang.String... cmds)
Executes specified git commands (with arguments)protected java.lang.String
read(java.io.File file)
Read a file's contentvoid
setUp()
Setup testprotected java.lang.String
shellQuote(java.io.File f)
protected java.lang.String
shellQuote(java.lang.String s)
static java.lang.String
toString(java.lang.String... lines)
static java.lang.String
toString(java.util.List<java.lang.String> lines)
protected java.nio.file.Path
writeLink(java.lang.String link, java.lang.String target)
protected java.io.File
writeTrashFile(java.lang.String name, java.lang.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 java.lang.Exception
Description copied from class:LocalDiskRepositoryTestCase
Setup test- Overrides:
setUp
in classLocalDiskRepositoryTestCase
- Throws:
java.lang.Exception
-
executeUnchecked
protected java.lang.String[] executeUnchecked(java.lang.String... cmds) throws java.lang.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:
java.lang.Exception
-
execute
protected java.lang.String[] execute(java.lang.String... cmds) throws java.lang.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:
java.lang.Exception
-
writeLink
protected java.nio.file.Path writeLink(java.lang.String link, java.lang.String target) throws java.lang.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:
java.lang.Exception
-
writeTrashFile
protected java.io.File writeTrashFile(java.lang.String name, java.lang.String data) throws java.io.IOException
- Throws:
java.io.IOException
-
read
protected java.lang.String read(java.io.File file) throws java.io.IOException
Description copied from class:LocalDiskRepositoryTestCase
Read a file's content- Overrides:
read
in classLocalDiskRepositoryTestCase
- Parameters:
file
- the file- Returns:
- the content of the file
- Throws:
java.io.IOException
-
deleteTrashFile
protected void deleteTrashFile(java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
executeAndPrint
protected java.lang.String[] executeAndPrint(java.lang.String... cmds) throws java.lang.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:
java.lang.Exception
-
executeAndPrintTestCode
protected java.lang.String[] executeAndPrintTestCode(java.lang.String... cmds) throws java.lang.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:
java.lang.Exception
-
cmdString
protected java.lang.String cmdString(java.lang.String... cmds)
-
escapeJava
protected java.lang.String escapeJava(java.lang.String line)
-
shellQuote
protected java.lang.String shellQuote(java.lang.String s)
-
shellQuote
protected java.lang.String shellQuote(java.io.File f)
-
assertStringArrayEquals
protected void assertStringArrayEquals(java.lang.String expected, java.lang.String[] actual)
-
assertArrayOfLinesEquals
protected void assertArrayOfLinesEquals(java.lang.String[] expected, java.lang.String[] actual)
-
toString
public static java.lang.String toString(java.lang.String... lines)
-
toString
public static java.lang.String toString(java.util.List<java.lang.String> lines)
-
contains
public static boolean contains(java.util.List<java.lang.String> lines, java.lang.String str)
-
-