I've seen a few threads on why it's a bad idea to try to embed ZK in your app. I'm not trying to do that for my production app. I am trying to do that for unit tests. I could try to mock out ZK but I'm concerned that'd be both a lot of typing and wouldn't, well, test against the real thing.

Has anyone done this before?

When I tried doing this I saw the ZK session request initiated by the unit test go through (after first trying IPv6, then falling back to IPv4), but then the first operation attempted timed out after 40 seconds. The same test case passes against a 3 node external ZK cluster.

Note that I'm spinning up a new ZK instance for every test run - I've tried inserting a several minute sleep after startup to give it time to initialize, but that didn't make a difference.import java.io.File;import java.util.UUID;import java.util.concurrent.Semaphore;import org.apache.commons.io.FileUtils;import org.apache.zookeeper.server.ZooKeeperServerMain;import org.slf4j.Logger;import org.slf4j.LoggerFactory;

The information contained in this communication may be CONFIDENTIAL and is intended only for the use of the recipient(s) named above. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please notify the sender and delete/destroy the original message and any copy of it from your computer or paper files.