forked from opensearch-project/opensearch-java
-
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.
Fix for AwsSdk2Transport error handling (opensearch-project#1068)
Signed-off-by: Wesley Workman <[email protected]>
- Loading branch information
Showing
5 changed files
with
148 additions
and
55 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
59 changes: 59 additions & 0 deletions
59
...ent/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2GetRequestIT.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,59 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch.integTest.aws; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.opensearch.client.opensearch.OpenSearchAsyncClient; | ||
import org.opensearch.client.opensearch.OpenSearchClient; | ||
import org.opensearch.client.opensearch.core.*; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
|
||
public class AwsSdk2GetRequestIT extends AwsSdk2TransportTestCase { | ||
@Test | ||
public void testSyncGetRequest() throws Exception { | ||
resetTestIndex(false); | ||
final OpenSearchClient client = getClient(false, null, null); | ||
|
||
SimplePojo doc1 = new SimplePojo("Document 1", "The text of document 1"); | ||
addDoc(client, "id1", doc1); | ||
|
||
Thread.sleep(1000); | ||
|
||
GetRequest doc1Request = new GetRequest.Builder().index(TEST_INDEX).id("id1").build(); | ||
GetResponse<SimplePojo> doc1Response = client.get(doc1Request, SimplePojo.class); | ||
Assert.assertTrue(doc1Response.found()); | ||
|
||
GetRequest doc2Request = new GetRequest.Builder().index(TEST_INDEX).id("does-not-exist").build(); | ||
GetResponse<SimplePojo> doc2Response = client.get(doc2Request, SimplePojo.class); | ||
Assert.assertFalse(doc2Response.found()); | ||
} | ||
|
||
@Test | ||
public void testAsyncGetRequest() throws Exception { | ||
resetTestIndex(false); | ||
final OpenSearchAsyncClient client = getAsyncClient(false, null, null); | ||
|
||
SimplePojo doc1 = new SimplePojo("Document 1", "The text of document 1"); | ||
addDoc(client, "id1", doc1).join(); | ||
|
||
Thread.sleep(1000); | ||
|
||
GetRequest doc1Request = new GetRequest.Builder().index(TEST_INDEX).id("id1").build(); | ||
CompletableFuture<GetResponse<SimplePojo>> doc1ResponseFuture = client.get(doc1Request, SimplePojo.class); | ||
|
||
GetRequest doc2Request = new GetRequest.Builder().index(TEST_INDEX).id("does-not-exist").build(); | ||
CompletableFuture<GetResponse<SimplePojo>> doc2ResponseFuture = client.get(doc2Request, SimplePojo.class); | ||
|
||
Assert.assertTrue(doc1ResponseFuture.join().found()); | ||
Assert.assertFalse(doc2ResponseFuture.join().found()); | ||
} | ||
} |
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