aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-09-06 14:23:07 +0300
committerGravatar Vitaly Takmazov2017-09-06 14:23:07 +0300
commit8094d66534f47ed302d271da4dba1147fe6b2a3c (patch)
treedcb2701d2462dd94f9964fa05e75ea02d6d06064 /juick-www/src/test/java/com
parent346c39037d6e5e9c2d006ac43439f865f418a62c (diff)
www: cleanup and fix configuration
Diffstat (limited to 'juick-www/src/test/java/com')
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java
index c5e9eb6a..0aba7e37 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -37,6 +37,7 @@ import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.apache.commons.text.StringEscapeUtils;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -101,6 +102,11 @@ public class WebAppTests {
public void setup() {
webClient = MockMvcWebClientBuilder.webAppContextSetup(this.wac).build();
webClient.getOptions().setJavaScriptEnabled(false);
+ webClient.getOptions().setCssEnabled(false);
+ }
+ @After
+ public void teardown() {
+ webClient.close();
}
@Test
@@ -204,7 +210,8 @@ public class WebAppTests {
assertThat(output, equalTo("<a href=\"/ugnich/?tag=%26gt%3B_%26lt%3B\">&gt;_&lt;</a>"));
}
- public DomElement fetchMeta(HtmlPage page, String name) throws IOException {
+ public DomElement fetchMeta(String url, String name) throws IOException {
+ HtmlPage page = webClient.getPage(url);
DomElement emptyMeta = new DomElement("", "meta", null, null);
return page.getElementsByTagName("meta").stream()
.filter(t -> t.getAttribute("name").equals(name)).findFirst().orElse(emptyMeta);
@@ -237,15 +244,13 @@ public class WebAppTests {
when(messagesService.canViewThread(1, 0)).thenReturn(true);
when(messagesService.getMessage(1)).thenReturn(msg);
- HtmlPage threadPage = webClient.getPage("http://localhost:8080/ugnich/1");
-
- assertThat(fetchMeta(threadPage, "twitter:card")
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "twitter:card")
.getAttribute("content"), equalTo("summary"));
msg.setAttachmentType("png");
- assertThat(fetchMeta(threadPage, "twitter:card")
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "twitter:card")
.getAttribute("content"), equalTo("summary_large_image"));
- assertThat(fetchMeta(threadPage, "og:description")
- .getAttribute("content"),
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "og:description")
+ .getAttribute("content"),
startsWith(StringEscapeUtils.escapeHtml4(MessageUtils.getMessageHashTags(msg))));
}