Пример #1
0
  @Test
  public void marshallTest()
      throws TransformerConfigurationException, TransformerException,
          TransformerFactoryConfigurationError {
    Job job = new Job();
    job.setSessionId(1);
    job.setName("Test");
    job.setDescription("Test Desc");

    List<Integer> start = new ArrayList<Integer>();
    start.add(1);
    start.add(2);

    job.setFirst(start);

    List<Integer> end = new ArrayList<Integer>();
    end.add(1);
    end.add(2);

    job.setLast(end);

    List<JobTask> tasks = new ArrayList<JobTask>();
    tasks.add(new JobTask(1, 1, "source/file/path", "result/file/path"));
    tasks.add(new JobTask(2, 1, "source/file/path", "result/file/path"));
    tasks.add(new JobTask(3, 1, "source/file/path", "result/file/path"));

    job.setTasks(tasks);

    DOMResult result = new DOMResult();
    marshaller.marshal(job, result);

    StringWriter writer = new StringWriter();
    TransformerFactory.newInstance()
        .newTransformer()
        .transform(new DOMSource(result.getNode()), new StreamResult(writer));

    String textResult = writer.toString();

    assertNotNull(textResult);
  }