Package com.sun.jersey.api.json

Examples of com.sun.jersey.api.json.JSONJAXBContext


*/
public class EmptyJSONElementTest extends TestCase {

    public void testOnlyEmptyElement() throws Exception {
       
        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(false).build(), EmptyElementBean.class);
        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();

        EmptyElementBean one = ju.unmarshalFromJSON(new StringReader("{\"emptyElementBean\":{}}"), EmptyElementBean.class);
        EmptyElementBean two = ju.unmarshalFromJSON(new StringReader("{\"emptyElementBean\":null}"), EmptyElementBean.class);

        assertEquals(one, two);
View Full Code Here


        assertEquals(one, two);
    }

    public void testEmptyElementAsAContainee() throws Exception {

        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(false).build(), EmptyElementBean.class, EmptyElementContainingBean.class);
        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();

        EmptyElementContainingBean one = JSONTestHelper.createTestInstance(EmptyElementContainingBean.class);
        EmptyElementContainingBean two = ju.unmarshalFromJSON(new StringReader("{\"emptyElementContainingBean\":{\"emptyElementBean\":{},\"c\":\"foo\",\"d\":\"bar\"}}"), EmptyElementContainingBean.class);

        assertEquals(one, two);
View Full Code Here

* @author Jakub.Podlesak@Sun.COM
*/
public class NamespaceSupportIssue272Test extends TestCase {

    public void testNaturalNotation() throws Exception {
        _testNamespaces(new JSONJAXBContext(JSONConfiguration.natural().build(), MyError.class, MyMessage.class, MyResponse.class));
    }
View Full Code Here

    }

    public void testMappedNotation() throws Exception {
        Map<String, String> jsonXml2JsonNs = new HashMap<String, String>();
        jsonXml2JsonNs.put("http://test.jaxb.com", "tjc");
        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.mapped().xml2JsonNs(jsonXml2JsonNs).build(), MyError.class, MyMessage.class, MyResponse.class);
        _testNamespaces(ctx);
    }
View Full Code Here

        classes = (Class[]) classCollection.toArray(new Class[0]);
    }
   
    public void testDefaultConfig() throws Exception {
        System.out.println("DEFAULT CONFIG");
        allBeansTest(new JSONJAXBContext(classes), beans);
    }
View Full Code Here

        allBeansTest(new JSONJAXBContext(classes), beans);
    }
   
    public void testInternalNotation() throws Exception {
        System.out.println("INTERNAL NOTATION");
        allBeansTest(new JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(false).build(), classes), beans);
    }
View Full Code Here

    public void testInternalNotationDeprecatedConfig() throws Exception {
        System.out.println("INTERNAL NOTATION DEPRECATED CONFIG");
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(JSONJAXBContext.JSON_NOTATION, JSONJAXBContext.JSONNotation.MAPPED);
        props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.FALSE);
        allBeansTest(new JSONJAXBContext(classes, props), beans);
    }
View Full Code Here

        allBeansTest(new JSONJAXBContext(classes, props), beans);
    }

    public void testInternalNotationAttrAsElems() throws Exception {
        System.out.println("INTERNAL NOTATION WITH SOME ATTR AS ELEMS");
        allBeansTest(new JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(true).attributeAsElement("i", "j").build(), classes), beans);
    }
View Full Code Here

        System.out.println("INTERNAL NOTATION WITH SOME ATTR AS ELEMS DEPRECATED CONFIG");
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(JSONJAXBContext.JSON_NOTATION, JSONJAXBContext.JSONNotation.MAPPED);
        props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE);
        props.put(JSONJAXBContext.JSON_ATTRS_AS_ELEMS, new HashSet<String>(2){{add("i");add("j");}});
        allBeansTest(new JSONJAXBContext(classes, props), beans);
    }
View Full Code Here

        allBeansTest(new JSONJAXBContext(classes, props), beans);
    }

    public void testJettisonBadgerfishNotation() throws Exception {
        System.out.println("BADGERFISH NOTATION");
        allBeansTest(new JSONJAXBContext(JSONConfiguration.badgerFish().build(), classes), beans);
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.json.JSONJAXBContext

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.