|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.junit.rules.ExternalResource
org.junit.contrib.java.lang.system.RestoreSystemProperties
public class RestoreSystemProperties
The RestoreSystemProperties
rule undoes changes of system
properties when the test finishes (whether it passes or fails).
Let's assume the system property YourProperty
has the
value YourValue
. Now run the test
public void YourTest { @Rule public final TestRule restoreSystemProperties = new RestoreSystemProperties(); @Test public void overrideProperty() { System.setProperty("YourProperty", "other value"); assertEquals("other value", System.getProperty("YourProperty")); } }After running the test, the system property
YourProperty
has
the value YourValue
again.
Constructor Summary | |
---|---|
RestoreSystemProperties()
Creates a RestoreSystemProperties rule that restores all
system properties. |
|
RestoreSystemProperties(String... properties)
Deprecated. Please use RestoreSystemProperties() . The
rule restores all properties. That's why you don't have to
specify the properties anymore. |
Method Summary | |
---|---|
void |
add(String property)
Deprecated. Simply remove all calls to this method. RestoreSystemProperties restores all properties
automatically. That's why you don't have to add the properties
anymore. |
protected void |
after()
|
protected void |
before()
|
Methods inherited from class org.junit.rules.ExternalResource |
---|
apply |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public RestoreSystemProperties(String... properties)
RestoreSystemProperties()
. The
rule restores all properties. That's why you don't have to
specify the properties anymore.
RestoreSystemProperties
rule that restores all
system properties.
public RestoreSystemProperties()
RestoreSystemProperties
rule that restores all
system properties.
Method Detail |
---|
@Deprecated public void add(String property)
RestoreSystemProperties
restores all properties
automatically. That's why you don't have to add the properties
anymore.
protected void before() throws Throwable
before
in class org.junit.rules.ExternalResource
Throwable
protected void after()
after
in class org.junit.rules.ExternalResource
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |