diff options
| author | reger <reger18@arcor.de> | 2016-11-14 01:37:16 +0100 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2016-11-14 01:37:16 +0100 |
| commit | 395f2e8946260eefa478b5b75be6f33ef4570bac (patch) | |
| tree | 98720e42de5667ce86a57895926f7ed9709e815b /test | |
| parent | 62f75417ef999703314f74e4d8f51c394d8ada80 (diff) | |
Make ServletRequest implement the standardized HttpServletRequest interface,
to make all readily available information from the original ServletRequest
available to YaCy servlets (without converting data to internal structures).
The implementation of the common interface allows easier integration of
YaCy servlets with the servlet standard (e.g. shared login service with
the servlet container etc.)
Diffstat (limited to 'test')
| -rw-r--r-- | test/java/net/yacy/cora/protocol/RequestHeaderTest.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/java/net/yacy/cora/protocol/RequestHeaderTest.java b/test/java/net/yacy/cora/protocol/RequestHeaderTest.java new file mode 100644 index 000000000..3cdb23cb9 --- /dev/null +++ b/test/java/net/yacy/cora/protocol/RequestHeaderTest.java @@ -0,0 +1,67 @@ +/**
+ * RequestHeaderTest
+ * part of YaCy
+ * Copyright 2016 by reger24; https://github.com/reger24
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.yacy.cora.protocol;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Unit tests for RequestHeader class.
+ *
+ * @author reger24
+ */
+public class RequestHeaderTest {
+
+ /**
+ * Test of getServerPort method, of class RequestHeader.
+ */
+ @Test
+ public void testGetServerPort() {
+ int portresult;
+ RequestHeader hdr = new RequestHeader();
+
+ // test host with port
+ hdr.put(HeaderFramework.HOST, "[:1]:8090");
+ portresult = hdr.getServerPort();
+ assertEquals (8090, portresult);
+
+ hdr.put(HeaderFramework.HOST, "127.0.0.1:8090");
+ portresult = hdr.getServerPort();
+ assertEquals (8090, portresult);
+
+ hdr.put(HeaderFramework.HOST, "localhost:8090");
+ portresult = hdr.getServerPort();
+ assertEquals (8090, portresult);
+
+ // test default port
+ hdr.put(HeaderFramework.HOST, "[:1]");
+ portresult = hdr.getServerPort();
+ assertEquals (80, portresult);
+
+ hdr.put(HeaderFramework.HOST, "127.0.0.1");
+ portresult = hdr.getServerPort();
+ assertEquals (80, portresult);
+
+ hdr.put(HeaderFramework.HOST, "localhost");
+ portresult = hdr.getServerPort();
+ assertEquals (80, portresult);
+ }
+
+}
|
