diff options
author | adamw <adam@warski.org> | 2017-11-27 12:22:29 +0100 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-11-27 12:22:55 +0100 |
commit | 8cf5bdc708a46fa9e842481db54caaf59123e4e6 (patch) | |
tree | d55a376b2b27a355e0d9f69377cdcfda2c669616 /core/src/test/scala | |
parent | fc07b4ac1c67c9a096fe1d63bf5049eabff8b6c1 (diff) | |
download | sttp-8cf5bdc708a46fa9e842481db54caaf59123e4e6.tar.gz sttp-8cf5bdc708a46fa9e842481db54caaf59123e4e6.tar.bz2 sttp-8cf5bdc708a46fa9e842481db54caaf59123e4e6.zip |
Basic validation of a constructed URI
Diffstat (limited to 'core/src/test/scala')
-rw-r--r-- | core/src/test/scala/com/softwaremill/sttp/UriTests.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala index 23fe3d5..73cb05d 100644 --- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala @@ -136,4 +136,21 @@ class UriTests extends FunSuite with Matchers { val uriAsString = "https://sub.example.com:8080/a/b/xyz?p1=v1&p2=v2#f" uri"$uriAsString".toJavaUri.toString should be(uriAsString) } + + val validationTestData = List( + (() => Uri("")) -> "host cannot be empty", + (() => Uri("h ttp", "example.org")) -> "scheme" + ) + + for { + (createUri, expectedException) <- validationTestData + } { + test(s"""should validate URI and throw "$expectedException" if not valid""") { + val caught = intercept[IllegalArgumentException] { + createUri() + } + + caught.getMessage.toLowerCase() should include(expectedException) + } + } } |