static JSONArray parseFirstEntries(final InputStream inputStream, final int count) throws ExecutionException, InterruptedException
    {
        final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);

        final JSONArray result = new JSONArray();

        final Document document = SAXReaderUtil.readDocument(inputStream);
        final List<Node> nodes = document.selectNodes("/rss/channel/item");
        for (final Node node : nodes) {
            if (!(node instanceof Element)) {
                continue;
            }

            try {
                final Element item = (Element) node;

                final JSONObject o = new JSONObject();
                o.put("link", item.elementText("link"));
                o.put("title", item.elementText("title"));
                o.put("date", JiveGlobals.formatDate(dateFormat.parse(item.elementText("pubDate"))));
                result.put(o);
            } catch (Exception e) {
                Log.debug("Unable to parse element as RSS data: {}", node.asXML(), e);
            }

            if (result.length() >= count) {
                break;
            }
        }
        return result;
    }
@Test
    public void testRssParsing() throws Exception
    {
        // Setup test fixture.
        try (final InputStream rssStream = BlogPostServlet.class.getResourceAsStream("/rss/ignite-blog.rss")) {

            // Execute system under test.
            final JSONArray result = BlogPostServlet.parseFirstEntries(rssStream, 2);

            // Verify results.
            assertEquals(2, result.length());
            assertEquals("https://discourse.igniterealtime.org/t/cve-2023-32315-openfire-vulnerability-update/93166", result.getJSONObject(0).getString("link"));
            assertEquals("CVE-2023-32315: Openfire vulnerability (update)", result.getJSONObject(0).getString("title"));

            assertEquals("https://discourse.igniterealtime.org/t/sparkweb-lives-again/93130", result.getJSONObject(1).getString("link"));
            assertEquals("SparkWeb lives again", result.getJSONObject(1).getString("title"));
        }
    }