Test truncated library snapshot headers
This commit is contained in:
@@ -20,6 +20,7 @@ package org.oxycblt.musikr.snapshot
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.EOFException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertThrows
|
import org.junit.Assert.assertThrows
|
||||||
@@ -60,4 +61,16 @@ class LibrarySnapshotCodecTest {
|
|||||||
LibrarySnapshotCodec.readHeader(ByteArrayInputStream(bytes))
|
LibrarySnapshotCodec.readHeader(ByteArrayInputStream(bytes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun readHeader_truncatedSchemaVersion_throwsEOFException() {
|
||||||
|
val output = ByteArrayOutputStream()
|
||||||
|
LibrarySnapshotCodec.writeHeader(output)
|
||||||
|
val bytes = output.toByteArray()
|
||||||
|
val truncated = bytes.copyOf(bytes.size - 1)
|
||||||
|
|
||||||
|
assertThrows(EOFException::class.java) {
|
||||||
|
LibrarySnapshotCodec.readHeader(ByteArrayInputStream(truncated))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user