X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneTextParserTest.java;h=3dc25e8c3821c6e4a6c6064f492bc9bbb572a70f;hb=771e8efcd92c7325423441d57c5a6ed90a835e6f;hp=7baceaab2ca59b4c3fa11eed4897a08a007423de;hpb=4c8a20cadda6c449e90300e5fa0a79b8a20700aa;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index 7baceaa..3dc25e8 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -19,10 +19,12 @@ 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; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.memory.MemorySone; /** * JUnit test case for {@link SoneTextParser}. @@ -106,6 +108,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 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 +153,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 +183,7 @@ public class SoneTextParserTest extends TestCase { */ @Override public Sone getSone(final String soneId, boolean create) { - return new Sone(soneId) { + return new MemorySone(soneId, false) { /** * {@inheritDoc}