Skip to content

Commit

Permalink
Merge pull request #168 from msavy/nd-query
Browse files Browse the repository at this point in the history
Alter test and echo server to sort query params to avoid non-determin…
  • Loading branch information
EricWittmann committed Aug 8, 2015
2 parents 35ecb4b + f378feb commit a992b8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
@@ -1,4 +1,4 @@
GET /SimpleEchoTest/echo/1.0.0/path/to/app/resource?param1=value1&param3=hello%20world&param2=value2 admin/admin
GET /SimpleEchoTest/echo/1.0.0/path/to/app/resource?param1=value1&param2=hello%20world&param3=value2 admin/admin
X-Custom-Header: MyValue
X-API-Key: 12345

Expand All @@ -8,7 +8,7 @@ Content-Type: application/json

{
"method" : "GET",
"resource" : "/path/to/app/resource?param1=value1&param3=hello+world&param2=value2",
"resource" : "/path/to/app/resource?param1=value1&param2=hello+world&param3=value2",
"uri" : "/path/to/app/resource",
"headers" : {
"X-Custom-Header" : "MyValue"
Expand Down
Expand Up @@ -15,9 +15,12 @@
*/
package io.apiman.test.common.mock;

import io.apiman.common.util.SimpleStringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Enumeration;

import javax.servlet.ServletException;
Expand Down Expand Up @@ -55,7 +58,9 @@ public static EchoResponse response(HttpServletRequest request, boolean withBody
EchoResponse response = new EchoResponse();
response.setMethod(request.getMethod());
if (request.getQueryString() != null) {
response.setResource(request.getRequestURI() + "?" + request.getQueryString()); //$NON-NLS-1$
String[] normalisedQueryString = request.getQueryString().split("&");
Arrays.sort(normalisedQueryString);
response.setResource(request.getRequestURI() + "?" + SimpleStringUtils.join("&", normalisedQueryString)); //$NON-NLS-1$
} else {
response.setResource(request.getRequestURI());
}
Expand Down

0 comments on commit a992b8f

Please sign in to comment.