1 package net.pterodactylus.sone.text;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
9 * JUnit test for {@link TextFilter}.
11 public class TextFilterTest {
14 public void textFilterCanBeCreated() {
19 public void textFilterRemovesHttpLinkToSameHost() {
20 String textWithHttpLink = "Some text with an http://foo.bar/link.html in it.";
21 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
25 public void textFilterRemovesHttpsLinkToSameHost() {
26 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
27 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
31 public void textWithoutALinkIsReturnedUnmodified() {
32 String textWithHttpLink = "Some text without a link in it.";
33 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text without a link in it."));
37 public void nothingIsRemovedWhenThereIsNoHostHeader() {
38 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
39 assertThat(TextFilter.filter(null, textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));
43 public void textFilterDoesNotRemoveLinksToDifferentHost() {
44 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
45 assertThat(TextFilter.filter("bar.baz", textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));