Package hudson.util

Examples of hudson.util.XStream2


    // Process form data and show it as serialized XML
    public void doSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
        // stapler-class in form data tells Stapler which Fruit subclass to use
        Fruit fruit = req.bindJSON(Fruit.class, req.getSubmittedForm().getJSONObject("fruit"));
        rsp.setContentType("text/plain");
        new XStream2().toXML(fruit, rsp.getWriter());
    }
View Full Code Here


    @Test
    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

        @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            try {
                ServletFileUpload f = new ServletFileUpload(new DiskFileItemFactory());
                List<?> v = f.parseRequest(req);
                assertEquals(1,v.size());
                XStream2 xs = new XStream2();
                System.out.println(xs.toXML(v.get(0)));
            } catch (FileUploadException e) {
                throw new ServletException(e);
            }
        }
View Full Code Here

    @Test
    public void testDeserializeOldPlainPassword () {
        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

        getTargetConfigFile(XSTREAM).write(item);
        getTargetConfigFile(XSTREAM).read();
    }

    private XStream initXStream() {
        XStream XSTREAM = new XStream2();
        XSTREAM.alias("project", FreeStyleProject.class);
        XSTREAM.alias("build", FreeStyleBuild.class);
        return XSTREAM;
    }
View Full Code Here

    private XmlFile getTargetConfigFile(XStream XSTREAM) {
        return new XmlFile(XSTREAM, targetConfigFile);
    }

    private XStream initXStream() {
        XStream XSTREAM = new XStream2();
        XSTREAM.alias("project", FreeStyleProject.class);
        XSTREAM.alias("build", FreeStyleBuild.class);
        return XSTREAM;
    }
View Full Code Here

        block.finishSuccess(null);
    }

    @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);
    }
View Full Code Here

        context.setThisBuild(entity);
        context.setOthers(new LinkedList<TriggeredItemEntity>());

        TestMarshalClass t = new TestMarshalClass(context, "Bobby", new TestMarshalClass(context, "SomeoneElse"));

        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

        TestMarshalClass t = new TestMarshalClass(context, "Me", new TestMarshalClass(context, "SomeoneElse"));

        XStream xStream = null;
        String xml = null;
        try {
            xStream = new XStream2();
            xStream.registerConverter(new TriggerContextConverter());
            xml = xStream.toXML(t);
        } catch (Exception e) {
            AssertionError error = new AssertionError("This should work, but did not. " + e.getMessage());
            error.initCause(e);
View Full Code Here

        TestMarshalClass t = new TestMarshalClass(context, "Me", new TestMarshalClass(context, "SomeoneElse"));

        XStream xStream = null;
        String xml = null;
        try {
            xStream = new XStream2();
            xStream.registerConverter(new TriggerContextConverter());
            xml = xStream.toXML(t);
        } catch (Exception e) {
            AssertionError error = new AssertionError("This should work, but did not. " + e.getMessage());
            error.initCause(e);
View Full Code Here

TOP

Related Classes of hudson.util.XStream2

Copyright © 2018 www.massapicom. 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.