-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat - Set which encoding your test JVM will start with (#1735)
* Set which encoding your test JVM will start with This patch adds a setting to the `java.test.config` object. ```jsonc { "java.test.config": { "encoding": "ISO-8859-1", }, } ``` The aim here is to be able to seamlessly test code which cares about the launch encoding of the JVM. Yes, such code is not good. But sometimes you don't control your dependencies enough to fix this. Since the debug launcher already cares about the `encoding` member of the config, the only thing required is to add the member, which is missing from the launch configs generated by the test plugin. ```typescript // In `configurationProvider.ts:` (vscode-java-debug) // VS Code internal console uses UTF-8 to display output by default. if (config.console === "internalConsole" && !config.encoding) { config.encoding = "UTF-8"; } ``` Fixes #1641 --------- Co-authored-by: Sheng Chen <sheche@microsoft.com> Co-authored-by: Adrian Wilkins <adrian.wilkins.contractor@dvla.gov.uk>
- Loading branch information
1 parent
d00d92a
commit 2612b25
Showing
6 changed files
with
113 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/test-projects/junit/src/test/java/junit4/TestEncoding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package junit4; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.nio.charset.Charset; | ||
|
||
/** | ||
* The test case in this class will fail unless you set `java.test.config : encoding` to ISO-8859-1 | ||
*/ | ||
public class TestEncoding { | ||
@Test | ||
public void latin1IsSet() { | ||
assertEquals( | ||
"ISO-8859-1", | ||
Charset.defaultCharset().name() | ||
); | ||
} | ||
} |