Example #1
0
 public static Element parseWithCRC(InputStream inputStream)
     throws XMLStreamException, CRCMismatchException {
   XMLInputFactory xif = XMLInputFactory.newFactory();
   Element element = parse(xif.createXMLStreamReader(inputStream));
   checkCRC(element);
   element.removeChildren(CRC_ELEMENT);
   return element;
 }
  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);
  }
  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);
  }
  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);
  }
Example #5
0
 public static Element parse(InputStream inputStream) throws XMLStreamException {
   XMLInputFactory xif = XMLInputFactory.newFactory();
   return parse(xif.createXMLStreamReader(inputStream));
 }
Example #6
0
 public static Element parse(InputStreamReader inputStreamReader)
     throws FileNotFoundException, XMLStreamException {
   XMLInputFactory xif = XMLInputFactory.newFactory();
   return parse(xif.createXMLStreamReader(inputStreamReader));
 }