Fix compilation error

remotes/1731411607042984726/tmp_refs/heads/master^2^2
tcdlpds 3 months ago
parent 897df05df3
commit 66e3f11f48

@ -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<String> 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<String> getCoverageClassesDirectories(AutomationContext automationContext) throws XPathExpressionException {
Set<String> 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<String> 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);

@ -267,14 +267,14 @@
<entgra-iot-community>entgra-iots-community-${project.version}</entgra-iot-community>
<!-- Carbon Device Management-->
<io.entgra.device.mgt.core.version>5.0.26-SNAPSHOT</io.entgra.device.mgt.core.version>
<io.entgra.device.mgt.core.version>5.2.4-SNAPSHOT</io.entgra.device.mgt.core.version>
<carbon.p2.plugin.version>5.1.2</carbon.p2.plugin.version>
<!--Orbit versions-->
<orbit.h2.engine.version>2.1.210.wso2v1</orbit.h2.engine.version>
<io.entgra.device.mgt.plugins.version>6.0.17-SNAPSHOT</io.entgra.device.mgt.plugins.version>
<io.entgra.device.mgt.plugins.version>6.1.1-SNAPSHOT</io.entgra.device.mgt.plugins.version>
<!--Testing-->
<google.gson.version>2.9.1</google.gson.version>

Loading…
Cancel
Save