Created
August 11, 2010 03:40
-
-
Save vdichev/518434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait XmlResponse { | |
self: TestResponse => | |
def xmlMatch(f: Elem => Unit) | |
(implicit errorFunc: ReportFailure): TestResponse = { | |
if (this.asInstanceOf[SelfType].code != 200) | |
errorFunc.fail("Response status is not 200!") | |
xml match { | |
case Full(xml) => f(xml); this | |
case _ => errorFunc.fail("Response contains no XML!") | |
} | |
} | |
def \\(node: Node): TestResponse = | |
xmlMatch(_ must XmlBaseMatchers.\\(node)) | |
def !\\(node: Node): TestResponse = | |
xmlMatch(_ must not(XmlBaseMatchers.\\(node))) | |
def \(node: Node): TestResponse = | |
xmlMatch(_ must XmlBaseMatchers.\(node)) | |
def !\(node: Node): TestResponse = | |
xmlMatch(_ must not(XmlBaseMatchers.\(node))) | |
def \\(label: String): TestResponse = | |
xmlMatch(_ must XmlBaseMatchers.\\(label)) | |
def !\\(label: String): TestResponse = | |
xmlMatch(_ must not(XmlBaseMatchers.\\(label))) | |
def \(label: String): TestResponse = | |
xmlMatch(_ must XmlBaseMatchers.\(label)) | |
def !\(label: String): TestResponse = | |
xmlMatch(_ must not(XmlBaseMatchers.\(label))) | |
} | |
implicit def testResponse2XmlResponse(response: TestResponse): XmlResponse = { | |
val r = response.asInstanceOf[response.SelfType] | |
new response.SelfType(r.baseUrl, | |
r.code, | |
r.msg, | |
r.headers, | |
r.body, | |
r.theHttpClient) with XmlResponse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment