Class TestSystemWrapper
- java.lang.Object
-
- org.silverpeas.core.test.util.lang.TestSystemWrapper
-
- All Implemented Interfaces:
SystemWrapper
@Singleton @Alternative @Priority(2010) public class TestSystemWrapper extends Object implements SystemWrapper
Default implementation that is nothing more than a delegate ofSystem
class.- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description TestSystemWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>
getenv()
Gets all the environment variables.String
getenv(String name)
Gets the value of a environment variable.Properties
getProperties()
Gets the system properties.String
getProperty(String key)
Gets a system property.String
getProperty(String key, String def)
Gets a system property.void
initFor(Object testInstance)
void
setProperties(Properties props)
Sets the specified properties in the system properties.String
setProperty(String key, String value)
Sets a new system property.void
setupDefaultParameters()
-
-
-
Method Detail
-
setupDefaultParameters
@PostConstruct public void setupDefaultParameters()
-
initFor
public void initFor(Object testInstance)
-
getenv
public String getenv(String name)
Description copied from interface:SystemWrapper
Gets the value of a environment variable.- Specified by:
getenv
in interfaceSystemWrapper
- Parameters:
name
- the name of the variable.- Returns:
- the value of the requested environment variable.
-
getenv
public Map<String,String> getenv()
Description copied from interface:SystemWrapper
Gets all the environment variables.- Specified by:
getenv
in interfaceSystemWrapper
- Returns:
- the map of environment variables.
-
getProperties
public Properties getProperties()
Description copied from interface:SystemWrapper
Gets the system properties.- Specified by:
getProperties
in interfaceSystemWrapper
- Returns:
- the system properties.
- See Also:
System.getProperties()
-
setProperties
public void setProperties(Properties props)
Description copied from interface:SystemWrapper
Sets the specified properties in the system properties. Opposite to the methodSystem.setProperties(java.util.Properties)
that replace the system properties with the specified ones, this method adds the specified ones among the existing system properties.- Specified by:
setProperties
in interfaceSystemWrapper
- Parameters:
props
- the system properties to add.- See Also:
Properties.putAll(java.util.Map)
-
setProperty
public String setProperty(String key, String value)
Description copied from interface:SystemWrapper
Sets a new system property. If the property isn't valued, id est has a null or an empty value, then it is not set. Only non-null and not empty property can be set.- Specified by:
setProperty
in interfaceSystemWrapper
- Parameters:
key
- the key of the property.value
- a non-null and non-empty value of the property.- Returns:
- the previous value of the system property,
or
null
if it did not have one or if the property to set isn't valid. - See Also:
System.setProperty(String, String)
-
getProperty
public String getProperty(String key)
Description copied from interface:SystemWrapper
Gets a system property.- Specified by:
getProperty
in interfaceSystemWrapper
- Parameters:
key
- the key of the system property.- Returns:
- the string value of the system property,
or
null
if there is no property with that key.
-
getProperty
public String getProperty(String key, String def)
Description copied from interface:SystemWrapper
Gets a system property.- Specified by:
getProperty
in interfaceSystemWrapper
- Parameters:
key
- the key of the system property.def
- the default value if there is no property value with the key.- Returns:
- the string value of the system property, or the default value if there is no property with that key.
-
-