mats3
mats3 copied to clipboard
Make JMS API exceptions-on-all-methods auto-test
See if it is possible to create an "automatic test" that checks how the Jms-Impl handles exceptions on all JMS API interaction points: Make a "complex interaction", exercising all of the Mats API that interacts with the JMS API. Run this once, recording which interactions are done. Then run it as many times as there was interaction points, now throwing a JMSException (and possibly a RTE) on successively each of the interaction points - each time asserting that the end result is as expected (usually "everything as normal"), and then asserting that the state of the system is as expected (number of connections, sessions etc).
Also possibly do the same iteration, but this time killing the ActiveMQ instance on each of the interaction points.
Another, maybe more realistic way, is to make a way to insert "hook points" throughout the codebase. This would call into a static class with lots of methods which are the hooks. Each hook would check a single boolean "hooksEnabled", and return immediately if false. Each hook would also have a onHook method which could be given a lambda. If hooks are enabled, this lambda would be checked for nullness, if set, then it would be invoked. Relevant params would be supplied from calling code to each hook, and this passed on to the lambda.
The lambdas could then implement latch-style stuff ("tell me when the endpoint code is at this point"), and/or throw relevant exceptions back to the calling code, emulating different failure scenarios.