Skip to content

Commit

Permalink
refactor some of the tests to use (thrown-with-msg? ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
pingles committed Sep 4, 2013
1 parent 033c405 commit bc4211e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/clj_hector/serialize.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
(cond (keyword? x) (x serializers)
(instance? Serializer x) x
:else (SerializerTypeInferer/getSerializer x))
(throw (NullPointerException. (str x " did not resolve to a serializer.")))))
(throw (IllegalArgumentException. (str x " did not resolve to a serializer.")))))

(defn- deserialize-composite
"Given a composite and a list of deserializers deserialize the
Expand Down
9 changes: 3 additions & 6 deletions test/clj_hector/test/serialize.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
(is (= :kw (.fromBytes s (.toBytes s :kw))))))

(deftest bad-serializer-name
(is (thrown? NullPointerException (serializer :bad-serializer-keyword)))
(try
(serializer :bad-serializer-keyword)
(is false "Should have gotten a NPE")
(catch NullPointerException e
(is (= ":bad-serializer-keyword did not resolve to a serializer." (.getMessage e))))))
(is (thrown-with-msg? IllegalArgumentException
#"bad-serializer-keyword did not resolve to a serializer"
(serializer :bad-serializer-keyword))))

0 comments on commit bc4211e

Please sign in to comment.