2

I am writing acceptance test, which validates HTTP response from embedded server. So it looks like

assert((200, """{
                |  "status" : "OK"
                |}""".stripMargin) === (code, response))

so far it works quite well on my Linux box, however when the test is invoked on Windows - it fails.

org.scalatest.exceptions.TestFailedException: "{[
  "status" : "OK"
]
}" did not equal "{[
  "status" : "OK"]
}"

I think this is because of line endings - those are different in Windows than in Linux. Is there any simple way to provide os-specific line endings in compiled test data?

jdevelop
  • 12,176
  • 10
  • 56
  • 112

1 Answers1

1

Check for both. Cuz "Most textual Internet protocols (including HTTP, SMTP, FTP, IRC and many others) mandate the use of ASCII CR+LF (0x0D 0x0A) on the protocol level, but recommend that tolerant applications recognize lone LF as well. "

Enjoy.

Observer
  • 710
  • 10
  • 14
  • actually it's just for tests, and I have no idea how to do that in neat way – jdevelop Jan 31 '13 at 16:46
  • strings constants glued by "\r\n" and "\n"? Or replace "\r\n" with "\n" and assert after that – Observer Jan 31 '13 at 17:02
  • that's what I've done, will see if that will help. But I don't like the solution here, I believe that line endings should be os-dependent. – jdevelop Jan 31 '13 at 17:11
  • Well they are, but if I understand your use-case correctly it depends on the platform your http-container installed. So you have no certainty what exactly the answer will be. – Observer Jan 31 '13 at 17:32