Skip to content

Commit

Permalink
Tests: use StandardCharsets.UTF_8 instead of "UTF-8" in a few strea…
Browse files Browse the repository at this point in the history
…m constructors
  • Loading branch information
carlosame committed Jul 10, 2024
1 parent 66b678d commit 83ff03e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

import javax.swing.JFrame;
import javax.swing.JPanel;
Expand Down Expand Up @@ -140,15 +141,16 @@ public JPainterCompare(Painter painter) {
try {
tmpFile = File.createTempFile(CONFIG_TMP_FILE_PREFIX, ".svg");

OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(tmpFile),
StandardCharsets.UTF_8);

painter.paint(g2d);
g2d.stream(osw);
osw.flush();
} catch (Exception e) {
e.printStackTrace();
throw new IllegalArgumentException(
Messages.formatMessage(ERROR_COULD_NOT_TRANSCODE_TO_SVG, new Object[] { e.getClass().getName() }));
throw new IllegalArgumentException(Messages.formatMessage(
ERROR_COULD_NOT_TRANSCODE_TO_SVG, new Object[] { e.getClass().getName() }));
}

//
Expand All @@ -165,8 +167,8 @@ public JPainterCompare(Painter painter) {
}
} catch (Exception e) {
e.printStackTrace();
throw new Error(
Messages.formatMessage(ERROR_COULD_NOT_CONVERT_FILE_PATH_TO_URL, new Object[] { e.getMessage() }));
throw new Error(Messages.formatMessage(
ERROR_COULD_NOT_CONVERT_FILE_PATH_TO_URL, new Object[] { e.getMessage() }));
}

if (l.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.Reader;
import java.io.StringWriter;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
Expand Down Expand Up @@ -92,7 +93,7 @@ public void test() throws Exception {
{
URL uri = new URL(TEST_URI);
InputStream is = uri.openStream();
Reader r = new InputStreamReader(is, "utf-8");
Reader r = new InputStreamReader(is, StandardCharsets.UTF_8);
TranscoderInput ti = new TranscoderInput(r);
ti.setURI(TEST_URI);
t = new TestTranscoder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -129,7 +130,7 @@ private void runTest(String filename) throws IOException, TranscoderException {
input = new TranscoderInput(wmfURL.toString());

OutputStreamWriter outW;
outW = new OutputStreamWriter(out, "UTF-8");
outW = new OutputStreamWriter(out, StandardCharsets.UTF_8);
TranscoderOutput output = new TranscoderOutput(outW);

wmft.transcode(input, output);
Expand Down

0 comments on commit 83ff03e

Please sign in to comment.