1 package net.pterodactylus.sone.text;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
6 import org.hamcrest.MatcherAssert;
7 import org.hamcrest.Matchers;
11 * JUnit test for {@link TextFilter}.
13 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
15 public class TextFilterTest {
18 public void textFilterCanBeCreated() {
23 public void textFilterRemovesHttpLinkToSameHost() {
24 String textWithHttpLink = "Some text with an http://foo.bar/link.html in it.";
25 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
29 public void textFilterRemovesHttpsLinkToSameHost() {
30 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
31 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
35 public void textWithoutALinkIsReturnedUnmodified() {
36 String textWithHttpLink = "Some text without a link in it.";
37 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text without a link in it."));
41 public void nothingIsRemovedWhenThereIsNoHostHeader() {
42 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
43 assertThat(TextFilter.filter(null, textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));
47 public void textFilterDoesNotRemoveLinksToDifferentHost() {
48 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
49 assertThat(TextFilter.filter("bar.baz", textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));