storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [3/6] storm git commit: added united tests and changed exception message
Date Thu, 06 Aug 2015 02:14:38 GMT
added united tests and changed exception message


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/394d62ae
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/394d62ae
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/394d62ae

Branch: refs/heads/master
Commit: 394d62ae39532dea42474578747a59a41e1e2d38
Parents: e7d8907
Author: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Authored: Mon Aug 3 11:57:29 2015 -0500
Committer: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Committed: Mon Aug 3 11:59:56 2015 -0500

----------------------------------------------------------------------
 .../src/jvm/backtype/storm/ConfigValidation.java      |  3 +--
 storm-core/test/clj/backtype/storm/config_test.clj    | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/394d62ae/storm-core/src/jvm/backtype/storm/ConfigValidation.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/ConfigValidation.java b/storm-core/src/jvm/backtype/storm/ConfigValidation.java
index 7fd918b..a4897c8 100644
--- a/storm-core/src/jvm/backtype/storm/ConfigValidation.java
+++ b/storm-core/src/jvm/backtype/storm/ConfigValidation.java
@@ -28,7 +28,6 @@ public class ConfigValidation {
     /**
      * Declares methods for validating configuration values.
      */
-    public static interface FieldValidator {
         /**
          * Validates the given field.
          * @param name the name of the field.
@@ -268,7 +267,7 @@ public class ConfigValidation {
                     return;
                 }
             }
-            throw new IllegalArgumentException("Field " + name + " must be a Number");
+            throw new IllegalArgumentException("Field " + name + " must be a Positive Number");
         }
     };
 

http://git-wip-us.apache.org/repos/asf/storm/blob/394d62ae/storm-core/test/clj/backtype/storm/config_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/config_test.clj b/storm-core/test/clj/backtype/storm/config_test.clj
index ac80b14..fa5575e 100644
--- a/storm-core/test/clj/backtype/storm/config_test.clj
+++ b/storm-core/test/clj/backtype/storm/config_test.clj
@@ -99,6 +99,20 @@
     (is (thrown-cause? java.lang.IllegalArgumentException
           (.validateField validator "test" [-100 (inc Integer/MAX_VALUE)])))))
 
+(deftest test-positive-number-validator
+  (let [validator ConfigValidation/PositiveNumberValidator]
+    (.validateField validator "test" nil)
+    (.validateField validator "test" 1.0)
+    (.validateField validator "test" 1)
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" -1.0)))
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" -1)))
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" 0)))
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" 0.0)))))
+
 (deftest test-topology-workers-is-integer
   (let [validator (CONFIG-SCHEMA-MAP TOPOLOGY-WORKERS)]
     (.validateField validator "test" 42)


Mime
View raw message