Examples of SampleRootElement


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

  @Test
  public void testWriteXmlRootElement() throws Exception {
    JsonXMLMapper<SampleRootElement> mapper = new JsonXMLMapper<SampleRootElement>(SampleRootElement.class);
    StringWriter writer = new StringWriter();
    SampleRootElement value = new SampleRootElement();
    mapper.writeObject(writer, value);
    writer.close();
    Assert.assertEquals("{\"sampleRootElement\":null}", writer.toString());
  }
View Full Code Here

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

  }

  @Test
  public void testCreateElement() throws JAXBException {
    JsonXMLRootProvider provider = new JsonXMLRootProvider();
    JAXBElement<?> sampleRootElement = provider.createElement(SampleRootElement.class, new SampleRootElement());
    Assert.assertEquals(new QName("sampleRootElement"), sampleRootElement.getName());
    Assert.assertEquals(SampleRootElement.class, sampleRootElement.getDeclaredType());
    JAXBElement<?> sampleType = provider.createElement(SampleType.class, new SampleType());
    Assert.assertEquals(new QName("sampleType"), sampleType.getName());
    Assert.assertEquals(SampleType.class, sampleType.getDeclaredType());
View Full Code Here

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

  @Test
  public void testMarshallSampleRootElement() throws Exception {
    JsonXML config = JsonXMLDefault.class.getAnnotation(JsonXML.class);
    StringWriter result = new StringWriter();
    Class<?> type = SampleRootElement.class;
    SampleRootElement sampleRootElement = new SampleRootElement();
    sampleRootElement.attribute = "hello";
    sampleRootElement.elements = Arrays.asList("world")

    XMLStreamWriter writer = new JsonXMLBinder().createXMLStreamWriter(type, config, result);
    Marshaller marshaller = JAXBContext.newInstance(type).createMarshaller();
View Full Code Here

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

  @Test
  public void testMarshallSampleRootElementWithVirtualRoot() throws Exception {
    JsonXML config = JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class);
    StringWriter result = new StringWriter();
    Class<?> type = SampleRootElement.class;
    SampleRootElement sampleRootElement = new SampleRootElement();
    sampleRootElement.attribute = "hello";
    sampleRootElement.elements = Arrays.asList("world")

    XMLStreamWriter writer = new JsonXMLBinder().createXMLStreamWriter(type, config, result);
    Marshaller marshaller = JAXBContext.newInstance(type).createMarshaller();
View Full Code Here

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

    String json = "{\"sampleRootElement\":{\"@attribute\":\"hello\",\"elements\":[\"world\"]}}";
    Class<SampleRootElement> type = SampleRootElement.class;

    XMLStreamReader reader = new JsonXMLBinder().createXMLStreamReader(type, config, new StringReader(json));
    Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller();
    SampleRootElement sampleRootElement = new JsonXMLBinder().unmarshal(type, config, unmarshaller, reader);

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

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

    String json = "{\"@attribute\":\"hello\",\"elements\":[\"world\"]}";
    Class<SampleRootElement> type = SampleRootElement.class;

    XMLStreamReader reader = new JsonXMLBinder().createXMLStreamReader(type, config, new StringReader(json));
    Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller();
    SampleRootElement sampleRootElement = new JsonXMLBinder().unmarshal(type, config, unmarshaller, reader);

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

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

  }
 
  @Test
  public void testWriteObjectSampleRootElement() throws Exception {
    JsonXML config = JsonXMLDefault.class.getAnnotation(JsonXML.class);
    SampleRootElement sampleRootElement = new SampleRootElement();
    sampleRootElement.attribute = "hello";
    sampleRootElement.elements = Arrays.asList("world");

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

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

  public void testReadObjectSampleRootElement() throws Exception {
    JsonXML config = JsonXMLDefault.class.getAnnotation(JsonXML.class);
    String json = "{\"sampleRootElement\":{\"@attribute\":\"hello\",\"elements\":[\"world\"]}}";

    JAXBContext context = JAXBContext.newInstance(SampleRootElement.class);
    SampleRootElement sampleRootElement =
        new JsonXMLBinder().readObject(SampleRootElement.class, config, context, 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.jaxb.sample.SampleRootElement

  @Test
  public void testWriteArraySampleRootElement() throws Exception {
    JsonXML config = JsonXMLDefault.class.getAnnotation(JsonXML.class);
    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();
    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.jaxb.sample.SampleRootElement

  @Test
  public void testWriteArraySampleRootElement_Document() throws Exception {
    JsonXML config = JsonXMLDefault.class.getAnnotation(JsonXML.class);
    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();
    JAXBContext context = JAXBContext.newInstance(SampleRootElement.class);
    new JsonXMLBinder(false).writeArray(SampleRootElement.class, config, context, writer, list);
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.