aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/test/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-08-18 13:58:34 +0300
committerGravatar Vitaly Takmazov2017-08-18 14:34:21 +0300
commit9c0f37b2fd7535a46c324ff7eb89ed9454aee88f (patch)
treebf663780bbd15deee547c79aa8b42b9735368d67 /juick-www/src/test/java/com/juick
parentf5a87d2b7072426cfe36527db1270e5f85b73e01 (diff)
www: no more ugnich templates
Diffstat (limited to 'juick-www/src/test/java/com/juick')
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java25
1 files changed, 21 insertions, 4 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 98df3660..d09bded2 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -22,6 +22,7 @@ import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.css.StyleElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.juick.Message;
+import com.juick.Tag;
import com.juick.User;
import com.juick.configuration.MockDataConfiguration;
import com.juick.server.configuration.BaseWebConfiguration;
@@ -31,6 +32,10 @@ import com.juick.test.util.MockUtils;
import com.juick.www.configuration.SapeConfiguration;
import com.juick.www.configuration.WwwAppConfiguration;
import com.juick.www.configuration.WwwServletConfiguration;
+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.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,9 +49,9 @@ import org.springframework.web.context.WebApplicationContext;
import javax.inject.Inject;
import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;
@@ -81,6 +86,9 @@ public class WebAppTests {
@Inject
MessagesService messagesService;
+ @Inject
+ PebbleEngine pebbleEngine;
+
@Before
public void setup() {
webClient = MockMvcWebClientBuilder.webAppContextSetup(this.wac).build();
@@ -176,6 +184,15 @@ public class WebAppTests {
return display == null || !display.getValue().equals("none");
}).count();
assertThat(visibleItems, equalTo(1L));
-
+ }
+ @Test
+ public void correctTagsEscaping() throws PebbleException, IOException {
+ PebbleTemplate template = pebbleEngine.getTemplate("views/test");
+ Writer writer = new StringWriter();
+ template.evaluate(writer,
+ Collections.singletonMap("tagsList",
+ Collections.singletonList(StringEscapeUtils.escapeHtml4(new Tag(">_<").getName()))));
+ String output = writer.toString().trim();
+ assertThat(output, equalTo("<a href=\"/ugnich/?tag=%26gt%3B_%26lt%3B\">&gt;_&lt;</a>"));
}
}