From c217eca998f89f96831fb29a80dce8c545c65da4 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Sat, 12 Apr 2014 23:26:02 +0200 Subject: [PATCH] Refactored code Replaced deprecated SAXBuilder constructor call --- .../java/com/sun/syndication/FeedTest.java | 36 ++++++++++--------- .../com/sun/syndication/TestXmlReader.java | 5 ++- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/sun/syndication/FeedTest.java b/src/test/java/com/sun/syndication/FeedTest.java index 2f6032b..733afa6 100644 --- a/src/test/java/com/sun/syndication/FeedTest.java +++ b/src/test/java/com/sun/syndication/FeedTest.java @@ -8,6 +8,7 @@ import junit.framework.TestCase; import org.jdom2.Document; import org.jdom2.input.SAXBuilder; +import org.jdom2.input.sax.XMLReaders; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.synd.SyndFeed; @@ -16,20 +17,21 @@ import com.sun.syndication.io.WireFeedInput; /** * @author pat, tucu - * + * */ public abstract class FeedTest extends TestCase { - private final String _feedFileName; - private Document _jDomDoc = null; - private WireFeed _wireFeed = null; - private SyndFeed _syndFeed = null; + + private final String fileName; + private Document jDomDoc = null; + private WireFeed wireFeed = null; + private SyndFeed syndFeed = null; protected FeedTest(final String feedFileName) { - _feedFileName = feedFileName; + fileName = feedFileName; } protected String getFeedFileName() { - return _feedFileName; + return fileName; } protected Reader getFeedReader() throws Exception { @@ -39,7 +41,7 @@ public abstract class FeedTest extends TestCase { } protected Document getJDomDoc() throws Exception { - final SAXBuilder saxBuilder = new SAXBuilder(false); + final SAXBuilder saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING); return saxBuilder.build(getFeedReader()); } @@ -54,24 +56,24 @@ public abstract class FeedTest extends TestCase { } protected Document getCachedJDomDoc() throws Exception { - if (_jDomDoc == null) { - _jDomDoc = getJDomDoc(); + if (jDomDoc == null) { + jDomDoc = getJDomDoc(); } - return _jDomDoc; + return jDomDoc; } protected WireFeed getCachedWireFeed() throws Exception { - if (_wireFeed == null) { - _wireFeed = getWireFeed(); + if (wireFeed == null) { + wireFeed = getWireFeed(); } - return _wireFeed; + return wireFeed; } protected SyndFeed getCachedSyndFeed() throws Exception { - if (_syndFeed == null) { - _syndFeed = getSyndFeed(); + if (syndFeed == null) { + syndFeed = getSyndFeed(); } - return _syndFeed; + return syndFeed; } } diff --git a/src/test/java/com/sun/syndication/TestXmlReader.java b/src/test/java/com/sun/syndication/TestXmlReader.java index 2195e84..5621d1a 100644 --- a/src/test/java/com/sun/syndication/TestXmlReader.java +++ b/src/test/java/com/sun/syndication/TestXmlReader.java @@ -45,6 +45,8 @@ public class TestXmlReader extends TestCase { protected void _testRawNoBomValid(final String encoding) throws Exception { + // TODO review this test + InputStream is = getXmlStream("no-bom", "xml", encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); @@ -170,7 +172,8 @@ public class TestXmlReader extends TestCase { final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml" : "xml-prolog-encoding", streamEnc, prologEnc); final XmlReader xmlReader = new XmlReader(is, cT, false); if (!streamEnc.equals("UTF-16")) { - // we can not assert things here becuase UTF-8, US-ASCII and ISO-8859-1 look alike for the chars used for detection + // we can not assert things here becuase UTF-8, US-ASCII and ISO-8859-1 look alike for + // the chars used for detection } else { assertEquals(xmlReader.getEncoding().substring(0, streamEnc.length()), streamEnc); }