This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new a7726f583 Remove odd comments in test
a7726f583 is described below

commit a7726f5839b21af54bfa7544874577c30b39e0be
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Sep 21 11:58:35 2025 -0400

    Remove odd comments in test
---
 .../utils/SeekableInMemoryByteChannelTest.java     | 45 +---------------------
 1 file changed, 1 insertion(+), 44 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
 
b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
index 4078dbfc9..35c44599c 100644
--- 
a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
+++ 
b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.commons.compress.utils;
 
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -70,12 +71,9 @@ void testReadingFromAPositionAfterEndReturnsEOF(final int 
size) throws Exception
 
     @Test
     void testShouldReadContentsProperly() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
             final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length);
-            // when
             final int readCount = c.read(readBuffer);
-            // then
             assertEquals(testData.length, readCount);
             assertArrayEquals(testData, readBuffer.array());
             assertEquals(testData.length, c.position());
@@ -84,12 +82,9 @@ void testShouldReadContentsProperly() throws IOException {
 
     @Test
     void testShouldReadContentsWhenBiggerBufferSupplied() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
             final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length 
+ 1);
-            // when
             final int readCount = c.read(readBuffer);
-            // then
             assertEquals(testData.length, readCount);
             assertArrayEquals(testData, Arrays.copyOf(readBuffer.array(), 
testData.length));
             assertEquals(testData.length, c.position());
@@ -98,13 +93,10 @@ void testShouldReadContentsWhenBiggerBufferSupplied() 
throws IOException {
 
     @Test
     void testShouldReadDataFromSetPosition() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
             final ByteBuffer readBuffer = ByteBuffer.allocate(4);
-            // when
             c.position(5L);
             final int readCount = c.read(readBuffer);
-            // then
             assertEquals(4L, readCount);
             assertEquals("data", new String(readBuffer.array(), 
StandardCharsets.UTF_8));
             assertEquals(testData.length, c.position());
@@ -113,13 +105,10 @@ void testShouldReadDataFromSetPosition() throws 
IOException {
 
     @Test
     void testShouldSetProperPosition() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
-            // when
             final long posAtFour = c.position(4L).position();
             final long posAtTheEnd = c.position(testData.length).position();
             final long posPastTheEnd = c.position(testData.length + 
1L).position();
-            // then
             assertEquals(4L, posAtFour);
             assertEquals(c.size(), posAtTheEnd);
             assertEquals(testData.length + 1L, posPastTheEnd);
@@ -128,12 +117,9 @@ void testShouldSetProperPosition() throws IOException {
 
     @Test
     void testShouldSetProperPositionOnTruncate() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
-            // when
             c.position(testData.length);
             c.truncate(4L);
-            // then
             assertEquals(4L, c.position());
             assertEquals(4L, c.size());
         }
@@ -141,13 +127,10 @@ void testShouldSetProperPositionOnTruncate() throws 
IOException {
 
     @Test
     void testShouldSignalEOFWhenPositionAtTheEnd() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
             final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length);
-            // when
             c.position(testData.length + 1);
             final int readCount = c.read(readBuffer);
-            // then
             assertEquals(0L, readBuffer.position());
             assertEquals(-1, readCount);
             assertEquals(-1, c.read(readBuffer));
@@ -156,89 +139,67 @@ void testShouldSignalEOFWhenPositionAtTheEnd() throws 
IOException {
 
     @Test
     void testShouldThrowExceptionOnReadingClosedChannel() {
-        // given
         final SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel();
-        // when
         c.close();
         assertThrows(ClosedChannelException.class, () -> 
c.read(ByteBuffer.allocate(1)));
     }
 
     @Test
     void testShouldThrowExceptionOnWritingToClosedChannel() {
-        // given
         final SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel();
-        // when
         c.close();
         assertThrows(ClosedChannelException.class, () -> 
c.write(ByteBuffer.allocate(1)));
     }
 
     @Test
     void testShouldThrowExceptionWhenSettingIncorrectPosition() {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel()) {
-            // when
             assertThrows(IOException.class, () -> c.position(Integer.MAX_VALUE 
+ 1L));
         }
     }
 
     @Test
     void testShouldThrowExceptionWhenTruncatingToIncorrectSize() {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel()) {
-            // when
             assertThrows(IllegalArgumentException.class, () -> 
c.truncate(Integer.MAX_VALUE + 1L));
         }
     }
 
     @Test
     void testShouldTruncateContentsProperly() throws ClosedChannelException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
-            // when
             c.truncate(4);
-            // then
             final byte[] bytes = Arrays.copyOf(c.array(), (int) c.size());
             assertEquals("Some", new String(bytes, StandardCharsets.UTF_8));
         }
     }
-
     // Contract Tests added in response to 
https://issues.apache.org/jira/browse/COMPRESS-499
-
     // https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html#close()
 
     @Test
     void testShouldWriteDataProperly() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel()) {
             final ByteBuffer inData = ByteBuffer.wrap(testData);
-            // when
             final int writeCount = c.write(inData);
-            // then
             assertEquals(testData.length, writeCount);
             assertEquals(testData.length, c.position());
             assertArrayEquals(testData, Arrays.copyOf(c.array(), (int) 
c.position()));
         }
     }
-
     // 
https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#position()
 
     @Test
     void testShouldWriteDataProperlyAfterPositionSet() throws IOException {
-        // given
         try (SeekableInMemoryByteChannel c = new 
SeekableInMemoryByteChannel(testData)) {
             final ByteBuffer inData = ByteBuffer.wrap(testData);
             final ByteBuffer expectedData = 
ByteBuffer.allocate(testData.length + 5).put(testData, 0, 5).put(testData);
-            // when
             c.position(5L);
             final int writeCount = c.write(inData);
-
-            // then
             assertEquals(testData.length, writeCount);
             assertArrayEquals(expectedData.array(), Arrays.copyOf(c.array(), 
(int) c.size()));
             assertEquals(testData.length + 5, c.position());
         }
     }
-
     // 
https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#size()
 
     /*
@@ -251,7 +212,6 @@ void 
testThrowsClosedChannelExceptionWhenPositionIsSetOnClosedChannel() throws E
             assertThrows(ClosedChannelException.class, () -> c.position(0));
         }
     }
-
     // 
https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#position(long)
 
     /*
@@ -299,7 +259,6 @@ void 
testTruncateMovesPositionWhenNewSizeIsBiggerThanSizeAndPositionIsEvenBigger
             assertEquals(testData.length + 1, c.position());
         }
     }
-
     // 
https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#truncate(long)
 
     /*
@@ -403,12 +362,10 @@ public void writingToAPositionAfterEndGrowsChannel() 
throws Exception {
             final ByteBuffer inData = ByteBuffer.wrap(testData);
             assertEquals(testData.length, c.write(inData));
             assertEquals(testData.length + 2, c.size());
-
             c.position(2);
             final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length);
             c.read(readBuffer);
             assertArrayEquals(testData, Arrays.copyOf(readBuffer.array(), 
testData.length));
         }
     }
-
 }

Reply via email to