-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MSHARED-938] #60
base: master
Are you sure you want to change the base?
[MSHARED-938] #60
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.nio.charset.Charset; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.Locale; | ||
|
@@ -168,4 +169,25 @@ private void assertCmdLineArgs( final String[] expected, final String cmdLine ) | |
assertEquals( expected.length, actual.length ); | ||
assertEquals( Arrays.asList( expected ), Arrays.asList( actual ) ); | ||
} | ||
|
||
@Test | ||
public void testChineseEncodingIssue() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is completely pointless:
What you need is an application that produces GBK bytes , those are read by Java with GBK into a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as i am concerned, the parameter Any idea of producing GBK bytes using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, this test will pass without this PR if system encoding is the same as the result of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why do you think so? It uses the same encoding as the surrounding Java process does. You cannot change this really on Windows, on Unix you can pass LC_ALL to the env.
You have two options:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I tried producing gbk bytes with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's wrong. You need to use System.out as an byte stream, not a char stream: |
||
throws Exception | ||
{ | ||
Commandline commandline = new Commandline( "ping www.baidu.com" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we cannot have tests which require outbound access. Espcially ICMP. Please change test. |
||
StreamConsumer err = new StreamConsumer() { | ||
@Override | ||
public void consumeLine( String line ) { | ||
|
||
} | ||
}; | ||
StreamConsumer out = new StreamConsumer() { | ||
@Override | ||
public void consumeLine( String line ) { | ||
System.out.println( line ); | ||
} | ||
}; | ||
CommandLineCallable commandLineCallable = CommandLineUtils.executeCommandLineAsCallable( commandline, null, out, err, 10, null, Charset.forName("GBK") ); | ||
commandLineCallable.call(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space before comma is not required.