Skip to content

Commit

Permalink
Fixed code for #17 and simplified package name
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Sharma committed Oct 16, 2023
1 parent a507309 commit f50d597
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 58 deletions.
6 changes: 3 additions & 3 deletions Listener-XML/soapuiextentter-listeners.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<tns:soapui-listeners xmlns:tns="http://eviware.com/soapui/config">
<!--This will initialize TestStep level reporting-->
<tns:listener id="TestStepListener" listenerClass="com.soapuiutils.extentter.soapui.listener.ExtenterTestRunListener"
<tns:listener id="TestStepListener" listenerClass="com.soapuiextentter.listener.ExtenterTestRunListener"
listenerInterface="com.eviware.soapui.model.testsuite.TestRunListener" />
<!--This will initialize TestCase level reporting-->
<tns:listener id="TestCaseListener" listenerClass="com.soapuiutils.extentter.soapui.listener.ExtenterTestSuiteRunListener"
<tns:listener id="TestCaseListener" listenerClass="com.soapuiextentter.listener.ExtenterTestSuiteRunListener"
listenerInterface="com.eviware.soapui.model.testsuite.TestSuiteRunListener" />
<!--This will initialize TestSuite level reporting-->
<tns:listener id="TestSuiteListener" listenerClass="com.soapuiutils.extentter.soapui.listener.ExtenterProjectRunListener"
<tns:listener id="TestSuiteListener" listenerClass="com.soapuiextentter.listener.ExtenterProjectRunListener"
listenerInterface="com.eviware.soapui.model.testsuite.ProjectRunListener" />
</tns:soapui-listeners>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.dataprovider.soapui.utils;
package com.soapuiextentter.dataproviderUtils;

import java.io.BufferedReader;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.dataprovider.soapui.utils;
package com.soapuiextentter.dataproviderUtils;

import java.io.File;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.dataprovider.soapui.utils;
package com.soapuiextentter.dataproviderUtils;

public class Hello {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.listener;
package com.soapuiextentter.listener;

import java.io.File;
import java.net.InetAddress;
Expand All @@ -12,8 +12,8 @@
import com.eviware.soapui.model.testsuite.TestProperty;
import com.eviware.soapui.model.testsuite.TestSuite;
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
import com.soapuiutils.extentter.soapui.service.SoapUIService;
import com.soapuiutils.extentter.soapui.service.SoapUIServiceImpl;
import com.soapuiextentter.service.SoapUIService;
import com.soapuiextentter.service.SoapUIServiceImpl;

/*
* Author : Akshay Sharma
Expand All @@ -34,7 +34,7 @@ public void beforeRun(ProjectRunner runner, ProjectRunContext context) {
HashMap<String, String> klovConfig = getKlovConfiguration(properties);
Projservice = new SoapUIServiceImpl();
String projectXmlPath = context.getProject().getPath();
int index = projectXmlPath.lastIndexOf("\\");
int index = projectXmlPath.lastIndexOf(File.separator);
reportPath = projectXmlPath.substring(0, index);
reportPath = reportPath + File.separator + "Reports";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.listener;
package com.soapuiextentter.listener;

import java.io.File;
import java.util.HashMap;
Expand All @@ -9,8 +9,8 @@
import com.eviware.soapui.model.testsuite.TestRunListener;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.soapuiutils.extentter.soapui.service.SoapUIService;
import com.soapuiutils.extentter.soapui.service.SoapUIServiceImpl;
import com.soapuiextentter.service.SoapUIService;
import com.soapuiextentter.service.SoapUIServiceImpl;

/*
* Author : Akshay Sharma
Expand All @@ -31,7 +31,7 @@ public void beforeRun(TestCaseRunner runner, TestCaseRunContext context) {
TCservice = new SoapUIServiceImpl();

String projectXmlPath = context.getTestCase().getTestSuite().getProject().getPath();
int index = projectXmlPath.lastIndexOf("\\");
int index = projectXmlPath.lastIndexOf(File.separator);
reportPath = projectXmlPath.substring(0, index);
reportPath = reportPath + File.separator + "Reports";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.listener;
package com.soapuiextentter.listener;

import java.io.File;
import java.util.HashMap;
Expand All @@ -9,8 +9,8 @@
import com.eviware.soapui.model.testsuite.TestSuiteRunContext;
import com.eviware.soapui.model.testsuite.TestSuiteRunListener;
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
import com.soapuiutils.extentter.soapui.service.SoapUIService;
import com.soapuiutils.extentter.soapui.service.SoapUIServiceImpl;
import com.soapuiextentter.service.SoapUIService;
import com.soapuiextentter.service.SoapUIServiceImpl;

/*
* Author : Akshay Sharma
Expand All @@ -32,7 +32,7 @@ public void afterRun(TestSuiteRunner runner, TestSuiteRunContext context) {
SoapUI.log("Reports are published at " + reportPath);
}
} catch (Throwable t) {
SoapUI.log("TSYS Extentter Error in beforeTestCase of TestSuiteRunListener " + t.getMessage());
SoapUI.log("SOAPUI Extentter Error in beforeTestCase of TestSuiteRunListener " + t.getMessage());
}
}

Expand All @@ -43,7 +43,7 @@ public void beforeRun(TestSuiteRunner runner, TestSuiteRunContext context) {
TSservice = new SoapUIServiceImpl();

String projectXmlPath = context.getTestSuite().getProject().getPath();
int index = projectXmlPath.lastIndexOf("\\");
int index = projectXmlPath.lastIndexOf(File.separator);
reportPath = projectXmlPath.substring(0, index);
reportPath = reportPath + File.separator + "Reports";

Expand All @@ -60,7 +60,7 @@ public void beforeRun(TestSuiteRunner runner, TestSuiteRunContext context) {
TSservice.startTestSuiteLogging(testSuiteName, testSuiteDesc, testSuiteId);
}
} catch (Exception t) {
SoapUI.log("TSYS Extentter plugin cannot be initialized. " + t.getMessage());
SoapUI.log("SOAPUI Extentter plugin cannot be initialized. " + t.getMessage());
}
}

Expand All @@ -80,7 +80,7 @@ public void beforeTestCase(TestSuiteRunner paramTestSuiteRunner, TestSuiteRunCon
TSservice.startTestCaseLogging(testCaseName, testSuiteId, testCaseId);
}
} catch (Throwable t) {
SoapUI.log("TSYS Extentter Error in beforeTestCase of TestSuiteRunListener " + t.getMessage());
SoapUI.log("SOAPUI Extentter Error in beforeTestCase of TestSuiteRunListener " + t.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.listener;
package com.soapuiextentter.listener;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.soapuiutils.extentter.soapui.reporter;
package com.soapuiextentter.reporter;

import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.markuputils.Markup;
Expand Down Expand Up @@ -212,24 +207,20 @@ public void logPass(TestStepResult testStepContext, String testSuiteId, String t
AuthType = testStepContext.getTestStep().getProperty("AuthType");

if (GroovyScript == null) {

actualReq = Request.getValue();
actualRes = Response.getValue();
Markup mReqRes = MarkupHelper.createCodeBlock(actualReq, actualRes);

endPoint = testStepContext.getTestStep().getProperty("Endpoint").getValue();

if (AuthType == null) {
assignCategory(testSuiteId, "REST");
} else {
assignCategory(testSuiteId, "SOAP");
}

if (endPoint.contains("#")) {

actualEndPoint = getEndpoint(endPoint);
endPointLocation = getEndpointRef(endPoint);

if (actualEndPoint.contains("-")) {
String[] Endpoints = actualEndPoint.split("-", 2);
String partOne = Endpoints[0].trim();
Expand All @@ -250,17 +241,13 @@ public void logPass(TestStepResult testStepContext, String testSuiteId, String t
}

actualData = "<br><b>\n\n ENDPOINT DETAILS : </b>" + actualEndPoint;

getTestNode(testSuiteId, testCaseId).pass(logText + " <b>Check Details </b> " + actualData
+ "<br><b>Below are the Actual Request and Response Data.</b>");

getTestNode(testSuiteId, testCaseId).info(mReqRes);
} else {
actualData = "<br><b>\n\n ENDPOINT DETAILS : </b>" + endPoint;

getTestNode(testSuiteId, testCaseId).pass(logText + " <b>Check Details </b> " + actualData
+ "<br><b>Below are the Actual Request and Response Data.</b>");

getTestNode(testSuiteId, testCaseId).info(mReqRes);
}
} else {
Expand Down Expand Up @@ -329,11 +316,9 @@ public void logFail(TestStepResult testStepContext, String testSuiteId, String t
AuthType = testStepContext.getTestStep().getProperty("AuthType");

if (GroovyScript == null) {

actualReq = Request.getValue();
actualRes = Response.getValue();
Markup mReqRes = MarkupHelper.createCodeBlock(actualReq, actualRes);

endPoint = testStepContext.getTestStep().getProperty("Endpoint").getValue();

if (AuthType == null) {
Expand All @@ -343,10 +328,8 @@ public void logFail(TestStepResult testStepContext, String testSuiteId, String t
}

if (endPoint.contains("#")) {

actualEndPoint = getEndpoint(endPoint);
endPointLocation = getEndpointRef(endPoint);

if (actualEndPoint.contains("-")) {
String[] Endpoints = actualEndPoint.split("-", 2);
String partOne = Endpoints[0].trim();
Expand All @@ -367,47 +350,33 @@ public void logFail(TestStepResult testStepContext, String testSuiteId, String t
}

actualData = "<br><b>\n\n ENDPOINT DETAILS : </b>" + actualEndPoint;

getTestNode(testSuiteId, testCaseId).fail(logText + " <b>Failed. Check Details </b> "
+ actualData + "<br><b>Below are the Actual Request and Response Data.</b>");

getTestNode(testSuiteId, testCaseId).info(mReqRes);

getTestNode(testSuiteId, testCaseId).info(new RuntimeException(failedMessages.toString()));

failedMessages.clear();
} else {
actualData = "<br><b>\n\n ENDPOINT DETAILS : </b>" + endPoint;

getTestNode(testSuiteId, testCaseId).fail(logText + " <b>Failed. Check Details </b> "
+ actualData + "<br><b>Below are the Actual Request and Response Data.</b>");

getTestNode(testSuiteId, testCaseId).info(mReqRes);

getTestNode(testSuiteId, testCaseId).info(new RuntimeException(failedMessages.toString()));

failedMessages.clear();
}
} else if (Request == null) {
SoapUI.log("Test Log Started for TestStep " + logText + " of TestCase " + testCaseId
+ " of TestSuite " + testSuiteId);

getTestNode(testSuiteId, testCaseId).fail(logText + " <b>Failed. Check Details </b> ");

getTestNode(testSuiteId, testCaseId).info(new RuntimeException(failedMessages.toString()));

failedMessages.clear();
} else {
getTestNode(testSuiteId, testCaseId).fail(logText + " <b>Failed.<b>");
}
} else {
SoapUI.log("Test Log Started for TestStep " + logText + " of TestCase " + testCaseId + " of TestSuite "
+ testSuiteId);

getTestNode(testSuiteId, testCaseId).fail(logText + " <b>Failed. Check Details </b> ");

getTestNode(testSuiteId, testCaseId).info(new RuntimeException(failedMessages.toString()));

failedMessages.clear();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.service;
package com.soapuiextentter.service;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soapuiutils.extentter.soapui.service;
package com.soapuiextentter.service;

import java.util.HashMap;
import java.util.List;
Expand All @@ -10,8 +10,8 @@
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
import com.soapuiextentter.reporter.Report;
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
import com.soapuiutils.extentter.soapui.reporter.Report;

/*
* Author : Akshay Sharma
Expand Down

0 comments on commit f50d597

Please sign in to comment.