diff options
author | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-31 15:50:19 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-31 15:50:19 +0200 |
commit | e5555bf2da861ce365b21d27309daf4d2de3580f (patch) | |
tree | 024bdf6996833e54b5b917811a1cef88a3c9c6ae /src/test/scala/cc | |
parent | 3bba5c875e0e5335d2fb41b8d82d9ebc1567989b (diff) | |
download | spray-json-e5555bf2da861ce365b21d27309daf4d2de3580f.tar.gz spray-json-e5555bf2da861ce365b21d27309daf4d2de3580f.tar.bz2 spray-json-e5555bf2da861ce365b21d27309daf4d2de3580f.zip |
move into its own package
Diffstat (limited to 'src/test/scala/cc')
-rw-r--r-- | src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala (renamed from src/test/scala/cc/spray/json/JsonLensesSpec.scala) | 29 | ||||
-rw-r--r-- | src/test/scala/cc/spray/json/lenses/JsonLensesTest.scala (renamed from src/test/scala/cc/spray/json/JsonLensesTest.scala) | 2 | ||||
-rw-r--r-- | src/test/scala/cc/spray/json/lenses/JsonPathExamplesSpec.scala (renamed from src/test/scala/cc/spray/json/JsonPathExamplesSpec.scala) | 3 | ||||
-rw-r--r-- | src/test/scala/cc/spray/json/lenses/SpecHelpers.scala (renamed from src/test/scala/cc/spray/json/SpecHelpers.scala) | 3 |
4 files changed, 24 insertions, 13 deletions
diff --git a/src/test/scala/cc/spray/json/JsonLensesSpec.scala b/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala index 715fc2a..f371f91 100644 --- a/src/test/scala/cc/spray/json/JsonLensesSpec.scala +++ b/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala @@ -1,10 +1,13 @@ package cc.spray.json +package lenses import DefaultJsonProtocol._ import org.specs2.mutable.Specification +import cc.spray.json.DeserializationException class JsonLensesSpec extends Specification with SpecHelpers { + import JsonLenses._ val n = field("n") @@ -16,7 +19,7 @@ class JsonLensesSpec extends Specification with SpecHelpers { """{"n": 2}""".extract[Int]('n) must be_==(2) } "missing" in { - """{"n": 2}""".extract[Int]('z) must throwAn[Exception]("""Expected field 'z' in '{"n":2}'""") + """{"n": 2}""".extract[Int]('z) must throwAn[Exception]( """Expected field 'z' in '{"n":2}'""") } "wrong type" in { """{"n": 2}""".extract[String]('n) must throwA[DeserializationException]("Expected String as JsString, but got 2") @@ -74,12 +77,12 @@ class JsonLensesSpec extends Specification with SpecHelpers { """[[1, 2], [3, 4]]""".extract[Int]((* / *)) must be_==(Seq(1, 2, 3, 4)) } "if outer is no array" in { - """{"a": 5}""".extract[Int]((* / "a")) must throwAn[Exception]("""Not a json array: {"a":5}""") - """{"a": 5}""".extract[Int]((* / *)) must throwAn[Exception]("""Not a json array: {"a":5}""") + """{"a": 5}""".extract[Int]((* / "a")) must throwAn[Exception]( """Not a json array: {"a":5}""") + """{"a": 5}""".extract[Int]((* / *)) must throwAn[Exception]( """Not a json array: {"a":5}""") } "if inner is no array" in { - """[{}, {}]""".extract[Int]((* / *)) must throwAn[Exception]("""Not a json array: {}""") - """{"a": 5}""".extract[Int](("a" / *)) must throwAn[Exception]("""Not a json array: 5""") + """[{}, {}]""".extract[Int]((* / *)) must throwAn[Exception]( """Not a json array: {}""") + """{"a": 5}""".extract[Int](("a" / *)) must throwAn[Exception]( """Not a json array: 5""") } } /*"filtered elements of an array" in { @@ -93,11 +96,11 @@ class JsonLensesSpec extends Specification with SpecHelpers { """{"n": 12}""" update (n ! set(23)) must be_json( """{"n": 23}""") } "missing" in { - """{"n": {"b": 4}}""" update ("n" / "c" ! set(23)) must be_json("""{"n": {"b": 4, "c": 23}}""") + """{"n": {"b": 4}}""" update ("n" / "c" ! set(23)) must be_json( """{"n": {"b": 4, "c": 23}}""") } "twice" in { val a = field("a") - """{"a": 5}""" update (a ! set(23) && a ! set(15)) must be_json("""{"a": 15}""") + """{"a": 5}""" update (a ! set(23) && a ! set(15)) must be_json( """{"a": 15}""") } } "update field" in { @@ -108,7 +111,7 @@ class JsonLensesSpec extends Specification with SpecHelpers { """{"n": 12}""" update (n ! updated[String](_ + "test")) must throwA[DeserializationException]("Expected String as JsString, but got 12") } "missing" in { - """{"n": 12}""" update (field("z") ! updated[Int](_ + 1)) must throwAn[Exception]("""Expected field 'z' in '{"n":12}'""") + """{"n": 12}""" update (field("z") ! updated[Int](_ + 1)) must throwAn[Exception]( """Expected field 'z' in '{"n":12}'""") } } "set field of member" in { @@ -119,11 +122,11 @@ class JsonLensesSpec extends Specification with SpecHelpers { """{"n": {"b": 4}}""" update ("n" / "b" ! updated[Int](1 +)) must be_json( """{"n": {"b": 5}}""") } "parent missing" in { - """{"x": {"b": 4}}""" update ("n" / "b" ! updated[Int](1 +)) must throwAn[Exception]("""Expected field 'n' in '{"x":{"b":4}}'""") + """{"x": {"b": 4}}""" update ("n" / "b" ! updated[Int](1 +)) must throwAn[Exception]( """Expected field 'n' in '{"x":{"b":4}}'""") } } "set element of array" in { - """["a", "b", 2, 5, 8, 3]""" update (element(3) ! set(35)) must be_json("""["a", "b", 2, 35, 8, 3]""") + """["a", "b", 2, 5, 8, 3]""" update (element(3) ! set(35)) must be_json( """["a", "b", 2, 35, 8, 3]""") } "change a found element" in { "in a homogenuous array" in { @@ -145,13 +148,13 @@ class JsonLensesSpec extends Specification with SpecHelpers { val lens = JsonLenses.find("a".is[Int](_ == 12)) / "b" / "c" / JsonLenses.find(JsonLenses.value.is[Int](_ == 5)) "existing" in { - """[{"a": 12, "b": {"c": [2, 5]}}, 13]""" update (lens ! set(42)) must be_json("""[{"a": 12, "b": {"c": [2, 42]}}, 13]""") + """[{"a": 12, "b": {"c": [2, 5]}}, 13]""" update (lens ! set(42)) must be_json( """[{"a": 12, "b": {"c": [2, 42]}}, 13]""") } "missing in first find" in { - """[{"a": 2, "b": {"c": [5]}}, 13]""" update (lens ! set(42)) must be_json("""[{"a": 2, "b": {"c": [5]}}, 13]""") + """[{"a": 2, "b": {"c": [5]}}, 13]""" update (lens ! set(42)) must be_json( """[{"a": 2, "b": {"c": [5]}}, 13]""") } "missing in second find" in { - """[{"a": 2, "b": {"c": [7]}}, 13]""" update (lens ! set(42)) must be_json("""[{"a": 2, "b": {"c": [7]}}, 13]""") + """[{"a": 2, "b": {"c": [7]}}, 13]""" update (lens ! set(42)) must be_json( """[{"a": 2, "b": {"c": [7]}}, 13]""") } } } diff --git a/src/test/scala/cc/spray/json/JsonLensesTest.scala b/src/test/scala/cc/spray/json/lenses/JsonLensesTest.scala index 15bba11..b91ecaa 100644 --- a/src/test/scala/cc/spray/json/JsonLensesTest.scala +++ b/src/test/scala/cc/spray/json/lenses/JsonLensesTest.scala @@ -1,7 +1,9 @@ package cc.spray.json +package lenses import Predef.{augmentString => _, wrapString => _, _} import DefaultJsonProtocol._ +import cc.spray.json.{JsValue, JsonParser} object JsonLensesTest extends App { diff --git a/src/test/scala/cc/spray/json/JsonPathExamplesSpec.scala b/src/test/scala/cc/spray/json/lenses/JsonPathExamplesSpec.scala index 4b0cbb1..f7e1559 100644 --- a/src/test/scala/cc/spray/json/JsonPathExamplesSpec.scala +++ b/src/test/scala/cc/spray/json/lenses/JsonPathExamplesSpec.scala @@ -4,10 +4,13 @@ * the Apache 2 license. http://www.apache.org/licenses/LICENSE-2.0 */ package cc.spray.json +package lenses import org.specs2.mutable.Specification +import cc.spray.json.{JsValue, JsonParser, DefaultJsonProtocol} class JsonPathExamplesSpec extends Specification with SpecHelpers { + import JsonLenses._ import DefaultJsonProtocol._ diff --git a/src/test/scala/cc/spray/json/SpecHelpers.scala b/src/test/scala/cc/spray/json/lenses/SpecHelpers.scala index 6a6ea43..427fdbb 100644 --- a/src/test/scala/cc/spray/json/SpecHelpers.scala +++ b/src/test/scala/cc/spray/json/lenses/SpecHelpers.scala @@ -1,6 +1,9 @@ package cc.spray.json +package lenses +import lenses.JsonLenses import org.specs2.mutable.Specification +import cc.spray.json.JsonParser trait SpecHelpers { self: Specification => |