mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Buffer output and do not create new temp array streams
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GitDiffCommand_DequoteOutputStreamTest {
|
||||
|
||||
@Test
|
||||
void shouldDequoteText() throws IOException {
|
||||
String s = "diff --git \"a/\\303\\272\\303\\274\\303\\276\\303\\253\\303\\251\\303\\245\\303\\253\\303\\245\\303\\251 \\303\\245g\\303\\260f\\303\\237\" \"b/\\303\\272\\303\\274\\303\\276\\303\\253\\303\\251\\303\\245\\303\\253\\303\\245\\303\\251 \\303\\245g\\303\\260f\\303\\237\"\n" +
|
||||
"new file mode 100644\n" +
|
||||
"index 0000000..8cb0607\n" +
|
||||
"--- /dev/null\n" +
|
||||
"+++ \"b/\\303\\272\\303\\274\\303\\276\\303\\253\\303\\251\\303\\245\\303\\253\\303\\245\\303\\251 \\303\\245g\\303\\260f\\303\\237\"\n" +
|
||||
"@@ -0,0 +1 @@\n" +
|
||||
"+rthms";
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
GitDiffCommand.DequoteOutputStream stream = new GitDiffCommand.DequoteOutputStream(buffer);
|
||||
byte[] bytes = s.getBytes();
|
||||
stream.write(bytes, 0, bytes.length);
|
||||
stream.flush();
|
||||
|
||||
Assertions.assertThat(buffer.toString()).isEqualTo("diff --git \"a/\\303\\272\\303\\274\\303\\276\\303\\253\\303\\251\\303\\245\\303\\253\\303\\245\\303\\251 \\303\\245g\\303\\260f\\303\\237\" \"b/\\303\\272\\303\\274\\303\\276\\303\\253\\303\\251\\303\\245\\303\\253\\303\\245\\303\\251 \\303\\245g\\303\\260f\\303\\237\"\n" +
|
||||
"new file mode 100644\n" +
|
||||
"index 0000000..8cb0607\n" +
|
||||
"--- /dev/null\n" +
|
||||
"+++ b/úüþëéåëåé ågðfß\n" +
|
||||
"@@ -0,0 +1 @@\n" +
|
||||
"+rthms");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user