Jettison
  1. Jettison
  2. JETTISON-111

Jettison 1.3.x array handling breaks XStream

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      With the latest version it is no longer possible to enfore array handling for an element. Actually the serializeAsArray flag triggers non-symmetric behavior of Jettison between its reader and writer. See following unit tests, that represent XStream's internal call sequence and which succeed with Jettison 1.2.

          public void testJettisonArraysAreBroken() throws XMLStreamException {
              final MappedXMLOutputFactory mof;
              final MappedXMLInputFactory mif;
              final Configuration config = new Configuration();
              mof = new MappedXMLOutputFactory(config);
              mif = new MappedXMLInputFactory(config);
              ByteArrayOutputStream out = new ByteArrayOutputStream();
              XMLStreamWriter writer = mof.createXMLStreamWriter(out);
              ((AbstractXMLStreamWriter)writer).serializeAsArray("list");
              writer.writeStartDocument();
              writer.writeStartElement("list");
              writer.writeStartElement("string");
              writer.writeCharacters("a");
              writer.writeEndElement();
              writer.writeStartElement("string");
              writer.writeCharacters("b");
              writer.writeEndElement();
              writer.writeEndElement();
              writer.writeEndDocument();
              writer.close();
              assertEquals("{'list':[{'string':['a','b']}]}".replace('\'', '"'), out.toString());
              ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
              XMLStreamReader reader = mif.createXMLStreamReader(in);
              assertEquals(XMLStreamConstants.START_ELEMENT, reader.next());
              assertEquals("list", reader.getLocalName());
              assertEquals(XMLStreamConstants.START_ELEMENT, reader.next());
              assertEquals("string", reader.getLocalName());
              assertEquals(XMLStreamConstants.CHARACTERS, reader.next());
              assertEquals("a", reader.getElementText());
              assertEquals(XMLStreamConstants.END_ELEMENT, reader.next());
              assertEquals(XMLStreamConstants.START_ELEMENT, reader.next());
              assertEquals("string", reader.getLocalName());
              assertEquals(XMLStreamConstants.CHARACTERS, reader.next());
              assertEquals("b", reader.getElementText());
              assertEquals(XMLStreamConstants.END_ELEMENT, reader.next());
              assertEquals(XMLStreamConstants.END_ELEMENT, reader.next());
          }
      
          public void testJettisonSingleElementArraysAreBroken() throws XMLStreamException {
              final MappedXMLOutputFactory mof;
              final MappedXMLInputFactory mif;
              final Configuration config = new Configuration();
              mof = new MappedXMLOutputFactory(config);
              mif = new MappedXMLInputFactory(config);
              ByteArrayOutputStream out = new ByteArrayOutputStream();
              XMLStreamWriter writer = mof.createXMLStreamWriter(out);
              ((AbstractXMLStreamWriter)writer).serializeAsArray("list");
              writer.writeStartDocument();
              writer.writeStartElement("list");
              writer.writeStartElement("string");
              writer.writeCharacters("a");
              writer.writeEndElement();
              writer.writeEndElement();
              writer.writeEndDocument();
              writer.close();
              assertEquals("{'list':[{'string':'a'}]}".replace('\'', '"'), out.toString());
              ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
              XMLStreamReader reader = mif.createXMLStreamReader(in);
              assertEquals(XMLStreamConstants.START_ELEMENT, reader.next());
              assertEquals("list", reader.getLocalName());
              assertEquals(XMLStreamConstants.START_ELEMENT, reader.next());
              assertEquals("string", reader.getLocalName());
              assertEquals(XMLStreamConstants.CHARACTERS, reader.next());
              assertEquals("a", reader.getElementText());
              assertEquals(XMLStreamConstants.END_ELEMENT, reader.next());
              assertEquals(XMLStreamConstants.END_ELEMENT, reader.next());
          }
      

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Jörg Schaible
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: