Package io.fabric8.etcd.api

Examples of io.fabric8.etcd.api.Response


  }

  @Override
  public INodeStatistics getNodeStats(String nodeId) {
    if (nodeId != null) {
      CamelProcessorMBean processorMBean = camelContextNode.getProcessorMBean(nodeId);
      if (processorMBean != null) {
        return new ProcessorNodeStatistics(processorMBean);
      }
    }
    return null;
View Full Code Here


        this.reader = reader;
    }

    public Response apply(HttpResponse response) {
        HttpEntity entity = response.getEntity();
        Response result = null;
        try {
            result = reader.read(entity.getContent());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (result.getErrorCode() != 0) {
            throw new EtcdException(result.getMessage(), result.getErrorCode());
        }
        return result;
    }
View Full Code Here

    private static final Gson GSON = new GsonBuilder().create();

    @Override
    public Response read(InputStream is) throws IOException {
        Response response = null;
        try (InputStreamReader isr = new InputStreamReader(is); JsonReader reader = new JsonReader(isr)) {
            response = GSON.fromJson(reader, ImmutableResponse.class);
        }
        return response;
    }
View Full Code Here

        assertEquals("Hello world", response.getPrevNode().getValue());
    }

    @Test
    public void testReadGetResponse() throws Exception {
        Response response = getResponseReader().read(getClass().getClassLoader().getResourceAsStream("get-response-1.json"));
        assertNotNull(response);
        assertEquals("get", response.getAction());
        assertNotNull(response.getNode());
        assertEquals("/message", response.getNode().getKey());
        assertEquals("Hello world", response.getNode().getValue());
    }
View Full Code Here

        assertEquals("Hello world", response.getNode().getValue());
    }

    @Test
    public void testReadDeleteResponse() throws Exception {
        Response response = getResponseReader().read(getClass().getClassLoader().getResourceAsStream("delete-response-1.json"));
        assertNotNull(response);
        assertEquals("delete", response.getAction());
        assertEquals("/message", response.getNode().getKey());
        assertNotNull(response.getNode());
        assertNull(response.getNode().getValue());
        assertNotNull(response.getPrevNode());
        assertEquals("Hello etcd", response.getPrevNode().getValue());
    }
View Full Code Here

                .setBody(Resources.toString(getClass()
                                .getClassLoader()
                                .getResource("get-response-1.json"),
                        Charsets.UTF_8)));

        Response response = client.getData().forKey("message");
        assertNotNull(response);
        assertEquals("get", response.getAction());
        assertEquals("Hello world", response.getNode().getValue());

        RecordedRequest request = server.takeRequest();
        assertEquals("GET",request.getMethod());
        assertTrue(request.getPath().startsWith(Keys.makeKey("message")));
        assertFalse(request.getPath().contains("recursive=true"));
View Full Code Here

                                .getClassLoader()
                                .getResource("get-response-1.json"),
                        Charsets.UTF_8)));

        Future<Response> futureResponse = client.getData().watch().forKey("message");
        Response response = futureResponse.get();
        assertNotNull(response);
        assertEquals("get", response.getAction());
        assertEquals("Hello world", response.getNode().getValue());

        RecordedRequest request = server.takeRequest();
        assertEquals("GET",request.getMethod());
        assertTrue(request.getPath().startsWith(Keys.makeKey("message")));
        assertFalse(request.getPath().contains("recursive=true"));
View Full Code Here

                .setBody(Resources.toString(getClass()
                                .getClassLoader()
                                .getResource("set-response-1.json"),
                        Charsets.UTF_8)));

        Response response = client.setData().value("Hello world").forKey("message");
        assertNotNull(response);
        assertEquals("set", response.getAction());
        assertEquals("Hello world", response.getNode().getValue());

        RecordedRequest request = server.takeRequest();
        assertEquals("PUT",request.getMethod());
        assertTrue(request.getPath().startsWith(Keys.makeKey("message")));
        assertTrue(request.getPath().contains("value=Hello+world"));
View Full Code Here

                .setBody(Resources.toString(getClass()
                                .getClassLoader()
                                .getResource("compare-and-swap-response-2.json"),
                        Charsets.UTF_8)));

        Response response = client.setData().prevValue("Hello world").value("Hello etcd").forKey("message");
        assertNotNull(response);
        assertEquals("compareAndSwap", response.getAction());
        assertEquals("Hello etcd", response.getNode().getValue());

        RecordedRequest request = server.takeRequest();
        assertEquals("PUT",request.getMethod());
        assertTrue(request.getPath().startsWith(Keys.makeKey("message")));
        assertTrue(request.getPath().contains("value=Hello+etcd"));
View Full Code Here

                .setBody(Resources.toString(getClass()
                                .getClassLoader()
                                .getResource("delete-response-1.json"),
                        Charsets.UTF_8)));

        Response response = client.delete().forKey("message");
        assertNotNull(response);
        assertEquals("delete", response.getAction());
        assertNotNull(response.getNode());
        assertNull(response.getNode().getValue());
        assertNotNull(response.getPrevNode());
        assertEquals("Hello etcd", response.getPrevNode().getValue());

        RecordedRequest request = server.takeRequest();
        assertEquals("DELETE",request.getMethod());
        assertTrue(request.getPath().startsWith(Keys.makeKey("message")));
        server.shutdown();
View Full Code Here

TOP

Related Classes of io.fabric8.etcd.api.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.