Search in sources :

Example 1 with SearchException

use of org.opensearch.search.SearchException in project OpenSearch by opensearch-project.

the class ExceptionSerializationTests method testSearchException.

public void testSearchException() throws IOException {
    SearchShardTarget target = new SearchShardTarget("foo", new ShardId("bar", "_na_", 1), null, OriginalIndices.NONE);
    SearchException ex = serialize(new SearchException(target, "hello world"));
    assertEquals(target, ex.shard());
    assertEquals(ex.getMessage(), "hello world");
    ex = serialize(new SearchException(null, "hello world", new NullPointerException()));
    assertNull(ex.shard());
    assertEquals(ex.getMessage(), "hello world");
    assertTrue(ex.getCause() instanceof NullPointerException);
}
Also used : ShardId(org.opensearch.index.shard.ShardId) SearchShardTarget(org.opensearch.search.SearchShardTarget) SearchException(org.opensearch.search.SearchException)

Aggregations

ShardId (org.opensearch.index.shard.ShardId)1 SearchException (org.opensearch.search.SearchException)1 SearchShardTarget (org.opensearch.search.SearchShardTarget)1