Package org.codehaus.jackson.mrbean

Examples of org.codehaus.jackson.mrbean.AbstractTypeMaterializer


    /**
     * First test verifies that bean builder works as expected
     */
    public void testLowLevelMaterializer() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        Class<?> impl = mat.materializeClass(config, Bean.class);
        assertNotNull(impl);
        assertTrue(Bean.class.isAssignableFrom(impl));
        // also, let's instantiate to make sure:
        Object ob = impl.newInstance();
        // and just for good measure do actual cast
        Bean bean = (Bean) ob;
        // call something to ensure generation worked...
        assertNull(bean.getA());

        // Also: let's verify that we can handle dup calls:
        Class<?> impl2 = mat.materializeClass(config, Bean.class);
        assertNotNull(impl2);
        assertSame(impl, impl2);
    }
View Full Code Here


        assertSame(impl, impl2);
    }

    public void testLowLevelMaterializerFailOnIncompatible() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        try {
            mat.materializeClass(config, InvalidBean.class);
            fail("Expected exception for incompatible property types");
        } catch (IllegalArgumentException e) {
            verifyException(e, "incompatible types");
        }
    }
View Full Code Here

        }
    }

    public void testLowLevelMaterializerFailOnUnrecognized() throws Exception
    {
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        //  by default early failure is disabled, enable:
        mat.enable(AbstractTypeMaterializer.Feature.FAIL_ON_UNMATERIALIZED_METHOD);
        DeserializationConfig config = new ObjectMapper().getDeserializationConfig();
        try {
            mat.materializeClass(config, PartialBean.class);
            fail("Expected exception for unrecognized method");
        } catch (IllegalArgumentException e) {
            verifyException(e, "Unrecognized abstract method 'foobar'");
        }       
    }
View Full Code Here

     * for "unknown" abstract methods
     */
    public void testPartialBean() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
        // ensure that we will only get deferred error methods
        mat.disable(AbstractTypeMaterializer.Feature.FAIL_ON_UNMATERIALIZED_METHOD);
        mapper.registerModule(new MrBeanModule(mat));
        PartialBean bean = mapper.readValue("{\"ok\":true}", PartialBean.class);
        assertNotNull(bean);
        assertTrue(bean.isOk());
        // and then exception
View Full Code Here

    }

    public void testMrBeanVersions()
    {
        if (runsFromAnt()) {
            assertVersion(new AbstractTypeMaterializer().version(), MAJOR_VERSION, MINOR_VERSION);
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.mrbean.AbstractTypeMaterializer

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.