Skip to content

Commit

Permalink
ConnectionString javadoc (#84)
Browse files Browse the repository at this point in the history
* ConnectionString javadoc

* fixes by review

* fix javadoc

* fix unit test

* (2) fix unit test
  • Loading branch information
surovenko authored Aug 29, 2024
1 parent d24eefa commit e3a8cbf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/one/nio/net/ConnectionString.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Available HTTP params for configure directly in ConnectionString url:
* <ul>
* <li>keepalive {@code true}</li>
* <li>bufferSize {@code 8000}</li>
* <li>timeout {@code 3000}</li>
* <li>readTimeout {@code 3000}</li>
* <li>connectTimeout {@code 1000}</li>
* <li>fifo {@code false}</li>
* <li>jmx {@code false}</li>
* <li>clientMinPoolSize {@code 0}</li>
* <li>clientMaxPoolSize {@code 5000}</li>
* <li>schedulingPolicy {@code OTHER}</li>
* <li>tos {@code 0}</li>
* <li>recvBuf {@code 0}</li>
* <li>sendBuf {@code 0}</li>
* <li>backlog {@code 128}</li>
* <li>selectors {@code 0}</li>
* <li>minWorkers {@code 0}</li>
* <li>maxWorkers {@code 0}</li>
* <li>queueTime {@code 0}</li>
* <li>closeSessions {@code false}</li>
* <li>threadPriority {@code Thread.NORM_PRIORITY}</li>
* </ul>
*/
public class ConnectionString {
private static final Pattern INTERFACE_PATTERN = Pattern.compile("\\{(.+)\\}");
private static final Map<String, Integer> WELL_KNOWN_PORTS = new HashMap<>();
Expand Down
13 changes: 13 additions & 0 deletions test/one/nio/net/ConnectionStringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e3a8cbf

Please sign in to comment.