ZkConfiguration extends KattaConfiguration { public String getZkRootPath() { if (_rootPath == null) { _rootPath = getProperty(ZOOKEEPER_ROOT_PATH, DEFAULT_ROOT_PATH).trim(); if (_rootPath.endsWith("/")) { _rootPath = _rootPath.substring(0, _rootPath.length() - 1); } if (!_rootPath.startsWith("/")) { _rootPath = "/" + _rootPath; } } return _rootPath; } ZkConfiguration();  ZkConfiguration(final String path);  ZkConfiguration(final File file);  ZkConfiguration(Properties properties, String filePath); boolean isEmbedded(); void setEmbedded(boolean embeddedZk); String getZKServers(); void setZKServers(String servers); int getZKTimeOut(); int getZKTickTime(); int getZKInitLimit(); int getZKSyncLimit(); String getZKDataDir(); String getZKDataLogDir(); String getZKNodeQueuePath(String node); String getZkPath(PathDef pathDef, String... names); String getZkRootPath(); void setZKRootPath(String rootPath); static String getZKName(String path); static String getZkParent(String path); static String buildZkPath(String... folders); static final String KATTA_PROPERTY_NAME; static final String ZOOKEEPER_EMBEDDED; static final String ZOOKEEPER_SERVERS; static final String ZOOKEEPER_TIMEOUT; static final String ZOOKEEPER_TICK_TIME; static final String ZOOKEEPER_INIT_LIMIT; static final String ZOOKEEPER_SYNC_LIMIT; static final String ZOOKEEPER_DATA_DIR; static final String ZOOKEEPER_LOG_DATA_DIR; static final String ZOOKEEPER_ROOT_PATH; static Character ZK_PATH_SEPARATOR; static final String DEFAULT_ROOT_PATH; }
@Test public void testSystemProperty() { try { System.clearProperty(ZkConfiguration.KATTA_PROPERTY_NAME); ZkConfiguration conf1 = new ZkConfiguration(); System.setProperty(ZkConfiguration.KATTA_PROPERTY_NAME, "/katta.zk.properties_alt_root"); ZkConfiguration conf2 = new ZkConfiguration(); assertEquals("/katta", conf1.getZkRootPath()); assertEquals("/test/katta20090510153800", conf2.getZkRootPath()); try { System.setProperty(ZkConfiguration.KATTA_PROPERTY_NAME, "/not-found"); new ZkConfiguration(); fail("Should have failed"); } catch (RuntimeException e) { } } finally { System.clearProperty(ZkConfiguration.KATTA_PROPERTY_NAME); } }