Code example for ByteArrayOutputStream

Methods: toByteArray

0
    String format = "foo \n bar";
    repository.setCommitMessageFormat(format);
    myTaskManager.setRepositories(Collections.singletonList(repository));
    TaskManagerImpl.Config config = myTaskManager.getState();
    Element element = XmlSerializer.serialize(config);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    JDOMUtil.writeDocument(new Document(element), stream, "\n");
 
    Document document = JDOMUtil.loadDocument(new ByteArrayInputStream(stream.toByteArray()));
    TaskManagerImpl.Config deserialize = XmlSerializer.deserialize(document, TaskManagerImpl.Config.class);
    myTaskManager.loadState(deserialize);
 
    TaskRepository[] repositories = myTaskManager.getAllRepositories();
    assertEquals(format, repositories[0].getCommitMessageFormat());
  } 
}