@Test(timeout = 30000)
public void testReadOnlyTxnLogDir() throws Exception {

    ClientBase.setupTestEnv();
    final int CLIENT_PORT = PortAssignment.unique();
    // Start up the ZK server to automatically create the necessary directories
    // and capture the directory where data is stored
    MainThread main = new MainThread(CLIENT_PORT, true, null);
    File tmpDir = main.tmpDir;
    main.start();
    Assert.assertTrue("waiting for server being up", ClientBase
            .waitForServerUp("127.0.0.1:" + CLIENT_PORT,
                    CONNECTION_TIMEOUT / 2));
    main.shutdown();
    // Make the transaction log directory read only
    File logDir = new File(main.logDir, FileTxnSnapLog.version + FileTxnSnapLog.VERSION);
    logDir.setWritable(false);
    // Restart ZK and observe a failure
    main = new MainThread(CLIENT_PORT, false, tmpDir, null);
    main.start();
    Assert.assertFalse("waiting for server being up", ClientBase
            .waitForServerUp("127.0.0.1:" + CLIENT_PORT,
                    CONNECTION_TIMEOUT / 2));
    main.shutdown();
    logDir.setWritable(true);
    main.deleteDirs();
}