@ScannerSide @ServerSide @ComputeEngineSide 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();
   }
 }
  @Test
 public void should_return_xxx() {
   // using Mockito
   System2 system = mock(System2.class);
   long now = 123456789L;
   doReturn(now).when(system).now();
   assertThat(new MyClass(system).xxx()).isEqualTo(now);
 }
 
 System.
 | Constructor and Description | 
|---|
| System2() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close(AutoCloseable closeable)Closes the object and throws an  IllegalStateExceptionon error. | 
| String | envVariable(String key)Shortcut for  System.getenv(String) | 
| Map<String,String> | envVariables()Shortcut for  System.getenv() | 
| TimeZone | getDefaultTimeZone() | 
| URL | getResource(String name) | 
| boolean | isJavaAtLeast17()True if Java 7 or Java 8 runtime environment | 
| boolean | isOsWindows()True if this is MS Windows. | 
| Date | newDate()Deprecated. 
 in 5.2. Please use  now() | 
| 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()
public boolean isJavaAtLeast17()
@Deprecated public Date newDate()
now()public TimeZone getDefaultTimeZone()
public URL getResource(String name)
Class.getResource(String)public void close(AutoCloseable closeable)
IllegalStateException on error.Copyright © 2009–2016 SonarSource. All rights reserved.