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
commit e2b2b08c83009332f6621c33c0562593565394e3 Author: Gary Gregory <[email protected]> AuthorDate: Mon Dec 8 13:04:30 2025 -0500 Simpler test method names --- .../utils/SeekableInMemoryByteChannelTest.java | 94 +++++++++++----------- 1 file changed, 47 insertions(+), 47 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 8ca895a7d..37342fec3 100644 --- a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java +++ b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java @@ -70,7 +70,7 @@ void testReadingFromAPositionAfterEndReturnsEOF(final int size) throws Exception } @Test - void testShouldReadContentsProperly() throws IOException { + void testReadContentsProperly() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length); final int readCount = c.read(readBuffer); @@ -81,7 +81,7 @@ void testShouldReadContentsProperly() throws IOException { } @Test - void testShouldReadContentsWhenBiggerBufferSupplied() throws IOException { + void testReadContentsWhenBiggerBufferSupplied() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length + 1); final int readCount = c.read(readBuffer); @@ -92,7 +92,7 @@ void testShouldReadContentsWhenBiggerBufferSupplied() throws IOException { } @Test - void testShouldReadDataFromSetPosition() throws IOException { + void testReadDataFromSetPosition() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { final ByteBuffer readBuffer = ByteBuffer.allocate(4); c.position(5L); @@ -104,7 +104,7 @@ void testShouldReadDataFromSetPosition() throws IOException { } @Test - void testShouldSetProperPosition() throws IOException { + void testSetProperPosition() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { final long posAtFour = c.position(4L).position(); final long posAtTheEnd = c.position(testData.length).position(); @@ -116,7 +116,7 @@ void testShouldSetProperPosition() throws IOException { } @Test - void testShouldSetProperPositionOnTruncate() throws IOException { + void testSetProperPositionOnTruncate() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { c.position(testData.length); c.truncate(4L); @@ -126,7 +126,7 @@ void testShouldSetProperPositionOnTruncate() throws IOException { } @Test - void testShouldSignalEOFWhenPositionAtTheEnd() throws IOException { + void testSignalEOFWhenPositionAtTheEnd() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { final ByteBuffer readBuffer = ByteBuffer.allocate(testData.length); c.position(testData.length + 1); @@ -138,21 +138,21 @@ void testShouldSignalEOFWhenPositionAtTheEnd() throws IOException { } @Test - void testShouldThrowExceptionOnReadingClosedChannel() { + void testThrowExceptionOnReadingClosedChannel() { final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(); c.close(); assertThrows(ClosedChannelException.class, () -> c.read(ByteBuffer.allocate(1))); } @Test - void testShouldThrowExceptionOnWritingToClosedChannel() { + void testThrowExceptionOnWritingToClosedChannel() { final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(); c.close(); assertThrows(ClosedChannelException.class, () -> c.write(ByteBuffer.allocate(1))); } @Test - void testShouldThrowWhenSettingIncorrectPosition() throws IOException { + void testThrowWhenSettingIncorrectPosition() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel()) { final ByteBuffer buffer = ByteBuffer.allocate(1); c.position(c.size() + 1); @@ -169,7 +169,7 @@ void testShouldThrowWhenSettingIncorrectPosition() throws IOException { } @Test - void testShouldThrowWhenTruncatingToIncorrectSize() throws IOException { + void testThrowWhenTruncatingToIncorrectSize() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel()) { final ByteBuffer buffer = ByteBuffer.allocate(1); c.truncate(c.size() + 1); @@ -183,7 +183,7 @@ void testShouldThrowWhenTruncatingToIncorrectSize() throws IOException { } @Test - void testShouldTruncateContentsProperly() throws ClosedChannelException { + void testTruncateContentsProperly() throws ClosedChannelException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData)) { c.truncate(4); final byte[] bytes = Arrays.copyOf(c.array(), (int) c.size()); @@ -194,7 +194,7 @@ void testShouldTruncateContentsProperly() throws ClosedChannelException { // https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html#close() @Test - void testShouldWriteDataProperly() throws IOException { + void testWriteDataProperly() throws IOException { try (SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel()) { final ByteBuffer inData = ByteBuffer.wrap(testData); final int writeCount = c.write(inData); @@ -206,7 +206,7 @@ void testShouldWriteDataProperly() throws IOException { // https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#position() @Test - void testShouldWriteDataProperlyAfterPositionSet() throws IOException { + void testWriteDataProperlyAfterPositionSet() throws IOException { 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); @@ -219,6 +219,17 @@ void testShouldWriteDataProperlyAfterPositionSet() throws IOException { } // https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#size() + /* + * <q>ClosedChannelException - If this channel is closed</q> + */ + @Test + void testThrowsClosedChannelExceptionWhenPositionIsReadOnClosedChannel() throws Exception { + try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { + c.close(); + assertThrows(ClosedChannelException.class, c::position); + } + } + /* * <q>ClosedChannelException - If this channel is closed</q> */ @@ -231,6 +242,28 @@ void testThrowsClosedChannelExceptionWhenPositionIsSetOnClosedChannel() throws E } // https://docs.oracle.com/javase/8/docs/api/java/nio/channels/SeekableByteChannel.html#position(long) + /* + * <q>ClosedChannelException - If this channel is closed</q> + */ + @Test + void testThrowsClosedChannelExceptionWhenSizeIsReadOnClosedChannel() throws Exception { + try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { + c.close(); + assertThrows(ClosedChannelException.class, c::size); + } + } + + /* + * <q>ClosedChannelException - If this channel is closed</q> + */ + @Test + void testThrowsClosedChannelExceptionWhenTruncateIsCalledOnClosedChannel() throws Exception { + try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { + c.close(); + assertThrows(ClosedChannelException.class, () -> c.truncate(0)); + } + } + /* * <q>IllegalArgumentException - If the new position is negative</q> */ @@ -334,46 +367,13 @@ void testTruncateToCurrentSizeDoesntChangeAnything() throws Exception { } } - /* - * <q>ClosedChannelException - If this channel is closed</q> - */ - @Test - void throwsClosedChannelExceptionWhenPositionIsReadOnClosedChannel() throws Exception { - try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { - c.close(); - assertThrows(ClosedChannelException.class, c::position); - } - } - - /* - * <q>ClosedChannelException - If this channel is closed</q> - */ - @Test - void throwsClosedChannelExceptionWhenSizeIsReadOnClosedChannel() throws Exception { - try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { - c.close(); - assertThrows(ClosedChannelException.class, c::size); - } - } - - /* - * <q>ClosedChannelException - If this channel is closed</q> - */ - @Test - void throwsClosedChannelExceptionWhenTruncateIsCalledOnClosedChannel() throws Exception { - try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { - c.close(); - assertThrows(ClosedChannelException.class, () -> c.truncate(0)); - } - } - /* * <q>Setting the position to a value that is greater than the current size is legal but does not change the size of the entity. A later attempt to write * bytes at such a position will cause the entity to grow to accommodate the new bytes; the values of any bytes between the previous end-of-file and the * newly-written bytes are unspecified.</q> */ @Test - void writingToAPositionAfterEndGrowsChannel() throws Exception { + void testWritingToAPositionAfterEndGrowsChannel() throws Exception { try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) { c.position(2); assertEquals(2, c.position());
