mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
Reformat files in node-api
This commit is contained in:
parent
cb9e27a84a
commit
f98942d7ad
@ -1,4 +1,5 @@
|
|||||||
@file:JvmName("ConfigUtilities")
|
@file:JvmName("ConfigUtilities")
|
||||||
|
|
||||||
package net.corda.nodeapi.config
|
package net.corda.nodeapi.config
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@file:JvmName("ClientContexts")
|
@file:JvmName("ClientContexts")
|
||||||
|
|
||||||
package net.corda.nodeapi.internal.serialization
|
package net.corda.nodeapi.internal.serialization
|
||||||
|
|
||||||
import net.corda.core.serialization.SerializationContext
|
import net.corda.core.serialization.SerializationContext
|
||||||
|
@ -140,6 +140,7 @@ object DefaultKryoCustomizer {
|
|||||||
// Use this to allow construction of objects using a JVM backdoor that skips invoking the constructors, if there
|
// Use this to allow construction of objects using a JVM backdoor that skips invoking the constructors, if there
|
||||||
// is no no-arg constructor available.
|
// is no no-arg constructor available.
|
||||||
private val defaultStrategy = Kryo.DefaultInstantiatorStrategy(fallbackStrategy)
|
private val defaultStrategy = Kryo.DefaultInstantiatorStrategy(fallbackStrategy)
|
||||||
|
|
||||||
override fun <T> newInstantiatorOf(type: Class<T>): ObjectInstantiator<T> {
|
override fun <T> newInstantiatorOf(type: Class<T>): ObjectInstantiator<T> {
|
||||||
// However this doesn't work for non-public classes in the java. namespace
|
// However this doesn't work for non-public classes in the java. namespace
|
||||||
val strat = if (type.name.startsWith("java.") && !isPublic(type.modifiers)) fallbackStrategy else defaultStrategy
|
val strat = if (type.name.startsWith("java.") && !isPublic(type.modifiers)) fallbackStrategy else defaultStrategy
|
||||||
@ -151,6 +152,7 @@ object DefaultKryoCustomizer {
|
|||||||
override fun write(kryo: Kryo, output: Output, obj: PartyAndCertificate) {
|
override fun write(kryo: Kryo, output: Output, obj: PartyAndCertificate) {
|
||||||
kryo.writeClassAndObject(output, obj.certPath)
|
kryo.writeClassAndObject(output, obj.certPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun read(kryo: Kryo, input: Input, type: Class<PartyAndCertificate>): PartyAndCertificate {
|
override fun read(kryo: Kryo, input: Input, type: Class<PartyAndCertificate>): PartyAndCertificate {
|
||||||
return PartyAndCertificate(kryo.readClassAndObject(input) as CertPath)
|
return PartyAndCertificate(kryo.readClassAndObject(input) as CertPath)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@file:JvmName("ServerContexts")
|
@file:JvmName("ServerContexts")
|
||||||
|
|
||||||
package net.corda.nodeapi.internal.serialization
|
package net.corda.nodeapi.internal.serialization
|
||||||
|
|
||||||
import net.corda.core.serialization.ClassWhitelist
|
import net.corda.core.serialization.ClassWhitelist
|
||||||
|
@ -26,8 +26,7 @@ open class ArraySerializer(override val type: Type, factory: SerializerFactory)
|
|||||||
private fun calcTypeName(type: Type): String =
|
private fun calcTypeName(type: Type): String =
|
||||||
if (type.componentType().isArray()) {
|
if (type.componentType().isArray()) {
|
||||||
val typeName = calcTypeName(type.componentType()); "$typeName[]"
|
val typeName = calcTypeName(type.componentType()); "$typeName[]"
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val arrayType = if (type.asClass()!!.componentType.isPrimitive) "[p]" else "[]"
|
val arrayType = if (type.asClass()!!.componentType.isPrimitive) "[p]" else "[]"
|
||||||
"${type.componentType().typeName}$arrayType"
|
"${type.componentType().typeName}$arrayType"
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ class CollectionSerializer(val declaredType: ParameterizedType, factory: Seriali
|
|||||||
if (supportedTypes.containsKey(declaredClass)) {
|
if (supportedTypes.containsKey(declaredClass)) {
|
||||||
// Simple case - it is already known to be a collection.
|
// Simple case - it is already known to be a collection.
|
||||||
return deriveParametrizedType(declaredType, uncheckedCast(declaredClass))
|
return deriveParametrizedType(declaredType, uncheckedCast(declaredClass))
|
||||||
}
|
} else if (actualClass != null && Collection::class.java.isAssignableFrom(actualClass)) {
|
||||||
else if (actualClass != null && Collection::class.java.isAssignableFrom(actualClass)) {
|
|
||||||
// Declared class is not collection, but [actualClass] is - represent it accordingly.
|
// Declared class is not collection, but [actualClass] is - represent it accordingly.
|
||||||
val collectionClass = findMostSuitableCollectionType(actualClass)
|
val collectionClass = findMostSuitableCollectionType(actualClass)
|
||||||
return deriveParametrizedType(declaredType, collectionClass)
|
return deriveParametrizedType(declaredType, collectionClass)
|
||||||
|
@ -151,8 +151,7 @@ abstract class CustomSerializer<T : Any> : AMQPSerializer<T> {
|
|||||||
* @param unmake A lambda that extracts the string value for an instance, that defaults to the [toString] method.
|
* @param unmake A lambda that extracts the string value for an instance, that defaults to the [toString] method.
|
||||||
*/
|
*/
|
||||||
abstract class ToString<T : Any>(clazz: Class<T>, withInheritance: Boolean = false,
|
abstract class ToString<T : Any>(clazz: Class<T>, withInheritance: Boolean = false,
|
||||||
private val maker: (String) -> T = clazz.getConstructor(String::class.java).let {
|
private val maker: (String) -> T = clazz.getConstructor(String::class.java).let { `constructor` ->
|
||||||
`constructor` ->
|
|
||||||
{ string -> `constructor`.newInstance(string) }
|
{ string -> `constructor`.newInstance(string) }
|
||||||
},
|
},
|
||||||
private val unmaker: (T) -> String = { obj -> obj.toString() })
|
private val unmaker: (T) -> String = { obj -> obj.toString() })
|
||||||
|
@ -45,8 +45,7 @@ class MapSerializer(private val declaredType: ParameterizedType, factory: Serial
|
|||||||
if (supportedTypes.containsKey(declaredClass)) {
|
if (supportedTypes.containsKey(declaredClass)) {
|
||||||
// Simple case - it is already known to be a map.
|
// Simple case - it is already known to be a map.
|
||||||
return deriveParametrizedType(declaredType, uncheckedCast(declaredClass))
|
return deriveParametrizedType(declaredType, uncheckedCast(declaredClass))
|
||||||
}
|
} else if (actualClass != null && Map::class.java.isAssignableFrom(actualClass)) {
|
||||||
else if (actualClass != null && Map::class.java.isAssignableFrom(actualClass)) {
|
|
||||||
// Declared class is not map, but [actualClass] is - represent it accordingly.
|
// Declared class is not map, but [actualClass] is - represent it accordingly.
|
||||||
val mapClass = findMostSuitableMapType(actualClass)
|
val mapClass = findMostSuitableMapType(actualClass)
|
||||||
return deriveParametrizedType(declaredType, mapClass)
|
return deriveParametrizedType(declaredType, mapClass)
|
||||||
@ -108,12 +107,10 @@ internal fun Class<*>.checkSupportedMapType() {
|
|||||||
if (HashMap::class.java.isAssignableFrom(this) && !LinkedHashMap::class.java.isAssignableFrom(this)) {
|
if (HashMap::class.java.isAssignableFrom(this) && !LinkedHashMap::class.java.isAssignableFrom(this)) {
|
||||||
throw IllegalArgumentException(
|
throw IllegalArgumentException(
|
||||||
"Map type $this is unstable under iteration. Suggested fix: use java.util.LinkedHashMap instead.")
|
"Map type $this is unstable under iteration. Suggested fix: use java.util.LinkedHashMap instead.")
|
||||||
}
|
} else if (WeakHashMap::class.java.isAssignableFrom(this)) {
|
||||||
else if (WeakHashMap::class.java.isAssignableFrom(this)) {
|
|
||||||
throw IllegalArgumentException("Weak references with map types not supported. Suggested fix: "
|
throw IllegalArgumentException("Weak references with map types not supported. Suggested fix: "
|
||||||
+ "use java.util.LinkedHashMap instead.")
|
+ "use java.util.LinkedHashMap instead.")
|
||||||
}
|
} else if (Dictionary::class.java.isAssignableFrom(this)) {
|
||||||
else if (Dictionary::class.java.isAssignableFrom(this)) {
|
|
||||||
throw IllegalArgumentException(
|
throw IllegalArgumentException(
|
||||||
"Unable to serialise deprecated type $this. Suggested fix: prefer java.util.map implementations")
|
"Unable to serialise deprecated type $this. Suggested fix: prefer java.util.map implementations")
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,7 @@ open class SerializationOutput(internal val serializerFactory: SerializerFactory
|
|||||||
// assigned to them first as they will be first read from the stream on receiving end.
|
// assigned to them first as they will be first read from the stream on receiving end.
|
||||||
// Skip for primitive types as they are too small and overhead of referencing them will be much higher than their content
|
// Skip for primitive types as they are too small and overhead of referencing them will be much higher than their content
|
||||||
if (suitableForObjectReference(obj.javaClass)) objectHistory.put(obj, objectHistory.size)
|
if (suitableForObjectReference(obj.javaClass)) objectHistory.put(obj, objectHistory.size)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
data.writeReferencedObject(ReferencedObject(retrievedRefCount))
|
data.writeReferencedObject(ReferencedObject(retrievedRefCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@ class ZonedDateTimeSerializer(factory: SerializerFactory) : CustomSerializer.Pro
|
|||||||
// so that any change to internals of `ZonedDateTime` is detected early.
|
// so that any change to internals of `ZonedDateTime` is detected early.
|
||||||
companion object {
|
companion object {
|
||||||
val ofLenient = ZonedDateTime::class.java.getDeclaredMethod("ofLenient", LocalDateTime::class.java, ZoneOffset::class.java, ZoneId::class.java)
|
val ofLenient = ZonedDateTime::class.java.getDeclaredMethod("ofLenient", LocalDateTime::class.java, ZoneOffset::class.java, ZoneId::class.java)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ofLenient.isAccessible = true
|
ofLenient.isAccessible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val additionalSerializers: Iterable<CustomSerializer<out Any>> = listOf(LocalDateTimeSerializer(factory), ZoneIdSerializer(factory))
|
override val additionalSerializers: Iterable<CustomSerializer<out Any>> = listOf(LocalDateTimeSerializer(factory), ZoneIdSerializer(factory))
|
||||||
|
|
||||||
override fun toProxy(obj: ZonedDateTime): ZonedDateTimeProxy = ZonedDateTimeProxy(obj.toLocalDateTime(), obj.offset, obj.zone)
|
override fun toProxy(obj: ZonedDateTime): ZonedDateTimeProxy = ZonedDateTimeProxy(obj.toLocalDateTime(), obj.offset, obj.zone)
|
||||||
|
@ -132,5 +132,10 @@ fun AMQPField.validateType(classloader: ClassLoader) = when (type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ClassLoader.exists(clazz: String) = run {
|
private fun ClassLoader.exists(clazz: String) = run {
|
||||||
try { this.loadClass(clazz); true } catch (e: ClassNotFoundException) { false } }
|
try {
|
||||||
|
this.loadClass(clazz); true
|
||||||
|
} catch (e: ClassNotFoundException) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ import java.util.List;
|
|||||||
public class ListsSerializationJavaTest {
|
public class ListsSerializationJavaTest {
|
||||||
|
|
||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
interface Parent {}
|
interface Parent {
|
||||||
|
}
|
||||||
|
|
||||||
public static class Child implements Parent {
|
public static class Child implements Parent {
|
||||||
private final int value;
|
private final int value;
|
||||||
|
@ -45,6 +45,7 @@ class AttachmentsClassLoaderTests : TestDependencyInjectionBase() {
|
|||||||
whenever(serviceHub.attachments).thenReturn(attachmentStorage)
|
whenever(serviceHub.attachments).thenReturn(attachmentStorage)
|
||||||
return this.withServiceHub(serviceHub)
|
return this.withServiceHub(serviceHub)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SerializationContext.withServiceHub(serviceHub: ServiceHub): SerializationContext {
|
private fun SerializationContext.withServiceHub(serviceHub: ServiceHub): SerializationContext {
|
||||||
return this.withTokenContext(SerializeAsTokenContextImpl(serviceHub) {}).withProperty(attachmentsClassLoaderEnabledPropertyName, true)
|
return this.withTokenContext(SerializeAsTokenContextImpl(serviceHub) {}).withProperty(attachmentsClassLoaderEnabledPropertyName, true)
|
||||||
}
|
}
|
||||||
|
@ -271,6 +271,7 @@ class CordaClassResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open class SubHashSet<E> : HashSet<E>()
|
open class SubHashSet<E> : HashSet<E>()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Check blacklisted subclass`() {
|
fun `Check blacklisted subclass`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
expectedEx.expect(IllegalStateException::class.java)
|
||||||
@ -281,6 +282,7 @@ class CordaClassResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SubSubHashSet<E> : SubHashSet<E>()
|
class SubSubHashSet<E> : SubHashSet<E>()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Check blacklisted subsubclass`() {
|
fun `Check blacklisted subsubclass`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
expectedEx.expect(IllegalStateException::class.java)
|
||||||
@ -291,6 +293,7 @@ class CordaClassResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionImpl(private val connection: Connection) : Connection by connection
|
class ConnectionImpl(private val connection: Connection) : Connection by connection
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Check blacklisted interface impl`() {
|
fun `Check blacklisted interface impl`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
expectedEx.expect(IllegalStateException::class.java)
|
||||||
@ -302,6 +305,7 @@ class CordaClassResolverTests {
|
|||||||
|
|
||||||
interface SubConnection : Connection
|
interface SubConnection : Connection
|
||||||
class SubConnectionImpl(private val subConnection: SubConnection) : SubConnection by subConnection
|
class SubConnectionImpl(private val subConnection: SubConnection) : SubConnection by subConnection
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Check blacklisted super-interface impl`() {
|
fun `Check blacklisted super-interface impl`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
expectedEx.expect(IllegalStateException::class.java)
|
||||||
@ -320,6 +324,7 @@ class CordaClassResolverTests {
|
|||||||
|
|
||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
class CordaSerializableHashSet<E> : HashSet<E>()
|
class CordaSerializableHashSet<E> : HashSet<E>()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Check blacklist precedes CordaSerializable`() {
|
fun `Check blacklist precedes CordaSerializable`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
expectedEx.expect(IllegalStateException::class.java)
|
||||||
|
@ -105,6 +105,7 @@ class SerializationTokenTest : TestDependencyInjectionBase() {
|
|||||||
object UnitSerializationToken : SerializationToken {
|
object UnitSerializationToken : SerializationToken {
|
||||||
override fun fromToken(context: SerializeAsTokenContext): Any = UnitSerializeAsToken()
|
override fun fromToken(context: SerializeAsTokenContext): Any = UnitSerializeAsToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toToken(context: SerializeAsTokenContext): SerializationToken = UnitSerializationToken
|
override fun toToken(context: SerializeAsTokenContext): SerializationToken = UnitSerializationToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun mapTest() {
|
fun mapTest() {
|
||||||
data class C(val c: Map<String, Int>)
|
data class C(val c: Map<String, Int>)
|
||||||
|
|
||||||
val c = C(mapOf("A" to 1, "B" to 2))
|
val c = C(mapOf("A" to 1, "B" to 2))
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
@ -26,6 +27,7 @@ class DeserializeMapTests {
|
|||||||
@Test(expected = java.io.NotSerializableException::class)
|
@Test(expected = java.io.NotSerializableException::class)
|
||||||
fun abstractMapFromMapOf() {
|
fun abstractMapFromMapOf() {
|
||||||
data class C(val c: AbstractMap<String, Int>)
|
data class C(val c: AbstractMap<String, Int>)
|
||||||
|
|
||||||
val c = C(mapOf("A" to 1, "B" to 2) as AbstractMap)
|
val c = C(mapOf("A" to 1, "B" to 2) as AbstractMap)
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
@ -35,6 +37,7 @@ class DeserializeMapTests {
|
|||||||
@Test(expected = java.io.NotSerializableException::class)
|
@Test(expected = java.io.NotSerializableException::class)
|
||||||
fun abstractMapFromTreeMap() {
|
fun abstractMapFromTreeMap() {
|
||||||
data class C(val c: AbstractMap<String, Int>)
|
data class C(val c: AbstractMap<String, Int>)
|
||||||
|
|
||||||
val c = C(TreeMap(mapOf("A" to 1, "B" to 2)))
|
val c = C(TreeMap(mapOf("A" to 1, "B" to 2)))
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
@ -44,6 +47,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun sortedMapTest() {
|
fun sortedMapTest() {
|
||||||
data class C(val c: SortedMap<String, Int>)
|
data class C(val c: SortedMap<String, Int>)
|
||||||
|
|
||||||
val c = C(sortedMapOf("A" to 1, "B" to 2))
|
val c = C(sortedMapOf("A" to 1, "B" to 2))
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
DeserializationInput(sf).deserialize(serialisedBytes)
|
DeserializationInput(sf).deserialize(serialisedBytes)
|
||||||
@ -52,6 +56,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun navigableMapTest() {
|
fun navigableMapTest() {
|
||||||
data class C(val c: NavigableMap<String, Int>)
|
data class C(val c: NavigableMap<String, Int>)
|
||||||
|
|
||||||
val c = C(TreeMap(mapOf("A" to 1, "B" to 2)).descendingMap())
|
val c = C(TreeMap(mapOf("A" to 1, "B" to 2)).descendingMap())
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
@ -61,6 +66,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun dictionaryTest() {
|
fun dictionaryTest() {
|
||||||
data class C(val c: Dictionary<String, Int>)
|
data class C(val c: Dictionary<String, Int>)
|
||||||
|
|
||||||
val v: Hashtable<String, Int> = Hashtable()
|
val v: Hashtable<String, Int> = Hashtable()
|
||||||
v.put("a", 1)
|
v.put("a", 1)
|
||||||
v.put("b", 2)
|
v.put("b", 2)
|
||||||
@ -74,6 +80,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun hashtableTest() {
|
fun hashtableTest() {
|
||||||
data class C(val c: Hashtable<String, Int>)
|
data class C(val c: Hashtable<String, Int>)
|
||||||
|
|
||||||
val v: Hashtable<String, Int> = Hashtable()
|
val v: Hashtable<String, Int> = Hashtable()
|
||||||
v.put("a", 1)
|
v.put("a", 1)
|
||||||
v.put("b", 2)
|
v.put("b", 2)
|
||||||
@ -87,6 +94,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun hashMapTest() {
|
fun hashMapTest() {
|
||||||
data class C(val c: HashMap<String, Int>)
|
data class C(val c: HashMap<String, Int>)
|
||||||
|
|
||||||
val c = C(HashMap(mapOf("A" to 1, "B" to 2)))
|
val c = C(HashMap(mapOf("A" to 1, "B" to 2)))
|
||||||
|
|
||||||
// expect this to throw
|
// expect this to throw
|
||||||
@ -97,6 +105,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun weakHashMapTest() {
|
fun weakHashMapTest() {
|
||||||
data class C(val c: WeakHashMap<String, Int>)
|
data class C(val c: WeakHashMap<String, Int>)
|
||||||
|
|
||||||
val c = C(WeakHashMap(mapOf("A" to 1, "B" to 2)))
|
val c = C(WeakHashMap(mapOf("A" to 1, "B" to 2)))
|
||||||
|
|
||||||
Assertions.assertThatThrownBy { TestSerializationOutput(VERBOSE, sf).serialize(c) }
|
Assertions.assertThatThrownBy { TestSerializationOutput(VERBOSE, sf).serialize(c) }
|
||||||
@ -106,6 +115,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun concreteTreeMapTest() {
|
fun concreteTreeMapTest() {
|
||||||
data class C(val c: TreeMap<String, Int>)
|
data class C(val c: TreeMap<String, Int>)
|
||||||
|
|
||||||
val c = C(TreeMap(mapOf("A" to 1, "B" to 3)))
|
val c = C(TreeMap(mapOf("A" to 1, "B" to 3)))
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
@ -115,6 +125,7 @@ class DeserializeMapTests {
|
|||||||
@Test
|
@Test
|
||||||
fun concreteLinkedHashMapTest() {
|
fun concreteLinkedHashMapTest() {
|
||||||
data class C(val c: LinkedHashMap<String, Int>)
|
data class C(val c: LinkedHashMap<String, Int>)
|
||||||
|
|
||||||
val c = C(LinkedHashMap(mapOf("A" to 1, "B" to 2)))
|
val c = C(LinkedHashMap(mapOf("A" to 1, "B" to 2)))
|
||||||
|
|
||||||
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
val serialisedBytes = TestSerializationOutput(VERBOSE, sf).serialize(c)
|
||||||
|
@ -402,6 +402,7 @@ class DeserializeSimpleTypesTests {
|
|||||||
@Test
|
@Test
|
||||||
fun arrayOfArrayOfInt() {
|
fun arrayOfArrayOfInt() {
|
||||||
class C(val c: Array<Array<Int>>)
|
class C(val c: Array<Array<Int>>)
|
||||||
|
|
||||||
val c = C(arrayOf(arrayOf(1, 2, 3), arrayOf(4, 5, 6)))
|
val c = C(arrayOf(arrayOf(1, 2, 3), arrayOf(4, 5, 6)))
|
||||||
|
|
||||||
val serialisedC = TestSerializationOutput(VERBOSE, sf1).serialize(c)
|
val serialisedC = TestSerializationOutput(VERBOSE, sf1).serialize(c)
|
||||||
@ -421,6 +422,7 @@ class DeserializeSimpleTypesTests {
|
|||||||
@Test
|
@Test
|
||||||
fun arrayOfIntArray() {
|
fun arrayOfIntArray() {
|
||||||
class C(val c: Array<IntArray>)
|
class C(val c: Array<IntArray>)
|
||||||
|
|
||||||
val c = C(arrayOf(IntArray(3), IntArray(3)))
|
val c = C(arrayOf(IntArray(3), IntArray(3)))
|
||||||
c.c[0][0] = 1; c.c[0][1] = 2; c.c[0][2] = 3
|
c.c[0][0] = 1; c.c[0][1] = 2; c.c[0][2] = 3
|
||||||
c.c[1][0] = 4; c.c[1][1] = 5; c.c[1][2] = 6
|
c.c[1][0] = 4; c.c[1][1] = 5; c.c[1][2] = 6
|
||||||
@ -447,14 +449,24 @@ class DeserializeSimpleTypesTests {
|
|||||||
arrayOf(IntArray(3), IntArray(3), IntArray(3)),
|
arrayOf(IntArray(3), IntArray(3), IntArray(3)),
|
||||||
arrayOf(IntArray(3), IntArray(3), IntArray(3))))
|
arrayOf(IntArray(3), IntArray(3), IntArray(3))))
|
||||||
|
|
||||||
for (i in 0..2) { for (j in 0..2) { for (k in 0..2) { c.c[i][j][k] = i + j + k } } }
|
for (i in 0..2) {
|
||||||
|
for (j in 0..2) {
|
||||||
|
for (k in 0..2) {
|
||||||
|
c.c[i][j][k] = i + j + k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val serialisedC = TestSerializationOutput(VERBOSE, sf1).serialize(c)
|
val serialisedC = TestSerializationOutput(VERBOSE, sf1).serialize(c)
|
||||||
val deserializedC = DeserializationInput(sf1).deserialize(serialisedC)
|
val deserializedC = DeserializationInput(sf1).deserialize(serialisedC)
|
||||||
|
|
||||||
for (i in 0..2) { for (j in 0..2) { for (k in 0..2) {
|
for (i in 0..2) {
|
||||||
|
for (j in 0..2) {
|
||||||
|
for (k in 0..2) {
|
||||||
assertEquals(c.c[i][j][k], deserializedC.c[i][j][k])
|
assertEquals(c.c[i][j][k], deserializedC.c[i][j][k])
|
||||||
}}}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -325,8 +325,10 @@ class EvolvabilityTests {
|
|||||||
data class C(val e: Int, val c: Int, val b: Int, val a: Int, val d: Int) {
|
data class C(val e: Int, val c: Int, val b: Int, val a: Int, val d: Int) {
|
||||||
@DeprecatedConstructorForDeserialization(1)
|
@DeprecatedConstructorForDeserialization(1)
|
||||||
constructor (b: Int, a: Int) : this(-1, -1, b, a, -1)
|
constructor (b: Int, a: Int) : this(-1, -1, b, a, -1)
|
||||||
|
|
||||||
@DeprecatedConstructorForDeserialization(2)
|
@DeprecatedConstructorForDeserialization(2)
|
||||||
constructor (a: Int, c: Int, b: Int) : this(-1, c, b, a, -1)
|
constructor (a: Int, c: Int, b: Int) : this(-1, c, b, a, -1)
|
||||||
|
|
||||||
@DeprecatedConstructorForDeserialization(3)
|
@DeprecatedConstructorForDeserialization(3)
|
||||||
constructor (a: Int, b: Int, c: Int, d: Int) : this(-1, c, b, a, d)
|
constructor (a: Int, b: Int, c: Int, d: Int) : this(-1, c, b, a, d)
|
||||||
}
|
}
|
||||||
@ -377,6 +379,7 @@ class EvolvabilityTests {
|
|||||||
|
|
||||||
// Add a parameter to inner but keep outer unchanged
|
// Add a parameter to inner but keep outer unchanged
|
||||||
data class Inner(val a: Int, val b: String?)
|
data class Inner(val a: Int, val b: String?)
|
||||||
|
|
||||||
data class Outer(val a: Int, val b: Inner)
|
data class Outer(val a: Int, val b: Inner)
|
||||||
|
|
||||||
val sc2 = f.readBytes()
|
val sc2 = f.readBytes()
|
||||||
@ -419,10 +422,13 @@ class EvolvabilityTests {
|
|||||||
data class C(val b: Int, val c: Int, val d: Int, val e: Int, val f: Int, val g: Int) {
|
data class C(val b: Int, val c: Int, val d: Int, val e: Int, val f: Int, val g: Int) {
|
||||||
@DeprecatedConstructorForDeserialization(1)
|
@DeprecatedConstructorForDeserialization(1)
|
||||||
constructor (b: Int, c: Int) : this(b, c, -1, -1, -1, -1)
|
constructor (b: Int, c: Int) : this(b, c, -1, -1, -1, -1)
|
||||||
|
|
||||||
@DeprecatedConstructorForDeserialization(2)
|
@DeprecatedConstructorForDeserialization(2)
|
||||||
constructor (b: Int, c: Int, d: Int) : this(b, c, d, -1, -1, -1)
|
constructor (b: Int, c: Int, d: Int) : this(b, c, d, -1, -1, -1)
|
||||||
|
|
||||||
@DeprecatedConstructorForDeserialization(3)
|
@DeprecatedConstructorForDeserialization(3)
|
||||||
constructor (b: Int, c: Int, d: Int, e: Int) : this(b, c, d, e, -1, -1)
|
constructor (b: Int, c: Int, d: Int, e: Int) : this(b, c, d, e, -1, -1)
|
||||||
|
|
||||||
@DeprecatedConstructorForDeserialization(4)
|
@DeprecatedConstructorForDeserialization(4)
|
||||||
constructor (b: Int, c: Int, d: Int, e: Int, f: Int) : this(b, c, d, e, f, -1)
|
constructor (b: Int, c: Int, d: Int, e: Int, f: Int) : this(b, c, d, e, f, -1)
|
||||||
}
|
}
|
||||||
|
@ -535,6 +535,7 @@ class SerializationOutputTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val FOO_PROGRAM_ID = "net.corda.nodeapi.internal.serialization.amqp.SerializationOutputTests.FooContract"
|
val FOO_PROGRAM_ID = "net.corda.nodeapi.internal.serialization.amqp.SerializationOutputTests.FooContract"
|
||||||
|
|
||||||
class FooState : ContractState {
|
class FooState : ContractState {
|
||||||
override val participants: List<AbstractParty> = emptyList()
|
override val participants: List<AbstractParty> = emptyList()
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ class SerializeAndReturnSchemaTest {
|
|||||||
@Test
|
@Test
|
||||||
fun getSchema() {
|
fun getSchema() {
|
||||||
data class C(val a: Int, val b: Int)
|
data class C(val a: Int, val b: Int)
|
||||||
|
|
||||||
val a = 1
|
val a = 1
|
||||||
val b = 2
|
val b = 2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user