Skip to content

Commit 0bb7838

Browse files
committed
improve test
1 parent 34879f0 commit 0bb7838

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

cloudplatform/connectivity-oauth/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoaderTest.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,9 @@ void testInvalidCertificate()
242242
assertThat(result.isFailure()).isTrue();
243243
// The root cause can be either HttpClientException (when using DefaultOAuth2TokenService with HttpClient 4)
244244
// or a security exception like CertificateException (when using HttpClient5OAuth2TokenService)
245-
final Throwable rootCause = getRootCause(result.getCause());
246-
assertThat(rootCause).isInstanceOfAny(HttpClientException.class, java.security.GeneralSecurityException.class);
247-
}
248-
249-
private static Throwable getRootCause( Throwable throwable )
250-
{
251-
Throwable cause = throwable;
252-
while( cause.getCause() != null && cause.getCause() != cause ) {
253-
cause = cause.getCause();
254-
}
255-
return cause;
245+
assertThat(result.getCause())
246+
.rootCause()
247+
.isInstanceOfAny(HttpClientException.class, java.security.GeneralSecurityException.class);
256248
}
257249

258250
@Test

0 commit comments

Comments
 (0)