Nova Ordis Utilities OS Support: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * Novaordis-utilities#Subjects =Overview=") |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
=Overview= | =Overview= | ||
=Testing with a Mock OS= | |||
The <tt>OS.getInstance()</tt> factory method looks up the "os.class" system property before it looks up "os.name". If "os.class" is set up, the implementation will interpret the value as a fully qualified <tt>io.novaordis.utilities.os.OS</tt> implementation class name, try to instantiate it and return it if successful. An instantiation failure will throw an exception (ClassNotFoundException or other). | |||
In order to mock an OS, provide an OS implementation in your class path and then set "os.class", with a code possibly similar to: | |||
<pre> | |||
@Before | |||
public void before() throws Exception { | |||
System.setProperty("os.class", ....); | |||
} | |||
@After | |||
public void after() throws Exception { | |||
System.clearProperty("os.class"); | |||
} | |||
</pre> |
Latest revision as of 15:52, 16 November 2016
Internal
Overview
Testing with a Mock OS
The OS.getInstance() factory method looks up the "os.class" system property before it looks up "os.name". If "os.class" is set up, the implementation will interpret the value as a fully qualified io.novaordis.utilities.os.OS implementation class name, try to instantiate it and return it if successful. An instantiation failure will throw an exception (ClassNotFoundException or other).
In order to mock an OS, provide an OS implementation in your class path and then set "os.class", with a code possibly similar to:
@Before public void before() throws Exception { System.setProperty("os.class", ....); } @After public void after() throws Exception { System.clearProperty("os.class"); }