From d60c127db2dc8dc744ca8a8876bd8a195c01f004 Mon Sep 17 00:00:00 2001 From: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:53:33 +0530 Subject: [PATCH] MOSIP-36454 - fixed build issue by adding suite setup in runner file (#947) Signed-off-by: Mohanachandran S --- .../apirig/testrunner/MosipTestRunner.java | 76 +++++++++---------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index 68d9ed76e..8137a736b 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Properties; +import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.bouncycastle.openssl.jcajce.JcaPEMWriter; import org.testng.TestNG; @@ -24,10 +25,9 @@ import io.mosip.testrig.apirig.dataprovider.BiometricDataProvider; import io.mosip.testrig.apirig.dbaccess.DBManager; import io.mosip.testrig.apirig.utils.AdminTestUtil; +import io.mosip.testrig.apirig.utils.AuthTestsUtil; import io.mosip.testrig.apirig.utils.CertificateGenerationUtil; import io.mosip.testrig.apirig.utils.CertsUtil; -import io.mosip.testrig.apirig.utils.ConfigManager; -import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil; import io.mosip.testrig.apirig.utils.EsignetConfigManager; import io.mosip.testrig.apirig.utils.EsignetUtil; import io.mosip.testrig.apirig.utils.GlobalConstants; @@ -60,7 +60,6 @@ public class MosipTestRunner { public static void main(String[] arg) { try { - Map envMap = System.getenv(); LOGGER.info("** ------------- Get ALL ENV varibales --------------------------------------------- **"); for (String envName : envMap.keySet()) { @@ -74,8 +73,9 @@ public static void main(String[] arg) { } else { ExtractResource.copyCommonResources(); } + AdminTestUtil.init(); EsignetConfigManager.init(); - BaseTestCase.suiteSetup(getRunType()); + suiteSetup(getRunType()); SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt"); setLogLevels(); @@ -127,7 +127,6 @@ public static void main(String[] arg) { } catch (Exception e) { LOGGER.error("Exception " + e.getMessage()); } - OTPListener.bTerminate = true; HealthChecker.bTerminate = true; @@ -135,6 +134,34 @@ public static void main(String[] arg) { System.exit(0); } + + public static void suiteSetup(String runType) { + if (EsignetConfigManager.IsDebugEnabled()) + LOGGER.setLevel(Level.ALL); + else + LOGGER.info("Test Framework for Mosip api Initialized"); + BaseTestCase.initialize(); + LOGGER.info("Done with BeforeSuite and test case setup! su TEST EXECUTION!\n\n"); + + if (!runType.equalsIgnoreCase("JAR")) { + AuthTestsUtil.removeOldMosipTempTestResource(); + } + BaseTestCase.currentModule = GlobalConstants.ESIGNET; + BaseTestCase.certsForModule = GlobalConstants.ESIGNET; + DBManager.executeDBQueries(EsignetConfigManager.getKMDbUrl(), EsignetConfigManager.getKMDbUser(), + EsignetConfigManager.getKMDbPass(), EsignetConfigManager.getKMDbSchema(), + getGlobalResourcePath() + "/" + "config/keyManagerDataDeleteQueriesForEsignet.txt"); + DBManager.executeDBQueries(EsignetConfigManager.getIdaDbUrl(), EsignetConfigManager.getIdaDbUser(), + EsignetConfigManager.getPMSDbPass(), EsignetConfigManager.getIdaDbSchema(), + getGlobalResourcePath() + "/" + "config/idaDeleteQueriesForEsignet.txt"); + DBManager.executeDBQueries(EsignetConfigManager.getMASTERDbUrl(), EsignetConfigManager.getMasterDbUser(), + EsignetConfigManager.getMasterDbPass(), EsignetConfigManager.getMasterDbSchema(), + getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt"); + BaseTestCase.setReportName(GlobalConstants.ESIGNET); + AdminTestUtil.initiateesignetTest(); + BaseTestCase.otpListener = new OTPListener(); + BaseTestCase.otpListener.run(); + } private static void setLogLevels() { AdminTestUtil.setLogLevel(); @@ -155,7 +182,6 @@ public static void startTestRunner() { File homeDir = null; TestNG runner = new TestNG(); List suitefiles = new ArrayList<>(); - List modulesToRun = BaseTestCase.listOfModules; String os = System.getProperty("os.name"); LOGGER.info(os); if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) { @@ -167,12 +193,8 @@ public static void startTestRunner() { LOGGER.info("ELSE :" + homeDir); } for (File file : homeDir.listFiles()) { - for (String fileName : modulesToRun) { - if (file.getName().toLowerCase().contains(fileName)) { - suitefiles.add(file.getAbsolutePath()); - } else if (fileName.equals("all") && file.getName().toLowerCase().contains("testng")) { - suitefiles.add(file.getAbsolutePath()); - } + if (file.getName().toLowerCase().contains(GlobalConstants.ESIGNET)) { + suitefiles.add(file.getAbsolutePath()); } } runner.setTestSuites(suitefiles); @@ -181,25 +203,6 @@ public static void startTestRunner() { runner.run(); } - /** - * The method to return class loader resource path - * - * @return String - * @throws IOException - */ - /* - * public static String getGlobalResourcePath() { if - * (checkRunType().equalsIgnoreCase("JAR")) { return new - * File(jarUrl).getParentFile().getAbsolutePath() + - * "/MosipTestResource/MosipTemporaryTestResource"; } else if - * (checkRunType().equalsIgnoreCase("IDE")) { String path = new - * File(MosipTestRunner.class.getClassLoader().getResource("").getPath()). - * getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource"; if - * (path.contains(GlobalConstants.TESTCLASSES)) path = - * path.replace(GlobalConstants.TESTCLASSES, "classes"); return path; } return - * "Global Resource File Path Not Found"; } - */ - public static String getGlobalResourcePath() { if (cachedPath != null) { return cachedPath; @@ -225,15 +228,6 @@ public static String getGlobalResourcePath() { public static String getResourcePath() { return getGlobalResourcePath(); -// if (checkRunType().equalsIgnoreCase("JAR")) { -// return new File(jarUrl).getParentFile().getAbsolutePath(); -// } else if (checkRunType().equalsIgnoreCase("IDE")) { -// String path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath(); -// if (path.contains(GlobalConstants.TESTCLASSES)) -// path = path.replace(GlobalConstants.TESTCLASSES, "classes"); -// return path; -// } -// return "Global Resource File Path Not Found"; } public static String generatePulicKey() { @@ -334,4 +328,4 @@ public static String getRunType() { return "IDE"; } -} +} \ No newline at end of file