Exemplo n.º 1
0
  @Test
  public void testModelValidate() throws Exception {

    JAXBContext ctx = JAXBContext.newInstance("jsr352.batch.jsl");

    Unmarshaller u = ctx.createUnmarshaller();
    u.setSchema(ValidatorHelper.getXJCLSchema());
    XJCLValidationEventHandler handler = new XJCLValidationEventHandler();
    u.setEventHandler(handler);
    URL url = this.getClass().getResource("/job1.xml");

    // Use this for anonymous type
    // Job job = (Job)u.unmarshal(url.openStream());

    // Use this for named complex type
    Object elem = u.unmarshal(url.openStream());
    assertFalse("XSD invalid, see sysout", handler.eventOccurred());

    JSLJob job = (JSLJob) ((JAXBElement) elem).getValue();

    assertEquals("job1", job.getId());
    assertEquals(1, job.getExecutionElements().size());
    Step step = (Step) job.getExecutionElements().get(0);
    assertEquals("step1", step.getId());
    Batchlet b = step.getBatchlet();
    assertEquals("step1Ref", b.getRef());
  }
Exemplo n.º 2
0
  @Test
  public void testModelNoValidate() throws Exception {

    JAXBContext ctx = JAXBContext.newInstance("jsr352.batch.jsl");

    Unmarshaller u = ctx.createUnmarshaller();
    URL url = this.getClass().getResource("/job1.xml");

    // Use this for anonymous type
    // Job job = (Job)u.unmarshal(url.openStream());

    // Use this for named complex type
    Object elem = u.unmarshal(url.openStream());
    JSLJob job = (JSLJob) ((JAXBElement) elem).getValue();

    assertEquals("job1", job.getId());
    assertEquals(1, job.getExecutionElements().size());
    Step step = (Step) job.getExecutionElements().get(0);
    assertEquals("step1", step.getId());
    Batchlet b = step.getBatchlet();
    assertEquals("step1Ref", b.getRef());
  }