1

I am trying to pass a HashMap parameter to the function I am using in Fitnesse. However, nothing is being passed correctly, as i am getting "{}" when remote debugging in eclipse.

Below is the method that I am calling:

public String issueHttpRequest(String url, Map<String,String> params){
client = new HttpClient();
PostMethod post = createPostMethod(url);
for (Map.Entry<String, String> entry : params.entrySet()){
    post.addParameter(entry.getKey(), entry.getValue());
    }

client.executeMethod(post);
String response = post.getResponseBodyAsString();

return response;
}

Here is how I am calling it from FitNesse:

!|script|CLASS_NAME|
|check|issueHttpRequest;|login|!{username:"guest",password:"guest"}|{"status":"success"}|

When remote debugging in eclipse, params is being passed as empty brackets {}.

Any help would be appreciated. Thanks in advance.

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
Ali Haydar
  • 41
  • 7
  • [Here](http://fitnesse.996250.n3.nabble.com/passing-hashmap-to-a-fixture-td10563.html) is a thread on the Fitnesse forums discussing this very question. It sounds like FitLibrary may be the solution. – Gaʀʀʏ Jan 13 '14 at 17:06
  • Thanks Garry. I have seen the post on the Fitnesse forums. However, I preferred not to use the FitLibrary, as I have no previous knowledge how to integrate with it. What I did so far is creating a method that casts json strings into Map, then I pass the json string from my fitnesse test. Do you think I should invest the time to look at FitLibrary? – Ali Haydar Jan 15 '14 at 12:02

1 Answers1

0

I noticed that the ! character before the script table might be a problem. Try without:

|script|CLASS_NAME| |check|issueHttpRequest;|login|!{username:"guest",password:"guest"}|{"status":"success"}|

Check SLIM MarkupHashTable DataType for reference.

I only tried map arguments do work for SLIM tests in script tables. So make sure you have this defined before your test if my proposed still workaround does work:

!define TEST_SYSTEM {slim}

FabienB
  • 1,104
  • 2
  • 11
  • 22