aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala/com/softwaremill
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-28 09:43:06 +0200
committeradamw <adam@warski.org>2017-07-28 09:43:06 +0200
commit8c7945ea87371d02906b84c45dc2d3b92f815306 (patch)
tree8cda5f1fd5afd9515eb535c415e33212fb5d5156 /core/src/test/scala/com/softwaremill
parent2b38d9b18620f9d4796f8b56f73e9b093051a1fa (diff)
downloadsttp-8c7945ea87371d02906b84c45dc2d3b92f815306.tar.gz
sttp-8c7945ea87371d02906b84c45dc2d3b92f815306.tar.bz2
sttp-8c7945ea87371d02906b84c45dc2d3b92f815306.zip
Reverting in-progress changes
Diffstat (limited to 'core/src/test/scala/com/softwaremill')
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala13
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/UriTests.scala57
2 files changed, 6 insertions, 64 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
index b0dbf53..85348e6 100644
--- a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
@@ -1,5 +1,7 @@
package com.softwaremill.sttp
+import java.net.URI
+
import org.scalatest.{FunSuite, Matchers}
class UriInterpolatorTests extends FunSuite with Matchers {
@@ -13,7 +15,7 @@ class UriInterpolatorTests extends FunSuite with Matchers {
val v4encoded = "f%2Fg"
val secure = true
- val testData: List[(String, List[(Uri, String)])] = List(
+ val testData: List[(String, List[(URI, String)])] = List(
"basic" -> List(
(uri"http://example.com", "http://example.com"),
(uri"http://example.com/", "http://example.com/"),
@@ -21,17 +23,14 @@ class UriInterpolatorTests extends FunSuite with Matchers {
(uri"http://example.com/a/b/c", "http://example.com/a/b/c"),
(uri"http://example.com/a/b/c/", "http://example.com/a/b/c/"),
(uri"http://example.com/a/b/c?x=y&h=j",
- "http://example.com/a/b/c?x=y&h=j"),
- (uri"http://example.com/a%20b?v%26v=v+v",
- "http://example.com/a%20b?v%26v=v+v"),
- (uri"http://example.com?x=y;p", "http://example.com?x=y;p")
+ "http://example.com/a/b/c?x=y&h=j")
),
"scheme" -> List(
(uri"http${if (secure) "s" else ""}://example.com",
s"https://example.com"),
(uri"${if (secure) "https" else "http"}://example.com",
s"https://example.com"),
- (uri"example.com?a=$v2", s"http://example.com?a=$v2queryEncoded")
+ (uri"example.com?a=$v2", s"example.com?a=$v2queryEncoded")
),
"authority" -> List(
(uri"http://$v1.com", s"http://$v1.com"),
@@ -116,7 +115,7 @@ class UriInterpolatorTests extends FunSuite with Matchers {
((interpolated, expected), i) <- testCases.zipWithIndex
} {
test(s"[$groupName] interpolate to $expected (${i + 1})") {
- interpolated.toString should be(expected)
+ interpolated should be(new URI(expected))
}
}
}
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
deleted file mode 100644
index e82cc9c..0000000
--- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.softwaremill.sttp
-
-import org.scalatest.{FunSuite, Matchers}
-
-class UriTests extends FunSuite with Matchers {
-
- val QF = QueryFragment
-
- val wholeUriTestData = List(
- Uri("http", "example.com", None, Nil, Nil, None) -> "http://example.com",
- Uri("https",
- "sub.example.com",
- Some(8080),
- List("a", "b", "xyz"),
- List(QF.KeyValue("p1", "v1"), QF.KeyValue("p2", "v2")),
- Some("f")) ->
- "https://sub.example.com:8080/a/b/xyz?p1=v1&p2=v2#f",
- Uri("http",
- "example.com",
- None,
- List(""),
- List(QF.KeyValue("p", "v"), QF.KeyValue("p", "v")),
- None) -> "http://example.com/?p=v&p=v",
- Uri("http",
- "exa mple.com",
- None,
- List("a b", "z", "ą:ę"),
- List(QF.KeyValue("p:1", "v&v"), QF.KeyValue("p2", "v v")),
- None) ->
- "http://exa%20mple.com/a%20b/z/%C4%85%3A%C4%99?p%3A1=v%26v&p2=v+v"
- )
-
- for {
- (uri, expected) <- wholeUriTestData
- } {
- test(s"$uri should serialize to $expected") {
- uri.toString should be(expected)
- }
- }
-
- val testUri = Uri("http", "example.com", None, Nil, Nil, None)
-
- val pathTestData = List(
- "a/b/c" -> List("a", "b", "c"),
- "/a/b/c" -> List("a", "b", "c"),
- "/" -> List(""),
- "" -> List("")
- )
-
- for {
- (path, expected) <- pathTestData
- } {
- test(s"$path should parse as $expected") {
- testUri.path(path).path.toList should be(expected)
- }
- }
-}