File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -58,4 +58,39 @@ public void timeoutWithRetry() {
5858 .getBody ();
5959 });
6060 }
61+
62+ @ Test
63+ public void timeoutWithRetryTimeout () {
64+ String projectKey = CommercetoolsTestUtils .getProjectKey ();
65+
66+ ProjectApiRoot b = ApiRootBuilder .of ()
67+ .defaultClient (ClientCredentials .of ()
68+ .withClientId (CommercetoolsTestUtils .getClientId ())
69+ .withClientSecret (CommercetoolsTestUtils .getClientSecret ())
70+ .build (),
71+ ServiceRegion .GCP_EUROPE_WEST1 )
72+ .withTelemetryMiddleware ((request , next ) -> next .apply (request ).thenApply ((response ) -> {
73+ try {
74+ Thread .sleep (15000 ); // ensure timeout
75+ }
76+ catch (InterruptedException e ) {
77+ throw new RuntimeException (e );
78+ }
79+ return response ;
80+ }))
81+ .withPolicies (policyBuilder -> policyBuilder .withTimeout (Duration .ofSeconds (7 ))
82+ .withRetry (builder -> builder .maxRetries (3 )
83+ .statusCodes (singletonList (HttpStatusCode .NOT_FOUND_404 ))
84+ .failures (singletonList (TimeoutExceededException .class )))
85+ .withTimeout (Duration .ofSeconds (3 )))
86+ .build (projectKey );
87+
88+ Assertions .assertThatExceptionOfType (TimeoutExceededException .class ).isThrownBy (() -> {
89+ Category category = b .categories ()
90+ .withId ("fdbaf4ea-fbc9-4fea-bac4-1d7e6c1995b3" )
91+ .get ()
92+ .executeBlocking ()
93+ .getBody ();
94+ });
95+ }
6196}
You can’t perform that action at this time.
0 commit comments