Source:
<code>public void testPutAndGet() throws URISyntaxException { elasticSearchCluster = app.createAndManageChild(EntitySpec.create(ElasticSearchCluster.class) .configure(DynamicCluster.INITIAL_SIZE, 3)); app.start(ImmutableList.of(testLocation)); EntityTestUtils.assertAttributeEqualsEventually(elasticSearchCluster, Startable.SERVICE_UP, true); assertEquals(elasticSearchCluster.getMembers().size(), 3); assertEquals(clusterDocumentCount(), 0); ElasticSearchNode anyNode = (ElasticSearchNode)elasticSearchCluster.getMembers().iterator().next(); String document = "{\"foo\" : \"bar\",\"baz\" : \"quux\"}"; String putBaseUri = "http://" + anyNode.getAttribute(Attributes.HOSTNAME) + ":" + anyNode.getAttribute(Attributes.HTTP_PORT); HttpToolResponse putResponse = HttpTool.httpPut( HttpTool.httpClientBuilder() .port(anyNode.getAttribute(Attributes.HTTP_PORT)) .build(), new URI(putBaseUri + "/mydocuments/docs/1"), ImmutableMap.<String, String>of(), Strings.toByteArray(document)); assertEquals(putResponse.getResponseCode(), 201); for (Entity entity : elasticSearchCluster.getMembers()) { ElasticSearchNode node = (ElasticSearchNode)entity; String getBaseUri = "http://" + node.getAttribute(Attributes.HOSTNAME) + ":" + node.getAttribute(Attributes.HTTP_PORT); HttpToolResponse getResponse = HttpTool.execAndConsume( HttpTool.httpClientBuilder().build(), new HttpGet(getBaseUri + "/mydocuments/docs/1/_source")); assertEquals(getResponse.getResponseCode(), 200); assertEquals(HttpValueFunctions.jsonContents("foo", String.class).apply(getResponse), "bar"); } Asserts.succeedsEventually(new Runnable() { public void run() { int count = clusterDocumentCount(); assertTrue(count >= 1, "count="+count); <START> LOG.info("Document count is "+count); <END> }}); }</code><technical_language>debug instead of info</technical_language>

Target:
public void testPutAndGet() throws URISyntaxException { elasticSearchCluster = app.createAndManageChild(EntitySpec.create(ElasticSearchCluster.class) .configure(DynamicCluster.INITIAL_SIZE, 3)); app.start(ImmutableList.of(testLocation)); EntityTestUtils.assertAttributeEqualsEventually(elasticSearchCluster, Startable.SERVICE_UP, true); assertEquals(elasticSearchCluster.getMembers().size(), 3); assertEquals(clusterDocumentCount(), 0); ElasticSearchNode anyNode = (ElasticSearchNode)elasticSearchCluster.getMembers().iterator().next(); String document = "{\"foo\" : \"bar\",\"baz\" : \"quux\"}"; String putBaseUri = "http://" + anyNode.getAttribute(Attributes.HOSTNAME) + ":" + anyNode.getAttribute(Attributes.HTTP_PORT); HttpToolResponse putResponse = HttpTool.httpPut( HttpTool.httpClientBuilder() .port(anyNode.getAttribute(Attributes.HTTP_PORT)) .build(), new URI(putBaseUri + "/mydocuments/docs/1"), ImmutableMap.<String, String>of(), Strings.toByteArray(document)); assertEquals(putResponse.getResponseCode(), 201); for (Entity entity : elasticSearchCluster.getMembers()) { ElasticSearchNode node = (ElasticSearchNode)entity; String getBaseUri = "http://" + node.getAttribute(Attributes.HOSTNAME) + ":" + node.getAttribute(Attributes.HTTP_PORT); HttpToolResponse getResponse = HttpTool.execAndConsume( HttpTool.httpClientBuilder().build(), new HttpGet(getBaseUri + "/mydocuments/docs/1/_source")); assertEquals(getResponse.getResponseCode(), 200); assertEquals(HttpValueFunctions.jsonContents("foo", String.class).apply(getResponse), "bar"); } Asserts.succeedsEventually(new Runnable() { public void run() { int count = clusterDocumentCount(); assertTrue(count >= 1, "count="+count); LOG.debug("Document count is {}", count); }}); }