Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-148 Proper handling of JSON-encoded multi-part parameter values.
- Loading branch information
1 parent
9fb5095
commit 6307981
Showing
4 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
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
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
53 changes: 53 additions & 0 deletions
53
rapidoid-integration-tests/src/test/java/org/rapidoid/http/HttpClientJSONParamsTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*- | ||
* #%L | ||
* rapidoid-integration-tests | ||
* %% | ||
* Copyright (C) 2014 - 2018 Nikolche Mihajlovski and contributors | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
package org.rapidoid.http; | ||
|
||
import org.junit.Test; | ||
import org.rapidoid.annotation.Authors; | ||
import org.rapidoid.annotation.Since; | ||
import org.rapidoid.setup.On; | ||
import org.rapidoid.u.U; | ||
|
||
import java.util.Map; | ||
|
||
@Authors("Nikolche Mihajlovski") | ||
@Since("5.5.4") | ||
public class HttpClientJSONParamsTest extends IsolatedIntegrationTest { | ||
|
||
@Test | ||
public void testHttpReqWithJsonParams() { | ||
On.post("/echo").json((Req req, ReqData data) -> data); | ||
|
||
long[] arr = {-10, 0, 20, 9090909090909090909L}; | ||
Map<String, Object> map = U.map("x", 1, "t", true); | ||
Map<String, Object> data = U.map("n", 1, "s", "abc", "arr", arr, "map", map); | ||
|
||
onlyPost("/echo", data); | ||
} | ||
|
||
} | ||
|
||
class ReqData { | ||
public int n; | ||
public String s; | ||
public long[] arr; | ||
public Map<String, Object> map; | ||
} |
8 changes: 8 additions & 0 deletions
8
.../test/resources/test-results/HttpClientJSONParamsTest/testHttpReqWithJsonParams/POST_echo
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HTTP/1.1 200 OK | ||
Connection: keep-alive | ||
Server: Rapidoid | ||
Date: XXXXX GMT | ||
Content-Type: application/json | ||
Content-Length: 77 | ||
|
||
{"n":1,"s":"abc","arr":[-10,0,20,9090909090909090909],"map":{"x":1,"t":true}} |