Examples of SampleRootElement


Examples of de.odysseus.staxon.json.jaxb.sample.SampleRootElement

  @Test
  public void testWriteArraySampleRootElementWithNull1() throws Exception {
    JsonXML config = JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class);
    List<SampleRootElement> list = new ArrayList<SampleRootElement>();
    list.add(new SampleRootElement());
    list.get(0).attribute = "hello";
    list.add(null);

    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(SampleRootElement.class);
View Full Code Here

Examples of de.odysseus.staxon.json.jaxb.sample.SampleRootElement

  @Test
  public void testWriteArraySampleRootElementWithNull2() throws Exception {
    JsonXML config = JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class);
    List<SampleRootElement> list = new ArrayList<SampleRootElement>();
    list.add(null);
    list.add(new SampleRootElement());
    list.get(1).attribute = "hello";

    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(SampleRootElement.class);
    new JsonXMLBinder().writeArray(SampleRootElement.class, config, context, writer, list);
View Full Code Here

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

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

  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

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

  @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

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

  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

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

  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
Copyright © 2018 www.massapi.com. 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.