Search in sources :

Example 11 with XmlFile

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);
    }
}
Also used : XmlFile(hudson.XmlFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 12 with XmlFile

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();
    }
}
Also used : XmlFile(hudson.XmlFile) XmlFile(hudson.XmlFile) File(java.io.File)

Example 13 with XmlFile

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();
    }
}
Also used : XmlFile(hudson.XmlFile) XmlFile(hudson.XmlFile) File(java.io.File)

Example 14 with XmlFile

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();
}
Also used : XmlFile(hudson.XmlFile) IOException(java.io.IOException)

Aggregations

XmlFile (hudson.XmlFile)14 IOException (java.io.IOException)8 File (java.io.File)6 FileFilter (java.io.FileFilter)2 ArrayList (java.util.ArrayList)2 ANTLRException (antlr.ANTLRException)1 ExtensionList (hudson.ExtensionList)1 ExtensionListView (hudson.ExtensionListView)1 ExtensionPoint (hudson.ExtensionPoint)1 RestartNotSupportedException (hudson.lifecycle.RestartNotSupportedException)1 FormException (hudson.model.Descriptor.FormException)1 AbstractQueueTask (hudson.model.queue.AbstractQueueTask)1 SubTask (hudson.model.queue.SubTask)1 FullControlOnceLoggedInAuthorizationStrategy (hudson.security.FullControlOnceLoggedInAuthorizationStrategy)1 LegacySecurityRealm (hudson.security.LegacySecurityRealm)1 NodeList (hudson.slaves.NodeList)1 SafeTimerTask (hudson.triggers.SafeTimerTask)1 AtomicFileWriter (hudson.util.AtomicFileWriter)1 IOException2 (hudson.util.IOException2)1 TextFile (hudson.util.TextFile)1