From 7de1dc89e954ee58b730419ea851740494174f47 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Mon, 18 Sep 2023 18:02:17 +0530 Subject: [PATCH] fix kernal path --- .../adminui/kernel/util/CommonLibrary.java | 5 ++ .../adminui/kernel/util/ConfigManager.java | 13 ++++- .../kernel/util/KeycloakUserManager.java | 3 +- .../testrig/adminui/utility/BaseClass.java | 5 ++ .../adminui/utility/BaseTestCaseFunc.java | 2 +- .../adminui/utility/ExtentReportManager.java | 2 +- .../testrig/adminui/utility/TestRunner.java | 52 ++++++++++++++++++- 7 files changed, 76 insertions(+), 6 deletions(-) diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java index 3384ad69..38287056 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java @@ -66,10 +66,15 @@ public boolean isValidToken(String cookie) { public Map readProperty(String propertyFileName) { Properties prop = new Properties(); try { + if(propertyFileName.equals("Kernel")) { + File propertyFile = new File(getResourcePathForKernel() + "config/" +TestRunner.GetKernalFilename()); + prop.load(new FileInputStream(propertyFile)); + }else { logger.info("propertyFileName: " + propertyFileName + "Path :" + getResourcePathForKernel() + "config/" + propertyFileName + ".properties"); logger.info("propertyFileName: " + propertyFileName + "Path :" + getResourcePathForKernel() + "config/" + propertyFileName + ".properties"); File propertyFile = new File(getResourcePathForKernel() + "config/" + propertyFileName + ".properties"); prop.load(new FileInputStream(propertyFile)); + } } catch (IOException e) { logger.info("Error occrued while reading propertyFileName " + propertyFileName + e.getMessage()); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/ConfigManager.java b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/ConfigManager.java index 4fc3c73a..43cdaac9 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/ConfigManager.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/ConfigManager.java @@ -172,6 +172,7 @@ public class ConfigManager { // private static String km_db_pass; // private static String km_db_schema; // + private static String enableDebug; private static String master_db_user; private static String master_db_pass; private static String master_db_schema; @@ -210,7 +211,8 @@ public static String getValueForKey(String key) { public static void init() { // Loading Kernel property - propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/Kernel.properties"); +// propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/Kernel.properties"); + propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/"+TestRunner.GetKernalFilename()); idrepo_client_secret = getValueForKey(MOSIP_IDREPO_CLIENT_SECRET); idrepo_client_id = getValueForKey(MOSIP_IDREPO_CLIENT_ID); @@ -398,6 +400,9 @@ public static String getShowSql() { public static String getDbSessionContext() { return hibernate_current_session_context_class; } + public static Boolean IsDebugEnabled() { + return enableDebug.equalsIgnoreCase("yes"); + } // // public static String getAuditDbUser() { // return audit_db_user; @@ -494,7 +499,9 @@ public static String getIAMUsersPassword() { } public static String getRolesForUser(String userId) { - propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/Kernel.properties"); + // propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/Kernel.properties"); + propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/"+TestRunner.GetKernalFilename()); + return propsKernel.getProperty("roles." + userId); } @@ -521,5 +528,7 @@ public static String getiam_apiinternalendpoint() { // public static String getAuthDemoServiceUrl() { // return ConfigManager.getAuthDemoServiceBaseUrl() + ":" + ConfigManager.getAuthDemoServicePort(); // } + + } \ No newline at end of file diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/KeycloakUserManager.java b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/KeycloakUserManager.java index c0cc7977..3af8f203 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/KeycloakUserManager.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/KeycloakUserManager.java @@ -31,7 +31,8 @@ public class KeycloakUserManager extends BaseTestCaseFunc { private static final Logger logger = Logger.getLogger(KeycloakUserManager.class); - public static Properties propsKernel = getproperty(TestRunner.getResourcePath() + "/"+"config/Kernel.properties"); +// public static Properties propsKernel = getproperty(TestRunner.getResourcePath() + "/"+"config/Kernel.properties"); + public static Properties propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "config/"+TestRunner.GetKernalFilename()); private static Keycloak getKeycloakInstance() { Keycloak key=null; diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java index d798739d..a0e64ae7 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.nio.file.Path; import java.util.HashMap; @@ -25,6 +26,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.Assert; import org.testng.ITest; +import org.testng.ITestResult; import org.testng.Reporter; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; @@ -215,4 +217,7 @@ private String getCommitId(){ } } + + + } diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseTestCaseFunc.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseTestCaseFunc.java index dd30ca38..8eb139cd 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseTestCaseFunc.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseTestCaseFunc.java @@ -35,7 +35,7 @@ public class BaseTestCaseFunc { public static Properties props = getproperty( TestRunner.getResourcePath() + "/" + "config/application.properties"); public static Properties propsKernel = getproperty( - TestRunner.getResourcePath() + "/" + "config/Kernel.properties"); + TestRunner.getResourcePath() + "/" + "config/"+TestRunner.GetKernalFilename()); public static Properties propsMap = getproperty( TestRunner.getResourcePath() + "/" + "config/valueMapping.properties"); public static Properties propsBio = getproperty( diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/ExtentReportManager.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/ExtentReportManager.java index ba45e432..975142b2 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/ExtentReportManager.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/ExtentReportManager.java @@ -15,7 +15,7 @@ public static ExtentReports getReports() { if(extent==null) { extent=new ExtentReports(); extent=new ExtentReports(); - Filepath=System.getProperty("user.dir")+"/Reports/"+"admin-ui-report-"+Commons.appendDate+".html"; + Filepath=System.getProperty("user.dir")+"/extent_reports/"+"admin-ui-report-"+Commons.appendDate+".html"; html=new ExtentSparkReporter(Filepath); extent.attachReporter(html); } diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java index c251de24..48dc61e5 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java @@ -1,6 +1,7 @@ package io.mosip.testrig.adminui.utility; import java.io.File; +import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -38,7 +39,7 @@ public static void main(String[] args) throws Exception { // BaseTestCase.setReportName("masterdata-" + localLanguageList.get(i)); //startTestRunner(); - testNg=new TestNG(); + /* testNg=new TestNG(); String listExcludedGroups=JsonUtil.JsonObjParsing(Commons.getTestData(),"setExcludedGroups"); testNg.setExcludedGroups(listExcludedGroups); @@ -58,9 +59,52 @@ public static void main(String[] args) throws Exception { }); // testNg.addListener(tla); + // testNg.run();*/ + + // MockSMTPListener mockSMTPListener = new MockSMTPListener(); + // mockSMTPListener.run(); + startTestRunner(); + } + + + public static void startTestRunner() throws Exception { + File homeDir = null; + // TestNG runner = new TestNG(); +testNg=new TestNG(); + + String listExcludedGroups=JsonUtil.JsonObjParsing(Commons.getTestData(),"setExcludedGroups"); + testNg.setExcludedGroups(listExcludedGroups); + testNg.setTestClasses(new Class[] { + + CenterTest.class,HolidaysTest.class,TemplateTest.class + + , + + DeviceTest.class,MachineTest.class + ,BlockListTest.class,CenterTypeTest.class, + DeviceSpecificationTest.class,DeviceTypesTest.class, + MachineSpecificationTest.class,MachineTypesTest.class, + DynamicFieldTest.class,DocumentCategoriesTest.class,DocumentTypes.class, + + BulkUploadTest.class + + }); + + System.getProperties().setProperty("testng.outpur.dir", "testng-report"); + testNg.setOutputDirectory("testng-report"); + System.getProperties().setProperty("emailable.report2.name", "AdminUI" + "-" + + System.getProperty("env.user") + System.currentTimeMillis() + "-report.html"); + + testNg.run(); + // MockSMTPListener mockSMTPListener = new MockSMTPListener(); + // mockSMTPListener.bTerminate = true; + + System.exit(0); } + + public static String getGlobalResourcePath() { if (checkRunType().equalsIgnoreCase("JAR")) { return new File(jarUrl).getParentFile().getAbsolutePath().toString(); @@ -95,6 +139,12 @@ public static String checkRunType() { else return "IDE"; } + public static String GetKernalFilename(){ + String path = System.getProperty("env.user"); + String kernalpath="Kernel_"+path+".properties"; + return kernalpath; + + } }