/**
* Test bad client configuration
*/
@Test(timeout=60000)
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);
LedgerManagerFactory m = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
assertTrue("Ledger manager is unexpected type",
(m instanceof FlatLedgerManagerFactory));
m.uninitialize();
// mismatching conf
conf.setLedgerManagerFactoryClass(HierarchicalLedgerManagerFactory.class);
try {
LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
fail("Shouldn't reach here");
} catch (Exception e) {
LOG.error("Received 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.setLedgerManagerFactoryClassName("DoesNotExist");
try {
LedgerManagerFactory f = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
fail("Shouldn't reach here");
} catch (Exception e) {
LOG.error("Received exception", e);