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 public class TextFilterTest {
16 public void textFilterCanBeCreated() {
21 public void textFilterRemovesHttpLinkToSameHost() {
22 String textWithHttpLink = "Some text with an http://foo.bar/link.html in it.";
23 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
27 public void textFilterRemovesHttpsLinkToSameHost() {
28 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
29 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text with an link.html in it."));
33 public void textWithoutALinkIsReturnedUnmodified() {
34 String textWithHttpLink = "Some text without a link in it.";
35 assertThat(TextFilter.filter("foo.bar", textWithHttpLink), is("Some text without a link in it."));
39 public void nothingIsRemovedWhenThereIsNoHostHeader() {
40 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
41 assertThat(TextFilter.filter(null, textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));
45 public void textFilterDoesNotRemoveLinksToDifferentHost() {
46 String textWithHttpLink = "Some text with an https://foo.bar/link.html in it.";
47 assertThat(TextFilter.filter("bar.baz", textWithHttpLink), is("Some text with an https://foo.bar/link.html in it."));