@@ -121,6 +121,7 @@ public class FunctionInvoker implements HttpFunction, RawBackgroundFunction {
|
|||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
MessageHeaders headers = result.getHeaders();
|
MessageHeaders headers = result.getHeaders();
|
||||||
|
httpResponse.setContentType(result.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString());
|
||||||
httpResponse.getWriter().write(new String(result.getPayload(), StandardCharsets.UTF_8));
|
httpResponse.getWriter().write(new String(result.getPayload(), StandardCharsets.UTF_8));
|
||||||
for (Entry<String, Object> header : headers.entrySet()) {
|
for (Entry<String, Object> header : headers.entrySet()) {
|
||||||
Object values = header.getValue();
|
Object values = header.getValue();
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public class FunctionInvokerHttpTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJsonInputFunction() throws Exception {
|
public void testJsonInputFunction() throws Exception {
|
||||||
|
|
||||||
@@ -103,8 +104,22 @@ public class FunctionInvokerHttpTests {
|
|||||||
|
|
||||||
|
|
||||||
assertThat(writer.toString()).isEqualTo(gson.toJson(expectedOutput));
|
assertThat(writer.toString()).isEqualTo(gson.toJson(expectedOutput));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithKanji() throws Exception {
|
||||||
|
|
||||||
|
FunctionInvoker handler = new FunctionInvoker(JsonInputFunction.class);
|
||||||
|
|
||||||
|
String expectedOutput = "Thank you for sending the message: 森林";
|
||||||
|
IncomingRequest input = new IncomingRequest("森林");
|
||||||
|
|
||||||
|
when(request.getReader()).thenReturn(new BufferedReader(new StringReader(gson.toJson(input))));
|
||||||
|
handler.service(request, response);
|
||||||
|
bufferedWriter.close();
|
||||||
|
|
||||||
|
|
||||||
|
assertThat(writer.toString()).isEqualTo(gson.toJson(expectedOutput));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user