X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneTextParserTest.java;h=76f375526f26553438793a7e7f19abc1e14bffc0;hb=658a702c550e15bd3c868ed399621606eeb4ef20;hp=b00fcfe37d060d34606076eff208a7e7c7bc9382;hpb=b56a6a037ee7a589636f8c8de88d6394acf517ff;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 b00fcfe..76f3755 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTextParserTest.java - Copyright © 2011–2012 David Roden + * Sone - SoneTextParserTest.java - Copyright © 2011–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,11 @@ 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.SoneProvider; /** * JUnit test case for {@link SoneTextParser}. @@ -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 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 // @@ -162,8 +181,8 @@ public class SoneTextParserTest extends TestCase { * {@inheritDoc} */ @Override - public Sone getSone(final String soneId, boolean create) { - return new Sone(soneId) { + public Sone getSone(final String soneId) { + return new Sone(soneId, false) { /** * {@inheritDoc}