=htp #16814 Fix ClassCastException in PathMatchers.NumberMatcher

Direct port of 43bb625bbd
This commit is contained in:
Mathias 2015-02-23 12:47:27 +01:00
parent cac9c9f2fb
commit f869d6ccbc
2 changed files with 16 additions and 4 deletions

View file

@ -80,6 +80,19 @@ class PathDirectivesSpec extends RoutingSpec with Inside {
"reject [/2147483648]" in test() // > Int.MaxValue
}
"pathPrefix(CustomShortNumber)" should {
object CustomShortNumber extends NumberMatcher[Short](Short.MaxValue, 10) {
def fromChar(c: Char) = fromDecimalChar(c)
}
val test = testFor(pathPrefix(CustomShortNumber) { echoCaptureAndUnmatchedPath })
"accept [/23]" in test("23:")
"accept [/12345yes]" in test("12345:yes")
"reject [/]" in test()
"reject [/abc]" in test()
"reject [/33000]" in test() // > Short.MaxValue
}
"pathPrefix(JavaUUID)" should {
val test = testFor(pathPrefix(JavaUUID) { echoCaptureAndUnmatchedPath })
"accept [/bdea8652-f26c-40ca-8157-0b96a2a8389d]" in test("bdea8652-f26c-40ca-8157-0b96a2a8389d:")