MCPcopy Create free account
hub / github.com/apache/qpid-proton / test_driver_disconnected

Function test_driver_disconnected

cpp/src/connection_driver_test.cpp:284–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284void test_driver_disconnected() {
285 // driver.disconnected() aborts the connection and calls the local on_transport_error()
286 record_handler ha, hb;
287 driver_pair d(ha, hb);
288 d.a.connect(ha);
289 d.b.accept(hb);
290 while (!d.a.connection().active() || !d.b.connection().active())
291 d.process();
292
293 // Close a with an error condition. The AMQP connection is still open.
294 d.a.disconnected(proton::error_condition("oops", "driver failure"));
295 ASSERT(!d.a.dispatch());
296 ASSERT(!d.a.connection().closed());
297 ASSERT(d.a.connection().error().empty());
298 ASSERT_EQUAL(0u, ha.connection_errors.size());
299 ASSERT_EQUAL("oops: driver failure", d.a.transport().error().what());
300 ASSERT_EQUAL(1u, ha.transport_errors.size());
301 ASSERT_EQUAL("oops: driver failure", ha.transport_errors.front());
302
303 // In a real app the IO code would detect the abort and do this:
304 d.b.disconnected(proton::error_condition("broken", "it broke"));
305 ASSERT(!d.b.dispatch());
306 ASSERT(!d.b.connection().closed());
307 ASSERT(d.b.connection().error().empty());
308 ASSERT_EQUAL(0u, hb.connection_errors.size());
309 // Proton-C adds (connection aborted) if transport closes too early,
310 // and provides a default message if there is no user message.
311 ASSERT_EQUAL("broken: it broke (connection aborted)", d.b.transport().error().what());
312 ASSERT_EQUAL(1u, hb.transport_errors.size());
313 ASSERT_EQUAL("broken: it broke (connection aborted)", hb.transport_errors.front());
314}
315
316void test_no_container() {
317 // An driver with no container should throw, not crash.

Callers 1

mainFunction · 0.85

Calls 14

activeMethod · 0.80
disconnectedMethod · 0.80
error_conditionClass · 0.70
closedMethod · 0.65
connectMethod · 0.45
acceptMethod · 0.45
connectionMethod · 0.45
processMethod · 0.45
dispatchMethod · 0.45
emptyMethod · 0.45
errorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected