Package org.springframework.batch.admin.web

Examples of org.springframework.batch.admin.web.JsonWrapper


    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"));
    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>() {
      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;
      }
    });
    JsonWrapper jobExecution = poll.get(500L, TimeUnit.MILLISECONDS);
    assertNotNull(jobExecution);

    BatchStatus status = jobExecution.get("jobExecution.status", BatchStatus.class);
    assertEquals(BatchStatus.STOPPED, status);

  }
View Full Code Here


        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

TOP

Related Classes of org.springframework.batch.admin.web.JsonWrapper

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.