diff options
author | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-06-28 14:42:05 +0200 |
---|---|---|
committer | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-08-02 11:04:01 +0200 |
commit | 03702b48989174dc8afa855e663a28e34b4da67b (patch) | |
tree | e89a4930aab1a53014b81e76be493dda41d9e007 /hv-collector-core/src/test/kotlin | |
parent | cf1465f37d20391a921df449d5dd01454f64910c (diff) |
Use Either instead of exceptions in frame decoder
Goals:
* Make code cleaner (in a FP way)
* Avoid costly exception throw each time we wait for the rest of the
frame (collecting stack traces is costly and we do not need them
anyway)
Closes ONAP-437
Change-Id: I40341d3c2cb85f3ff581d89167245cb009dbb070
Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-core/src/test/kotlin')
-rw-r--r-- | hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt index 1ddcc3dc..33f71684 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt @@ -30,7 +30,6 @@ import org.jetbrains.spek.api.dsl.it import org.onap.dcae.collectors.veshv.domain.WireFrame import org.onap.dcae.collectors.veshv.domain.WireFrameDecoder import org.onap.dcae.collectors.veshv.domain.WireFrameEncoder -import org.onap.dcae.collectors.veshv.domain.exceptions.InvalidWireFrameMarkerException import reactor.test.test /** @@ -43,11 +42,11 @@ internal object WireChunkDecoderTest : Spek({ val anotherPayload = "ala ma kota a kot ma ale".toByteArray() val encoder = WireFrameEncoder(alloc) - + fun WireChunkDecoder.decode(frame: WireFrame) = decode(encoder.encode(frame)) fun createInstance() = WireChunkDecoder(WireFrameDecoder(), alloc) - + fun verifyMemoryReleased(vararg byteBuffers: ByteBuf) { for (bb in byteBuffers) { assertThat(bb.refCnt()) @@ -90,7 +89,7 @@ internal object WireChunkDecoderTest : Spek({ it("should yield error") { createInstance().decode(input).test() - .verifyError(InvalidWireFrameMarkerException::class.java) + .verifyError(WireFrameException::class.java) } it("should leave memory unreleased") { @@ -132,7 +131,7 @@ internal object WireChunkDecoderTest : Spek({ it("should yield decoded input frame and error") { createInstance().decode(input).test() .expectNextMatches { it.payloadSize == samplePayload.size } - .verifyError(InvalidWireFrameMarkerException::class.java) + .verifyError(WireFrameException::class.java) } it("should leave memory unreleased") { @@ -170,7 +169,7 @@ internal object WireChunkDecoderTest : Spek({ .expectNextMatches { it.payloadSize == samplePayload.size } .verifyComplete() cut.decode(input2).test() - .verifyError(InvalidWireFrameMarkerException::class.java) + .verifyError(WireFrameException::class.java) } it("should release memory for 1st input") { |