diff options
author | Neil Fuller <nfuller@google.com> | 2014-05-21 16:21:35 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2014-05-29 15:35:45 +0100 |
commit | ad9ec1060806e6c60a7eb2a9682d8684aad68e0e (patch) | |
tree | 77a1c9ad852aa872c7be52ee4c833c509000b2cc | |
parent | f5259a201dae2e25dffabbece3f66d931a7d8dd7 (diff) | |
download | cts-ad9ec1060806e6c60a7eb2a9682d8684aad68e0e.tar.gz |
Reset System properities between tests
This is to avoid test leakage.
The properties are reset to their initial values with this
change, clearing any of the ones set by tests. Vogar
was already doing something like this.
Some of the existing property setting was rendered
unnecessary / pointless by Narayan's immutable
system property commit
(f63153ac0ec510b0111d01805097bbd08ccf64ab).
Note: This change will cause a merge conflict for the
internal master due to changes in the CTS runner.
Change-Id: I7edfc325857f701ab0c5b9958703b3a592e8eb82
-rw-r--r-- | tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java index 83c339bc2a0..96aeb51b635 100644 --- a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java +++ b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java @@ -75,16 +75,7 @@ public class InstrumentationCtsTestRunner extends InstrumentationTestRunner { public void onCreate(Bundle arguments) { // We might want to move this to /sdcard, if is is mounted/writable. File cacheDir = getTargetContext().getCacheDir(); - - // Set some properties that the core tests absolutely need. - System.setProperty("user.language", "en"); - System.setProperty("user.region", "US"); - - System.setProperty("java.home", cacheDir.getAbsolutePath()); - System.setProperty("user.home", cacheDir.getAbsolutePath()); System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath()); - System.setProperty("user.dir", cacheDir.getAbsolutePath()); - mEnvironment = new TestEnvironment(); @@ -203,7 +194,6 @@ public class InstrumentationCtsTestRunner extends InstrumentationTestRunner { static class TestEnvironment { private final Locale mDefaultLocale; private final TimeZone mDefaultTimeZone; - private final String mUserHome; private final String mJavaIoTmpDir; private final HostnameVerifier mHostnameVerifier; private final SSLSocketFactory mSslSocketFactory; @@ -211,17 +201,16 @@ public class InstrumentationCtsTestRunner extends InstrumentationTestRunner { TestEnvironment() { mDefaultLocale = Locale.getDefault(); mDefaultTimeZone = TimeZone.getDefault(); - mUserHome = System.getProperty("user.home"); mJavaIoTmpDir = System.getProperty("java.io.tmpdir"); mHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier(); mSslSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); } void reset() { + System.setProperties(null); + System.setProperty("java.io.tmpdir", mJavaIoTmpDir); Locale.setDefault(mDefaultLocale); TimeZone.setDefault(mDefaultTimeZone); - System.setProperty("user.home", mUserHome); - System.setProperty("java.io.tmpdir", mJavaIoTmpDir); Authenticator.setDefault(null); CookieHandler.setDefault(null); ResponseCache.setDefault(null); |