+ parts = soneTextParser.parse("\nTest.\n\n\nTest.", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "Test.\n\nTest.", is(convertText(parts, PlainTextPart.class)));
+ }
+
+ /**
+ * Tests parsing of KSK links.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @SuppressWarnings("static-method")
+ @Test
+ public void testKSKLinks() throws IOException {
+ SoneTextParser soneTextParser = new SoneTextParser(null, null);
+ Iterable<Part> parts;
+
+ /* check basic links. */
+ parts = soneTextParser.parse("KSK@gpl.txt", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "[KSK@gpl.txt|gpl.txt|gpl.txt]", is(convertText(parts, FreenetLinkPart.class)));
+
+ /* check embedded links. */
+ parts = soneTextParser.parse("Link is KSK@gpl.txt\u200b.", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\u200b.", is(convertText(parts, PlainTextPart.class, FreenetLinkPart.class)));
+
+ /* check embedded links and line breaks. */
+ parts = soneTextParser.parse("Link is KSK@gpl.txt\nKSK@test.dat\n", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\n[KSK@test.dat|test.dat|test.dat]", is(convertText(parts, PlainTextPart.class, FreenetLinkPart.class)));
+ }
+
+ /**
+ * Test case for a bug that was discovered in 0.6.7.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @SuppressWarnings({ "synthetic-access", "static-method" })
+ @Test
+ public void testEmptyLinesAndSoneLinks() throws IOException {
+ SoneTextParser soneTextParser = new SoneTextParser(new TestSoneProvider(), null);
+ Iterable<Part> parts;
+
+ /* check basic links. */
+ parts = soneTextParser.parse("Some text.\n\nLink to sone://DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU and stuff.", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "Some text.\n\nLink to [Sone|DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU] and stuff.", is(convertText(parts, PlainTextPart.class, SonePart.class)));
+ }
+
+ /**
+ * Test for a bug discovered in Sone 0.8.4 where a plain “http://” would be
+ * parsed into a link.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @SuppressWarnings({ "synthetic-access", "static-method" })
+ @Test
+ public void testEmpyHttpLinks() throws IOException {
+ SoneTextParser soneTextParser = new SoneTextParser(new TestSoneProvider(), null);
+ Iterable<Part> parts;
+
+ /* check empty http links. */
+ parts = soneTextParser.parse("Some text. Empty link: http:// – nice!", null);
+ assertThat("Parts", parts, notNullValue());
+ assertThat("Part Text", "Some text. Empty link: http:// – nice!", is(convertText(parts, PlainTextPart.class)));