Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Message in result page. #225

Merged
merged 20 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions teamengine-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<artifactId>teamengine-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>teamengine-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.opengis.cite.saxon</groupId>
<artifactId>saxon9</artifactId>
Expand All @@ -47,6 +52,11 @@
<artifactId>xml-resolver</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.thaiopensource</groupId>
<artifactId>jing</artifactId>
Expand Down

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions teamengine-core/src/main/java/com/occamlab/te/TECore.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.XMLConstants; // Addition for Fortify modifications

import org.apache.commons.io.FileUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.Comment;
Expand Down Expand Up @@ -217,6 +219,7 @@ public class TECore implements Runnable {
public static String Clause = "";
public static String Purpose = "";
public static ArrayList<String> rootTestName = new ArrayList<String>();
public static Document userInputs = null;

public TECore() {

Expand Down Expand Up @@ -330,6 +333,32 @@ public void execute() throws Exception {
// Create xml execution report file
LogUtils.createFullReportLog(opts.getLogDir().getAbsolutePath()
+ File.separator + opts.getSessionId());
File resultsDir = new File(opts.getLogDir(),
opts.getSessionId());
Map<String, String> testInputMap = new HashMap<String, String>();
testInputMap = extractTestInputs(userInputs, opts);

if (! new File(resultsDir, "testng").exists() && null != testInputMap)
{
/*
* Transform CTL result into EARL result,
* when the CTL test is executed through the webapp.
*/
try {

File testLog = new File(resultsDir, "report_logs.xml");
CtlEarlReporter report = new CtlEarlReporter();

if (null != opts.getSourcesName()) {
report.generateEarlReport(resultsDir, testLog,
opts.getSourcesName(),
testInputMap);
}
} catch (IOException iox) {
throw new RuntimeException(
"Failed to serialize EARL results to " + iox);
}
}
}
}
}
Expand Down Expand Up @@ -1320,6 +1349,9 @@ public void setFormResults(Document doc) {
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(new DOMSource(doc), new StreamResult(sw));
if(userInputs == null){
userInputs = doc;
}
LOGR.info("Setting form results:\n " + sw.toString());
} catch(Exception e) {
LOGR.log(Level.SEVERE, "Failed to log the form results", e);
Expand Down Expand Up @@ -2443,7 +2475,70 @@ public String getTestServletURL() {
public void setTestServletURL(String testServletURL) {
this.testServletURL = testServletURL;
}
/**
* Transform CTL result into EARL report using XSLT.
* @param outputDir
*/
public void earlHtmlReport(String outputDir) {

ClassLoader cl = Thread.currentThread().getContextClassLoader();
String resourceDir = cl.getResource("com/occamlab/te/earl/lib").getPath();
String earlXsl = cl.getResource("com/occamlab/te/earl_html_report.xsl").toString();
File earlResult = null;
File htmlOutput = null;
File file = new File(outputDir + System.getProperty("file.separator") + "testng");
String[] dir = file.list();
String outDir = null;
if(!file.exists()){
htmlOutput = new File(outputDir,"result");
earlResult = new File(outputDir, "earl-results.rdf");
} else if (new File(file + System.getProperty("file.separator") + dir[0]).isDirectory()) {
earlResult = new File(file + System.getProperty("file.separator") + dir[0], "earl-results.rdf");
outDir = file + System.getProperty("file.separator") + dir[0];
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);
} catch (Exception e) {
System.out.println(e.getMessage() + e.getCause());
}
}

/**
* This method is used to extract the test input into
* Map from the document element.
* @param userInput Document node
* @param runOpts
* @return User Input Map
*/
private Map<String, String> extractTestInputs(Document userInput,
RuntimeOptions runOpts) {
Map<String, String> inputMap = new HashMap<String, String>();
if (null != userInputs) {
NodeList values = userInputs.getDocumentElement()
.getElementsByTagName("value");
if (values.getLength() == 0) {
throw new IllegalArgumentException("No test inputs found.");
}
for (int i = 0; i < values.getLength(); i++) {
Element value = (Element) values.item(i);
inputMap.put(value.getAttribute("key"), value.getTextContent());
}
} else if (null != opts.getParams()) {
List<String> runParams = opts.getParams();
for (String param : runParams) {
String[] kvp = param.split("=");
inputMap.put(kvp[0], kvp[1]);
}
}
return inputMap;
}

/**
* Builds a DOM Document representing a classpath resource.
*
Expand Down
2 changes: 2 additions & 0 deletions teamengine-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<include>**/*.xsl</include>
<include>**/*.ctl</include>
<include>**/*.xsd</include>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2(){1 h=5;h.I=2(){2 n(c,a){4(1 d=0;d<c.9;d++)i[c[d]]=a}2 o(c){1 a=r.H("J"),d=3;a.K=c;a.M="L/t";a.G="t";a.u=a.v=2(){6(!d&&(!8.7||8.7=="F"||8.7=="z")){d=q;e[c]=q;a:{4(1 p y e)6(e[p]==3)B a;j&&5.C(k)}a.u=a.v=x;a.D.O(a)}};r.N.R(a)}1 f=Q,l=h.P(),i={},e={},j=3,k=x,b;5.T=2(c){k=c;j=q};4(b=0;b<f.9;b++){1 m=f[b].w?f[b]:f[b].S(/\\s+/),g=m.w();n(m,g)}4(b=0;b<l.9;b++)6(g=i[l[b].E.A]){e[g]=3;o(g)}}})();',56,56,'|var|function|false|for|SyntaxHighlighter|if|readyState|this|length|||||||||||||||||true|document||javascript|onload|onreadystatechange|pop|null|in|complete|brush|break|highlight|parentNode|params|loaded|language|createElement|autoloader|script|src|text|type|body|removeChild|findElements|arguments|appendChild|split|all'.split('|'),0,{}))
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
;(function()
{
// CommonJS
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;

function Brush()
{
// Created by Peter Atoria @ http://iAtoria.com

var inits = 'class interface function package';

var keywords = '-Infinity ...rest Array as AS3 Boolean break case catch const continue Date decodeURI ' +
'decodeURIComponent default delete do dynamic each else encodeURI encodeURIComponent escape ' +
'extends false final finally flash_proxy for get if implements import in include Infinity ' +
'instanceof int internal is isFinite isNaN isXMLName label namespace NaN native new null ' +
'Null Number Object object_proxy override parseFloat parseInt private protected public ' +
'return set static String super switch this throw true try typeof uint undefined unescape ' +
'use void while with'
;

this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
{ regex: new RegExp(this.getKeywords(inits), 'gm'), css: 'color3' }, // initializations
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
{ regex: new RegExp('var', 'gm'), css: 'variable' }, // variable
{ regex: new RegExp('trace', 'gm'), css: 'color1' } // trace
];

this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags);
};

Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['actionscript3', 'as3'];

SyntaxHighlighter.brushes.AS3 = Brush;

// CommonJS
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
;(function()
{
// CommonJS
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;

function Brush()
{
// AppleScript brush by David Chambers
// http://davidchambersdesign.com/
var keywords = 'after before beginning continue copy each end every from return get global in local named of set some that the then times to where whose with without';
var ordinals = 'first second third fourth fifth sixth seventh eighth ninth tenth last front back middle';
var specials = 'activate add alias AppleScript ask attachment boolean class constant delete duplicate empty exists false id integer list make message modal modified new no paragraph pi properties quit real record remove rest result reveal reverse run running save string true word yes';

this.regexList = [

{ regex: /(--|#).*$/gm,
css: 'comments' },

{ regex: /\(\*(?:[\s\S]*?\(\*[\s\S]*?\*\))*[\s\S]*?\*\)/gm, // support nested comments
css: 'comments' },

{ regex: /"[\s\S]*?"/gm,
css: 'string' },

{ regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g,
css: 'color1' },

{ regex: /(-)?(\d)+(\.(\d)?)?(E\+(\d)+)?/g, // numbers
css: 'color1' },

{ regex: /(?:&(amp;|gt;|lt;)?|=|� |>|<|≥|>=|≤|<=|\*|\+|-|\/|÷|\^)/g,
css: 'color2' },

{ regex: /\b(?:and|as|div|mod|not|or|return(?!\s&)(ing)?|equals|(is(n't| not)? )?equal( to)?|does(n't| not) equal|(is(n't| not)? )?(greater|less) than( or equal( to)?)?|(comes|does(n't| not) come) (after|before)|is(n't| not)?( in)? (back|front) of|is(n't| not)? behind|is(n't| not)?( (in|contained by))?|does(n't| not) contain|contain(s)?|(start|begin|end)(s)? with|((but|end) )?(consider|ignor)ing|prop(erty)?|(a )?ref(erence)?( to)?|repeat (until|while|with)|((end|exit) )?repeat|((else|end) )?if|else|(end )?(script|tell|try)|(on )?error|(put )?into|(of )?(it|me)|its|my|with (timeout( of)?|transaction)|end (timeout|transaction))\b/g,
css: 'keyword' },

{ regex: /\b\d+(st|nd|rd|th)\b/g, // ordinals
css: 'keyword' },

{ regex: /\b(?:about|above|against|around|at|below|beneath|beside|between|by|(apart|aside) from|(instead|out) of|into|on(to)?|over|since|thr(ough|u)|under)\b/g,
css: 'color3' },

{ regex: /\b(?:adding folder items to|after receiving|choose( ((remote )?application|color|folder|from list|URL))?|clipboard info|set the clipboard to|(the )?clipboard|entire contents|display(ing| (alert|dialog|mode))?|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|quoted form|return(ed)?|second(?! item)(s)?|list (disks|folder)|text item(s| delimiters)?|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|using( delimiters)?|starting at|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor)|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|(do( shell)?|load|run|store) script|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|POSIX (file|path)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|group|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
css: 'color3' },

{ regex: new RegExp(this.getKeywords(specials), 'gm'), css: 'color3' },
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
{ regex: new RegExp(this.getKeywords(ordinals), 'gm'), css: 'keyword' }
];
};

Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['applescript'];

SyntaxHighlighter.brushes.AppleScript = Brush;

// CommonJS
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();
Loading