Refactor serialization tests and move them to test/io package
Add tests for singleton deserializing.
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.concurrent.thread
|
||||
import org.junit.Test
|
||||
import test.io.serializeAndDeserialize
|
||||
|
||||
class LazyJVMTest {
|
||||
|
||||
@@ -85,19 +86,4 @@ class LazyJVMTest {
|
||||
assertEquals(lazy.value, lazy2.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun <T> serializeAndDeserialize(value: T): T {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
val objectOutputStream = ObjectOutputStream(outputStream)
|
||||
|
||||
objectOutputStream.writeObject(value)
|
||||
objectOutputStream.close()
|
||||
outputStream.close()
|
||||
|
||||
val inputStream = ByteArrayInputStream(outputStream.toByteArray())
|
||||
val inputObjectStream = ObjectInputStream(inputStream)
|
||||
return inputObjectStream.readObject() as T
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user