Skip to content
Permalink
Browse files
Fix broken tests.
  • Loading branch information
garydgregory committed May 5, 2022
1 parent 33f57cf commit 47043448a42634b2f85b0ff0543a225b64fb0884
Showing 1 changed file with 8 additions and 7 deletions.
@@ -31,6 +31,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;

public class SeekableInMemoryByteChannelTest {

@@ -100,7 +101,7 @@ public void shouldThrowExceptionOnReadingClosedChannel() throws IOException {
final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel();
//when
c.close();
c.read(ByteBuffer.allocate(1));
assertThrows(ClosedChannelException.class, () -> c.read(ByteBuffer.allocate(1)));
}

@Test
@@ -141,7 +142,7 @@ public void shouldThrowExceptionOnWritingToClosedChannel() throws IOException {
final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel();
//when
c.close();
c.write(ByteBuffer.allocate(1));
assertThrows(ClosedChannelException.class, () -> c.write(ByteBuffer.allocate(1)));
}

@Test
@@ -189,7 +190,7 @@ public void shouldThrowExceptionWhenSettingIncorrectPosition() throws IOExceptio
//given
final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel();
//when
c.position(Integer.MAX_VALUE + 1L);
assertThrows(IOException.class, () -> c.position(Integer.MAX_VALUE + 1L));
c.close();
}

@@ -198,7 +199,7 @@ public void shouldThrowExceptionWhenTruncatingToIncorrectSize() {
//given
final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel();
//when
c.truncate(Integer.MAX_VALUE + 1L);
assertThrows(IllegalArgumentException.class, () -> c.truncate(Integer.MAX_VALUE + 1L));
c.close();
}

@@ -256,7 +257,7 @@ public void throwsClosedChannelExceptionWhenSizeIsReadOnClosedChannel() throws E
public void throwsClosedChannelExceptionWhenPositionIsSetOnClosedChannel() throws Exception {
try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) {
c.close();
c.position(0);
assertThrows(ClosedChannelException.class, () -> c.position(0));
}
}

@@ -302,7 +303,7 @@ public void writingToAPositionAfterEndGrowsChannel() throws Exception {
@Test
public void throwsIOExceptionWhenPositionIsSetToANegativeValue() throws Exception {
try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) {
c.position(-1);
assertThrows(IOException.class, () -> c.position(-1));
}
}

@@ -396,7 +397,7 @@ public void truncateMovesPositionWhenNewSizeIsBiggerThanSizeAndPositionIsEvenBig
@Test
public void throwsIllegalArgumentExceptionWhenTruncatingToANegativeSize() throws Exception {
try (SeekableByteChannel c = new SeekableInMemoryByteChannel()) {
c.truncate(-1);
assertThrows(IllegalArgumentException.class, () -> c.truncate(-1));
}
}

0 comments on commit 4704344

Please sign in to comment.