summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2016-10-14 09:42:43 +0200
committerluccioman <luccioman@users.noreply.github.com>2016-10-14 09:58:14 +0200
commit7136b1ad6061e9e0297cf3945f38cc1317e09de8 (patch)
tree824a2cfbc5f0ec32a97e23cc1a98af2a085b1a94 /test
parent407563b9f098a05492dff1d47d86e7c3e8cd9a20 (diff)
HTML validation : fixed URL encoding of Pictures link.
Diffstat (limited to 'test')
-rw-r--r--test/java/net/yacy/server/serverObjectsTest.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/java/net/yacy/server/serverObjectsTest.java b/test/java/net/yacy/server/serverObjectsTest.java
new file mode 100644
index 000000000..12ec903fe
--- /dev/null
+++ b/test/java/net/yacy/server/serverObjectsTest.java
@@ -0,0 +1,72 @@
+// (C) 2016 by luccioman; http://github.com/luccioman
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package net.yacy.server;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for serverObjects
+ */
+public class serverObjectsTest {
+
+ /**
+ * This method allow manual check of the output obtained with different file
+ * types encoding reserved characters.
+ *
+ * @throws UnsupportedEncodingException
+ */
+ @Test
+ public void testPut() throws UnsupportedEncodingException {
+ String raw = "query with reserved chars : \"#<>?`{}/:;=@[\\]^|\t&";
+ String urlEncoded = URLEncoder.encode(raw, StandardCharsets.UTF_8.name());
+
+ serverObjects prop = new serverObjects();
+
+ prop.put("raw", raw);
+ System.out.println("no file type raw : " + prop.get("raw"));
+
+ prop.put("urlEncoded", urlEncoded);
+ System.out.println("no file type urlEncoded : " + prop.get("urlEncoded") + "\n");
+
+ prop.putHTML("html raw", raw);
+ System.out.println("html raw : " + prop.get("html raw"));
+
+ prop.putHTML("html urlEncoded", urlEncoded);
+ System.out.println("html urlEncoded : " + prop.get("html urlEncoded") + "\n");
+
+ prop.putXML("xml raw", raw);
+ System.out.println("xml raw : " + prop.get("xml raw"));
+
+ prop.putHTML("xml urlEncoded", urlEncoded);
+ System.out.println("xml urlEncoded : " + prop.get("xml urlEncoded") + "\n");
+
+ prop.putJSON("json raw", raw);
+ System.out.println("json raw : " + prop.get("json raw"));
+
+ prop.putJSON("json urlEncoded", urlEncoded);
+ System.out.println("json urlEncoded : " + prop.get("json urlEncoded") + "\n");
+ }
+
+}