Store locality of a Sone in the Sone itself.
[Sone.git] / src / test / java / net / pterodactylus / sone / text / SoneTextParserTest.java
index 7baceaa..9a060f6 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.text;
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.util.Arrays;
 
 import junit.framework.TestCase;
 import net.pterodactylus.sone.core.SoneProvider;
@@ -106,6 +107,24 @@ public class SoneTextParserTest extends TestCase {
                assertEquals("Part Text", "Some text.\n\nLink to [Sone|DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU] and stuff.", 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" })
+       public void testEmpyHttpLinks() throws IOException {
+               SoneTextParser soneTextParser = new SoneTextParser(new TestSoneProvider(), null);
+               Iterable<Part> parts;
+
+               /* check empty http links. */
+               parts = soneTextParser.parse(null, new StringReader("Some text. Empty link: http:// – nice!"));
+               assertNotNull("Parts", parts);
+               assertEquals("Part Text", "Some text. Empty link: http:// – nice!", convertText(parts, PlainTextPart.class));
+       }
+
        //
        // PRIVATE METHODS
        //
@@ -133,7 +152,7 @@ public class SoneTextParserTest extends TestCase {
                                }
                        }
                        if (!classValid) {
-                               assertEquals("Part’s Class", null, part.getClass());
+                               fail("Part’s Class (" + part.getClass() + ") is not one of " + Arrays.toString(validClasses));
                        }
                        if (part instanceof PlainTextPart) {
                                text.append(((PlainTextPart) part).getText());
@@ -163,7 +182,7 @@ public class SoneTextParserTest extends TestCase {
                 */
                @Override
                public Sone getSone(final String soneId, boolean create) {
-                       return new Sone(soneId) {
+                       return new Sone(soneId, false) {
 
                                /**
                                 * {@inheritDoc}