This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
The following commit(s) were added to refs/heads/master by this push: new 1f5be19 Bugfix: TextConverter: Do not duplicate the content of text files. 1f5be19 is described below commit 1f5be198145795285f1d3fe7dad57cad833c0845 Author: Stephan Markwalder <stephan.markwal...@appway.com> AuthorDate: Fri Apr 10 15:34:03 2020 +0200 Bugfix: TextConverter: Do not duplicate the content of text files. --- .../org/apache/tomcat/jakartaee/TextConverter.java | 2 -- .../apache/tomcat/jakartaee/TextConverterTest.java | 34 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/tomcat/jakartaee/TextConverter.java b/src/main/java/org/apache/tomcat/jakartaee/TextConverter.java index 5ad1b0b..d823ffd 100644 --- a/src/main/java/org/apache/tomcat/jakartaee/TextConverter.java +++ b/src/main/java/org/apache/tomcat/jakartaee/TextConverter.java @@ -62,8 +62,6 @@ public class TextConverter implements Converter { String srcString = Util.toString(src, StandardCharsets.ISO_8859_1); String destString = profile.convert(srcString); - dest.write(destString.getBytes()); - ByteArrayInputStream bais = new ByteArrayInputStream(destString.getBytes(StandardCharsets.ISO_8859_1)); Util.copy(bais, dest); } diff --git a/src/test/java/org/apache/tomcat/jakartaee/TextConverterTest.java b/src/test/java/org/apache/tomcat/jakartaee/TextConverterTest.java new file mode 100644 index 0000000..2d015f3 --- /dev/null +++ b/src/test/java/org/apache/tomcat/jakartaee/TextConverterTest.java @@ -0,0 +1,34 @@ +package org.apache.tomcat.jakartaee; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import org.junit.Test; + +public class TextConverterTest { + + private static final String INPUT = "javax.servlet.http.HttpServletRequest"; + private static final String OUTPUT = "jakarta.servlet.http.HttpServletRequest"; + + @Test + public void testConvert() throws IOException { + + // prepare + TextConverter converter = new TextConverter(); + ByteArrayInputStream in = new ByteArrayInputStream(INPUT.getBytes(StandardCharsets.ISO_8859_1)); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + EESpecProfile profile = EESpecProfile.EE; + + // test + converter.convert(in, out, profile); + + // assert + String result = new String(out.toByteArray(), StandardCharsets.ISO_8859_1); + assertEquals(OUTPUT, result); + + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org