Skip to content

Commit

Permalink
Added the message page and fixed #230.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keshav Nangare committed Sep 18, 2017
1 parent 1bfd5a9 commit 1be4308
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 17 deletions.
20 changes: 13 additions & 7 deletions teamengine-core/src/main/java/com/occamlab/te/TECore.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public class TECore implements Runnable {
public static String Purpose = "";
public static ArrayList<String> rootTestName = new ArrayList<String>();
public static Document userInputs = null;
public Boolean supportHtmlReport = false;

public TECore() {

Expand Down Expand Up @@ -335,6 +336,7 @@ public void execute() throws Exception {
+ File.separator + opts.getSessionId());
File resultsDir = new File(opts.getLogDir(),
opts.getSessionId());
if(supportHtmlReport == true){
Map<String, String> testInputMap = new HashMap<String, String>();
testInputMap = extractTestInputs(userInputs, opts);

Expand All @@ -360,6 +362,7 @@ public void execute() throws Exception {
}
}
}
}
}
}

Expand Down Expand Up @@ -865,6 +868,7 @@ public int executeTest(TestEntry test, XdmNode params, XPathContext context)

if(test.getIsConformanceClass().equals("true")){
logger.println("<conformanceClass name=\"" + test.getLocalName() + "\"" + " isBasic=\"" + test.getIsBasic() + "\"" + " result=\"" + test.getResult() + "\" />");
supportHtmlReport = true;
}
logger.println("</log>");
logger.flush();
Expand Down Expand Up @@ -2476,7 +2480,7 @@ public void setTestServletURL(String testServletURL) {
this.testServletURL = testServletURL;
}
/**
* Transform CTL result into EARL report using XSLT.
* Transform EARL result into HTML report using XSLT.
* @param outputDir
*/
public void earlHtmlReport(String outputDir) {
Expand All @@ -2498,12 +2502,14 @@ public void earlHtmlReport(String outputDir) {
htmlOutput = new File(outputDir, "result");
}
try {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(earlXsl));
transformer.setParameter("outputDir", htmlOutput);
transformer.transform(new StreamSource(earlResult),
new StreamResult(new FileOutputStream("index.html")));
FileUtils.copyDirectory(new File(resourceDir), htmlOutput);
if (earlResult.exists()) {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(earlXsl));
transformer.setParameter("outputDir", htmlOutput);
transformer.transform(new StreamSource(earlResult),
new StreamResult(new FileOutputStream("index.html")));
FileUtils.copyDirectory(new File(resourceDir), htmlOutput);
}
} catch (Exception e) {
System.out.println(e.getMessage() + e.getCause());
}
Expand Down
1 change: 1 addition & 0 deletions teamengine-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<include>**/*.xsd</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>**/*.html</include>
</includes>
</configuration>
</plugin>
Expand Down
84 changes: 84 additions & 0 deletions teamengine-web/src/main/webapp/infoMessage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<html>
<title>Info message page</title>
<head>
<style>
body {
background-color: #E6E6E6;
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;
/*padding-top: 50px;*/
text-align: left;
}

.container {
margin: auto;
max-width: 70%;
min-width: 200px;
}

.box hr {
diplay: block;
border: none;
border-bottom: 1px dashed #ccc;
}

.box {
background-color: #fbfbfb;
border: 1px solid #AAA;
border-bottom: 1px solid #888;
border-radius: 3px;
color: black;
box-shadow: 0px 2px 2px #AAA;
padding: 20px;
}

.box h1, .box h2 {
display: block;
text-align: center;
}

.box h1 {
color: #666;
font-weight: normal;
font-size: 50px;
padding: 0;
margin: 0;
margin-top: 10px;
line-height: 50px
}

.box h2 {
color: #666;
font-weight: normal;
font-size: 1.5em;
}

.box p {
display: block;
margin-bottom: 10px;
}

.box ul li {
margin-bottom: 7px;
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<h2>
<p id="sessionIdHtml">Results for session</p>
</h2>
<hr />
<p>This test suite does not support the new HTML report and the
XML report must be used instead.</p>
<ul>
<li><p>
See the <a id="oldResultUrl" href="#">detailed old test report</a>
.
</p></li>
</ul>
</div>
</div>
</body>
</html>
31 changes: 21 additions & 10 deletions teamengine-web/src/main/webapp/viewSessionLog.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,22 @@ public void jspInit() {
}
$( document ).ready(function() {
console.log( "document loaded" );
var no_of_cc = $("#noConformanceClass").val();
if(no_of_cc == 0){
alert("This test suite does not support HTML reports and the old report must be used instead.");
}
console.log( "document loaded" );
if(document.getElementById("sessionIdHtml")) {
$('#sessionIdHtml').append('<%=request.getParameter("session")%>');
$('#sessionId').hide();
}
if(document.getElementById("oldResultUrl")) {
$('#oldResultUrl').attr('href', '<%=request.getContextPath()%>/viewOldSessionLog.jsp?session=<%=request.getParameter("session")%>');
$('#oldResultUrlPara').hide();
}
});
</script>
</head>
<body>
<%@ include file="header.jsp" %>
<h2>Results for session <%=request.getParameter("session")%></h2>
<span id ="sessionId"><h2>Results for session <%=request.getParameter("session")%></h2></span>
<%
File userlog = new File(Conf.getUsersDir(), request.getRemoteUser());
String sessionId = request.getParameter("session");
Expand Down Expand Up @@ -179,18 +183,25 @@ File userLog = new File(Conf.getUsersDir(), request.getRemoteUser());
File htmlReportDir = new File(userLog, sessionId + System.getProperty("file.separator") + "html");
String resultdir = userLog.toString() + System.getProperty("file.separator") + sessionId;
File resDir = new File(resultdir + System.getProperty("file.separator") + "testng");
File earlHtml = null;
if(!resDir.exists()){
resDir = new File(userLog.toString() + System.getProperty("file.separator") + sessionId );
}
if(resDir.exists()){
core.earlHtmlReport(resultdir.toString());
File earlHtml = new File(resultdir + System.getProperty("file.separator") + "result" + System.getProperty("file.separator") + "index.html");
earlHtml = new File(resultdir + System.getProperty("file.separator") + "result" + System.getProperty("file.separator") + "index.html");
}
/* if ( htmlReportDir.isDirectory()) { */
%>
<%
String testurl= "reports/" + request.getRemoteUser()+ "/" + request.getParameter("session") + "/result/index.html";
String testurl;
if(earlHtml.exists()){
testurl = "reports/" + request.getRemoteUser()+ "/" + request.getParameter("session") + "/result/index.html";
} else {
//This page will be displayed if test-suite is not supporting the new html report.
testurl = "/infoMessage.html";
}
%>

<jsp:include page="<%= testurl %>"></jsp:include>
Expand All @@ -206,8 +217,8 @@ String testurl= "reports/" + request.getRemoteUser()+ "/" + request.getParameter
</p> --%>
<% /* } */ %>

<p>
See the <a href="<%=request.getContextPath()%>/viewOldSessionLog.jsp?session=<%=sessionId%>">detailed old test report</a>.
<p id="oldResultUrlPara">
See the <a id="oldResultUrlPara" href="<%=request.getContextPath()%>/viewOldSessionLog.jsp?session=<%=sessionId%>">detailed old test report</a>.
</p>

<%--
Expand Down

0 comments on commit 1be4308

Please sign in to comment.