forked from mojohaus/exec-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes mojohausgh-158
- Loading branch information
Showing
2 changed files
with
38 additions
and
5 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
23 changes: 23 additions & 0 deletions
23
src/test/java/org/codehaus/mojo/exec/LineRedirectOutputStreamTest.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,23 @@ | ||
package org.codehaus.mojo.exec; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
public class LineRedirectOutputStreamTest { | ||
|
||
@Test | ||
public void givenUtf8Output_whenRedirecting_thenShouldDecodeProperly() throws IOException { | ||
StringBuilder sb = new StringBuilder(); | ||
String firstLine = "Hello 😃 😄"; | ||
String secondLine = "foo bar éà"; | ||
|
||
try (LineRedirectOutputStream os = new LineRedirectOutputStream(sb::append)) { | ||
os.write(String.join("\n", firstLine, secondLine).getBytes(Charset.defaultCharset())); | ||
} | ||
|
||
Assert.assertEquals(firstLine + secondLine, sb.toString()); | ||
} | ||
} |