XMLDecoder { public Vector<LoggingEvent> decodeEvents(final String document) { if (document != null) { if (document.trim().equals("")) { return null; } String newDoc = null; String newPartialEvent; if (document.lastIndexOf(RECORD_END) == -1) { partialEvent = partialEvent + document; return null; } if (document.lastIndexOf(RECORD_END) + RECORD_END.length() < document.length()) { newDoc = document.substring(0, document.lastIndexOf(RECORD_END) + RECORD_END.length()); newPartialEvent = document.substring(document.lastIndexOf(RECORD_END) + RECORD_END.length()); } else { newDoc = document; newPartialEvent = ""; } if (partialEvent != null) { newDoc = partialEvent + newDoc; } partialEvent = newPartialEvent; Document doc = parse(newDoc); if (doc == null) { return null; } return decodeEvents(doc); } return null; } XMLDecoder(final Component o);  XMLDecoder(); void setAdditionalProperties(final Map properties); Vector decode(final URL url); Vector<LoggingEvent> decodeEvents(final String document); LoggingEvent decode(final String data);  }
@Test public void testNestedCData() { XMLDecoder xmlDecoder = new XMLDecoder(); String log4jEvent = EVENT_START; for (String tag : new String[] { "log4j:message", "log4j:NDC", "log4j:MDC", "log4j:throwable" }) { log4jEvent = log4jEvent + String.format("<%1$s><![CDATA[%2$s]]></%1$s>", tag, CONTENT_WITH_CDATA); } log4jEvent = log4jEvent + EVENT_LOCATION + EVENT_END; Vector<LoggingEvent> events = xmlDecoder.decodeEvents(log4jEvent + log4jEvent); assertEquals(events.size(), 2); for (LoggingEvent event : events) { assertEquals(event.getMessage(), CONTENT_WITH_CDATA); assertEquals(event.getNDC(), CONTENT_WITH_CDATA); assertEquals(event.getProperties().get(CONTENT_WITH_CDATA), ""); assertEquals(event.getThrowableStrRep()[0], CONTENT_WITH_CDATA); } }