Skip to content

Commit c53ead2

Browse files
Add test for UrlUtil#openStream method
DEVSIX-3683
1 parent 1318d89 commit c53ead2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

io/src/test/java/com/itextpdf/io/util/UrlUtilTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ This file is part of the iText (R) project.
4646
import com.itextpdf.test.annotations.type.UnitTest;
4747
import java.io.File;
4848
import java.io.IOException;
49+
import java.io.InputStream;
50+
import java.net.MalformedURLException;
51+
import java.net.URL;
52+
import java.nio.charset.StandardCharsets;
4953
import java.nio.file.Paths;
5054
import org.junit.Assert;
5155
import org.junit.BeforeClass;
@@ -86,4 +90,14 @@ public void nullBaseUriTest() throws IOException {
8690
File tempFile = null;
8791
Assert.assertEquals(expected, FileUtil.getParentDirectory(tempFile));
8892
}
93+
94+
@Test
95+
public void openStreamTest() throws IOException {
96+
String resPath = "./src/test/resources/com/itextpdf/io/util/textFile.dat";
97+
InputStream openStream = UrlUtil.openStream(new File(resPath).toURI().toURL());
98+
99+
String actual = new String(StreamUtil.inputStreamToArray(openStream), StandardCharsets.UTF_8);
100+
Assert.assertEquals("Hello world from text file!", actual);
101+
102+
}
89103
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world from text file!

0 commit comments

Comments
 (0)