Package org.mojavemvc.marshalling

Examples of org.mojavemvc.marshalling.JSONEntityMarshaller


    }
   
    @Test
    public void jsonEntityMarshallerSupportsJSONContentType() {
       
        JSONEntityMarshaller m = new JSONEntityMarshaller();
        String[] contentTypes = m.contentTypesHandled();
        assertEquals(1, contentTypes.length);
        assertEquals("application/json", contentTypes[0]);
    }
View Full Code Here


    }
   
    @Test
    public void jsonEntityMarshallerReturnsView() {
       
        JSONEntityMarshaller m = new JSONEntityMarshaller();
        SimplePojo entity = new SimplePojo("test");
        View v = m.marshall(entity);
        assertTrue(v instanceof JSON);
        assertEquals(new JSON(entity).toString(), ((JSON)v).toString());
    }
View Full Code Here

    }
   
    @Test
    public void jsonEntityMarshallerUnmarshalls() {
       
        JSONEntityMarshaller m = new JSONEntityMarshaller();
        String json = "{\"val\":\"test\"}";
        ByteArrayInputStream in = new ByteArrayInputStream(json.getBytes());
        SimplePojo entity = m.unmarshall(in, SimplePojo.class);
        assertNotNull(entity);
        assertEquals("test", entity.getVal());
    }
View Full Code Here

    /* Marshallable marshalling */
   
    @Test
    public void jsonEntityMarshallerHandlesMarshallable() {
       
        JSONEntityMarshaller m = new JSONEntityMarshaller();
        SimplePojo entity = new SimplePojo("test");
        MarshallablePojo<SimplePojo> marshallable =
                new MarshallablePojo<SimplePojo>(entity);
        View v = m.marshall(marshallable);
        assertTrue(v instanceof JSON);
        assertEquals(new JSON(entity).toString(), ((JSON)v).toString());
    }
View Full Code Here

    /* @Marshall marshalling */
   
    @Test
    public void jsonEntityMarshallerHandlesMarshallAnnotation() {
       
        JSONEntityMarshaller m = new JSONEntityMarshaller();
        SimplePojo entity = new SimplePojo("test");
        AnnotatedPojo marshallable = new AnnotatedPojo(entity);
        View v = m.marshall(marshallable);
        assertTrue(v instanceof JSON);
        assertEquals(new JSON(entity).toString(), ((JSON)v).toString());
    }
View Full Code Here

        Map<String, EntityMarshaller> marshallerMap = new HashMap<String, EntityMarshaller>();
       
        /* place the framework marshallers in the map first so that they
         * can be overridden by user's marshallers */
        addToEntityMarshallerMap(new PlainTextEntityMarshaller(), marshallerMap);
        addToEntityMarshallerMap(new JSONEntityMarshaller(), marshallerMap);
        addToEntityMarshallerMap(new XMLEntityMarshaller(), marshallerMap);
       
        String marshallersNamespaces = config.getInitParameter(ENTITY_MARSHALLERS);
        if (!isEmpty(marshallersNamespaces)) {
            List<String> packages = new ArrayList<String>();
View Full Code Here

TOP

Related Classes of org.mojavemvc.marshalling.JSONEntityMarshaller

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.