Source:
<code>public static void main(String[] args) throws IOException { Map<String, List<String>> routingData = new HashMap<>(); routingData.put("zk-0", ImmutableList.of("sharding-key-0", "sharding-key-1", "sharding-key-2")); routingData.put("zk-1", ImmutableList.of("sharding-key-3", "sharding-key-4", "sharding-key-5")); routingData.put("zk-2", ImmutableList.of("sharding-key-6", "sharding-key-7", "sharding-key-8")); String host = "localhost"; int port = 11000; String namespace = "MY-HELIX-APP"; MockMetadataStoreDirectoryServer server = new MockMetadataStoreDirectoryServer(host, port, namespace, routingData); server.startServer(); CloseableHttpClient httpClient = HttpClients.createDefault(); String testZkRealm = "zk-0"; HttpGet getRequest = new HttpGet( <START> "http://localhost:" + port + REST_PREFIX + namespace + ZK_REALM_ENDPOINT + testZkRealm); <END> try { CloseableHttpResponse getResponse = httpClient.execute(getRequest); System.out.println(getResponse.toString()); List<String> shardingKeyList = OBJECT_MAPPER.readValue(getResponse.getEntity().getContent(), List.class); System.out.println(shardingKeyList); Assert.assertEquals(shardingKeyList, routingData.get(testZkRealm)); } catch (IOException e) { e.printStackTrace(); } HttpPost postRequest = new HttpPost( "http://localhost:" + port + REST_PREFIX + namespace + ZK_REALM_ENDPOINT + testZkRealm); try { CloseableHttpResponse postResponse = httpClient.execute(postRequest); System.out.println(postResponse.toString()); } catch (IOException e) { e.printStackTrace(); } server.stopServer(); System.out.println("MockMetadataStoreDirectoryServer test passed!"); }</code><technical_language>Nit: host declared, string replaced host</technical_language>

Target:
public static void main(String[] args) throws IOException { Map<String, List<String>> routingData = new HashMap<>(); routingData.put("zk-0", ImmutableList.of("sharding-key-0", "sharding-key-1", "sharding-key-2")); routingData.put("zk-1", ImmutableList.of("sharding-key-3", "sharding-key-4", "sharding-key-5")); routingData.put("zk-2", ImmutableList.of("sharding-key-6", "sharding-key-7", "sharding-key-8")); String host = "localhost"; int port = 11000; String endpoint = "http://" + host + ":" + port; String namespace = "MY-HELIX-NAMESPACE"; MockMetadataStoreDirectoryServer server = new MockMetadataStoreDirectoryServer(host, port, namespace, routingData); server.startServer(); CloseableHttpClient httpClient = HttpClients.createDefault(); String testZkRealm = "zk-0"; HttpGet getRequest = new HttpGet(endpoint + REST_PREFIX + namespace + ZK_REALM_ENDPOINT + testZkRealm); try { CloseableHttpResponse getResponse = httpClient.execute(getRequest); System.out.println(getResponse.toString()); List<String> shardingKeyList = OBJECT_MAPPER.readValue(getResponse.getEntity().getContent(), List.class); System.out.println(shardingKeyList); Assert.assertEquals(shardingKeyList, routingData.get(testZkRealm)); } catch (IOException e) { e.printStackTrace(); } HttpPost postRequest = new HttpPost(endpoint + REST_PREFIX + namespace + ZK_REALM_ENDPOINT + testZkRealm); try { CloseableHttpResponse postResponse = httpClient.execute(postRequest); System.out.println(postResponse.toString()); } catch (IOException e) { e.printStackTrace(); } server.stopServer(); System.out.println("MockMetadataStoreDirectoryServer test passed!"); }