diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java index b2500f3490..05a8e1d9d4 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.util.xml; import java.io.StringReader; import java.io.StringWriter; -import java.net.Socket; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLStreamException; @@ -26,7 +25,6 @@ import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamResult; -import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; @@ -36,7 +34,7 @@ import org.xml.sax.XMLReader; import org.xmlunit.util.Predicate; import static org.junit.Assert.*; -import static org.xmlunit.matchers.CompareMatcher.*; +import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; /** * @author Arjen Poutsma @@ -66,13 +64,12 @@ public abstract class AbstractStaxHandlerTestCase { @SuppressWarnings("deprecation") // on JDK 9 public void createXMLReader() throws Exception { xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); + xmlReader.setEntityResolver((publicId, systemId) -> new InputSource(new StringReader(""))); } @Test public void noNamespacePrefixes() throws Exception { - Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible()); - StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler); @@ -86,20 +83,8 @@ public abstract class AbstractStaxHandlerTestCase { assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter)); } - private static boolean wwwSpringframeworkOrgIsAccessible() { - try { - new Socket("www.springframework.org", 80).close(); - } - catch (Exception e) { - return false; - } - return true; - } - @Test public void namespacePrefixes() throws Exception { - Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible()); - StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler);