CURATOR-33 recursive TreeCache recipe

To test it, just start the curator framework and the TreeCache, but don't start the testing server. Then start the testing server. The tree cache will get a CONNECTED event, and nothing will happen. If you then stop the server and start it again, the cache will start working because it gets a reconnected event.

To get the error you need to make sure that all retries have been exhausted prior to starting the test server.

To actually put an assertion into the test case, I guess you'll just need to make it time based. I.e. Assert that you get an initialised event from the TreeCache within 5 seconds of the server starting

As for the start() method, what you're suggesting should work, assuming you add something to handle the CONNECTED state in the listener. Alternatively, look at how its done in LeaderLatch.