Package org.springframework.web.client

Examples of org.springframework.web.client.RestTemplate.exchange()


  @Test
  public void testJobConfigurationUpload() throws Exception {
    RestTemplate template = new RestTemplate();
    HttpEntity<String> request = new HttpEntity<String>(FileUtils.readFileToString(new File(
        "src/test/resources/test-job-context.xml")));
    ResponseEntity<String> result = template.exchange(serverRunning.getUrl() + "/job-configuration.json",
        HttpMethod.POST, request, String.class);
    JsonWrapper wrapper = new JsonWrapper(result.getBody());
    // System.err.println(wrapper);
    assertNotNull(wrapper.get("jobs.resource"));
    assertNotNull(wrapper.get("jobs.registrations['test-job'].name"));
View Full Code Here


  @Test
  public void testJobLaunch() throws Exception {

    RestTemplate template = new RestTemplate();
    ResponseEntity<String> result = template.exchange(serverRunning.getUrl() + "/jobs/job2.json?jobParameters=fail=true", HttpMethod.POST,
        null, String.class);
    JsonWrapper wrapper = new JsonWrapper(result.getBody());
    // System.err.println(wrapper);
    assertNotNull(wrapper.get("jobExecution.resource"));
    assertNotNull(wrapper.get("jobExecution.status"));
View Full Code Here

    final String resource = wrapper.get("jobExecution.resource", String.class);
    Poller<JsonWrapper> poller = new DirectPoller<JsonWrapper>(100L);
    Future<JsonWrapper> poll = poller.poll(new Callable<JsonWrapper>() {
      public JsonWrapper call() throws Exception {
        RestTemplate template = new RestTemplate();
        ResponseEntity<String> result = template.exchange(resource, HttpMethod.GET, null, String.class);
        JsonWrapper wrapper = new JsonWrapper(result.getBody());
        // System.err.println(wrapper);
        Map<?, ?> map = wrapper.get("jobExecution.stepExecutions", Map.class);
        return map.isEmpty() || wrapper.get("jobExecution.stepExecutions['job2.step1']['resource']") == null ? null
            : wrapper;
View Full Code Here

    JsonWrapper jobExecution = poll.get(500L, TimeUnit.MILLISECONDS);
    assertNotNull(jobExecution);
    // System.err.println(jobExecution);

    // Verify that there is a step execution in the result
    result = template.exchange(
        jobExecution.get("jobExecution.stepExecutions['job2.step1'].resource", String.class), HttpMethod.GET,
        null, String.class);
    wrapper = new JsonWrapper(result.getBody());
    // System.err.println(wrapper);
    assertNotNull(wrapper.get("stepExecution.id"));
View Full Code Here

  @Test
  public void testJobStop() throws Exception {

    RestTemplate template = new RestTemplate();
    ResponseEntity<String> result = template.exchange(serverRunning.getUrl()
        + "/jobs/infinite.json?jobParameters=timestamp=" + System.currentTimeMillis(), HttpMethod.POST, null,
        String.class);
    JsonWrapper wrapper = new JsonWrapper(result.getBody());
    // System.err.println(wrapper);
    assertNotNull(wrapper.get("jobExecution.resource"));
View Full Code Here

    // System.err.println(wrapper);
    assertNotNull(wrapper.get("jobExecution.resource"));
    assertNotNull(wrapper.get("jobExecution.status"));
    assertNotNull(wrapper.get("jobExecution.id"));

    template.exchange(wrapper.get("jobExecution.resource", String.class), HttpMethod.DELETE, null, String.class);

    // Poll for the completed job execution
    final String resource = wrapper.get("jobExecution.resource", String.class);
    Poller<JsonWrapper> poller = new DirectPoller<JsonWrapper>(100L);
    Future<JsonWrapper> poll = poller.poll(new Callable<JsonWrapper>() {
View Full Code Here

    final String resource = wrapper.get("jobExecution.resource", String.class);
    Poller<JsonWrapper> poller = new DirectPoller<JsonWrapper>(100L);
    Future<JsonWrapper> poll = poller.poll(new Callable<JsonWrapper>() {
      public JsonWrapper call() throws Exception {
        RestTemplate template = new RestTemplate();
        ResponseEntity<String> result = template.exchange(resource, HttpMethod.GET, null, String.class);
        JsonWrapper wrapper = new JsonWrapper(result.getBody());
        // System.err.println(wrapper);
        BatchStatus status = wrapper.get("jobExecution.status", BatchStatus.class);
        return status.isGreaterThan(BatchStatus.STOPPING) ? wrapper : null;
      }
View Full Code Here

    for (String path : properties.stringPropertyNames()) {
      if (!StringUtils.hasText(path) || !path.startsWith("GET")) {
        continue;
      }
      path = path.substring(path.indexOf("/"));
      ResponseEntity<String> result = template.exchange(serverRunning.getUrl() + path, HttpMethod.GET,
          null, String.class, params);
      JsonWrapper wrapper = new JsonWrapper(result.getBody());
      // System.err.println(wrapper);
      assertNotNull(wrapper);
    }
View Full Code Here

            ((TitledBorder) filesPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Files");
            projectsPanel.repaint();

            // load the project information
            RestTemplate template = new RestTemplate();
            ResponseEntity<ProjectDetail> entity = template.exchange(url, HttpMethod.GET, getHttpEntity(), ProjectDetail.class);

            if (entity.getStatusCode() != null && entity.getStatusCode().equals(HttpStatus.OK)) {

                ProjectDetail projectDetail = entity.getBody();
View Full Code Here

            try {
                ResponseEntity<FileDetailList> fileDetailListResult;

                if (password != null) {
                    fileDetailListResult = template.exchange(url, HttpMethod.GET, getHttpEntity(), FileDetailList.class);
                } else {
                    fileDetailListResult = template.getForEntity(url, FileDetailList.class);
                }

                int reshakeableCounter = 0;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.