Skip to content

Commit 34bc440

Browse files
committed
Make serialization test methods available
1 parent d37b04f commit 34bc440

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

jvm/src/test/scala/scala/xml/JavaByteSerialization.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import java.io._
44

55
object JavaByteSerialization {
66
def roundTrip[T](obj: T): T = {
7-
def serialize(in: T): Array[Byte] = {
8-
val bos = new ByteArrayOutputStream()
9-
val oos = new ObjectOutputStream(bos)
10-
oos.writeObject(in)
11-
oos.flush()
12-
bos.toByteArray()
13-
}
7+
deserialize[T](serialize[T](obj))
8+
}
149

15-
def deserialize(in: Array[Byte]): T = {
16-
val bis = new ByteArrayInputStream(in)
17-
val ois = new ObjectInputStream(bis)
18-
ois.readObject.asInstanceOf[T]
19-
}
10+
def serialize[T](in: T): Array[Byte] = {
11+
val bos = new ByteArrayOutputStream()
12+
val oos = new ObjectOutputStream(bos)
13+
oos.writeObject(in)
14+
oos.flush()
15+
bos.toByteArray()
16+
}
2017

21-
deserialize(serialize(obj))
18+
def deserialize[T](in: Array[Byte]): T = {
19+
val bis = new ByteArrayInputStream(in)
20+
val ois = new ObjectInputStream(bis)
21+
ois.readObject.asInstanceOf[T]
2222
}
2323
}

0 commit comments

Comments
 (0)