Examples of loadAs()


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

        Yaml yaml = new Yaml(representer);
        String output = yaml.dump(c);
        assertEquals(Util.getLocalResource("javabeans/mycar-with-global-tag1.yaml"), output);
        // load
        Yaml beanLoader = new Yaml();
        MyCar car = beanLoader.loadAs(output, MyCar.class);
        assertNotNull(car);
        assertEquals("00-FF-Q2", car.getPlate());
        assertEquals(5, car.getWheels().size());
        for (Date d : car.getWheels().values()) {
            // give a day for any timezone
View Full Code Here

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

    public void testYaml() {
        String serialized = Util.getLocalResource("issues/issue73-2.txt");
        // System.out.println(serialized);
        Yaml beanLoader = new Yaml();
        beanLoader.setBeanAccess(BeanAccess.FIELD);
        Blog rehydrated = beanLoader.loadAs(serialized, Blog.class);
        checkTestBlog(rehydrated);
    }

    protected void checkTestBlog(Blog blog) {
        Set<Post> posts = blog.getPosts();
View Full Code Here

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

        String serialized = yamlDumper.dumpAsMap(original);
        // System.out.println(serialized);
        assertEquals(Util.getLocalResource("issues/issue55_1.txt"), serialized);
        Yaml blogLoader = new Yaml();
        blogLoader.setBeanAccess(BeanAccess.FIELD);
        Blog rehydrated = blogLoader.loadAs(serialized, Blog.class);
        checkTestBlog(rehydrated);
    }

    @SuppressWarnings("unchecked")
    public void testYamlWithoutConfiguration() {
View Full Code Here

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

    }

    public void testYamlFailure() {
        Yaml beanLoader = new Yaml();
        try {
            beanLoader.loadAs(Util.getLocalResource("issues/issue55_1.txt"), Blog.class);
            fail("BeanAccess.FIELD is required.");
        } catch (Exception e) {
            assertTrue(e.getMessage(), e.getMessage().contains("Unable to find property 'posts'"));
        }
    }
View Full Code Here

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

public class JavaBeanListTest extends TestCase {

    public void testYaml() {
        Yaml beanLoader = new Yaml();
        beanLoader.setBeanAccess(BeanAccess.FIELD);
        BlogBean rehydrated = (BlogBean) beanLoader.loadAs(
                Util.getLocalResource("issues/issue55_2.txt"), BlogBean.class);
        assertEquals(4, rehydrated.getPosts().size());
    }

    public void testFailureWithoutFieldAccess() {
View Full Code Here

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

    }

    public void testFailureWithoutFieldAccess() {
        Yaml beanLoader = new Yaml();
        try {
            beanLoader.loadAs(Util.getLocalResource("issues/issue55_2.txt"), BlogBean.class);
            fail("Private field must not be available");
        } catch (Exception e) {
            assertTrue(e.getMessage().contains("Unable to find property 'posts'"));
        }
    }
View Full Code Here

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

public class FieldListTest extends TestCase {

    public void testYaml() {
        Yaml beanLoader = new Yaml();
        beanLoader.setBeanAccess(BeanAccess.FIELD);
        BlogField rehydrated = beanLoader.loadAs(Util.getLocalResource("issues/issue55_2.txt"),
                BlogField.class);
        assertEquals(4, rehydrated.getPosts().size());
    }

    public void testFailureWithoutFieldAccess() {
View Full Code Here

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

    }

    public void testFailureWithoutFieldAccess() {
        Yaml beanLoader = new Yaml();
        try {
            beanLoader.loadAs(Util.getLocalResource("issues/issue55_2.txt"), BlogField.class);
            fail("Private field must not be available");
        } catch (Exception e) {
            assertTrue(e.getMessage().contains("Unable to find property 'posts'"));
        }
    }
View Full Code Here

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

        BeanData bean = new BeanData();
        bean.setId("id1");
        bean.setNumber(3.5f);
        Yaml yaml = new Yaml();
        String txt = yaml.dump(bean);
        BeanData parsed = yaml.loadAs(txt, BeanData.class);
        assertEquals(3.5f, parsed.getNumber());
    }

    public void testCompact() {
        Yaml yaml = new Yaml(new CompactConstructor());
View Full Code Here

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

        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        Human son2 = beanLoader.loadAs(output, Human.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());

        Human father2 = son2.getFather();
        assertEquals("Father", father2.getName());
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.