Source:
<code>public void testGetLedgerMetaService() throws Exception { baseConf.setZkServers(zkUtil.getZooKeeperConnectString()); BookKeeper.DigestType digestType = BookKeeper.DigestType.CRC32; int numLedgers = 4; int numMsgs = 100; LedgerHandle[] lh = new LedgerHandle[numLedgers]; for (int i = 0; i < numLedgers; i++) { lh[i] = bkc.createLedger(digestType, "".getBytes()); } String content = "Apache BookKeeper is cool!"; for (int i = 0; i < numMsgs; i++) { for (int j = 0; j < numLedgers; j++) { lh[j].addEntry(content.getBytes()); } } for (int i = 0; i < numLedgers; i++) { lh[i].close(); } HttpService getLedgerMetaService = bkHttpServiceProvider.provideGetLedgerMetaService(); HttpServiceRequest request1 = new HttpServiceRequest(null, HttpServer.Method.GET, null); HttpServiceResponse response1 = getLedgerMetaService.handle(request1); assertEquals(HttpServer.StatusCode.NOT_FOUND.getValue(), response1.getStatusCode()); HashMap<String, String> params = Maps.newHashMap(); Long ledgerId = Long.valueOf(lh[0].getId()); params.put("ledger_id", ledgerId.toString()); HttpServiceRequest request2 = new HttpServiceRequest(null, HttpServer.Method.GET, params); HttpServiceResponse response2 = getLedgerMetaService.handle(request2); assertEquals(HttpServer.StatusCode.OK.getValue(), response2.getStatusCode()); @SuppressWarnings("unchecked") HashMap<String, String> respBody = JsonUtil.fromJson(response2.getBody(), HashMap.class); <START> assertEquals(1, respBody.size()); <END> }</code><technical_language>check contents match of ledger created above</technical_language>

Target:
public void testGetLedgerMetaService() throws Exception { baseConf.setZkServers(zkUtil.getZooKeeperConnectString()); BookKeeper.DigestType digestType = BookKeeper.DigestType.CRC32; int numLedgers = 4; int numMsgs = 100; LedgerHandle[] lh = new LedgerHandle[numLedgers]; for (int i = 0; i < numLedgers; i++) { lh[i] = bkc.createLedger(digestType, "password".getBytes()); } String content = "Apache BookKeeper is cool!"; for (int i = 0; i < numMsgs; i++) { for (int j = 0; j < numLedgers; j++) { lh[j].addEntry(content.getBytes()); } } for (int i = 0; i < numLedgers; i++) { lh[i].close(); } HttpEndpointService getLedgerMetaService = bkHttpServiceProvider .provideHttpEndpointService(HttpServer.ApiType.GET_LEDGER_META); HttpServiceRequest request1 = new HttpServiceRequest(null, HttpServer.Method.GET, null); HttpServiceResponse response1 = getLedgerMetaService.handle(request1); assertEquals(HttpServer.StatusCode.NOT_FOUND.getValue(), response1.getStatusCode()); HashMap<String, String> params = Maps.newHashMap(); Long ledgerId = Long.valueOf(lh[0].getId()); params.put("ledger_id", ledgerId.toString()); HttpServiceRequest request2 = new HttpServiceRequest(null, HttpServer.Method.GET, params); HttpServiceResponse response2 = getLedgerMetaService.handle(request2); assertEquals(HttpServer.StatusCode.OK.getValue(), response2.getStatusCode()); @SuppressWarnings("unchecked") HashMap<String, String> respBody = JsonUtil.fromJson(response2.getBody(), HashMap.class); assertEquals(1, respBody.size()); assertTrue(respBody.get(ledgerId.toString()).toString() .equals(new String(lh[0].getLedgerMetadata().serialize()))); }