Refactor serialization tests and move them to test/io package

Add tests for singleton deserializing.
This commit is contained in:
Ilya Gorbunov
2017-02-13 18:42:44 +03:00
parent b67aed61ce
commit 6af986cfdd
4 changed files with 84 additions and 111 deletions
+1 -15
View File
@@ -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
}
}