Skip to content

Commit

Permalink
EncodingTests.test021() fails on win
Browse files Browse the repository at this point in the history
Original test assumed workspace always uses system default encoding and
projects follow that if nothing is set explikcitly.

This assumption was not correct anymore after
eclipse-platform/eclipse.platform.resources#51
and eclipse-platform/eclipse.platform.resources@961d080

For the concrete test to succeed we should set "system" encoding on the
project we use.

Fixes #462
  • Loading branch information
iloveeclipse committed Feb 19, 2023
1 parent b95ff99 commit c9b8cb1
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,21 @@ public void test016() throws JavaModelException, CoreException {
* Verification is done by comparing source with file contents read directly with VM encoding...
*/
public void test021() throws JavaModelException, CoreException {
getWorkspaceRoot().setDefaultCharset(vmEncoding, null);
try {
// Get class file and compare source
IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar");
this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class");
assertNotNull(this.utf8Source);
String source = this.utf8Source.getSource();
assertNotNull(source);
String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, vmEncoding));
assertSourceEquals("Encoded UTF-8 source should have been decoded the same way!", source, encodedContents);

// Get class file and compare source
IPackageFragmentRoot root = getPackageFragmentRoot("Encoding", "testUTF8.jar");
this.utf8Source = root.getPackageFragment("testUTF8").getClassFile("Test.class");
assertNotNull(this.utf8Source);
String source = this.utf8Source.getSource();
assertNotNull(source);
String encodedContents = new String (Util.getResourceContentsAsCharArray(this.utf8File, vmEncoding));
assertSourceEquals("Encoded UTF-8 source should have been decoded the same way!", source, encodedContents);

// Cannot compare bytes array without encoding as we're dependent of linux/windows os for new lines delimiter
// Cannot compare bytes array without encoding as we're dependent of linux/windows os for new lines delimiter
} finally {
getWorkspaceRoot().setDefaultCharset(wkspEncoding, null);
}
}

/*
Expand Down

0 comments on commit c9b8cb1

Please sign in to comment.