Package de.odysseus.staxon.json.jaxrs.jaxb.model

Examples of de.odysseus.staxon.json.jaxrs.jaxb.model.SampleRootElement


    JsonXMLArrayProvider provider = new JsonXMLArrayProvider(null);
    Annotation[] annotations = new Annotation[0];
    Type type = getClass().getDeclaredField("sampleRootElementList").getGenericType();
   
    List<SampleRootElement> list = new ArrayList<SampleRootElement>();
    list.add(new SampleRootElement());
    list.get(0).attribute = "hello";
    list.add(new SampleRootElement());
    list.get(1).attribute = "world";

    StringWriter writer = new StringWriter();
    provider.write(List.class,
        type, annotations, MediaType.APPLICATION_JSON_TYPE, null, writer, list);
View Full Code Here


  public void testReadSampleRootElement() throws Exception {
    JsonXMLObjectProvider provider = new JsonXMLObjectProvider(null);
    Annotation[] annotations = new Annotation[0];
    String json = "{\"sampleRootElement\":{\"@attribute\":\"hello\",\"elements\":[\"world\"]}}";

    SampleRootElement sampleRootElement = (SampleRootElement)provider.read(SampleRootElement.class,
        null, annotations, MediaType.APPLICATION_JSON_TYPE, null, new StringReader(json));

    Assert.assertEquals("hello", sampleRootElement.attribute);
    Assert.assertEquals("world", sampleRootElement.elements.get(0));
  }
View Full Code Here

  @Test
  public void testWriteSampleRootElement() throws Exception {
    JsonXMLObjectProvider provider = new JsonXMLObjectProvider(null);
    Annotation[] annotations = new Annotation[0];
   
    SampleRootElement sampleRootElement = new SampleRootElement();
    sampleRootElement.attribute = "hello";
    sampleRootElement.elements = Arrays.asList("world")

    StringWriter writer = new StringWriter();
    provider.write(SampleRootElement.class,
View Full Code Here

  public void testReadNull() throws Exception {
    JsonXMLObjectProvider provider = new JsonXMLObjectProvider(null);
    Annotation[] annotations = new Annotation[0];
    String json = "null";

    SampleRootElement sampleRootElement = (SampleRootElement)provider.read(SampleRootElement.class,
        null, annotations, MediaType.APPLICATION_JSON_TYPE, null, new StringReader(json));

    Assert.assertNull(sampleRootElement);
  }
View Full Code Here

  public void testReadNullWithVirtualRoot() throws Exception {
    JsonXMLObjectProvider provider = new JsonXMLObjectProvider(null);
    Annotation[] annotations = new Annotation[]{JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class)};
    String json = "null";

    SampleRootElement sampleRootElement = (SampleRootElement)provider.read(SampleRootElement.class,
        null, annotations, MediaType.APPLICATION_JSON_TYPE, null, new StringReader(json));

    Assert.assertNotNull(sampleRootElement);
  }
View Full Code Here

TOP

Related Classes of de.odysseus.staxon.json.jaxrs.jaxb.model.SampleRootElement

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.