From 3e59749f3b8fa52bb0be2219b981c67c663e32f1 Mon Sep 17 00:00:00 2001 From: Maduranga Siriwardena Date: Thu, 16 Jan 2025 19:56:54 +0530 Subject: [PATCH] Add logs to identify RegistryMountTestCase test failure reason --- .../integration/test/restclients/OAuth2RestClient.java | 5 +++++ .../integration/test/saml/RegistryMountTestCase.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java index 914083d0ca9..bfb0c87db0c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java @@ -103,6 +103,11 @@ public String createApplication(ApplicationModel application) throws IOException try (CloseableHttpResponse response = getResponseOfHttpPost(applicationManagementApiBasePath, jsonRequest, getHeaders())) { + + if (response.getStatusLine().getStatusCode() >= 400) { + String responseBody = EntityUtils.toString(response.getEntity()); + throw new RuntimeException("Error occurred while creating the application. Response: " + responseBody); + } String[] locationElements = response.getHeaders(LOCATION_HEADER)[0].toString().split(PATH_SEPARATOR); return locationElements[locationElements.length - 1]; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java index 4cd191ac59d..537b51842a2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java @@ -285,7 +285,7 @@ private Tenant getRegistryMountTenantInfo() { return registryMountTenant; } - private void createApplication() throws Exception{ + private void createApplication() throws Exception { ApplicationModel applicationCreationModel = new ApplicationModel() .name(APPLICATION_NAME) @@ -294,7 +294,12 @@ private void createApplication() throws Exception{ .saml(getSAMLConfigurations())) .claimConfiguration(getClaimConfiguration()); - appId = applicationMgtRestClient.createApplication(applicationCreationModel); + try { + appId = applicationMgtRestClient.createApplication(applicationCreationModel); + } catch (RuntimeException e) { + log.error("Error while creating the application", e); + throw new Exception("Error while creating the application", e); + } } private void deleteApplication() throws Exception{