diff --git a/integration-test/src/test/java/io/entgra/community/iots/integration/test/common/extensions/CarbonServerManagerExtension.java b/integration-test/src/test/java/io/entgra/community/iots/integration/test/common/extensions/CarbonServerManagerExtension.java index 16c6f1e..e7f1017 100644 --- a/integration-test/src/test/java/io/entgra/community/iots/integration/test/common/extensions/CarbonServerManagerExtension.java +++ b/integration-test/src/test/java/io/entgra/community/iots/integration/test/common/extensions/CarbonServerManagerExtension.java @@ -22,8 +22,11 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.DirectoryFileFilter; import org.apache.commons.io.filefilter.RegexFileFilter; import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.beans.User; import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; @@ -39,10 +42,7 @@ import org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader; import javax.xml.xpath.XPathExpressionException; import java.io.File; import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; +import java.util.*; public class CarbonServerManagerExtension { @@ -53,6 +53,7 @@ public class CarbonServerManagerExtension { private ServerLogReader inputStreamHandler; private ServerLogReader errorStreamHandler; private boolean isCoverageEnable = false; + private Set coverageClassesDirectories = new HashSet(); private String coverageDumpFilePath; private int portOffset = 0; private static final String SERVER_SHUTDOWN_MESSAGE = "Halting JVM"; @@ -183,6 +184,7 @@ public class CarbonServerManagerExtension { try { this.isCoverageEnable = Boolean.parseBoolean(this.automationContext.getConfigurationValue("//coverage")); + this.coverageClassesDirectories = this.getCoverageClassesDirectories(this.automationContext); } catch (XPathExpressionException var8) { throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", var8); } @@ -196,6 +198,28 @@ public class CarbonServerManagerExtension { } } + private Set getCoverageClassesDirectories(AutomationContext automationContext) throws XPathExpressionException { + Set coverageDirectories = new HashSet(); + Node configurationNode = automationContext.getConfigurationNode("//coverageClassesRelativeDirectories"); + if (configurationNode != null) { + NodeList childNodes = configurationNode.getChildNodes(); + if (childNodes != null) { + for(int i = 0; i <= childNodes.getLength() - 1; ++i) { + Node node = childNodes.item(i); + if (node != null && "coverageClassesRelativeDirectory".equals(node.getNodeName())) { + coverageDirectories.add(node.getTextContent()); + } + } + } + } else if (StringUtils.isNotEmpty(automationContext.getConfigurationValue("//coverageClassesRelativeDirectory"))) { + coverageDirectories.add(automationContext.getConfigurationValue("//coverageClassesRelativeDirectory")); + } else { + coverageDirectories.add("repository" + File.separator + "components" + File.separator + "plugins" + File.separator); + } + + return coverageDirectories; + } + public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException { if(this.process != null) { log.info("Shutting down server.."); @@ -235,8 +259,7 @@ public class CarbonServerManagerExtension { if(this.isCoverageEnable) { try { log.info("Generating Jacoco code coverage..."); - this.generateCoverageReport(new File(this.carbonHome + File.separator + "repository" - + File.separator + "components" + File.separator + "plugins" + File.separator)); + this.generateCoverageReport(this.coverageClassesDirectories); } catch (IOException var7) { log.error("Failed to generate code coverage ", var7); throw new AutomationFrameworkException("Failed to generate code coverage ", var7); @@ -250,7 +273,7 @@ public class CarbonServerManagerExtension { } - private void generateCoverageReport(File classesDir) throws IOException, AutomationFrameworkException { + private void generateCoverageReport(Set classesDir) throws IOException, AutomationFrameworkException { checkJacocoDataFileSizes(FrameworkPathUtil.getJacocoCoverageHome()); CodeCoverageUtils.executeMerge(FrameworkPathUtil.getJacocoCoverageHome(), FrameworkPathUtil.getCoverageMergeFilePath()); ReportGenerator reportGenerator = new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()), classesDir, new File(CodeCoverageUtils.getJacocoReportDirectory()), (File)null); diff --git a/pom.xml b/pom.xml index bcf987e..d7b1c54 100644 --- a/pom.xml +++ b/pom.xml @@ -267,14 +267,14 @@ entgra-iots-community-${project.version} - 5.0.26-SNAPSHOT + 5.2.4-SNAPSHOT 5.1.2 2.1.210.wso2v1 - 6.0.17-SNAPSHOT + 6.1.1-SNAPSHOT 2.9.1