11package akka .persistence .journal .sqlasync
22
33import akka .actor .Actor
4- import akka .persistence .JournalProtocol .{WriteMessageRejected , WriteMessageSuccess , WriteMessages , WriteMessagesSuccessful }
4+ import akka .persistence .JournalProtocol .{WriteMessageRejected , WriteMessages , WriteMessagesSuccessful }
55import akka .persistence .helper .MySQLInitializer
66import akka .persistence .journal .JournalSpec
7- import akka .persistence .{AtomicWrite , PersistentImpl , PersistentRepr }
7+ import akka .persistence .{AtomicWrite , CapabilityFlag , PersistentImpl , PersistentRepr }
88import akka .testkit .TestProbe
99import com .typesafe .config .ConfigFactory
1010import java .io .NotSerializableException
@@ -14,6 +14,8 @@ class MySQLAsyncJournalSpec
1414 extends JournalSpec (ConfigFactory .load(" mysql-application.conf" ))
1515 with MySQLInitializer {
1616
17+ override protected def supportsRejectingNonSerializableObjects : CapabilityFlag = true
18+
1719 " ScalikeJDBCWriteJournal" must {
1820 " not execute SQL when all the events is not serializable" in {
1921 val probe = TestProbe ()
@@ -50,40 +52,5 @@ class MySQLAsyncJournalSpec
5052 }
5153 probe.expectNoMsg(1 .second)
5254 }
53-
54- " handle partial serialization errors" in {
55- val probe = TestProbe ()
56-
57- val notSerializableEvent = new Object { override def toString = " not serializable" }
58- val messages = (6 to 8 ).map { i =>
59- val event = if (i == 7 ) notSerializableEvent else s " b- $i"
60- AtomicWrite (PersistentRepr (
61- payload = event,
62- sequenceNr = i,
63- persistenceId = pid,
64- sender = Actor .noSender,
65- writerUuid = writerUuid
66- ))
67- }
68- journal ! WriteMessages (messages, probe.ref, actorInstanceId)
69- probe.expectMsg(WriteMessagesSuccessful )
70-
71- val Pid = pid
72- val WriterUuid = writerUuid
73- probe.expectMsgPF() {
74- case WriteMessageSuccess (PersistentImpl (payload, 6L , Pid , _, _, Actor .noSender, WriterUuid ), _) =>
75- payload should be(" b-6" )
76- }
77- probe.expectMsgPF() {
78- case WriteMessageRejected (PersistentImpl (payload, 7L , Pid , _, _, Actor .noSender, WriterUuid ), cause, _) =>
79- payload should be(notSerializableEvent)
80- cause.isInstanceOf [NotSerializableException ] should be(true )
81- }
82- probe.expectMsgPF() {
83- case WriteMessageSuccess (PersistentImpl (payload, 8L , Pid , _, _, Actor .noSender, WriterUuid ), _) =>
84- payload should be(" b-8" )
85- }
86- probe.expectNoMsg(1 .second)
87- }
8855 }
8956}
0 commit comments