### Question:
CollectingTransformErrorListener extends AbstractTransformErrorListener { @Nonnull @ReturnsMutableCopy public ErrorList getErrorList () { return m_aRWLock.readLockedGet (m_aErrors::getClone); } CollectingTransformErrorListener(); @Nonnull @ReturnsMutableCopy ErrorList getErrorList(); @Nonnull EChange clearResourceErrors(); @Override String toString();  }### Answer:
@Test public void testAll () throws TransformerConfigurationException, TransformerException { final CollectingTransformErrorListener el = new CollectingTransformErrorListener (); final TransformerFactory fac = XMLTransformerFactory.createTransformerFactory (el.andThen (new LoggingTransformErrorListener (L_EN)), new LoggingTransformURIResolver ()); assertNotNull (fac); Templates t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test1.xslt")); assertNotNull (t1); assertTrue (el.getErrorList ().containsNoError ()); { final Document aDoc = XMLFactory.newDocument (); t1.newTransformer ().transform (TransformSourceFactory.create (new ClassPathResource ("xml/xslt1.xml")), new DOMResult (aDoc)); assertNotNull (aDoc); assertNotNull (aDoc.getDocumentElement ()); assertEquals ("html", aDoc.getDocumentElement ().getTagName ()); } t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test2.xslt")); assertNotNull (t1); assertTrue (el.getErrorList ().containsNoError ()); assertNull (XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("test1.txt"))); assertTrue (el.getErrorList ().containsAtLeastOneError ()); CommonsTestHelper.testToStringImplementation (el); }
@Test public void testSecure () throws TransformerConfigurationException, TransformerException { final CollectingTransformErrorListener el = new CollectingTransformErrorListener (); final TransformerFactory fac = XMLTransformerFactory.createTransformerFactory (el.andThen (new LoggingTransformErrorListener (L_EN)), new LoggingTransformURIResolver ()); assertNotNull (fac); XMLTransformerFactory.makeTransformerFactorySecure (fac, "file"); Templates t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test1.xslt")); assertNotNull (t1); assertTrue (el.getErrorList ().containsNoError ()); { final Document aDoc = XMLFactory.newDocument (); t1.newTransformer ().transform (TransformSourceFactory.create (new ClassPathResource ("xml/xslt1.xml")), new DOMResult (aDoc)); assertNotNull (aDoc); assertNotNull (aDoc.getDocumentElement ()); assertEquals ("html", aDoc.getDocumentElement ().getTagName ()); } t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test2.xslt")); assertNotNull (t1); assertTrue (el.getErrorList ().containsNoError ()); assertNull (XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("test1.txt"))); assertTrue (el.getErrorList ().containsAtLeastOneError ()); CommonsTestHelper.testToStringImplementation (el); }