@@ -22,6 +22,13 @@ object ActorMailboxSpec {
22
22
mailbox-type = "akka.dispatch.BoundedMailbox"
23
23
}
24
24
25
+ requiring-bounded-dispatcher {
26
+ mailbox-capacity = 1000
27
+ mailbox-push-timeout-time = 10s
28
+ mailbox-type = "akka.dispatch.BoundedMailbox"
29
+ mailbox-requirement = "akka.dispatch.BoundedMessageQueueSemantics"
30
+ }
31
+
25
32
unbounded-mailbox {
26
33
mailbox-type = "akka.dispatch.UnboundedMailbox"
27
34
}
@@ -80,10 +87,32 @@ object ActorMailboxSpec {
80
87
dispatcher = bounded-dispatcher
81
88
mailbox = unbounded-mailbox
82
89
}
83
- }
84
-
85
- akka.actor.mailbox.requirements {
86
- "akka.dispatch.BoundedMessageQueueSemantics" = bounded-mailbox
90
+ /bounded-deque-requirements-configured {
91
+ dispatcher = requiring-bounded-dispatcher
92
+ mailbox = akka.actor.mailbox.bounded-deque-based
93
+ }
94
+ /bounded-deque-require-unbounded-configured {
95
+ dispatcher = requiring-bounded-dispatcher
96
+ mailbox = akka.actor.mailbox.unbounded-deque-based
97
+ }
98
+ /bounded-deque-require-unbounded-unconfigured {
99
+ dispatcher = requiring-bounded-dispatcher
100
+ }
101
+ /bounded-deque-requirements-configured-props-disp {
102
+ mailbox = akka.actor.mailbox.bounded-deque-based
103
+ }
104
+ /bounded-deque-require-unbounded-configured-props-disp {
105
+ mailbox = akka.actor.mailbox.unbounded-deque-based
106
+ }
107
+ /bounded-deque-requirements-configured-props-mail {
108
+ dispatcher = requiring-bounded-dispatcher
109
+ }
110
+ /bounded-deque-require-unbounded-configured-props-mail {
111
+ dispatcher = requiring-bounded-dispatcher
112
+ }
113
+ /bounded-deque-require-unbounded-unconfigured-props-mail {
114
+ dispatcher = requiring-bounded-dispatcher
115
+ }
87
116
}
88
117
""" )
89
118
@@ -97,10 +126,16 @@ object ActorMailboxSpec {
97
126
98
127
class StashQueueReportingActor extends QueueReportingActor with Stash
99
128
100
- val UnboundedMailboxTypes = Seq (classOf [QueueBasedMessageQueue ], classOf [UnboundedMessageQueueSemantics ])
101
- val BoundedMailboxTypes = Seq (classOf [QueueBasedMessageQueue ], classOf [BoundedMessageQueueSemantics ])
102
- val UnboundedDeqMailboxTypes = Seq (classOf [QueueBasedMessageQueue ], classOf [DequeBasedMessageQueue ],
129
+ val UnboundedMailboxTypes = Seq (classOf [UnboundedMessageQueueSemantics ])
130
+ val BoundedMailboxTypes = Seq (classOf [BoundedMessageQueueSemantics ])
131
+ val UnboundedDeqMailboxTypes = Seq (
132
+ classOf [DequeBasedMessageQueueSemantics ],
133
+ classOf [UnboundedMessageQueueSemantics ],
103
134
classOf [UnboundedDequeBasedMessageQueueSemantics ])
135
+ val BoundedDeqMailboxTypes = Seq (
136
+ classOf [DequeBasedMessageQueueSemantics ],
137
+ classOf [BoundedMessageQueueSemantics ],
138
+ classOf [BoundedDequeBasedMessageQueueSemantics ])
104
139
}
105
140
106
141
class ActorMailboxSpec extends AkkaSpec (ActorMailboxSpec .mailboxConf) with DefaultTimeout with ImplicitSender {
@@ -122,7 +157,7 @@ class ActorMailboxSpec extends AkkaSpec(ActorMailboxSpec.mailboxConf) with Defau
122
157
checkMailboxQueue(Props [QueueReportingActor ], " default-default" , UnboundedMailboxTypes )
123
158
}
124
159
125
- " get an unbounded dequeu message queue when it is only configured on the props" in {
160
+ " get an unbounded deque message queue when it is only configured on the props" in {
126
161
checkMailboxQueue(Props [QueueReportingActor ].withMailbox(" akka.actor.mailbox.unbounded-deque-based" ),
127
162
" default-override-from-props" , UnboundedDeqMailboxTypes )
128
163
}
@@ -132,7 +167,7 @@ class ActorMailboxSpec extends AkkaSpec(ActorMailboxSpec.mailboxConf) with Defau
132
167
" default-override-from-trait" , BoundedMailboxTypes )
133
168
}
134
169
135
- " get an unbounded dequeu message queue when it's only mixed with Stash" in {
170
+ " get an unbounded deque message queue when it's only mixed with Stash" in {
136
171
checkMailboxQueue(Props [StashQueueReportingActor ],
137
172
" default-override-from-stash" , UnboundedDeqMailboxTypes )
138
173
}
@@ -141,24 +176,20 @@ class ActorMailboxSpec extends AkkaSpec(ActorMailboxSpec.mailboxConf) with Defau
141
176
checkMailboxQueue(Props [QueueReportingActor ], " default-bounded" , BoundedMailboxTypes )
142
177
}
143
178
144
- " get an unbounded dequeu message queue when it's configured as mailbox" in {
179
+ " get an unbounded deque message queue when it's configured as mailbox" in {
145
180
checkMailboxQueue(Props [QueueReportingActor ], " default-unbounded-deque" , UnboundedDeqMailboxTypes )
146
181
}
147
182
148
183
" fail to create actor when an unbounded dequeu message queue is configured as mailbox overriding RequestMailbox" in {
149
- filterEvents(EventFilter [ActorInitializationException ]()) {
150
- verifyActorTermination(system.actorOf(Props [BoundedQueueReportingActor ], " default-unbounded-deque-override-trait" ))
151
- }
184
+ intercept[IllegalArgumentException ](system.actorOf(Props [BoundedQueueReportingActor ], " default-unbounded-deque-override-trait" ))
152
185
}
153
186
154
187
" get an unbounded message queue when defined in dispatcher" in {
155
188
checkMailboxQueue(Props [QueueReportingActor ], " unbounded-default" , UnboundedMailboxTypes )
156
189
}
157
190
158
191
" fail to create actor when an unbounded message queue is defined in dispatcher overriding RequestMailbox" in {
159
- filterEvents(EventFilter [ActorInitializationException ]()) {
160
- verifyActorTermination(system.actorOf(Props [BoundedQueueReportingActor ], " unbounded-default-override-trait" ))
161
- }
192
+ intercept[IllegalArgumentException ](system.actorOf(Props [BoundedQueueReportingActor ], " unbounded-default-override-trait" ))
162
193
}
163
194
164
195
" get a bounded message queue when it's configured as mailbox overriding unbounded in dispatcher" in {
@@ -183,5 +214,84 @@ class ActorMailboxSpec extends AkkaSpec(ActorMailboxSpec.mailboxConf) with Defau
183
214
" bounded-unbounded-override-props" , UnboundedMailboxTypes )
184
215
}
185
216
217
+ " get a bounded deque-based message queue if configured and required" in {
218
+ checkMailboxQueue(Props [StashQueueReportingActor ], " bounded-deque-requirements-configured" , BoundedDeqMailboxTypes )
219
+ }
220
+
221
+ " fail with a unbounded deque-based message queue if configured and required" in {
222
+ intercept[IllegalArgumentException ](system.actorOf(Props [StashQueueReportingActor ], " bounded-deque-require-unbounded-configured" ))
223
+ }
224
+
225
+ " fail with a bounded deque-based message queue if not configured" in {
226
+ intercept[IllegalArgumentException ](system.actorOf(Props [StashQueueReportingActor ], " bounded-deque-require-unbounded-unconfigured" ))
227
+ }
228
+
229
+ " get a bounded deque-based message queue if configured and required with Props" in {
230
+ checkMailboxQueue(
231
+ Props [StashQueueReportingActor ]
232
+ .withDispatcher(" requiring-bounded-dispatcher" )
233
+ .withMailbox(" akka.actor.mailbox.bounded-deque-based" ),
234
+ " bounded-deque-requirements-configured-props" ,
235
+ BoundedDeqMailboxTypes )
236
+ }
237
+
238
+ " fail with a unbounded deque-based message queue if configured and required with Props" in {
239
+ intercept[IllegalArgumentException ](system.actorOf(
240
+ Props [StashQueueReportingActor ]
241
+ .withDispatcher(" requiring-bounded-dispatcher" )
242
+ .withMailbox(" akka.actor.mailbox.unbounded-deque-based" ),
243
+ " bounded-deque-require-unbounded-configured-props" ))
244
+ }
245
+
246
+ " fail with a bounded deque-based message queue if not configured with Props" in {
247
+ intercept[IllegalArgumentException ](system.actorOf(
248
+ Props [StashQueueReportingActor ]
249
+ .withDispatcher(" requiring-bounded-dispatcher" ),
250
+ " bounded-deque-require-unbounded-unconfigured-props" ))
251
+ }
252
+
253
+ " get a bounded deque-based message queue if configured and required with Props (dispatcher)" in {
254
+ checkMailboxQueue(
255
+ Props [StashQueueReportingActor ]
256
+ .withDispatcher(" requiring-bounded-dispatcher" ),
257
+ " bounded-deque-requirements-configured-props-disp" ,
258
+ BoundedDeqMailboxTypes )
259
+ }
260
+
261
+ " fail with a unbounded deque-based message queue if configured and required with Props (dispatcher)" in {
262
+ intercept[IllegalArgumentException ](system.actorOf(
263
+ Props [StashQueueReportingActor ]
264
+ .withDispatcher(" requiring-bounded-dispatcher" ),
265
+ " bounded-deque-require-unbounded-configured-props-disp" ))
266
+ }
267
+
268
+ " fail with a bounded deque-based message queue if not configured with Props (dispatcher)" in {
269
+ intercept[IllegalArgumentException ](system.actorOf(
270
+ Props [StashQueueReportingActor ]
271
+ .withDispatcher(" requiring-bounded-dispatcher" ),
272
+ " bounded-deque-require-unbounded-unconfigured-props-disp" ))
273
+ }
274
+
275
+ " get a bounded deque-based message queue if configured and required with Props (mailbox)" in {
276
+ checkMailboxQueue(
277
+ Props [StashQueueReportingActor ]
278
+ .withMailbox(" akka.actor.mailbox.bounded-deque-based" ),
279
+ " bounded-deque-requirements-configured-props-mail" ,
280
+ BoundedDeqMailboxTypes )
281
+ }
282
+
283
+ " fail with a unbounded deque-based message queue if configured and required with Props (mailbox)" in {
284
+ intercept[IllegalArgumentException ](system.actorOf(
285
+ Props [StashQueueReportingActor ]
286
+ .withMailbox(" akka.actor.mailbox.unbounded-deque-based" ),
287
+ " bounded-deque-require-unbounded-configured-props-mail" ))
288
+ }
289
+
290
+ " fail with a bounded deque-based message queue if not configured with Props (mailbox)" in {
291
+ intercept[IllegalArgumentException ](system.actorOf(
292
+ Props [StashQueueReportingActor ],
293
+ " bounded-deque-require-unbounded-unconfigured-props-mail" ))
294
+ }
295
+
186
296
}
187
297
}
0 commit comments