This is an automated email from the ASF dual-hosted git repository. boglesby pushed a commit to branch feature/GEODE-9104 in repository https://gitbox.apache.org/repos/asf/geode.git
commit c243b32f81c512ea0201756b5499b7be68276dfd Author: Barry Oglesby <bogle...@pivotal.io> AuthorDate: Tue Mar 30 11:35:03 2021 -0700 GEODE-9104: Removed ESCAPE_NON_ASCII feature so non-ASCII characters are displayed --- .../web/controllers/RestAccessControllerTest.java | 42 ++++++++++++++++++++++ ...tomer-containing-chinese-query-full-result.json | 7 ++++ ...mer-containing-chinese-query-struct-result.json | 6 ++++ .../controllers/customer-containing-chinese.json | 5 +++ .../geode/rest/internal/web/util/JSONUtils.java | 2 -- 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/web/controllers/RestAccessControllerTest.java b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/web/controllers/RestAccessControllerTest.java index 5ea7510..84e0a8b 100644 --- a/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/web/controllers/RestAccessControllerTest.java +++ b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/web/controllers/RestAccessControllerTest.java @@ -105,6 +105,12 @@ public class RestAccessControllerTest { private static final String ORDER_CAS_OLD_JSON = "order-cas-old.json"; private static final String ORDER_CAS_NEW_JSON = "order-cas-new.json"; private static final String ORDER_CAS_WRONG_OLD_JSON = "order-cas-wrong-old.json"; + private static final String CUSTOMER_CONTAINING_CHINESE_JSON = + "customer-containing-chinese.json"; + private static final String CUSTOMER_CONTAINING_CHINESE_QUERY_FULL_RESULT_JSON = + "customer-containing-chinese-query-full-result.json"; + private static final String CUSTOMER_CONTAINING_CHINESE_QUERY_STRUCT_RESULT_JSON = + "customer-containing-chinese-query-struct-result.json"; private static final String SLASH = "/"; private static final String KEY_PREFIX = "/?+ @&./"; @@ -167,6 +173,9 @@ public class RestAccessControllerTest { loadResource(ORDER_CAS_OLD_JSON); loadResource(ORDER_CAS_NEW_JSON); loadResource(ORDER_CAS_WRONG_OLD_JSON); + loadResource(CUSTOMER_CONTAINING_CHINESE_JSON); + loadResource(CUSTOMER_CONTAINING_CHINESE_QUERY_FULL_RESULT_JSON); + loadResource(CUSTOMER_CONTAINING_CHINESE_QUERY_STRUCT_RESULT_JSON); RestAgent.createParameterizedQueryRegion(); @@ -1357,6 +1366,39 @@ public class RestAccessControllerTest { } + @Test + @WithMockUser + public void putGetQueryCustomerContainingMandarin() throws Exception { + // Put customer containing mandarin + mockMvc.perform(put("/v1/customers/1") + .content(jsonResources.get(CUSTOMER_CONTAINING_CHINESE_JSON)) + .with(POST_PROCESSOR)) + .andExpect(status().isOk()) + .andExpect(header().string("Location", BASE_URL + "/customers/1")); + + // Get customer containing mandarin + mockMvc.perform(get("/v1/customers/1") + .with(POST_PROCESSOR)) + .andExpect(status().isOk()) + .andExpect(content().json(jsonResources.get(CUSTOMER_CONTAINING_CHINESE_JSON))); + + // Query full customer containing mandarin + mockMvc.perform( + get("/v1/queries/adhoc?q=SELECT * FROM " + SEPARATOR + "customers WHERE customerId = 1") + .with(POST_PROCESSOR)) + .andExpect(status().isOk()) + .andExpect( + content().json(jsonResources.get(CUSTOMER_CONTAINING_CHINESE_QUERY_FULL_RESULT_JSON))); + + // Query struct customer containing mandarin + mockMvc.perform(get("/v1/queries/adhoc?q=SELECT firstName, lastName FROM " + SEPARATOR + + "customers WHERE customerId = 1") + .with(POST_PROCESSOR)) + .andExpect(status().isOk()) + .andExpect(content() + .json(jsonResources.get(CUSTOMER_CONTAINING_CHINESE_QUERY_STRUCT_RESULT_JSON))); + } + private void deleteAllQueries() throws Exception { MvcResult result = mockMvc.perform(get("/v1/queries") .with(POST_PROCESSOR)) diff --git a/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-full-result.json b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-full-result.json new file mode 100644 index 0000000..a7d63cf --- /dev/null +++ b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-full-result.json @@ -0,0 +1,7 @@ +[ + { + "customerId": 1, + "firstName": "名", + "lastName": "姓" + } +] \ No newline at end of file diff --git a/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-struct-result.json b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-struct-result.json new file mode 100644 index 0000000..c4f4c57 --- /dev/null +++ b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese-query-struct-result.json @@ -0,0 +1,6 @@ +[ + { + "firstName": "名", + "lastName": "姓" + } +] \ No newline at end of file diff --git a/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese.json b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese.json new file mode 100644 index 0000000..2d9bc5c --- /dev/null +++ b/geode-web-api/src/integrationTest/resources/org/apache/geode/rest/internal/web/controllers/customer-containing-chinese.json @@ -0,0 +1,5 @@ +{ + "customerId": 1, + "firstName": "名", + "lastName": "姓" +} \ No newline at end of file diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/util/JSONUtils.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/util/JSONUtils.java index 9f62470..392cd69 100644 --- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/util/JSONUtils.java +++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/util/JSONUtils.java @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator.Feature; -import com.fasterxml.jackson.core.json.JsonWriteFeature; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.util.Assert; @@ -53,7 +52,6 @@ public abstract class JSONUtils { } public static JsonGenerator enableDisableJSONGeneratorFeature(JsonGenerator generator) { - generator.enable(JsonWriteFeature.ESCAPE_NON_ASCII.mappedFeature()); generator.disable(Feature.AUTO_CLOSE_TARGET); generator.setPrettyPrinter(new DefaultPrettyPrinter()); return generator;