summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-11-12 15:57:53 -0800
committerJames Iry <jamesiry@gmail.com>2013-11-12 15:57:53 -0800
commit8bed4a8b2211f8c6d84ae66ec95e71d3485162a9 (patch)
tree22c96933c8b30cc49bca1eee39e449cd9d1be190 /test
parent5cef951d0d230cfecd1138a0cc18643052437100 (diff)
parent1ca329e7f9795ae8256f010b94742417db6d4a55 (diff)
downloadscala-8bed4a8b2211f8c6d84ae66ec95e71d3485162a9.tar.gz
scala-8bed4a8b2211f8c6d84ae66ec95e71d3485162a9.tar.bz2
scala-8bed4a8b2211f8c6d84ae66ec95e71d3485162a9.zip
Merge pull request #3121 from rjfwhite/SI-7568
SI-7568 Adding Serializable to ResizableArrayAccess inner class
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/collection/PriorityQueueTest.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/junit/scala/collection/PriorityQueueTest.scala b/test/junit/scala/collection/PriorityQueueTest.scala
new file mode 100644
index 0000000000..a14f1bf4c8
--- /dev/null
+++ b/test/junit/scala/collection/PriorityQueueTest.scala
@@ -0,0 +1,32 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import scala.collection.mutable
+import java.io.{ObjectInputStream, ByteArrayInputStream, ByteArrayOutputStream, ObjectOutputStream}
+
+@RunWith(classOf[JUnit4])
+/* Test for SI-7568 */
+class PriorityQueueTest {
+ val priorityQueue = new mutable.PriorityQueue[Int]()
+ val elements = List.fill(1000)(scala.util.Random.nextInt(Int.MaxValue))
+ priorityQueue.enqueue(elements :_*)
+
+ @Test
+ def canSerialize() {
+ val outputStream = new ByteArrayOutputStream()
+ new ObjectOutputStream(outputStream).writeObject(priorityQueue)
+ }
+
+ @Test
+ def maintainsStateWhenDeserialized() {
+ val outputStream = new ByteArrayOutputStream()
+ new ObjectOutputStream(outputStream).writeObject(priorityQueue)
+ val bytes = outputStream.toByteArray
+
+ val objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes))
+ val deserializedPriorityQueue = objectInputStream.readObject().asInstanceOf[PriorityQueue[Int]]
+ assert(deserializedPriorityQueue.dequeueAll == elements.sorted.reverse)
+ }
+}