Merge "Fix junit tests under windows when the platform is explicitly changed" into stable-3.6

This commit is contained in:
Matthias Sohn 2014-12-22 09:29:43 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit 79201ac95e
2 changed files with 15 additions and 5 deletions

View File

@ -184,6 +184,7 @@ public void setWindows() {
setProperty("file.separator", "\\"); setProperty("file.separator", "\\");
setProperty("path.separator", ";"); setProperty("path.separator", ";");
setProperty("line.separator", "\r\n"); setProperty("line.separator", "\r\n");
setPlatformChecker();
} }
/** /**
@ -194,5 +195,6 @@ public void setUnix() {
setProperty("file.separator", "/"); setProperty("file.separator", "/");
setProperty("path.separator", ":"); setProperty("path.separator", ":");
setProperty("line.separator", "\n"); setProperty("line.separator", "\n");
setPlatformChecker();
} }
} }

View File

@ -163,11 +163,19 @@ public static void setInstance(SystemReader newReader) {
private void init() { private void init() {
// Creating ObjectChecker must be deferred. Unit tests change // Creating ObjectChecker must be deferred. Unit tests change
// behavior of is{Windows,MacOS} in constructor of subclass. // behavior of is{Windows,MacOS} in constructor of subclass.
if (platformChecker == null) { if (platformChecker == null)
platformChecker = new ObjectChecker() setPlatformChecker();
.setSafeForWindows(isWindows()) }
.setSafeForMacOS(isMacOS());
} /**
* Should be used in tests when the platform is explicitly changed.
*
* @since 3.6
*/
protected final void setPlatformChecker() {
platformChecker = new ObjectChecker()
.setSafeForWindows(isWindows())
.setSafeForMacOS(isMacOS());
} }
/** /**