Top Description Inners Fields Constructors Methods
org.eclipse.jgit.junit

public Class MockSystemReader

extends SystemReader
Class Inheritance
Imports
java.io.File, .IOException, java.lang.reflect.Field, java.text.DateFormat, .SimpleDateFormat, java.time.Duration, .ZoneId, .ZoneOffset, java.util.HashMap, .Locale, .Map, .TimeZone, java.util.concurrent.TimeUnit, org.eclipse.jgit.errors.ConfigInvalidException, org.eclipse.jgit.lib.Config, .Constants, .StoredConfig, org.eclipse.jgit.storage.file.FileBasedConfig, org.eclipse.jgit.util.FS, .SystemReader, org.eclipse.jgit.util.time.MonotonicClock, .ProposedTimestamp

Mock org.eclipse.jgit.util.SystemReader for tests.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private FileBasedConfig
pack-priv long
pack-priv FileBasedConfig
private FileBasedConfig
pack-priv final Map<String, String>

Constructor Summary

AccessConstructor and Description
public
MockSystemReader()

Constructor for MockSystemReader

Method Summary

Modifier and TypeMethod and Description
public void
clearProperties()

Clear properties

public MonotonicClock
getClock()

Overrides org.eclipse.jgit.util.SystemReader.getClock.

Get clock instance preferred by this system.

public long
getCurrentTime()

Implements abstract org.eclipse.jgit.util.SystemReader.getCurrentTime.

Get the current system time

public DateFormat
getDateTimeInstance(int dateStyle, int timeStyle)

Overrides org.eclipse.jgit.util.SystemReader.getDateTimeInstance.

Returns a date/time format instance for the given styles.

public String
getenv(String
system variable to read
variable
)

Implements abstract org.eclipse.jgit.util.SystemReader.getenv.

Get value of the system variable

public String
getHostname()

Implements abstract org.eclipse.jgit.util.SystemReader.getHostname.

Gets the hostname of the local host.

public FileBasedConfig
getJGitConfig()

Overrides org.eclipse.jgit.util.SystemReader.getJGitConfig.

Get the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.

public Locale
getLocale()

Overrides org.eclipse.jgit.util.SystemReader.getLocale.

Get the locale to use

public String
getProperty(String
of the system property to read
key
)

Implements abstract org.eclipse.jgit.util.SystemReader.getProperty.

Get value of the system property

public SimpleDateFormat
getSimpleDateFormat(String pattern)

Overrides org.eclipse.jgit.util.SystemReader.getSimpleDateFormat.

Returns a simple date format instance as specified by the given pattern.

public StoredConfig
getSystemConfig()

Overrides org.eclipse.jgit.util.SystemReader.getSystemConfig.

Get the gitconfig configuration found in the system-wide "etc" directory.

public int
getTimezone(long
a system timestamp
when
)

Implements abstract org.eclipse.jgit.util.SystemReader.getTimezone.

Get the local time zone

public TimeZone
getTimeZone()

Overrides org.eclipse.jgit.util.SystemReader.getTimeZone.

Get system time zone, possibly mocked for testing

public ZoneId
getTimeZoneId()

Overrides org.eclipse.jgit.util.SystemReader.getTimeZoneId.

Get system time zone, possibly mocked for testing

public StoredConfig
getUserConfig()

Overrides org.eclipse.jgit.util.SystemReader.getUserConfig.

Get the git configuration found in the user home.

private void
public FileBasedConfig
openJGitConfig(Config
a config with values not found directly in the returned config
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Implements abstract org.eclipse.jgit.util.SystemReader.openJGitConfig.

Open the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.

public FileBasedConfig
openSystemConfig(Config
a config with values not found directly in the returned config. Null is a reasonable value here.
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Implements abstract org.eclipse.jgit.util.SystemReader.openSystemConfig.

Open the gitconfig configuration found in the system-wide "etc" directory.

public FileBasedConfig
openUserConfig(Config
a config with values not found directly in the returned config
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Implements abstract org.eclipse.jgit.util.SystemReader.openUserConfig.

Open the git configuration found in the user home.

private void
public void
setCurrentPlatform()

Assign some properties for the currently executing platform

public void
setJGitConfig(FileBasedConfig
set the jgit configuration
jgitConfig
)

Set the jgit config stored at $XDG_CONFIG_HOME/jgit/config

public void
setProperty(String
the key
key
,
String
the value
value
)

Set a property

public FileBasedConfig

Returns:

the old system-level config
setSystemGitConfig
(FileBasedConfig
the new system-level git config
systemGitConfig
)

Set the system-level git config

public void
setUnix()

Emulate Unix

public FileBasedConfig

Returns:

the old user-level git config
setUserGitConfig
(FileBasedConfig
set another user-level git config
userGitConfig
)

Set the user-level git config

public void
setWindows()

Emulate Windows

public void
tick(int
number of seconds to add to the current time.
secDelta
)

Adjusts the current time in seconds.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jgit.util.SystemReader:
checkPathcheckPathcivilNowgetDefaultCharsetgetInstancegetSimpleDateFormatgetTimeZoneAtgetXdgConfigDirectoryisLinuxisMacOSisPerformanceTraceEnabledisWindowsnowsetInstancesetPlatformChecker

Field Detail

jgitConfigback to summary
private FileBasedConfig jgitConfig

Hides org.eclipse.jgit.util.SystemReader.jgitConfig.

nowback to summary
pack-priv long now
systemGitConfigback to summary
pack-priv FileBasedConfig systemGitConfig
userGitConfigback to summary
private FileBasedConfig userGitConfig
valuesback to summary
pack-priv final Map<String, String> values

Constructor Detail

MockSystemReaderback to summary
public MockSystemReader()

Constructor for MockSystemReader

Method Detail

clearPropertiesback to summary
public void clearProperties()

Clear properties

getClockback to summary
public MonotonicClock getClock()

Overrides org.eclipse.jgit.util.SystemReader.getClock.

Doc from org.eclipse.jgit.util.SystemReader.getClock.

Get clock instance preferred by this system.

Returns:MonotonicClock

clock instance preferred by this system.

Annotations
@Override
getCurrentTimeback to summary
public long getCurrentTime()

Implements abstract org.eclipse.jgit.util.SystemReader.getCurrentTime.

Doc from org.eclipse.jgit.util.SystemReader.getCurrentTime.

Get the current system time

Returns:long

the current system time

Annotations
@Override
getDateTimeInstanceback to summary
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle)

Overrides org.eclipse.jgit.util.SystemReader.getDateTimeInstance.

Doc from org.eclipse.jgit.util.SystemReader.getDateTimeInstance.

Returns a date/time format instance for the given styles.

Parameters
dateStyle:int

the date style as specified in java.text.DateFormat#getDateTimeInstance(int, int)

timeStyle:int

the time style as specified in java.text.DateFormat#getDateTimeInstance(int, int)

Returns:DateFormat

the date format

Annotations
@Override
getenvback to summary
public String getenv(String variable)

Implements abstract org.eclipse.jgit.util.SystemReader.getenv.

Doc from org.eclipse.jgit.util.SystemReader.getenv.

Get value of the system variable

Parameters
variable:String

system variable to read

Returns:String

value of the system variable

Annotations
@Override
getHostnameback to summary
public String getHostname()

Implements abstract org.eclipse.jgit.util.SystemReader.getHostname.

Doc from org.eclipse.jgit.util.SystemReader.getHostname.

Gets the hostname of the local host. If no hostname can be found, the hostname is set to the default value "localhost".

Returns:String

the canonical hostname

Annotations
@Override
getJGitConfigback to summary
public FileBasedConfig getJGitConfig()

Overrides org.eclipse.jgit.util.SystemReader.getJGitConfig.

Doc from org.eclipse.jgit.util.SystemReader.getJGitConfig.

Get the jgit configuration located at $XDG_CONFIG_HOME/jgit/config. The configuration will be reloaded automatically if the configuration file was modified. If the configuration file wasn't modified returns the cached configuration.

Returns:FileBasedConfig

the jgit configuration located at $XDG_CONFIG_HOME/jgit/config

Annotations
@Override
getLocaleback to summary
public Locale getLocale()

Overrides org.eclipse.jgit.util.SystemReader.getLocale.

Doc from org.eclipse.jgit.util.SystemReader.getLocale.

Get the locale to use

Returns:Locale

the locale to use

Annotations
@Override
getPropertyback to summary
public String getProperty(String key)

Implements abstract org.eclipse.jgit.util.SystemReader.getProperty.

Doc from org.eclipse.jgit.util.SystemReader.getProperty.

Get value of the system property

Parameters
key:String

of the system property to read

Returns:String

value of the system property

Annotations
@Override
getSimpleDateFormatback to summary
public SimpleDateFormat getSimpleDateFormat(String pattern)

Overrides org.eclipse.jgit.util.SystemReader.getSimpleDateFormat.

Doc from org.eclipse.jgit.util.SystemReader.getSimpleDateFormat.

Returns a simple date format instance as specified by the given pattern.

Parameters
pattern:String

the pattern as defined in java.text.SimpleDateFormat#SimpleDateFormat(String)

Returns:SimpleDateFormat

the simple date format

Annotations
@Override
getSystemConfigback to summary
public StoredConfig getSystemConfig() throws IOException, ConfigInvalidException

Overrides org.eclipse.jgit.util.SystemReader.getSystemConfig.

Doc from org.eclipse.jgit.util.SystemReader.getSystemConfig.

Get the gitconfig configuration found in the system-wide "etc" directory. The configuration will be reloaded automatically if the configuration file was modified otherwise returns the cached system level config.

Returns:StoredConfig

the gitconfig configuration found in the system-wide "etc" directory

Annotations
@Override
Exceptions
IOException:
if something went wrong when reading files
ConfigInvalidException:
if configuration is invalid
getTimezoneback to summary
public int getTimezone(long when)

Implements abstract org.eclipse.jgit.util.SystemReader.getTimezone.

Doc from org.eclipse.jgit.util.SystemReader.getTimezone.

Get the local time zone

Parameters
when:long

a system timestamp

Returns:int

the local time zone

Annotations
@Override
getTimeZoneback to summary
public TimeZone getTimeZone()

Overrides org.eclipse.jgit.util.SystemReader.getTimeZone.

Doc from org.eclipse.jgit.util.SystemReader.getTimeZone.

Get system time zone, possibly mocked for testing

Returns:TimeZone

system time zone, possibly mocked for testing

Annotations
@Override
getTimeZoneIdback to summary
public ZoneId getTimeZoneId()

Overrides org.eclipse.jgit.util.SystemReader.getTimeZoneId.

Doc from org.eclipse.jgit.util.SystemReader.getTimeZoneId.

Get system time zone, possibly mocked for testing

Returns:ZoneId

system time zone, possibly mocked for testing

Annotations
@Override
getUserConfigback to summary
public StoredConfig getUserConfig() throws IOException, ConfigInvalidException

Overrides org.eclipse.jgit.util.SystemReader.getUserConfig.

Doc from org.eclipse.jgit.util.SystemReader.getUserConfig.

Get the git configuration found in the user home. The configuration will be reloaded automatically if the configuration file was modified. Also reloads the system config if the system config file was modified. If the configuration file wasn't modified returns the cached configuration.

Returns:StoredConfig

the git configuration found in the user home

Annotations
@Override
Exceptions
IOException:
if something went wrong when reading files
ConfigInvalidException:
if configuration is invalid
initback to summary
private void init(String n)
openJGitConfigback to summary
public FileBasedConfig openJGitConfig(Config parent, FS fs)

Implements abstract org.eclipse.jgit.util.SystemReader.openJGitConfig.

Doc from org.eclipse.jgit.util.SystemReader.openJGitConfig.

Open the jgit configuration located at $XDG_CONFIG_HOME/jgit/config. Use 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.

Parameters
parent:Config

a config with values not found directly in the returned config

fs:FS

the file system abstraction which will be necessary to perform certain file system operations.

Returns:FileBasedConfig

the jgit configuration located at $XDG_CONFIG_HOME/jgit/config

Annotations
@Override
openSystemConfigback to summary
public FileBasedConfig openSystemConfig(Config parent, FS fs)

Implements abstract org.eclipse.jgit.util.SystemReader.openSystemConfig.

Doc from org.eclipse.jgit.util.SystemReader.openSystemConfig.

Open the gitconfig configuration found in the system-wide "etc" directory. Use getSystemConfig() to get the current system-wide git configuration since it manages automatic reloading when the gitconfig file was modified and avoids unnecessary reloads.

Parameters
parent:Config

a config with values not found directly in the returned config. Null is a reasonable value here.

fs:FS

the file system abstraction which will be necessary to perform certain file system operations.

Returns:FileBasedConfig

the gitconfig configuration found in the system-wide "etc" directory

Annotations
@Override
openUserConfigback to summary
public FileBasedConfig openUserConfig(Config parent, FS fs)

Implements abstract org.eclipse.jgit.util.SystemReader.openUserConfig.

Doc from org.eclipse.jgit.util.SystemReader.openUserConfig.

Open the git configuration found in the user home. Use 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.

Parameters
parent:Config

a config with values not found directly in the returned config

fs:FS

the file system abstraction which will be necessary to perform certain file system operations.

Returns:FileBasedConfig

the git configuration found in the user home

Annotations
@Override
resetOsNamesback to summary
private void resetOsNames()
setCurrentPlatformback to summary
public void setCurrentPlatform()

Assign some properties for the currently executing platform

setJGitConfigback to summary
public void setJGitConfig(FileBasedConfig jgitConfig)

Set the jgit config stored at $XDG_CONFIG_HOME/jgit/config

Parameters
jgitConfig:FileBasedConfig

set the jgit configuration

Since
5.5
setPropertyback to summary
public void setProperty(String key, String value)

Set a property

Parameters
key:String

the key

value:String

the value

setSystemGitConfigback to summary
public FileBasedConfig setSystemGitConfig(FileBasedConfig systemGitConfig)

Set the system-level git config

Parameters
systemGitConfig:FileBasedConfig

the new system-level git config

Returns:FileBasedConfig

the old system-level config

Since
5.1.9
setUnixback to summary
public void setUnix()

Emulate Unix

setUserGitConfigback to summary
public FileBasedConfig setUserGitConfig(FileBasedConfig userGitConfig)

Set the user-level git config

Parameters
userGitConfig:FileBasedConfig

set another user-level git config

Returns:FileBasedConfig

the old user-level git config

Since
5.1.9
setWindowsback to summary
public void setWindows()

Emulate Windows

tickback to summary
public void tick(int secDelta)

Adjusts the current time in seconds.

Parameters
secDelta:int

number of seconds to add to the current time.

Since
4.2
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jgit.junit back to summary

private final Class MockSystemReader.MockConfig

extends FileBasedConfig
Class Inheritance

Constructor Summary

AccessConstructor and Description
private
MockConfig(File cfgLocation, FS fs)

Method Summary

Modifier and TypeMethod and Description
public boolean
isOutdated()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Whether the currently loaded configuration file is outdated

public void
load()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.load.

Load the configuration from the persistent store.

public void
save()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.save.

Save the configuration to the persistent store.

public String
toString()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jgit.storage.file.FileBasedConfig:
cleargetFilenotifyUponTransientChangesreadIncludedConfig

Constructor Detail

MockConfigback to summary
private MockConfig(File cfgLocation, FS fs)

Method Detail

isOutdatedback to summary
public boolean isOutdated()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Whether the currently loaded configuration file is outdated

Returns:boolean

returns true if the currently loaded configuration file is older than the file on disk

Annotations
@Override
loadback to summary
public void load() throws IOException, ConfigInvalidException

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.load.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.load.

Load the configuration from the persistent store.

If the configuration does not exist, this configuration is cleared, and thus behaves the same as though the backing store exists, but is empty.

Load the configuration as a Git text style configuration file.

If the file does not exist, this configuration is cleared, and thus behaves the same as though the file exists, but is empty.

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.lib.StoredConfig.load.

the configuration could not be read (but does exist).

ConfigInvalidException:

Doc from org.eclipse.jgit.lib.StoredConfig.load.

the configuration is not properly formatted.

saveback to summary
public void save() throws IOException

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.save.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.save.

Save the configuration to the persistent store.

Save the configuration as a Git text style configuration file.

Warning

Although this method uses the traditional Git file locking approach to protect against concurrent writes of the configuration file, it does not ensure that the file has not been modified since the last read, which means updates performed by other objects accessing the same backing file may be lost.

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.lib.StoredConfig.save.

the configuration could not be written.

toStringback to summary
public String toString()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override