Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml.serialize()


    public void testDump() {
        Yaml yaml = new Yaml();
        Node intNode = yaml.represent(7);
        assertEquals("tag:yaml.org,2002:int", intNode.getTag().toString());
        // System.out.println(intNode);
        List<Event> intEvents = yaml.serialize(intNode);
        String tag = ((ScalarEvent) intEvents.get(2)).getTag();
        assertEquals("Without the tag emitter would not know how to emit '7'",
                "tag:yaml.org,2002:int", tag);
        //
        Node strNode = yaml.represent("7");
View Full Code Here


        // System.out.println(node);
        assertEquals(
                "Representation tree from an object and from its YAML document must be the same.",
                yaml.compose(new StringReader(etalon)).toString(), node.toString());
        //
        List<Event> events = yaml.serialize(node);
        int i = 0;
        for (Event etalonEvent : yaml.parse(new StringReader(etalon))) {
            Event ev1 = events.get(i++);
            assertEquals(etalonEvent.getClass(), ev1.getClass());
            if (etalonEvent instanceof ScalarEvent) {
View Full Code Here

        Yaml dumper2 = new Yaml(new JodaTimeRepresenter(), options2);
        Node node2 = dumper2.represent(bean);
        assertEquals(node2.toString(), node1.toString());
        // compare Events with flow style AUTO and flow style BLOCK
        List<Event> events1 = dumper.serialize(node1);
        List<Event> events2 = dumper2.serialize(node2);
        assertEquals(events2.size(), events1.size());
        int i = 0;
        for (Event etalonEvent : events2) {
            assertEquals(etalonEvent, events1.get(i++));
            if (etalonEvent instanceof ScalarEvent) {
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.