GH-2723: Handle unsupported XML properties

Fixes spring-projects/spring-integration#2723

Not all XML components support all the configuration properties.
For example Saxon HE doesn't support `XMLConstants.ACCESS_EXTERNAL_DTD`
and end up with an exception like:
`IllegalArgumentException: Unknown configuration property http://javax.xml.XMLConstants/property/accessExternalDTD`

* Change `XsltPayloadTransformer` to re-use `TransformerFactoryUtils`
from spring-ws as a centralized source of `TransformerFactory`
configuration.
* Wrap `XMLConstants.ACCESS_EXTERNAL_STYLESHEET` to the `try..catch`
and log INFO about not supported property

**Cherry-pick to 5.0.x & 4.3.x**
This commit is contained in:
Artem Bilan
2019-01-29 12:03:34 -05:00
committed by Gary Russell
parent 4c6ffec6fe
commit a283ad60fb
2 changed files with 30 additions and 13 deletions

View File

@@ -26,7 +26,6 @@ import javax.xml.transform.Result;
import javax.xml.transform.Templates;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMResult;
import org.junit.Before;
@@ -161,10 +160,12 @@ public class XsltPayloadTransformerTests {
@Test
public void testXsltPayloadWithBadTransformerFactoryClassName() throws IOException {
XsltPayloadTransformer transformer = new XsltPayloadTransformer(getXslResourceThatOutputsText(), "foo.bar.Baz");
XsltPayloadTransformer transformer =
new XsltPayloadTransformer(getXslResourceThatOutputsText(), "foo.bar.Baz");
transformer.setBeanFactory(Mockito.mock(BeanFactory.class));
assertThatThrownBy(transformer::afterPropertiesSet)
.isExactlyInstanceOf(TransformerFactoryConfigurationError.class);
.isExactlyInstanceOf(IllegalStateException.class)
.hasCauseExactlyInstanceOf(ClassNotFoundException.class);
}
@Test