Skip to content

Commit

Permalink
Updated to latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jan 15, 2024
1 parent 5d48e0e commit 42137a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
import com.helger.commons.io.stream.NonBlockingByteArrayInputStream;
import com.helger.commons.string.StringHelper;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Test class for class {@link ChunkedInputStream}.
*
Expand All @@ -56,11 +54,10 @@
public final class ChunkedInputStreamTest
{
@Test
@SuppressFBWarnings ("RR_NOT_CHECKED")
public void testReadBufferFromEmpty () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [17];
assertThrows (EOFException.class, () -> cIS.read (buf, 0, buf.length));
Expand All @@ -70,8 +67,9 @@ public void testReadBufferFromEmpty () throws IOException
@Test
public void testReadPastEOS () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("3\n123\r\n0\r\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
try (
final InputStream aIS = new NonBlockingByteArrayInputStream ("3\n123\r\n0\r\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [17];
int ret = cIS.read (buf, 0, buf.length);
Expand All @@ -86,7 +84,7 @@ public void testReadPastEOS () throws IOException
public void testReadByteFromEmpty () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream (ArrayHelper.EMPTY_BYTE_ARRAY);
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
assertThrows (EOFException.class, () -> cIS.read ());
}
Expand All @@ -96,7 +94,7 @@ public void testReadByteFromEmpty () throws IOException
public void testReadOneChunkBuffer () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("3\n123".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [3];
final int ret = cIS.read (buf, 0, buf.length);
Expand All @@ -110,9 +108,11 @@ public void testReadOneChunkBufferHex () throws IOException
{
final int nLen = 0xaf;
final String sPayload = StringHelper.getRepeated ('a', nLen);
try (final InputStream aIS = new NonBlockingByteArrayInputStream ((Integer.toHexString (nLen) + "\r\n" + sPayload)
.getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
try (
final InputStream aIS = new NonBlockingByteArrayInputStream ((Integer.toHexString (nLen) +
"\r\n" +
sPayload).getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [nLen];
final int ret = cIS.read (buf, 0, buf.length);
Expand All @@ -127,7 +127,7 @@ public void testReadOneChunkBufferHex () throws IOException
public void testReadOneChunkBytes () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("3\n123".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
int ret = cIS.read ();
assertEquals ("Read first char", '1', ret);
Expand All @@ -142,8 +142,9 @@ public void testReadOneChunkBytes () throws IOException
@Test
public void testReadTwoChunkBuffer () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("2\r\n12\r\n1\na\r\n0\r\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
try (
final InputStream aIS = new NonBlockingByteArrayInputStream ("2\r\n12\r\n1\na\r\n0\r\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [3];
final int ret = cIS.read (buf, 0, buf.length);
Expand All @@ -163,7 +164,7 @@ public void testReadTwoChunkBufferMultipleReads () throws IOException
"2\r\n12\r\n1\na\r\n0\r\nThis is ignored" })
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream (sSrc.getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final byte [] buf = new byte [3];
int ret = cIS.read (buf, 0, 1);
Expand All @@ -188,7 +189,7 @@ public void testReadTwoChunkByteMultipleReads () throws IOException
{
final String sSrc = "2\r\n12\r\n1\na\r\n0\r\n";
try (final InputStream aIS = new NonBlockingByteArrayInputStream (sSrc.getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
int ret = cIS.read ();
assertEquals ("Read one Chunk-1: correct data returned", '1', ret);
Expand All @@ -206,8 +207,9 @@ public void testReadTwoChunkByteMultipleReads () throws IOException
@Test
public void testReadBrokenChunk1 () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream ("bla foo fasel\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
try (
final InputStream aIS = new NonBlockingByteArrayInputStream ("bla foo fasel\n".getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final int ret = cIS.read ();
assertEquals (-1, ret);
Expand All @@ -217,10 +219,11 @@ public void testReadBrokenChunk1 () throws IOException
@Test
public void testReadBrokenChunk2 () throws IOException
{
try (final InputStream aIS = new NonBlockingByteArrayInputStream (("Filename: 2022-06-29-14-47-02-1409.txt\r\n" +
"\r\n" +
"Lorem ipsum dolor sit amet").getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
try (
final InputStream aIS = new NonBlockingByteArrayInputStream (("Filename: 2022-06-29-14-47-02-1409.txt\r\n" +
"\r\n" +
"Lorem ipsum dolor sit amet").getBytes (StandardCharsets.ISO_8859_1));
final ChunkedInputStream cIS = new ChunkedInputStream (aIS))
{
final int ret = cIS.read ();
assertEquals ('\r', ret);
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@
</developers>

<properties>
<log4j.version>2.20.0</log4j.version>
<spring-boot.version>2.7.12</spring-boot.version>
<log4j.version>2.22.1</log4j.version>
<spring-boot.version>2.7.18</spring-boot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.helger.commons</groupId>
<artifactId>ph-commons-parent-pom</artifactId>
<version>11.0.5</version>
<version>11.1.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -91,7 +91,7 @@
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-css-parent-pom</artifactId>
<version>7.0.0</version>
<version>7.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit 42137a5

Please sign in to comment.