public class System2 extends Object
System
. It aims to improve testability of classes
that interact with low-level system methods, for example :
public class MyClass { private final System2 system; public MyClass(System2 s) { this.system = s; } public long xxx() { return system.now(); } }
Constructor and Description |
---|
System2() |
Modifier and Type | Method and Description |
---|---|
String |
envVariable(String key)
Shortcut for
System.getenv(String) |
Map<String,String> |
envVariables()
Shortcut for
System.getenv() |
boolean |
isOsWindows()
True if this is MS Windows.
|
long |
now()
Shortcut for
System.currentTimeMillis() |
void |
println(String obj) |
Properties |
properties()
Shortcut for
System.getProperties() |
String |
property(String key)
Shortcut for
System.getProperty(String) |
public System2()
public long now()
System.currentTimeMillis()
public Properties properties()
System.getProperties()
@CheckForNull public String property(String key)
System.getProperty(String)
public Map<String,String> envVariables()
System.getenv()
@CheckForNull public String envVariable(String key)
System.getenv(String)
public boolean isOsWindows()
Copyright © 2009-2014 SonarSource. All Rights Reserved.