Consul { public boolean createPermanentData(final String name, final String data) { final Response response = httpClient .target(endpoint) .path("/v1/kv/").path(name) .queryParam("cas", "0") .request() .put(Entity.text(data)); if (response.getStatus() != Response.Status.OK.getStatusCode()) { LOG.log(Level.WARNING, "Could not create permanent value " + name + "/" + data + " got response " + response.getStatus() + " but expected 200"); return false; } final String result = response.readEntity(String.class); if (result.equals("true")) { return true; } return false; } Consul(final String endpoint); boolean isValid(); ConsulSession createSession(final String name, final int ttlMs, final int lockDelay); boolean writeSessionData(final String name, final String data, final String sessionId); boolean createPermanentData(final String name, final String data); boolean writePermanentData(
            final String name, final String data); boolean removePermanentData(final String name); String readData(final String name); ConsulWatch createWatch(final String pathToWatch); static final int DEFAULT_LOCK_DELAY; }
@Test public void createPermanentData() { final Consul consul = new Consul(System.getProperty(EP_PROPERTY)); assertTrue(consul.isValid()); final String keyName = "thepermanentone"; consul.removePermanentData(keyName); assertTrue(consul.createPermanentData(keyName, "SomeValue")); assertFalse(consul.createPermanentData(keyName, "AlreadyExists")); assertThat(consul.readData(keyName), is("SomeValue")); assertTrue(consul.writePermanentData(keyName, "OtherValue")); assertThat(consul.readData(keyName), is("OtherValue")); assertTrue(consul.removePermanentData(keyName)); }