Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.TypeDescription


        assertEquals(carYaml1, new Yaml().dump(car2));
    }

    public void testLoadClassTag() {
        Constructor constructor = new Constructor();
        constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
        Yaml yaml = new Yaml(constructor);
        Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
        assertEquals("12-XP-F4", car.getPlate());
        List<Wheel> wheels = car.getWheels();
        assertNotNull(wheels);
View Full Code Here


public class TypeSafeCollectionsTest extends TestCase {

    public void testTypeSafeList() {
        Constructor constructor = new Constructor(Car.class);
        TypeDescription carDescription = new TypeDescription(Car.class);
        carDescription.putListPropertyType("wheels", Wheel.class);
        constructor.addTypeDescription(carDescription);
        Yaml yaml = new Yaml(constructor);
        Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
        assertEquals("12-XP-F4", car.getPlate());
        List<Wheel> wheels = car.getWheels();
View Full Code Here

        }
    }

    public void testTypeSafeMap() {
        Constructor constructor = new Constructor(MyCar.class);
        TypeDescription carDescription = new TypeDescription(MyCar.class);
        carDescription.putMapPropertyType("wheels", MyWheel.class, Object.class);
        constructor.addTypeDescription(carDescription);
        Yaml yaml = new Yaml(constructor);
        MyCar car = (MyCar) yaml.load(Util
                .getLocalResource("constructor/car-no-root-class-map.yaml"));
        assertEquals("00-FF-Q2", car.getPlate());
View Full Code Here

        assertEquals(Util.getLocalResource("constructor/cararray-with-tags.yaml"), yaml.dump(car));
    }

    public void testLoadClassTag() {
        Constructor constructor = new Constructor();
        constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
        Yaml yaml = new Yaml(constructor);
        Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
        assertEquals("12-XP-F4", car.getPlate());
        List<Wheel> wheels = car.getWheels();
        assertNotNull(wheels);
View Full Code Here

            assertEquals("TypeDescription is required.", e.getMessage());
        }
    }

    public void testLoadClassNoRoot() {
        Constructor constructor = new Constructor(new TypeDescription(CarWithArray.class));
        Yaml yaml = new Yaml(constructor);
        CarWithArray car = (CarWithArray) yaml.load(Util
                .getLocalResource("constructor/car-no-root-class.yaml"));
        assertEquals("12-XP-F4", car.getPlate());
        Wheel[] wheels = car.getWheels();
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testJavaBeanWithTypeDescription() {
        Constructor c = new CustomBeanConstructor();
        TypeDescription descr = new TypeDescription(CodeBean.class, new Tag(
                "!de.oddb.org,2007/ODDB::Util::Code"));
        c.addTypeDescription(descr);
        Yaml yaml = new Yaml(c);
        String input = Util.getLocalResource("issues/issue56-1.yaml");
        int counter = 0;
View Full Code Here

    }

    public void testLoadClassTag() {
        Constructor constructor = new Constructor();
        constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
        Yaml yaml = new Yaml(constructor);
        String source = Util.getLocalResource("constructor/car-without-tags.yaml");
        Car car = (Car) yaml.load(source);
        assertEquals("12-XP-F4", car.getPlate());
        List<Wheel> wheels = car.getWheels();
View Full Code Here

            assertEquals("TypeDescription is required.", e.getMessage());
        }
    }

    public void testLoadClassNoRoot() {
        Constructor constructor = new Constructor(new TypeDescription(Car.class));
        Yaml yaml = new Yaml(constructor);
        Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
        assertEquals("12-XP-F4", car.getPlate());
        List<Wheel> wheels = car.getWheels();
        assertNotNull(wheels);
View Full Code Here

        yaml2dump.setBeanAccess(BeanAccess.FIELD);
        A data = createA();
        String dump = yaml2dump.dump(data);
        // System.out.println(dump);

        TypeDescription aTypeDescr = new TypeDescription(A.class);
        aTypeDescr.putMapPropertyType("meta", String.class, String[].class);

        Constructor c = new Constructor();
        c.addTypeDescription(aTypeDescr);
        Yaml yaml2load = new Yaml(c);
        yaml2load.setBeanAccess(BeanAccess.FIELD);
View Full Code Here

        yaml2dump.setBeanAccess(BeanAccess.FIELD);
        B data = createB();
        String dump = yaml2dump.dump(data);
        // System.out.println(dump);

        TypeDescription aTypeDescr = new TypeDescription(B.class);
        aTypeDescr.putListPropertyType("meta", String[].class);

        Constructor c = new Constructor();
        c.addTypeDescription(aTypeDescr);
        Yaml yaml2load = new Yaml(c);
        yaml2load.setBeanAccess(BeanAccess.FIELD);
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.TypeDescription

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.