You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2023/01/11 03:18:27 UTC

[incubator-tuweni] branch main updated: add tests for property validators related to ports. Fixes #253

This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/main by this push:
     new 2717dbcde add tests for property validators related to ports. Fixes #253
     new b70014b81 Merge pull request #483 from atoulme/add_tests_for_ports
2717dbcde is described below

commit 2717dbcdee5cffb965b58653981f087ef327a41f
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Tue Jan 10 18:36:08 2023 -0800

    add tests for property validators related to ports. Fixes #253
---
 .../apache/tuweni/config/PropertyValidatorTest.java    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/config/src/test/java/org/apache/tuweni/config/PropertyValidatorTest.java b/config/src/test/java/org/apache/tuweni/config/PropertyValidatorTest.java
index 01a63e099..8dbeb712f 100644
--- a/config/src/test/java/org/apache/tuweni/config/PropertyValidatorTest.java
+++ b/config/src/test/java/org/apache/tuweni/config/PropertyValidatorTest.java
@@ -89,4 +89,22 @@ class PropertyValidatorTest {
     assertTrue(longPropertyValidator.validate("foo", null, 32L).isEmpty());
     assertEquals(1, longPropertyValidator.validate("foo", null, 31L).size());
   }
+
+  @Test
+  void testIsValidPort() {
+    PropertyValidator<Integer> portValidator = PropertyValidator.isValidPort();
+    assertTrue(portValidator.validate("foo", null, 8080).isEmpty());
+    assertTrue(portValidator.validate("foo", null, 60000).isEmpty());
+    assertEquals(1, portValidator.validate("foo", null, 65536).size());
+    assertEquals(1, portValidator.validate("foo", null, 0).size());
+  }
+
+  @Test
+  void testIsValidPortOrZero() {
+    PropertyValidator<Integer> portValidator = PropertyValidator.isValidPortOrZero();
+    assertTrue(portValidator.validate("foo", null, 8080).isEmpty());
+    assertTrue(portValidator.validate("foo", null, 60000).isEmpty());
+    assertTrue(portValidator.validate("foo", null, 0).isEmpty());
+    assertEquals(1, portValidator.validate("foo", null, 65536).size());
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org