Unit Test für die HTMLEncode Funktion.
authorFelix Dörre <felix@dogcraft.de>
Tue, 1 Jul 2014 20:40:36 +0000 (22:40 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 1 Jul 2014 20:40:36 +0000 (22:40 +0200)
tests/org/cacert/gigi/util/TestHTMLEncoder.java [new file with mode: 0644]

diff --git a/tests/org/cacert/gigi/util/TestHTMLEncoder.java b/tests/org/cacert/gigi/util/TestHTMLEncoder.java
new file mode 100644 (file)
index 0000000..7875df9
--- /dev/null
@@ -0,0 +1,26 @@
+package org.cacert.gigi.util;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestHTMLEncoder {
+
+       @Test
+       public void testEncodeSimpleString() {
+               assertEquals("1234_ä", HTMLEncoder.encodeHTML("1234_ä"));
+       }
+       @Test
+       public void testEncodeQuotes() {
+               assertEquals("\\&quot;_ä.", HTMLEncoder.encodeHTML("\\\"_ä."));
+       }
+       @Test
+       public void testEncodeTagString() {
+               assertEquals("&lt;td class=&quot;&amp;amp;&quot;&gt;",
+                               HTMLEncoder.encodeHTML("<td class=\"&amp;\">"));
+       }
+       @Test
+       public void testEncodeSingleQuoteString() {
+               assertEquals("&#39;&amp;#39;", HTMLEncoder.encodeHTML("'&#39;"));
+       }
+}