Package org.springframework.batch.admin.web

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


    model.put("endJobInstance", 30);
    model.put("totalJobInstances", 100);
    job.render(model, request, response);
    String content = response.getContentAsString();
    //    System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals(1, wrapper.get("job.jobInstances", Map.class).size());
    assertEquals(3, wrapper.get("job", Map.class).size());
  }
View Full Code Here


    errors.reject("no.such.job", "No such Job");
    model.put("baseUrl", "http://localhost:8080/springsource");
    job.render(model, request, response);
    String content = response.getContentAsString();
    // System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals(1, wrapper.get("errors", Map.class).size());
    assertEquals("No such Job", wrapper.get("errors['no.such.job']"));
  }
View Full Code Here

    errors.reject("job.already.complete", "Already complete");
    model.put("baseUrl", "http://localhost:8080/springsource");
    job.render(model, request, response);
    String content = response.getContentAsString();
    // System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals(1, wrapper.get("errors", Map.class).size());
    assertEquals("Already complete", wrapper.get("errors['job.already.complete']"));
  }
View Full Code Here

        123456789L), Arrays.asList(MetaDataInstanceFactory.createJobExecution()), TimeZone.getTimeZone("GMT"))));
    model.put("baseUrl", "http://localhost:8080/springsource");
    job.render(model, request, response);
    String content = response.getContentAsString();
    //    System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals("STARTING", wrapper.get("job.jobInstances['123456789'].lastJobExecutionStatus", String.class));
  }
View Full Code Here

    model.put("nextJob", 31);
    model.put("previousJob", 21);
    jobs.render(model, request, response);
    String content = response.getContentAsString();
    // System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals(2, wrapper.get("jobs.registrations", Map.class).size());
    assertEquals(5, wrapper.get("page", Map.class).size());
  }
View Full Code Here

    model.put("endJob", 30);
    model.put("totalJobs", 100);
    jobs.render(model, request, response);
    String content = response.getContentAsString();
    // System.err.println(content);
    JsonWrapper wrapper = new JsonWrapper(content);
    assertEquals(2, wrapper.get("jobs.registrations", Map.class).size());
    assertEquals(1, wrapper.getMap().size()); // no pages
  }
View Full Code Here

  @Test
  public void testHomePage() throws Exception {
    RestTemplate template = new RestTemplate();
    ResponseEntity<String> result = template.exchange(serverRunning.getUrl() + "/home.json", HttpMethod.GET, null,
        String.class);
    JsonWrapper wrapper = new JsonWrapper(result.getBody());
    assertNotNull(wrapper.get("feed.resources"));
    assertNotNull(wrapper.get("feed.resources['/files'].uri"));
  }
View Full Code Here

  @Test
  public void testJobsPage() throws Exception {
    RestTemplate template = new RestTemplate();
    ResponseEntity<String> result = template.exchange(serverRunning.getUrl() + "/jobs.json", HttpMethod.GET, null,
        String.class);
    JsonWrapper wrapper = new JsonWrapper(result.getBody());
    // System.err.println(wrapper);
    assertNotNull(wrapper.get("jobs.resource"));
    assertNotNull(wrapper.get("jobs.registrations.infinite.name"));
  }
View Full Code Here

    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

  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"));
    assertNotNull(wrapper.get("jobExecution.id"));

    // 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);
        Map<?, ?> map = wrapper.get("jobExecution.stepExecutions", Map.class);
        return map.isEmpty() || wrapper.get("jobExecution.stepExecutions['job2.step1']['resource']") == null ? null
            : wrapper;
      }
    });
    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"));
    assertNotNull(wrapper.get("stepExecution.status"));
    assertNotNull(wrapper.get("jobExecution.resource"));
    assertNotNull(wrapper.get("jobExecution.status"));
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.