Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (25 sloc) 1.136 kb
package org.elasticmq.rest
import org.scalatest.FunSuite
import org.scalatest.matchers.MustMatchers
import org.scalatest.prop.TableDrivenPropertyChecks
class RestPathTestSuite extends FunSuite with MustMatchers with TableDrivenPropertyChecks {
import RestPath._
val paths = Table[RestPath, String, Option[Map[String, String]]](
("rest path", "input path", "expected result"),
(root, "/", Some(Map())),
(root / "a" / "b", "/a/b", Some(Map())),
(root / "a" / "b", "/a/c", None),
(root / "a" / "b", "/a", None),
(root / "a" / "b", "/a/b/d", None),
(root / "a" / """[a-z][0-9]+""".r, "/a/aa", None),
(root / "a" / """[a-z][0-9]+""".r, "/a/a123", Some(Map())),
(root / "a" / %("p1") / "c", "/a/zzz/c", Some(Map("p1" -> "zzz"))),
(root / "a" / %("p1") / %("p2"), "/a/zzz/yyy", Some(Map("p1" -> "zzz", "p2" -> "yyy"))),
(root / "a" / %("p1") / %("p2"), "/a/zzz", None)
)
forAll (paths) { (restPath, inputPath, expectedResult) =>
test(restPath+" for "+inputPath+" should give result "+expectedResult) {
restPath.matchAndExtract(inputPath) must equal (expectedResult)
}
}
}
Jump to Line
Something went wrong with that request. Please try again.