Skip to content

Commit

Permalink
Merge pull request #735 from jayesh12234/develop
Browse files Browse the repository at this point in the history
MOSIP-34496
  • Loading branch information
aranaravi authored Jul 16, 2024
2 parents 6ea2581 + 76c6cbb commit 8d37582
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package io.mosip.testrig.residentui.utility;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.WebSocket;
Expand All @@ -14,18 +15,15 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.json.JSONException;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;


import io.mosip.testrig.residentui.fw.util.AdminTestUtil;

import io.mosip.testrig.residentui.kernel.util.ConfigManager;
import io.mosip.testrig.residentui.utility.pojo.Root;



public class MockSMTPListener {
private static Logger logger = Logger.getLogger(MockSMTPListener.class);

Expand All @@ -35,25 +33,22 @@ public class MockSMTPListener {
public static Boolean bTerminate = false;

public MockSMTPListener() {

if (ConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
}

public void run() {
try {

String a1="wss://smtp.";
//String externalurlvar="https://iam.dev3.mosip.net";
//String externalurlvar="https://iam.qatriple.mosip.net";
String externalurlvar =ConfigManager.getiam_keyclockurl();
String a2= externalurlvar.substring(externalurlvar.indexOf(".")+1);
String a3="/mocksmtp/websocket";

WebSocket ws = HttpClient
.newHttpClient()
.newWebSocketBuilder()
.buildAsync(URI.create(a1+a2+a3), new WebSocketClient())
.join();

Properties kernelprops = ConfigManager.propsKernel;
String a1 = "wss://smtp.";
String externalurl = kernelprops.getProperty("keycloak-external-url");
String a2 = externalurl.substring(externalurl.indexOf(".") + 1);
String a3 = "/mocksmtp/websocket";

WebSocket ws = HttpClient.newHttpClient().newWebSocketBuilder()
.buildAsync(URI.create(a1 + a2 + a3), new WebSocketClient()).join();
} catch (Exception e) {
logger.error(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class TestRunner {

public static void main(String[] args) throws Exception {
AdminTestUtil.initialize();
mockSMTPListener = new MockSMTPListener();
mockSMTPListener = new MockSMTPListener();
mockSMTPListener.run();
String identityGenManual=ConfigManager.getidentityGenManual();
if(identityGenManual.equals("yes")) {
Expand All @@ -55,14 +55,14 @@ public static void main(String[] args) throws Exception {


public static void startTestRunner() throws Exception {

File homeDir = null;
TestNG runner = new TestNG();
if(!ConfigManager.gettestcases().equals("")) {
XmlSuite suite = new XmlSuite();
suite.setName("MySuite");
suite.addListener("io.mosip.testrig.residentui.utility.EmailableReport");

XmlClass getInformation = new XmlClass("io.mosip.testrig.residentui.testcase.GetInformation");
XmlClass getMyUIN = new XmlClass("io.mosip.testrig.residentui.testcase.GetMyUIN");
XmlClass GetPersonalisedCard = new XmlClass("io.mosip.testrig.residentui.testcase.GetPersonalisedCard");
Expand All @@ -74,7 +74,7 @@ public static void startTestRunner() throws Exception {
XmlClass updateMyDataName = new XmlClass("io.mosip.testrig.residentui.testcase.UpdateMyData");
XmlClass VerifyEmailIDWIthInvalidVid = new XmlClass("io.mosip.testrig.residentui.testcase.VerifyPhoneNumberEmailID");
XmlClass viewMyHistory = new XmlClass("io.mosip.testrig.residentui.testcase.ViewMyHistory");


List<XmlClass> classes = new ArrayList<>();
String[] Scenarionames=ConfigManager.gettestcases().split(",");
Expand All @@ -89,7 +89,7 @@ public static void startTestRunner() throws Exception {
classes.add(getMyUIN);
}

if(test.equals("GetPersonalisedCard"))
if(test.equals("getPersonalisedCard"))
classes.add(GetPersonalisedCard);

if(Scenarioname.contains("logintest"))
Expand Down Expand Up @@ -129,48 +129,48 @@ public static void startTestRunner() throws Exception {
runner.setXmlSuites(suites);

}else {
List<String> suitefiles = new ArrayList<String>();
String os = System.getProperty("os.name");

if (checkRunType().contains("IDE") || os.toLowerCase().contains("windows") == true) {
homeDir = new File(getResourcePath() + "/testngFile");
List<String> suitefiles = new ArrayList<String>();
String os = System.getProperty("os.name");

} else {
homeDir = new File(getResourcePath() + "/testngFile");
if (checkRunType().contains("IDE") || os.toLowerCase().contains("windows") == true) {
homeDir = new File(getResourcePath() + "/testngFile");

}
} else {
homeDir = new File(getResourcePath() + "/testngFile");

for (File file : homeDir.listFiles()) {
if (file.getName().toLowerCase() != null) {
suitefiles.add(file.getAbsolutePath());
}
}

runner.setTestSuites(suitefiles);

for (File file : homeDir.listFiles()) {
if (file.getName().toLowerCase() != null) {
suitefiles.add(file.getAbsolutePath());
}
}

runner.setTestSuites(suitefiles);

}

String language=ConfigManager.getloginlang();
if(language.equals("sin")) {
language="";
}

if(language.equals("sin")) {
language="";
}
System.getProperties().setProperty("testng.outpur.dir", "testng-report");
runner.setOutputDirectory("testng-report");
System.getProperties().setProperty("emailable.report2.name", "RESIDENT-" + BaseTestCase.environment + "-"
+ language + "-run-" + System.currentTimeMillis() + "-report.html");


runner.run();

MockSMTPListener mockSMTPListener = new MockSMTPListener();
mockSMTPListener.bTerminate = true;

System.exit(0);

}

public static String getGlobalResourcePath() {
public static String getGlobalResourcePath() {
if (checkRunType().equalsIgnoreCase("JAR")) {
return new File(jarUrl).getParentFile().getAbsolutePath().toString();
} else if (checkRunType().equalsIgnoreCase("IDE")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public class Root{
public Cc cc;
public String messageId;
public String type;
public String text;
}

0 comments on commit 8d37582

Please sign in to comment.