Skip to content

Commit

Permalink
MOSIP-36454 - fixed build issue by adding suite setup in runner file (#…
Browse files Browse the repository at this point in the history
…947)

Signed-off-by: Mohanachandran S <[email protected]>
  • Loading branch information
mohanachandran-s authored Oct 9, 2024
1 parent 1ae3f87 commit d60c127
Showing 1 changed file with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -60,7 +60,6 @@ public class MosipTestRunner {
public static void main(String[] arg) {

try {

Map<String, String> envMap = System.getenv();
LOGGER.info("** ------------- Get ALL ENV varibales --------------------------------------------- **");
for (String envName : envMap.keySet()) {
Expand All @@ -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();

Expand Down Expand Up @@ -127,14 +127,41 @@ public static void main(String[] arg) {
} catch (Exception e) {
LOGGER.error("Exception " + e.getMessage());
}

OTPListener.bTerminate = true;

HealthChecker.bTerminate = true;

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();
Expand All @@ -155,7 +182,6 @@ public static void startTestRunner() {
File homeDir = null;
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();
List<String> modulesToRun = BaseTestCase.listOfModules;
String os = System.getProperty("os.name");
LOGGER.info(os);
if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -334,4 +328,4 @@ public static String getRunType() {
return "IDE";
}

}
}

0 comments on commit d60c127

Please sign in to comment.