+ assertThat(parts, notNullValue());
+ assertThat(convertText(parts, PlainTextPart.class, FreenetLinkPart.class),
+ is("Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\n[KSK@test.dat|test.dat|test.dat]"));
+ }
+
+ /**
+ * Test case for a bug that was discovered in 0.6.7.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Test
+ public void testEmptyLinesAndSoneLinks() throws IOException {
+ Iterable<Part> parts;
+
+ /* check basic links. */
+ parts = soneTextParser.parse(null, new StringReader("Some text.\n\nLink to sone://DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU and stuff."));
+ assertThat(parts, notNullValue());
+ assertThat(convertText(parts, PlainTextPart.class, SonePart.class),
+ is("Some text.\n\nLink to [Sone|DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU] and stuff."));
+ }
+
+ /**
+ * 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
+ */
+ @Test
+ public void testEmpyHttpLinks() throws IOException {
+ Iterable<Part> parts;
+
+ /* check empty http links. */
+ parts = soneTextParser.parse(null, new StringReader("Some text. Empty link: http:// – nice!"));
+ assertThat(parts, notNullValue());
+ assertThat(convertText(parts, PlainTextPart.class), is("Some text. Empty link: http:// – nice!"));
+ }
+
+ @Test
+ public void linksToPostAreParsedCorrectly() throws IOException {
+ postProvider.addValidPostId("foo", "Post about foo...");
+ Iterable<Part> parts = soneTextParser.parse(null, new StringReader("This post://foo is awesome."));
+ assertThat(convertText(parts, PlainTextPart.class, PostPart.class), is("This [post|foo|Post about foo...] is awesome."));