Examples of loadAs()


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

    /**
     * local tag is ignored
     */
    public void testEmptyBean5() {
        Yaml beanLoader = new Yaml();
        EmptyBean bean = beanLoader.loadAs("!Bla-bla-bla {}", EmptyBean.class);
        assertNotNull(bean);
        assertNull(bean.getFirstName());
        assertEquals(5, bean.getHatSize());
    }

View Full Code Here

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

     * invalid document
     */
    public void testEmptyBean6() {
        Yaml beanLoader = new Yaml();
        try {
            beanLoader.loadAs("{", EmptyBean.class);
            fail("Invalid document provided.");
        } catch (Exception e) {
            assertEquals(
                    "while parsing a flow node; expected the node content, but found StreamEnd;  in 'string', line 1, column 2:\n    {\n     ^",
                    e.getMessage());
View Full Code Here

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

        String s = yaml.dumpAsMap(listProvider);
        // System.out.println(s);
        assertEquals("list:\n- foo\n- bar\n", s);
        // parse
        Yaml loader = new Yaml();
        ListProvider<String> listProvider2 = loader.loadAs(s, ListProvider.class);
        assertEquals("foo", listProvider2.getList().get(0));
        assertEquals("bar", listProvider2.getList().get(1));
        assertEquals(listProvider, listProvider2);
    }
View Full Code Here

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

        // System.out.println(s);
        String etalon = Util.getLocalResource("issues/issue61-1.yaml");
        assertEquals(etalon, s);
        // parse
        Yaml loader = new Yaml();
        ListProvider listProvider2 = loader.loadAs(s, ListProvider.class);
        Bean foo2 = (Bean) listProvider2.getList().get(0);
        assertEquals("foo", foo2.getName());
        assertEquals(0, foo2.getNumber());
        Bean bar2 = (Bean) listProvider2.getList().get(1);
        assertEquals("bar", bar2.getName());
View Full Code Here

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

    @Test
    public void ignoreImplicitTag() {
        Yaml yaml = yaml();
        try {
            yaml.loadAs(reader(), Car.class);
            fail();
        } catch (Exception e) {
            assertTrue(e
                    .getMessage()
                    .startsWith(
View Full Code Here

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

        Yaml yaml = new Yaml();
        String dump2 = yaml.dumpAsMap(customerAB);
        // System.out.println(dump2);
        Yaml loader = new Yaml();
        CustomerAB parsed = loader.loadAs(dump2, CustomerAB.class);
        assertNotNull(parsed);
    }

    public void testAB_asMapValue() {
        SuperSaverAccount supersaver = new SuperSaverAccount();
View Full Code Here

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

        String s = yaml.dumpAsMap(listProvider);
        // System.out.println(s);
        assertEquals("map:\n  foo: 17\n  bar: 19\n", s);
        // parse
        Yaml loader = new Yaml();
        MapProvider<String, Integer> listProvider2 = loader.loadAs(s, MapProvider.class);
        assertEquals(new Integer(17), listProvider2.getMap().get("foo"));
        assertEquals(new Integer(19), listProvider2.getMap().get("bar"));
        assertEquals(listProvider, listProvider2);
    }
View Full Code Here

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

        // System.out.println(s);
        String etalon = Util.getLocalResource("issues/issue61-2.yaml");
        assertEquals(etalon, s);
        // parse
        Yaml loader = new Yaml();
        MapProvider listProvider2 = loader.loadAs(s, MapProvider.class);
        Bean foo2 = (Bean) listProvider2.getMap().get("foo");
        assertEquals("foo", foo2.getName());
        assertEquals(0, foo2.getNumber());
        Bean bar2 = (Bean) listProvider2.getMap().get("bar");
        assertEquals("bar", bar2.getName());
View Full Code Here

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

        String output = beanDumper.dumpAsMap(bean);
        assertEquals(
                "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n  name: Triangle25\n",
                output);
        Yaml beanLoader = new Yaml();
        TriangleBean loadedBean = beanLoader.loadAs(output, TriangleBean.class);
        assertNotNull(loadedBean);
        assertEquals("Bean25", loadedBean.getName());
        assertEquals(7, loadedBean.getShape().process());
    }
View Full Code Here

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

    public void testClassNotFound() {
        String output = "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle777\n  name: Triangle25\n";
        Yaml beanLoader = new Yaml();
        try {
            beanLoader.loadAs(output, TriangleBean.class);
            fail("Class not found expected.");
        } catch (Exception e) {
            assertEquals(
                    "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.TriangleBean; exception=Cannot create property=shape for JavaBean=TriangleBean name=Bean25; null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.Triangle777; exception=Class not found: org.yaml.snakeyaml.javabeans.Triangle777;  in 'string', line 2, column 8:\n    shape: !!org.yaml.snakeyaml.javabeans.T ... \n           ^;  in 'string', line 1, column 1:\n    name: Bean25\n    ^",
                    e.getMessage());
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.