mirror of
https://github.com/corda/corda.git
synced 2025-06-23 01:19:00 +00:00
ENT-3440 Allow custom serializers that extend CordaThrowable.
This commit is contained in:
@ -1,14 +1,13 @@
|
||||
package net.corda.serialization.internal.amqp
|
||||
|
||||
import net.corda.core.CordaException
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
import net.corda.finance.contracts.asset.Cash
|
||||
import org.apache.qpid.proton.amqp.Symbol
|
||||
import org.apache.qpid.proton.codec.Data
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.lang.reflect.Type
|
||||
import java.math.BigDecimal
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertSame
|
||||
|
||||
@ -56,6 +55,19 @@ class CustomSerializerRegistryTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exception types can have custom serializers`() {
|
||||
@CordaSerializable
|
||||
class MyCustomException : CordaException("Custom exception annotated with @CordaSerializable")
|
||||
|
||||
val customExceptionSerializer = TestCustomSerializer("a") { type -> type == MyCustomException::class.java }
|
||||
unit.register(customExceptionSerializer)
|
||||
|
||||
assertSame(
|
||||
customExceptionSerializer,
|
||||
unit.find(MyCustomException::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `two custom serializers cannot register to serialize the same type`() {
|
||||
val weSerializeCash = TestCustomSerializer("a") { type -> type == Cash::class.java }
|
||||
|
Reference in New Issue
Block a user