Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec test doesn't populate multiParams #155

tommey opened this issue Jul 18, 2014 · 2 comments

Spec test doesn't populate multiParams #155

tommey opened this issue Jul 18, 2014 · 2 comments


Copy link

@tommey tommey commented Jul 18, 2014

Hi guys,

I'm new to Scala and so to Finatra, but I found a serious bug in the testing part. If I pass a Map with parameters to the call, the multiParams HashMap doesn't get populated with it.

You can reproduce it with this:

package com.twitter.finatra

import com.twitter.finatra.test.FlatSpecHelper

class RequestResponseSpec extends FlatSpecHelper
    class ExampleApp extends Controller
        get("/") { request =>
            val name = request.multiParams.getOrElse("name", "Anonymous").toString

    val server = new FinatraServer
    server.register(new ExampleApp)

    "GET / with name parameter" should "return the given name in response" in {
        val name = "James"
        get("/", Map("name" -> name))
        response.body should equal(name)
        response.code should equal(200)

It results in this:

"[Anonymou]s" did not equal "[Jame]s"
org.scalatest.exceptions.TestFailedException: "[Anonymou]s" did not equal "[Jame]s"

I have tried to go after it and put some breakpoints, but I'm really just a newbie, so I found that the name parameter gets into the route (I saw /?name=James as path), but then it is not parsed into the multiParams map.

I have the following settings in IntelliJ IDEA 14 EAP:

Windows 7, JDK 1.8_05, Scala 2.11.1, Scalatest 2.2.0 (for 2.11)
Language level: Scala 2.11 ()
Compiler: SBT :: scala-comiler-bundle:2.10.3

Tell me if you need more information or if you can reproduce it or I do something totally wrong.

Thank you,

@tommey tommey changed the title Spec test doesn't pass multiParams Spec test doesn't populate multiParams Jul 18, 2014
Copy link

@dvarelap dvarelap commented Jul 23, 2014

Hey @tommey try to use params instead of multiParams in this line

val name = request.params.getOrElse("name", "Anonymous").toString

that would fix the test.

Copy link

@tommey tommey commented Jul 23, 2014

Oh, I didn't see that, in debug mode I found it to be under request.request._params: RequestParamMap, I have searched for it and found out that it will return POST or if not available the GET parameter with the given name, which fits my needs.
Thank you for pointing it out! :)
Also I checked the documentation on and it suggest to use this way too (was it changed or where did I come up with the idea of using the multiParams?!:)).
Issue solved.

@tommey tommey closed this Jul 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants