From e3a8cbfda97bf65295f18ef0618fd0e6b31f138a Mon Sep 17 00:00:00 2001
From: surovenko <98164430+surovenko@users.noreply.github.com>
Date: Thu, 29 Aug 2024 14:37:33 +0200
Subject: [PATCH] ConnectionString javadoc (#84)
* ConnectionString javadoc
* fixes by review
* fix javadoc
* fix unit test
* (2) fix unit test
---
src/one/nio/net/ConnectionString.java | 25 ++++++++++++++++++++++
test/one/nio/net/ConnectionStringTest.java | 13 +++++++++++
2 files changed, 38 insertions(+)
diff --git a/src/one/nio/net/ConnectionString.java b/src/one/nio/net/ConnectionString.java
index 43387c9..93fe648 100755
--- a/src/one/nio/net/ConnectionString.java
+++ b/src/one/nio/net/ConnectionString.java
@@ -32,6 +32,31 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Available HTTP params for configure directly in ConnectionString url:
+ *
+ * - keepalive {@code true}
+ * - bufferSize {@code 8000}
+ * - timeout {@code 3000}
+ * - readTimeout {@code 3000}
+ * - connectTimeout {@code 1000}
+ * - fifo {@code false}
+ * - jmx {@code false}
+ * - clientMinPoolSize {@code 0}
+ * - clientMaxPoolSize {@code 5000}
+ * - schedulingPolicy {@code OTHER}
+ * - tos {@code 0}
+ * - recvBuf {@code 0}
+ * - sendBuf {@code 0}
+ * - backlog {@code 128}
+ * - selectors {@code 0}
+ * - minWorkers {@code 0}
+ * - maxWorkers {@code 0}
+ * - queueTime {@code 0}
+ * - closeSessions {@code false}
+ * - threadPriority {@code Thread.NORM_PRIORITY}
+ *
+ */
public class ConnectionString {
private static final Pattern INTERFACE_PATTERN = Pattern.compile("\\{(.+)\\}");
private static final Map WELL_KNOWN_PORTS = new HashMap<>();
diff --git a/test/one/nio/net/ConnectionStringTest.java b/test/one/nio/net/ConnectionStringTest.java
index baf4ba2..24d59c0 100755
--- a/test/one/nio/net/ConnectionStringTest.java
+++ b/test/one/nio/net/ConnectionStringTest.java
@@ -49,6 +49,19 @@ public void testConnectionStrings() {
assertEquals("?", conn.getStringParam("question"));
assertEquals(345, conn.getIntParam("int", 0));
+ conn = new ConnectionString("https://example.com?str=s&empty=&int=123");
+ assertEquals("example.com", conn.getHost());
+ assertEquals(443, conn.getPort());
+ assertEquals("?str=s&empty=&int=123", conn.getPath());
+ assertEquals("s", conn.getStringParam("str"));
+ assertEquals("", conn.getStringParam("empty", "def"));
+ assertEquals(123, conn.getIntParam("int", 0));
+
+ conn = new ConnectionString("https://example.com/somePath");
+ assertEquals("example.com", conn.getHost());
+ assertEquals(443, conn.getPort());
+ assertEquals("/somePath", conn.getPath());
+
conn = new ConnectionString("socket://[::1]:12345?:=true");
assertEquals("[::1]", conn.getHost());
assertEquals(12345, conn.getPort());