mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Moved test from RecordIOWriterTest to RecordIOReaderTest
Moved testReadWhileWriteAcrossBoundary to RecordIOReader as it verifies a fix in the RecordIOReader class Fixes #8024
This commit is contained in:
parent
9f64fccef9
commit
f08a628b5c
2 changed files with 21 additions and 22 deletions
|
@ -152,6 +152,27 @@ public class RecordIOReaderTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWhileWriteAcrossBoundary() throws Exception {
|
||||
char[] tooBig = fillArray( BLOCK_SIZE/4);
|
||||
StringElement input = new StringElement(new String(tooBig));
|
||||
byte[] inputSerialized = input.serialize();
|
||||
try(RecordIOWriter writer = new RecordIOWriter(file);
|
||||
RecordIOReader reader = new RecordIOReader(file)){
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
writer.writeEvent(inputSerialized);
|
||||
}
|
||||
assertThat(reader.readEvent(), equalTo(inputSerialized));
|
||||
for (int j = 0; j < 2; j++) {
|
||||
writer.writeEvent(inputSerialized);
|
||||
}
|
||||
for (int j = 0; j < 3; j++) {
|
||||
assertThat(reader.readEvent(), equalTo(inputSerialized));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private char[] fillArray(final int fillSize) {
|
||||
char[] blockSize= new char[fillSize];
|
||||
Arrays.fill(blockSize, 'e');
|
||||
|
|
|
@ -99,28 +99,6 @@ public class RecordIOWriterTest {
|
|||
reader.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWhileWriteAcrossBoundary() throws Exception {
|
||||
char[] tooBig = fillArray( BLOCK_SIZE/4);
|
||||
StringElement input = new StringElement(new String(tooBig));
|
||||
byte[] inputSerialized = input.serialize();
|
||||
try(RecordIOWriter writer = new RecordIOWriter(file);
|
||||
RecordIOReader reader = new RecordIOReader(file)){
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
writer.writeEvent(inputSerialized);
|
||||
}
|
||||
assertThat(reader.readEvent(), equalTo(inputSerialized));
|
||||
for (int j = 0; j < 2; j++) {
|
||||
writer.writeEvent(inputSerialized);
|
||||
}
|
||||
for (int j = 0; j < 3; j++) {
|
||||
assertThat(reader.readEvent(), equalTo(inputSerialized));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private char[] fillArray(final int fillSize) {
|
||||
char[] blockSize= new char[fillSize];
|
||||
Arrays.fill(blockSize, 'e');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue