Package hudson.util

Examples of hudson.util.XStream2.fromXML()


    public void testUpgrade()
            throws IOException, InterruptedException {

        XStream2 xs = new XStream2();
        InputStream is = FirstFailureTriggerTest.class.getResourceAsStream("oldformat.xml");
        FirstFailureTrigger t = (FirstFailureTrigger) xs.fromXML(is);
        assertEquals(t.failureCount, 1);
    }
}
View Full Code Here


        String plainPassword = "plain-password";
        String oldXml = "<hudson.plugins.deploy.glassfish.GlassFish3xAdapter><userName>manager</userName><password>"
            + plainPassword + "</password><home>/</home><hostname></hostname></hudson.plugins.deploy.glassfish.GlassFish3xAdapter>";
        XStream2 xs = new XStream2();

        PasswordProtectedAdapterCargo adapter = (PasswordProtectedAdapterCargo)xs.fromXML(oldXml);
        Assert.assertEquals(plainPassword, adapter.getPassword());
       
        String newXml = xs.toXML(adapter);
        Assert.assertThat("Password should be scrambled", newXml, CoreMatchers.not(JUnitMatchers.containsString(plainPassword)));
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private static <T> T reserialize(T object) {
        XStream2 xs = new XStream2();
        String xml = xs.toXML(object);
        System.out.println(xml);
        return (T) xs.fromXML(xml);
    }

    private static class Thing {
        final int number;
        Thing(int number) {
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertNotNull(readT.getEntity().getThisBuild());
        assertThat("Event is not a ChangeBasedEvent", readT.getEntity().getEvent(), instanceOf(ChangeBasedEvent.class));
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertTrue(readT.getEntity().getEvent() instanceof PatchsetCreated);
        assertNotNull(readT.getEntity().getThisBuild());
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertTrue(readT.getEntity().getEvent() instanceof ChangeAbandoned);
        assertNotNull(readT.getEntity().getThisBuild());
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertTrue(readT.getEntity().getEvent() instanceof ChangeMerged);
        assertNotNull(readT.getEntity().getThisBuild());
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertTrue(readT.getEntity().getEvent() instanceof ChangeRestored);
        assertNotNull(readT.getEntity().getThisBuild());
View Full Code Here

     */
    @Test
    public void testUnmarshalOldData1() throws Exception {
        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        Object obj = xStream.fromXML(getClass().getResourceAsStream("retriggerAction_oldData.xml"));
        assertTrue(obj instanceof RetriggerAction);
        RetriggerAction action = (RetriggerAction)obj;
        TriggerContext context = Whitebox.getInternalState(action, "context");
        assertNotNull(context.getEvent());
        assertThat("Event is not a ChangeBasedEvent", context.getEvent(), instanceOf(ChangeBasedEvent.class));
View Full Code Here

        XStream xStream = new XStream2();
        xStream.registerConverter(new TriggerContextConverter());
        String xml = xStream.toXML(t);

        TestMarshalClass readT = (TestMarshalClass)xStream.fromXML(xml);

        assertNotNull(readT.getEntity());
        assertNotNull(readT.getEntity().getEvent());
        assertTrue(readT.getEntity().getEvent() instanceof DraftPublished);
        assertNotNull(readT.getEntity().getThisBuild());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.