forked from opendistro-for-elasticsearch/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an integ test to check unicode characters in GET request (open…
…distro-for-elasticsearch#38) Issue: None NLPchina/elasticsearch-sql#781 New integ test to execute sql query by calling the GET endpoint as well as passing unicode characters (this is to verify we don't have NLPchina/elasticsearch-sql#781 issue). + Minor update in loggin setup. Tested: successful build with all tests
- Loading branch information
Showing
5 changed files
with
99 additions
and
11 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
src/test/java/com/amazon/opendistroforelasticsearch/sql/esintgtest/GetEndpointQueryIT.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 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.esintgtest; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import static com.amazon.opendistroforelasticsearch.sql.esintgtest.TestsConstants.TEST_INDEX_ACCOUNT; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
/** | ||
* Tests to cover requests with "?format=csv" parameter | ||
*/ | ||
public class GetEndpointQueryIT extends SQLIntegTestCase { | ||
|
||
@Override | ||
protected void init() throws Exception { | ||
loadIndex(Index.ACCOUNT); | ||
} | ||
|
||
@Test | ||
public void unicodeTermInQuery() throws IOException { | ||
|
||
// NOTE: There are unicode characters in name, not just whitespace. | ||
final String name = "盛虹"; | ||
final String query = String.format(Locale.ROOT, "SELECT id, firstname FROM %s " + | ||
"WHERE firstname=matchQuery('%s') LIMIT 2", TEST_INDEX_ACCOUNT, name); | ||
|
||
final JSONObject result = executeQueryWithGetRequest(query); | ||
final JSONArray hits = getHits(result); | ||
Assert.assertThat(hits.length(), equalTo(1)); | ||
Assert.assertThat(hits.query("/0/_id"), equalTo("919")); | ||
Assert.assertThat(hits.query("/0/_source/firstname"), equalTo(name)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1965,7 +1965,7 @@ | |
{"index":{"_type": "account", "_id":"914"}} | ||
{"account_number":914,"balance":7120,"firstname":"Esther","lastname":"Bean","age":32,"gender":"F","address":"583 Macon Street","employer":"Applica","email":"[email protected]","city":"Homeworth","state":"MN"} | ||
{"index":{"_type": "account", "_id":"919"}} | ||
{"account_number":919,"balance":39655,"firstname":"Shauna","lastname":"Hanson","age":27,"gender":"M","address":"557 Hart Place","employer":"Exospace","email":"[email protected]","city":"Outlook","state":"LA"} | ||
{"account_number":919,"balance":39655,"firstname":"盛虹","lastname":"Hanson","age":27,"gender":"M","address":"557 Hart Place","employer":"Exospace","email":"[email protected]","city":"Outlook","state":"LA"} | ||
{"index":{"_type": "account", "_id":"921"}} | ||
{"account_number":921,"balance":49119,"firstname":"Barbara","lastname":"Wade","age":29,"gender":"M","address":"687 Hoyts Lane","employer":"Roughies","email":"[email protected]","city":"Sattley","state":"CO"} | ||
{"index":{"_type": "account", "_id":"926"}} | ||
|