Exemplo n.º 1
0
  public void testOutputStreamUTF8() throws Exception {
    FlushRoot control = getControlObject();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    marshaller.marshal(control, baos);

    XMLInputFactory xif = XMLInputFactory.newFactory();
    Object test = unmarshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));

    assertEquals(control, test);
  }
Exemplo n.º 2
0
  public void testJSONOutputStreamUTF8() throws Exception {
    marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json");
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");

    FlushRoot control = getControlObject();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    marshaller.marshal(control, baos);

    XMLInputFactory xif = XMLInputFactory.newFactory();
    Object test = unmarshaller.unmarshal(new ByteArrayInputStream(baos.toByteArray()));

    assertEquals(control, test);
  }
Exemplo n.º 3
0
  public void testXMLStreamWriter() throws Exception {
    FlushRoot control = getControlObject();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    XMLOutputFactory xof = XMLOutputFactory.newFactory();
    XMLStreamWriter xsw = xof.createXMLStreamWriter(baos);
    marshaller.marshal(control, xsw);

    XMLInputFactory xif = XMLInputFactory.newFactory();
    XMLStreamReader xsr = xif.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray()));
    Object test = unmarshaller.unmarshal(xsr);

    assertEquals(control, test);
  }