CORDA-540: AMQP specific fixes in "node-api" project (#1765)

This commit is contained in:
Viktor Kolomeyko
2017-10-03 15:07:34 +01:00
committed by GitHub
parent e6e3c29d74
commit e2bb14da8e
7 changed files with 19 additions and 17 deletions

View File

@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException
val attachmentsClassLoaderEnabledPropertyName = "attachments.class.loader.enabled"
object NotSupportedSeralizationScheme : SerializationScheme {
object NotSupportedSerializationScheme : SerializationScheme {
private fun doThrow(): Nothing = throw UnsupportedOperationException("Serialization scheme not supported.")
override fun canDeserializeVersion(byteSequence: ByteSequence, target: SerializationContext.UseCase): Boolean = doThrow()
@ -107,7 +107,7 @@ open class SerializationFactoryImpl : SerializationFactory() {
registeredSchemes
.filter { scheme -> scheme.canDeserializeVersion(it.first, it.second) }
.forEach { return@computeIfAbsent it }
NotSupportedSeralizationScheme
NotSupportedSerializationScheme
}
}

View File

@ -5,7 +5,6 @@ import com.nhaarman.mockito_kotlin.whenever
import net.corda.core.contracts.*
import net.corda.core.crypto.SecureHash
import net.corda.core.internal.declaredField
import net.corda.core.internal.toLedgerTransaction
import net.corda.core.internal.toWireTransaction
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.AttachmentStorage
@ -302,7 +301,7 @@ class AttachmentsClassLoaderTests : TestDependencyInjectionBase() {
@Test
fun `test deserialize of WireTransaction where contract cannot be found`() {
kryoSpecific<AttachmentsClassLoaderTests>("Kryo verifies/loads attachments on deserialization, whereas AMQP currently does not") {
kryoSpecific("Kryo verifies/loads attachments on deserialization, whereas AMQP currently does not") {
ClassLoaderForTests().use { child ->
val contractClass = Class.forName(ISOLATED_CONTRACT_CLASS_NAME, true, child)
val contract = contractClass.newInstance() as DummyContractBackdoor

View File

@ -23,7 +23,7 @@ class ListsSerializationTest : TestDependencyInjectionBase() {
val javaEmptyListClass = Collections.emptyList<Any>().javaClass
fun<T : Any> verifyEnvelope(serBytes: SerializedBytes<T>, envVerBody: (Envelope) -> Unit) =
amqpSpecific<ListsSerializationTest>("AMQP specific envelope verification") {
amqpSpecific("AMQP specific envelope verification") {
val context = SerializationFactory.defaultFactory.defaultContext
val envelope = DeserializationInput(SerializerFactory(context.whitelist, context.deserializationClassLoader)).getEnvelope(serBytes)
envVerBody(envelope)
@ -54,7 +54,7 @@ class ListsSerializationTest : TestDependencyInjectionBase() {
}
@Test
fun `check empty list serialises as Java emptyList`() = kryoSpecific<ListsSerializationTest>("Kryo specific test"){
fun `check empty list serialises as Java emptyList`() = kryoSpecific("Kryo specific test"){
val nameID = 0
val serializedForm = emptyList<Int>().serialize()
val output = ByteArrayOutputStream().apply {
@ -71,7 +71,7 @@ class ListsSerializationTest : TestDependencyInjectionBase() {
data class WrongPayloadType(val payload: ArrayList<Int>)
@Test
fun `check throws for forbidden declared type`() = amqpSpecific<ListsSerializationTest>("Such exceptions are not expected in Kryo mode.") {
fun `check throws for forbidden declared type`() = amqpSpecific("Such exceptions are not expected in Kryo mode.") {
val payload = ArrayList<Int>()
payload.add(1)
payload.add(2)

View File

@ -22,7 +22,7 @@ class MapsSerializationTest : TestDependencyInjectionBase() {
}
@Test
fun `check EmptyMap serialization`() = amqpSpecific<MapsSerializationTest>("kotlin.collections.EmptyMap is not enabled for Kryo serialization") {
fun `check EmptyMap serialization`() = amqpSpecific("kotlin.collections.EmptyMap is not enabled for Kryo serialization") {
assertEqualAfterRoundTripSerialization(emptyMap<Any, Any>())
}
@ -41,7 +41,7 @@ class MapsSerializationTest : TestDependencyInjectionBase() {
data class WrongPayloadType(val payload: HashMap<String, String>)
@Test
fun `check throws for forbidden declared type`() = amqpSpecific<ListsSerializationTest>("Such exceptions are not expected in Kryo mode.") {
fun `check throws for forbidden declared type`() = amqpSpecific("Such exceptions are not expected in Kryo mode.") {
val payload = HashMap<String, String>(smallMap)
val wrongPayloadType = WrongPayloadType(payload)
Assertions.assertThatThrownBy { wrongPayloadType.serialize() }
@ -64,7 +64,7 @@ class MapsSerializationTest : TestDependencyInjectionBase() {
}
@Test
fun `check empty map serialises as Java emptyMap`() = kryoSpecific<MapsSerializationTest>("Specifically checks Kryo serialization") {
fun `check empty map serialises as Java emptyMap`() = kryoSpecific("Specifically checks Kryo serialization") {
val nameID = 0
val serializedForm = emptyMap<Int, Int>().serialize()
val output = ByteArrayOutputStream().apply {

View File

@ -5,6 +5,7 @@ import com.esotericsoftware.kryo.util.DefaultClassResolver
import net.corda.core.serialization.serialize
import net.corda.node.services.statemachine.SessionData
import net.corda.testing.TestDependencyInjectionBase
import net.corda.testing.kryoSpecific
import org.junit.Assert.*
import org.junit.Test
import java.io.ByteArrayOutputStream
@ -39,7 +40,7 @@ class SetsSerializationTest : TestDependencyInjectionBase() {
}
@Test
fun `check empty set serialises as Java emptySet`() {
fun `check empty set serialises as Java emptySet`() = kryoSpecific("Checks Kryo header properties") {
val nameID = 0
val serializedForm = emptySet<Int>().serialize()
val output = ByteArrayOutputStream().apply {