aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-11-27 12:22:29 +0100
committeradamw <adam@warski.org>2017-11-27 12:22:55 +0100
commit8cf5bdc708a46fa9e842481db54caaf59123e4e6 (patch)
treed55a376b2b27a355e0d9f69377cdcfda2c669616 /core/src/test/scala
parentfc07b4ac1c67c9a096fe1d63bf5049eabff8b6c1 (diff)
downloadsttp-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.scala17
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)
+ }
+ }
}