| 282 | } |
| 283 | |
| 284 | void 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 | |
| 316 | void test_no_container() { |
| 317 | // An driver with no container should throw, not crash. |
no test coverage detected