Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.DumperOptions


        // System.out.println(output);
        assertEquals("í\n", output);
    }

    public void testDoubleQuotedStyle() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
        Yaml yaml = new Yaml(options);
        String output = yaml.dump("í");
        // System.out.println(output);
        assertEquals("\"í\"\n", output);
    }
View Full Code Here


        String output1 = yaml.dumpAs(bean, new Tag("!!foo.bar"), null);
        assertEquals("!!foo.bar\na: aaa\nnumbers: [1, 2, 3]\n", output1);
    }

    public void testDumperNullStyle2() {
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        Bean124 bean = new Bean124();
        String output1 = yaml.dumpAs(bean, new Tag("!!foo2.bar2"), null);
        assertEquals("!!foo2.bar2\na: aaa\nnumbers:\n- 1\n- 2\n- 3\n", output1);
    }
View Full Code Here

    /**
     * test fix for issue 18 -
     * http://code.google.com/p/snakeyaml/issues/detail?id=18
     */
    public void testLong() {
        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        Yaml yaml = new Yaml(options);
        Foo foo = new Foo();
        String output = yaml.dump(foo);
        // System.out.println(output);
        Foo foo2 = (Foo) yaml.load(output);
View Full Code Here

        }
    }

    public void testRepresenterNoConstructorAvailable() {
        MyBean2 bean = new MyBean2("Gnome", true);
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        assertEquals("!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean2 {valid: true}\n",
                yaml.dump(bean));
    }
View Full Code Here

        }
    }

    public void testRepresenterGetterWithException() {
        MyBean3 bean = new MyBean3("Gnome", false);
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        try {
            String str = yaml.dump(bean);
            fail("Exception must be reported: " + str);
        } catch (Exception e) {
View Full Code Here

        reminders.put("today", "do nothig");
        reminders.put("tomorrow", "go shoping");
        house.setReminders(reminders);
        house.setNumber(1);
        house.setStreet("Wall Street");
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(FlowStyle.BLOCK);
        Yaml beanDumper = new Yaml(options);
        String yaml = beanDumper.dump(house);
        String etalon = Util.getLocalResource("javabeans/house-dump2.yaml");
        assertEquals(etalon, yaml);
        // load
View Full Code Here

    public void testDoNotFilterPropertyIncludeReadOnly() {
        BeanToRemoveProperty bean = new BeanToRemoveProperty();
        bean.setNumber(26);
        bean.setId("ID126");
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        String dump = yaml.dump(bean);
        // System.out.println(dump);
        assertEquals(
                "!!org.yaml.snakeyaml.representer.FilterPropertyToDumpTest$BeanToRemoveProperty {id: ID126,\n  number: 26, something: true}\n",
View Full Code Here

    public void testMap() throws Exception {
        BeanWithMap fact = new BeanWithMap();
        GenericMap<Integer> shash = fact.getMap();
        shash.put("toto", new Integer(10));
        DumperOptions options = new DumperOptions();
        options.setAllowReadOnlyProperties(true);
        Yaml yaml = new Yaml(options);
        // String txt = yaml.dump(fact);
        // assertTrue(txt.contains("org.yaml.snakeyaml.issues.issue143.GenericMapTest"));
    }
View Full Code Here

        // System.out.println(result);
        assertEquals(result, yaml.dump(yaml.load(result)));
    }

    public void testJavaStackTraceWithNoSpecialCharacters() {
        DumperOptions options = new DumperOptions();
        options.setWidth(50);
        Yaml yaml = new Yaml(options);
        String input = Util.getLocalResource("representer/stacktrace2.txt");
        assertEquals(-1, input.indexOf(':'));
        assertEquals(-1, input.indexOf('\t'));
        String result = yaml.dump(input);
View Full Code Here

        String output = yaml.dump(new Date());
        assertTrue(output, output.endsWith("Z\n"));
    }

    public void testTimezone() {
        DumperOptions options = new DumperOptions();
        options.setTimeZone(TimeZone.getTimeZone("GMT+1:00"));
        Yaml yaml = new Yaml(options);
        Date date = new Date();
        String output = yaml.dump(date);
        // System.out.println(output);
        assertTrue(output, output.trim().endsWith("+1:00"));
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.DumperOptions

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.