use of hudson.XmlFile in project hudson-2.x by hudson.
the class Queue method save.
/**
* Persists the queue contents to the disk.
*/
public synchronized void save() {
if (BulkChange.contains(this))
return;
// write out the tasks on the queue
ArrayList<Queue.Item> items = new ArrayList<Queue.Item>();
for (Item item : getItems()) {
if (item.task instanceof TransientTask)
continue;
items.add(item);
}
try {
XmlFile queueFile = new XmlFile(XSTREAM, getXMLQueueFile());
queueFile.write(items);
SaveableListener.fireOnChange(this, queueFile);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to write out the queue file " + getXMLQueueFile(), e);
}
}
use of hudson.XmlFile in project hudson-2.x by hudson.
the class SuiteResultTest method testSuiteResultPersistence.
public void testSuiteResultPersistence() throws Exception {
SuiteResult source = parseOne(getDataFile("junit-report-1233.xml"));
File dest = File.createTempFile("testSuiteResultPersistence", ".xml");
try {
XmlFile xmlFile = new XmlFile(dest);
xmlFile.write(source);
SuiteResult result = (SuiteResult) xmlFile.read();
assertNotNull(result);
assertEquals(source.getName(), result.getName());
assertEquals(source.getTimestamp(), result.getTimestamp());
assertEquals(source.getDuration(), result.getDuration());
assertEquals(source.getStderr(), result.getStderr());
assertEquals(source.getStdout(), result.getStdout());
assertEquals(source.getCases().size(), result.getCases().size());
assertNotNull(result.getCase("testGetBundle"));
} finally {
dest.delete();
}
}
use of hudson.XmlFile in project hudson-2.x by hudson.
the class NodeListTest method testSerialization.
public void testSerialization() throws Exception {
NodeList nl = new NodeList();
nl.add(new DummyNode());
nl.add(new EphemeralNode());
File tmp = File.createTempFile("test", "test");
try {
XmlFile x = new XmlFile(Hudson.XSTREAM, tmp);
x.write(nl);
String xml = FileUtils.readFileToString(tmp);
System.out.println(xml);
assertEquals(4, xml.split("\n").length);
NodeList back = (NodeList) x.read();
assertEquals(1, back.size());
assertEquals(DummyNode.class, back.get(0).getClass());
} finally {
tmp.delete();
}
}
use of hudson.XmlFile in project hudson-2.x by hudson.
the class LabelAtom method load.
public void load() {
XmlFile file = getConfigFile();
if (file.exists()) {
try {
file.unmarshal(this);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + file, e);
}
}
properties.setOwner(this);
updateTransientActions();
}
Aggregations