File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/test/java/org/typesense/api Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .typesense .api ;
2+
3+ import junit .framework .TestCase ;
4+ import org .typesense .resources .Node ;
5+
6+ import java .net .UnknownHostException ;
7+ import java .time .Duration ;
8+ import java .util .ArrayList ;
9+ import java .util .HashMap ;
10+
11+ public class RetryTest extends TestCase {
12+
13+ private Client client ;
14+
15+ public void setUp () throws Exception {
16+ super .setUp ();
17+ ArrayList <Node > nodes = new ArrayList <>();
18+ nodes .add (new Node ("http" ,"unknownhost123" ,"8108" ));
19+ Configuration configuration = new Configuration (nodes , Duration .ofSeconds (1 ),"xyz" );
20+ configuration .numRetries = 2 ;
21+ configuration .retryInterval = Duration .ofSeconds (2 );
22+ this .client = new Client (configuration );
23+ }
24+
25+ public void testRetry () throws Exception {
26+ long start = System .currentTimeMillis ();
27+ try {
28+ client .health .retrieve ();
29+ } catch (Exception e ) {
30+ long timeTaken = System .currentTimeMillis () - start ;
31+ assertTrue (e .getCause () instanceof UnknownHostException );
32+ assertTrue (timeTaken > 4000 );
33+ return ;
34+ }
35+
36+ throw new Exception ("Retry did not throw exception." );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments