/**
* Test bad client configuration
*/
@Test
public void testBadConf() throws Exception {
ClientConfiguration conf = new ClientConfiguration();
// success case
String root0 = "/goodconf0";
zkc.create(root0, new byte[0],
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
conf.setZkLedgersRootPath(root0);
LedgerManager m = LedgerManagerFactory.newLedgerManager(conf, zkc);
assertTrue("Ledger manager is unexpected type",
(m instanceof FlatLedgerManager));
// mismatching conf
conf.setLedgerManagerType(HierarchicalLedgerManager.NAME);
try {
LedgerManagerFactory.newLedgerManager(conf, zkc);
fail("Shouldn't reach here");
} catch (Exception e) {
assertTrue("Invalid exception",
e.getMessage().contains("does not match existing layout"));
}
// invalid ledger manager
String root1 = "/badconf1";
zkc.create(root1, new byte[0],
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
conf.setZkLedgersRootPath(root1);
conf.setLedgerManagerType("DoesNotExist");
try {
LedgerManagerFactory.newLedgerManager(conf, zkc);
fail("Shouldn't reach here");
} catch (Exception e) {
assertTrue("Invalid exception",