public class MockSystemReader extends SystemReader
SystemReader for tests.| Constructor and Description |
|---|
MockSystemReader()
Constructor for
MockSystemReader |
| Modifier and Type | Method and Description |
|---|---|
void |
clearProperties()
Clear properties
|
MonotonicClock |
getClock()
Get clock instance preferred by this system.
|
long |
getCurrentTime()
Get the current system time
|
DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
Returns a date/time format instance for the given styles.
|
String |
getenv(String variable)
Get value of the system variable
|
String |
getHostname()
Gets the hostname of the local host.
|
FileBasedConfig |
getJGitConfig()
Get the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.
|
Locale |
getLocale()
Get the locale to use
|
String |
getProperty(String key)
Get value of the system property
|
SimpleDateFormat |
getSimpleDateFormat(String pattern)
Returns a simple date format instance as specified by the given pattern.
|
StoredConfig |
getSystemConfig()
Get the gitconfig configuration found in the system-wide "etc" directory.
|
TimeZone |
getTimeZone()
Get system time zone, possibly mocked for testing
|
int |
getTimezone(long when)
Get the local time zone
|
StoredConfig |
getUserConfig()
Get the git configuration found in the user home.
|
FileBasedConfig |
openJGitConfig(Config parent,
FS fs)
Open the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.
|
FileBasedConfig |
openSystemConfig(Config parent,
FS fs)
Open the gitconfig configuration found in the system-wide "etc"
directory.
|
FileBasedConfig |
openUserConfig(Config parent,
FS fs)
Open the git configuration found in the user home.
|
void |
setCurrentPlatform()
Assign some properties for the currently executing platform
|
void |
setJGitConfig(FileBasedConfig jgitConfig)
Set the jgit config stored at $XDG_CONFIG_HOME/jgit/config
|
void |
setProperty(String key,
String value)
Set a property
|
FileBasedConfig |
setSystemGitConfig(FileBasedConfig systemGitConfig)
Set the system-level git config
|
void |
setUnix()
Emulate Unix
|
FileBasedConfig |
setUserGitConfig(FileBasedConfig userGitConfig)
Set the user-level git config
|
void |
setWindows()
Emulate Windows
|
void |
tick(int secDelta)
Adjusts the current time in seconds.
|
String |
toString() |
checkPath, checkPath, getInstance, getSimpleDateFormat, isMacOS, isWindows, setInstance, setPlatformCheckerpublic FileBasedConfig setUserGitConfig(FileBasedConfig userGitConfig)
userGitConfig - set another user-level git configpublic void setJGitConfig(FileBasedConfig jgitConfig)
jgitConfig - set the jgit configurationpublic FileBasedConfig setSystemGitConfig(FileBasedConfig systemGitConfig)
systemGitConfig - the new system-level git configpublic void clearProperties()
public void setProperty(String key, String value)
key - value - public String getenv(String variable)
getenv in class SystemReadervariable - system variable to readpublic String getProperty(String key)
getProperty in class SystemReaderkey - of the system property to readpublic FileBasedConfig openUserConfig(Config parent, FS fs)
SystemReader.getUserConfig() to get the current git configuration in the user
home since it manages automatic reloading when the gitconfig file was
modified and avoids unnecessary reloads.openUserConfig in class SystemReaderparent - a config with values not found directly in the returned configfs - the file system abstraction which will be necessary to perform
certain file system operations.public FileBasedConfig openSystemConfig(Config parent, FS fs)
SystemReader.getSystemConfig() to get the current system-wide
git configuration since it manages automatic reloading when the gitconfig
file was modified and avoids unnecessary reloads.openSystemConfig in class SystemReaderparent - a config with values not found directly in the returned
config. Null is a reasonable value here.fs - the file system abstraction which will be necessary to perform
certain file system operations.public StoredConfig getUserConfig() throws IOException, ConfigInvalidException
SystemReadergetUserConfig in class SystemReaderIOException - if something went wrong when reading filesConfigInvalidException - if configuration is invalidpublic FileBasedConfig getJGitConfig()
SystemReadergetJGitConfig in class SystemReaderpublic StoredConfig getSystemConfig() throws IOException, ConfigInvalidException
SystemReadergetSystemConfig in class SystemReaderIOException - if something went wrong when reading filesConfigInvalidException - if configuration is invalidpublic String getHostname()
getHostname in class SystemReaderpublic long getCurrentTime()
getCurrentTime in class SystemReaderpublic MonotonicClock getClock()
getClock in class SystemReaderpublic void tick(int secDelta)
secDelta - number of seconds to add to the current time.public int getTimezone(long when)
getTimezone in class SystemReaderwhen - a system timestamppublic TimeZone getTimeZone()
getTimeZone in class SystemReaderpublic Locale getLocale()
getLocale in class SystemReaderpublic SimpleDateFormat getSimpleDateFormat(String pattern)
getSimpleDateFormat in class SystemReaderpattern - the pattern as defined in
SimpleDateFormat(String)public DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
getDateTimeInstance in class SystemReaderdateStyle - the date style as specified in
DateFormat.getDateTimeInstance(int, int)timeStyle - the time style as specified in
DateFormat.getDateTimeInstance(int, int)public void setCurrentPlatform()
public void setWindows()
public void setUnix()
public FileBasedConfig openJGitConfig(Config parent, FS fs)
SystemReaderSystemReader.getJGitConfig() to get the current jgit configuration in the
user home since it manages automatic reloading when the jgit config file
was modified and avoids unnecessary reloads.openJGitConfig in class SystemReaderparent - a config with values not found directly in the returned configfs - the file system abstraction which will be necessary to perform
certain file system operations.Copyright © 2021 Eclipse JGit Project. All rights reserved.