Skip to content

Commit cc699b9

Browse files
committed
ConfigurationEncodingTests.testGetSystemDefaultEncoding failure (#77)
Updated test to use Platform.getSystemCharset() API. Note: running this test in the IDE still fails because IDE ALWAYS sets "file.encoding" system property, see #24 Fixes #77
1 parent e7b9488 commit cc699b9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/ConfigurationEncodingTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.core.resources.IResource;
1818
import org.eclipse.core.resources.ResourcesPlugin;
1919
import org.eclipse.core.runtime.CoreException;
20+
import org.eclipse.core.runtime.Platform;
2021
import org.eclipse.core.runtime.Preferences;
2122
import org.eclipse.debug.core.DebugPlugin;
2223
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -60,21 +61,20 @@ protected String getDefaultEncoding() {
6061
*/
6162
public void testGetSystemDefaultEncoding() throws CoreException {
6263
String oldencoding = ResourcesPlugin.getEncoding();
63-
String oldsystemencoding = System.getProperty("file.encoding");
64+
String defaultEncoding = getDefaultEncoding();
65+
String systemEncoding = Platform.getSystemCharset().name();
6466
try {
65-
getResourcesPreferences().setValue(ResourcesPlugin.PREF_ENCODING, getDefaultEncoding());
66-
System.setProperty("file.encoding", "UTF-16BE");
67+
getResourcesPreferences().setValue(ResourcesPlugin.PREF_ENCODING, defaultEncoding);
6768
ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest");
6869
assertNotNull("the configuration could not be found", config);
6970
assertTrue("there should be no encoding set on the configuration", config.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, (String) null) == null);
7071
String encoding = getLaunchManager().getEncoding(config);
7172
assertNotNull("The configuration encoding should not be null", encoding);
72-
assertEquals("The configuration encoding should match the file system encoding", encoding, System.getProperty("file.encoding"));
73+
assertEquals("The configuration encoding should match the file system encoding", systemEncoding, encoding);
7374
}
7475
finally {
7576
//ensure old encoding is restored
76-
getResourcesPreferences().setValue(ResourcesPlugin.PREF_ENCODING, (oldencoding == null ? getDefaultEncoding() : oldencoding));
77-
System.setProperty("file.encoding", oldsystemencoding);
77+
getResourcesPreferences().setValue(ResourcesPlugin.PREF_ENCODING, (oldencoding == null ? defaultEncoding : oldencoding));
7878
}
7979
}
8080

0 commit comments

Comments
 (0)