@Test public void testInsert() throws Exception { InputStream stream = new ByteArrayInputStream(insertDocOperation.getBytes(StandardCharsets.UTF_8)); AtomicInteger numSent = new AtomicInteger(0); FeedClient feedClient = mock(FeedClient.class); XmlFeedReader.read(stream, feedClient, numSent); assertThat(numSent.get(), is(2)); }
public static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent) throws Exception { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http: parserFactory.setValidating(false); parserFactory.setNamespaceAware(false); SAXParser parser = parserFactory.newSAXParser(); SAXClientFeeder saxClientFeeder = new SAXClientFeeder(feedClient, numSent); InputSource inputSource = new InputSource(); inputSource.setEncoding(StandardCharsets.UTF_8.displayName()); inputSource.setByteStream(inputStream); parser.setProperty("http: parser.parse(inputSource, saxClientFeeder); }
XmlFeedReader { public static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent) throws Exception { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http: parserFactory.setValidating(false); parserFactory.setNamespaceAware(false); SAXParser parser = parserFactory.newSAXParser(); SAXClientFeeder saxClientFeeder = new SAXClientFeeder(feedClient, numSent); InputSource inputSource = new InputSource(); inputSource.setEncoding(StandardCharsets.UTF_8.displayName()); inputSource.setByteStream(inputStream); parser.setProperty("http: parser.parse(inputSource, saxClientFeeder); } }
XmlFeedReader { public static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent) throws Exception { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http: parserFactory.setValidating(false); parserFactory.setNamespaceAware(false); SAXParser parser = parserFactory.newSAXParser(); SAXClientFeeder saxClientFeeder = new SAXClientFeeder(feedClient, numSent); InputSource inputSource = new InputSource(); inputSource.setEncoding(StandardCharsets.UTF_8.displayName()); inputSource.setByteStream(inputStream); parser.setProperty("http: parser.parse(inputSource, saxClientFeeder); } private  XmlFeedReader(); }
XmlFeedReader { public static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent) throws Exception { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http: parserFactory.setValidating(false); parserFactory.setNamespaceAware(false); SAXParser parser = parserFactory.newSAXParser(); SAXClientFeeder saxClientFeeder = new SAXClientFeeder(feedClient, numSent); InputSource inputSource = new InputSource(); inputSource.setEncoding(StandardCharsets.UTF_8.displayName()); inputSource.setByteStream(inputStream); parser.setProperty("http: parser.parse(inputSource, saxClientFeeder); } private  XmlFeedReader(); static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent); }
XmlFeedReader { public static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent) throws Exception { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http: parserFactory.setValidating(false); parserFactory.setNamespaceAware(false); SAXParser parser = parserFactory.newSAXParser(); SAXClientFeeder saxClientFeeder = new SAXClientFeeder(feedClient, numSent); InputSource inputSource = new InputSource(); inputSource.setEncoding(StandardCharsets.UTF_8.displayName()); inputSource.setByteStream(inputStream); parser.setProperty("http: parser.parse(inputSource, saxClientFeeder); } private  XmlFeedReader(); static void read(InputStream inputStream, FeedClient feedClient, AtomicInteger numSent);  }