commit
56fba96f71
|
@ -3,3 +3,5 @@ eclipsecompiled
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
*.iml
|
||||||
|
.idea
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>rhino</groupId>
|
<groupId>org.mozilla</groupId>
|
||||||
<artifactId>js</artifactId>
|
<artifactId>rhino</artifactId>
|
||||||
<version>1.7R2</version>
|
<version>1.7R4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -60,6 +60,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
|
0
src/main/java/be/klak/junit/jasmine/JasmineSpecFailureException.java
Executable file → Normal file
0
src/main/java/be/klak/junit/jasmine/JasmineSpecFailureException.java
Executable file → Normal file
14
src/main/java/be/klak/junit/jasmine/JasmineSpecRunnerGenerator.java
Executable file → Normal file
14
src/main/java/be/klak/junit/jasmine/JasmineSpecRunnerGenerator.java
Executable file → Normal file
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
class JasmineSpecRunnerGenerator {
|
class JasmineSpecRunnerGenerator {
|
||||||
|
|
||||||
|
@ -66,12 +67,17 @@ class JasmineSpecRunnerGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String loadTemplate() {
|
private String loadTemplate() {
|
||||||
String template = null;
|
|
||||||
try {
|
try {
|
||||||
template = FileUtils.readFileToString(new File(suite.jsRootDir() + "/lib/specRunner.tpl"));
|
return IOUtils.toString(
|
||||||
|
Thread
|
||||||
|
.currentThread()
|
||||||
|
.getContextClassLoader()
|
||||||
|
.getResourceAsStream("js/lib/specRunner.tpl")
|
||||||
|
);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new IllegalStateException("spec runner template file not found!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("spec runner template file not found!", e);
|
throw new IllegalStateException("spec runner template file could not be read!", e);
|
||||||
}
|
}
|
||||||
return template;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.runner.Description;
|
import org.junit.runner.Description;
|
||||||
|
@ -18,7 +21,9 @@ import be.klak.rhino.RhinoContext;
|
||||||
public class JasmineTestRunner extends Runner {
|
public class JasmineTestRunner extends Runner {
|
||||||
|
|
||||||
private static final int SLEEP_TIME_MILISECONDS = 50;
|
private static final int SLEEP_TIME_MILISECONDS = 50;
|
||||||
private static final String JASMINE_LIB_DIR = "/lib/jasmine-1.0.2/";
|
|
||||||
|
// relative to classpath
|
||||||
|
private static final String JASMINE_LIB_DIR = "js/lib/jasmine-1.0.2";
|
||||||
|
|
||||||
private JasmineDescriptions jasmineSuite;
|
private JasmineDescriptions jasmineSuite;
|
||||||
|
|
||||||
|
@ -67,8 +72,8 @@ public class JasmineTestRunner extends Runner {
|
||||||
protected void pre(RhinoContext context) { }
|
protected void pre(RhinoContext context) { }
|
||||||
|
|
||||||
private void setUpJasmine(RhinoContext context) {
|
private void setUpJasmine(RhinoContext context) {
|
||||||
context.load(getJsLibDir() + "jasmine.js");
|
context.loadFromClasspath(JASMINE_LIB_DIR + "/jasmine.js");
|
||||||
context.load(getJsLibDir() + "jasmine.delegator_reporter.js");
|
context.loadFromClasspath(JASMINE_LIB_DIR + "/jasmine.delegator_reporter.js");
|
||||||
|
|
||||||
context.evalJS("jasmine.getEnv().addReporter(new jasmine.DelegatorJUnitReporter());");
|
context.evalJS("jasmine.getEnv().addReporter(new jasmine.DelegatorJUnitReporter());");
|
||||||
}
|
}
|
||||||
|
@ -106,11 +111,26 @@ public class JasmineTestRunner extends Runner {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetEnvjsWindowSpace() {
|
private void resetEnvjsWindowSpace() {
|
||||||
this.rhinoContext.evalJS("window.location = '" + suiteAnnotation.jsRootDir() + "/lib/blank.html';");
|
URL blankUrl = Thread
|
||||||
}
|
.currentThread()
|
||||||
|
.getContextClassLoader()
|
||||||
|
.getResource("js/lib/blank.html");
|
||||||
|
|
||||||
private String getJsLibDir() {
|
if (blankUrl == null) {
|
||||||
return suiteAnnotation.jsRootDir() + JASMINE_LIB_DIR;
|
throw new IllegalStateException("Unable to load js/lib/blank.html from classpath");
|
||||||
|
}
|
||||||
|
|
||||||
|
String blankUrlStr = blankUrl.toExternalForm();
|
||||||
|
|
||||||
|
// "file:/path/to/file" is not legal, but "file:///path/to/file" is
|
||||||
|
if (blankUrlStr.startsWith("file:/") && (! blankUrlStr.startsWith("file:///"))) {
|
||||||
|
blankUrlStr = "file://" + blankUrlStr.substring(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rhinoContext.evalJS(String.format(
|
||||||
|
"window.location = '%s';",
|
||||||
|
blankUrlStr
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JasmineDescriptions getJasmineDescriptions() {
|
private JasmineDescriptions getJasmineDescriptions() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package be.klak.rhino;
|
package be.klak.rhino;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
import org.mozilla.javascript.ContextFactory;
|
import org.mozilla.javascript.ContextFactory;
|
||||||
import org.mozilla.javascript.Function;
|
import org.mozilla.javascript.Function;
|
||||||
|
@ -86,6 +88,24 @@ public class RhinoContext {
|
||||||
// Main.processFile(this.jsContext, this.jsScope, fileName);
|
// Main.processFile(this.jsContext, this.jsScope, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{{ loadFromClasspath
|
||||||
|
/**
|
||||||
|
* Loads a resource from the classpath.
|
||||||
|
*
|
||||||
|
* @param resource the resource to resolve from the classpath
|
||||||
|
*/
|
||||||
|
public void loadFromClasspath(final String resource) {
|
||||||
|
URL rsrcUrl =
|
||||||
|
Thread.currentThread().getContextClassLoader().getResource(resource);
|
||||||
|
|
||||||
|
if (rsrcUrl == null) {
|
||||||
|
throw new IllegalArgumentException("resource " + resource + " not found on classpath");
|
||||||
|
}
|
||||||
|
|
||||||
|
evalJS(String.format("load('%s')", rsrcUrl.toExternalForm()));
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
|
|
||||||
public Object executeFunction(ScriptableObject object, String fnName, Object[] arguments) {
|
public Object executeFunction(ScriptableObject object, String fnName, Object[] arguments) {
|
||||||
Object fnPointer = object.get(fnName, object);
|
Object fnPointer = object.get(fnName, object);
|
||||||
if (fnPointer == null || !(fnPointer instanceof Function)) {
|
if (fnPointer == null || !(fnPointer instanceof Function)) {
|
||||||
|
@ -108,11 +128,8 @@ public class RhinoContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadEnv(String jsDir) {
|
public void loadEnv(String jsDir) {
|
||||||
// TODO ensure rhino 1.7R3 instead of R2 -> geen shim nodig + paths
|
loadFromClasspath("js/lib/env.rhino.1.2.js");
|
||||||
// gedoe in orde zetten hier
|
loadFromClasspath("js/lib/env.utils.js");
|
||||||
load(jsDir + "/lib/es5-shim-0.0.4.min.js");
|
|
||||||
load(jsDir + "/lib/env.rhino.1.2.js");
|
|
||||||
load(jsDir + "/lib/env.utils.js");
|
|
||||||
load(jsDir + "/envJsOptions.js");
|
load(jsDir + "/envJsOptions.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +142,7 @@ public class RhinoContext {
|
||||||
private Context createJavascriptContext() {
|
private Context createJavascriptContext() {
|
||||||
Context jsContext = ContextFactory.getGlobal().enterContext();
|
Context jsContext = ContextFactory.getGlobal().enterContext();
|
||||||
jsContext.setOptimizationLevel(-1);
|
jsContext.setOptimizationLevel(-1);
|
||||||
jsContext.setLanguageVersion(Context.VERSION_1_5); // TODO 1.8 plx
|
jsContext.setLanguageVersion(Context.VERSION_1_8);
|
||||||
jsContext.setErrorReporter(new ChainedErrorReporter(jsContext.getErrorReporter()));
|
jsContext.setErrorReporter(new ChainedErrorReporter(jsContext.getErrorReporter()));
|
||||||
return jsContext;
|
return jsContext;
|
||||||
}
|
}
|
||||||
|
|
0
src/test/javascript/lib/blank.html → src/main/resources/js/lib/blank.html
Executable file → Normal file
0
src/test/javascript/lib/blank.html → src/main/resources/js/lib/blank.html
Executable file → Normal file
27978
src/test/javascript/lib/env.rhino.1.2.js → src/main/resources/js/lib/env.rhino.1.2.js
Executable file → Normal file
27978
src/test/javascript/lib/env.rhino.1.2.js → src/main/resources/js/lib/env.rhino.1.2.js
Executable file → Normal file
File diff suppressed because one or more lines are too long
380
src/test/javascript/lib/env.utils.js → src/main/resources/js/lib/env.utils.js
Executable file → Normal file
380
src/test/javascript/lib/env.utils.js → src/main/resources/js/lib/env.utils.js
Executable file → Normal file
|
@ -1,191 +1,189 @@
|
||||||
|
/**
|
||||||
/**
|
* Rhino and Envjs additions, filling the missing pieces such as a decent stacktrace
|
||||||
* Rhino and Envjs additions, filling the missing pieces such as a decent stacktrace
|
* 1) Firefox knows new Error().stack but Envjs does not.
|
||||||
* 1) Firefox knows new Error().stack but Envjs does not.
|
*/
|
||||||
*/
|
(function() {
|
||||||
(function() {
|
var NEWLINE = "\r\n";
|
||||||
var NEWLINE = "\r\n";
|
|
||||||
|
function manuallyTriggerException() {
|
||||||
function manuallyTriggerException() {
|
var manuallyTriggeredExMessage = "";
|
||||||
var manuallyTriggeredExMessage = "";
|
try {
|
||||||
try {
|
OEIWABEZIG
|
||||||
OEIWABEZIG
|
} catch(e) {
|
||||||
} catch(e) {
|
// TODO knip- en plakwerk: de eerste lijn moet natuurlijk weg etc...
|
||||||
// TODO knip- en plakwerk: de eerste lijn moet natuurlijk weg etc...
|
return e;
|
||||||
return e;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
function stripRhinoSpecificExceptionLines(stack) {
|
||||||
function stripRhinoSpecificExceptionLines(stack) {
|
var ignoreTracingInStackFor = [ "env.utils.js", "org.mozilla.javascript" ];
|
||||||
var ignoreTracingInStackFor = [ "env.utils.js", "org.mozilla.javascript" ];
|
|
||||||
|
return stack.split(NEWLINE).filter(function(stackLine) {
|
||||||
return stack.split(NEWLINE).filter(function(stackLine) {
|
return ignoreTracingInStackFor.every(function(ignoreThisInTrace) {
|
||||||
return ignoreTracingInStackFor.every(function(ignoreThisInTrace) {
|
return stackLine.indexOf(ignoreThisInTrace) < 0;
|
||||||
return stackLine.indexOf(ignoreThisInTrace) < 0;
|
});
|
||||||
});
|
}).reduce(function(prev, curr) {
|
||||||
}).reduce(function(prev, curr) {
|
return prev + NEWLINE + curr;
|
||||||
return prev + NEWLINE + curr;
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
window.Error.writeStackTrace = function(e) {
|
||||||
window.Error.writeStackTrace = function(e) {
|
var stringWriter = new java.io.StringWriter();
|
||||||
var stringWriter = new java.io.StringWriter();
|
var printWriter = new java.io.PrintWriter(stringWriter);
|
||||||
var printWriter = new java.io.PrintWriter(stringWriter);
|
e.rhinoException.printStackTrace(printWriter);
|
||||||
e.rhinoException.printStackTrace(printWriter);
|
return stringWriter.toString() + "" // I don't want the java.lang.String object!
|
||||||
return stringWriter.toString() + "" // I don't want the java.lang.String object!
|
};
|
||||||
};
|
|
||||||
|
window.Error.prototype.getStackTrace = function() {
|
||||||
window.Error.prototype.getStackTrace = function() {
|
// TODO add other stuff from Object.keys(new Error("bla")) (see Firebug)
|
||||||
// TODO add other stuff from Object.keys(new Error("bla")) (see Firebug)
|
var trace = this.message + NEWLINE;
|
||||||
var trace = this.message + NEWLINE;
|
if(this.stack) {
|
||||||
if(this.stack) {
|
trace += this.stack;
|
||||||
trace += this.stack;
|
} else if(this.rhinoException) {
|
||||||
} else if(this.rhinoException) {
|
trace += window.Error.writeStackTrace(this.rhinoException);
|
||||||
trace += window.Error.writeStackTrace(this.rhinoException);
|
} else {
|
||||||
} else {
|
trace += stripRhinoSpecificExceptionLines(window.Error.writeStackTrace(manuallyTriggerException()));
|
||||||
trace += stripRhinoSpecificExceptionLines(window.Error.writeStackTrace(manuallyTriggerException()));
|
}
|
||||||
}
|
|
||||||
|
return trace;
|
||||||
return trace;
|
}
|
||||||
}
|
|
||||||
|
})();
|
||||||
})();
|
|
||||||
|
/**
|
||||||
/**
|
* Envjs specific hacks
|
||||||
* Envjs specific hacks
|
* 1) Fix Envjs relative path system to work with Windows path systems
|
||||||
* 1) Fix Envjs relative path system to work with Windows path systems
|
* 2) Fix CSS2Properties support for parsing style attributes: get from raw node context.
|
||||||
* 2) Fix CSS2Properties support for parsing style attributes: get from raw node context.
|
* 3) Fix CSS2Properties support for setting values: all properties have the same objmaps, wtf?
|
||||||
* 3) Fix CSS2Properties support for setting values: all properties have the same objmaps, wtf?
|
* 4) Fix focus() which sets document.activeElement correctly for jQuery:focus
|
||||||
* 4) Fix focus() which sets document.activeElement correctly for jQuery:focus
|
* 5) Fix Input click() behavior for checkboxes. Warning: jQ's click() <-> DOM's click (checked value too late set)!
|
||||||
* 5) Fix Input click() behavior for checkboxes. Warning: jQ's click() <-> DOM's click (checked value too late set)!
|
**/
|
||||||
**/
|
(function() {
|
||||||
(function() {
|
|
||||||
|
var oldEnvjsUriFn = Envjs.uri;
|
||||||
var oldEnvjsUriFn = Envjs.uri;
|
Envjs.uri = function(path, baseDir) {
|
||||||
Envjs.uri = function(path, baseDir) {
|
if(baseDir) {
|
||||||
if(baseDir) {
|
return oldEnvjsUriFn(path, baseDir);
|
||||||
return oldEnvjsUriFn(path, baseDir);
|
}
|
||||||
}
|
return oldEnvjsUriFn(path, "file:///" + ("" + Envjs.getcwd()).replace(/\\/g, '/') + "/");
|
||||||
return oldEnvjsUriFn(path, "file:///" + ("" + Envjs.getcwd()).replace(/\\/g, '/') + "/");
|
};
|
||||||
};
|
|
||||||
|
(function(Element) {
|
||||||
(function(Element) {
|
|
||||||
|
var style = "style";
|
||||||
var style = "style";
|
function lookupStyleInNodeAttributes(el) {
|
||||||
function lookupStyleInNodeAttributes(el) {
|
if(el.attributes) {
|
||||||
if(el.attributes) {
|
for(var i = 0; i < el.attributes.length; i++) {
|
||||||
for(var i = 0; i < el.attributes.length; i++) {
|
if(el.attributes[i].nodeName === style) {
|
||||||
if(el.attributes[i].nodeName === style) {
|
return el.attributes[i].nodeValue;
|
||||||
return el.attributes[i].nodeValue;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
var styleSetFn = Element.__lookupGetter__(style);
|
||||||
var styleSetFn = Element.__lookupGetter__(style);
|
Element.__defineGetter__(style, function() {
|
||||||
Element.__defineGetter__(style, function() {
|
if(!this.cssText) {
|
||||||
if(!this.cssText) {
|
this.cssText = lookupStyleInNodeAttributes(this);
|
||||||
this.cssText = lookupStyleInNodeAttributes(this);
|
}
|
||||||
}
|
return styleSetFn.apply(this);
|
||||||
return styleSetFn.apply(this);
|
});
|
||||||
});
|
|
||||||
|
})(HTMLElement.prototype);
|
||||||
})(HTMLElement.prototype);
|
|
||||||
|
(function(input) {
|
||||||
(function(input) {
|
var oldClick = input.prototype.click;
|
||||||
var oldClick = input.prototype.click;
|
input.prototype.click = function() {
|
||||||
input.prototype.click = function() {
|
if(this.type === "checkbox") {
|
||||||
if(this.type === "checkbox") {
|
this.checked = !this.checked;
|
||||||
this.checked = !this.checked;
|
}
|
||||||
}
|
oldClick.apply(this, arguments);
|
||||||
oldClick.apply(this, arguments);
|
}
|
||||||
}
|
})(HTMLInputElement);
|
||||||
})(HTMLInputElement);
|
|
||||||
|
(function(Input, Textarea, document) {
|
||||||
(function(Input, Textarea, document) {
|
var activeElement;
|
||||||
var activeElement;
|
function fixFocusForPrototype(element) {
|
||||||
function fixFocusForPrototype(element) {
|
var originalFocus = element.prototype.focus;
|
||||||
var originalFocus = element.prototype.focus;
|
element.prototype.focus = function(element) {
|
||||||
element.prototype.focus = function(element) {
|
activeElement = this;
|
||||||
activeElement = this;
|
originalFocus.apply(this, arguments);
|
||||||
originalFocus.apply(this, arguments);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
fixFocusForPrototype(Input);
|
||||||
fixFocusForPrototype(Input);
|
fixFocusForPrototype(Textarea);
|
||||||
fixFocusForPrototype(Textarea);
|
|
||||||
|
document.__defineGetter__("activeElement", function() {
|
||||||
document.__defineGetter__("activeElement", function() {
|
return activeElement;
|
||||||
return activeElement;
|
});
|
||||||
});
|
|
||||||
|
})(HTMLInputElement, HTMLTextAreaElement, document);
|
||||||
})(HTMLInputElement, HTMLTextAreaElement, document);
|
|
||||||
|
(function(css) {
|
||||||
(function(css) {
|
|
||||||
|
var setCssProperty = css.prototype.setProperty;
|
||||||
var setCssProperty = css.prototype.setProperty;
|
css.prototype.setProperty = function(name, value) {
|
||||||
css.prototype.setProperty = function(name, value) {
|
// create a shallow clone of __supportedStyles__ (styleIndex' default value) if prototype not yet set
|
||||||
// create a shallow clone of __supportedStyles__ (styleIndex' default value) if prototype not yet set
|
if(Object.keys(Object.getPrototypeOf(this.styleIndex)).length === 0) {
|
||||||
if(Object.keys(Object.getPrototypeOf(this.styleIndex)).length === 0) {
|
this.styleIndex = Object.create(this.styleIndex);
|
||||||
this.styleIndex = Object.create(this.styleIndex);
|
}
|
||||||
}
|
|
||||||
|
return setCssProperty.call(this, name, value);
|
||||||
return setCssProperty.call(this, name, value);
|
}
|
||||||
}
|
})(CSS2Properties);
|
||||||
})(CSS2Properties);
|
})();
|
||||||
})();
|
|
||||||
|
/**
|
||||||
/**
|
* Envjs timeout fixes which use native Java code to re-implement setTimeout and setInterval
|
||||||
* Envjs timeout fixes which use native Java code to re-implement setTimeout and setInterval
|
* also sets clearTimeout & clearInterval on same level.
|
||||||
* also sets clearTimeout & clearInterval on same level.
|
*/
|
||||||
*/
|
(function() {
|
||||||
(function() {
|
var threadTimeoutPool = new java.util.HashMap();
|
||||||
var threadTimeoutPool = {};
|
|
||||||
|
window.setTimeout = function(closure, timeout) {
|
||||||
window.setTimeout = function(closure, timeout) {
|
var thread = spawn(function() {
|
||||||
var thread = spawn(function() {
|
try {
|
||||||
try {
|
java.lang.Thread.sleep(timeout);
|
||||||
java.lang.Thread.sleep(timeout);
|
closure();
|
||||||
closure();
|
} catch(e) {
|
||||||
} catch(e) {
|
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
throw(e);
|
||||||
throw(e);
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
threadTimeoutPool.put(thread.getId(), thread);
|
||||||
threadTimeoutPool[thread.getId()] = thread;
|
return thread.getId();
|
||||||
return thread.getId();
|
};
|
||||||
};
|
|
||||||
|
window.setInterval = function(closure, timeout) {
|
||||||
window.setInterval = function(closure, timeout) {
|
var thread = spawn(function() {
|
||||||
var thread = spawn(function() {
|
try {
|
||||||
try {
|
while(true) {
|
||||||
while(true) {
|
java.lang.Thread.sleep(timeout);
|
||||||
java.lang.Thread.sleep(timeout);
|
closure();
|
||||||
closure();
|
}
|
||||||
}
|
} catch(e) {
|
||||||
} catch(e) {
|
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
throw(e);
|
||||||
throw(e);
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
threadTimeoutPool.put(thread.getId(), thread);
|
||||||
threadTimeoutPool[thread.getId()] = thread;
|
return thread.getId();
|
||||||
return thread.getId();
|
};
|
||||||
};
|
|
||||||
|
window.clearTimeout = function(threadId) {
|
||||||
window.clearTimeout = function(threadId) {
|
if (threadId) {
|
||||||
if (threadId) {
|
if(threadTimeoutPool.containsKey(threadId)) {
|
||||||
if(threadTimeoutPool[threadId]) {
|
threadTimeoutPool.remove(threadId).interrupt();
|
||||||
threadTimeoutPool[threadId].interrupt();
|
}
|
||||||
delete threadTimeoutPool[threadId];
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
};
|
window.clearInterval = window.clearTimeout;
|
||||||
|
})();
|
||||||
window.clearInterval = window.clearTimeout;
|
|
||||||
})();
|
|
40
src/test/javascript/lib/jasmine-1.0.2/MIT.LICENSE → src/main/resources/js/lib/jasmine-1.0.2/MIT.LICENSE
Executable file → Normal file
40
src/test/javascript/lib/jasmine-1.0.2/MIT.LICENSE → src/main/resources/js/lib/jasmine-1.0.2/MIT.LICENSE
Executable file → Normal file
|
@ -1,20 +1,20 @@
|
||||||
Copyright (c) 2008-2010 Pivotal Labs
|
Copyright (c) 2008-2010 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
"Software"), to deal in the Software without restriction, including
|
"Software"), to deal in the Software without restriction, including
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
376
src/test/javascript/lib/jasmine-1.0.2/jasmine-html.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine-html.js
Executable file → Normal file
376
src/test/javascript/lib/jasmine-1.0.2/jasmine-html.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine-html.js
Executable file → Normal file
|
@ -1,188 +1,188 @@
|
||||||
jasmine.TrivialReporter = function(doc) {
|
jasmine.TrivialReporter = function(doc) {
|
||||||
this.document = doc || document;
|
this.document = doc || document;
|
||||||
this.suiteDivs = {};
|
this.suiteDivs = {};
|
||||||
this.logRunningSpecs = false;
|
this.logRunningSpecs = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||||
var el = document.createElement(type);
|
var el = document.createElement(type);
|
||||||
|
|
||||||
for (var i = 2; i < arguments.length; i++) {
|
for (var i = 2; i < arguments.length; i++) {
|
||||||
var child = arguments[i];
|
var child = arguments[i];
|
||||||
|
|
||||||
if (typeof child === 'string') {
|
if (typeof child === 'string') {
|
||||||
el.appendChild(document.createTextNode(child));
|
el.appendChild(document.createTextNode(child));
|
||||||
} else {
|
} else {
|
||||||
if (child) { el.appendChild(child); }
|
if (child) { el.appendChild(child); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
if (attr == "className") {
|
if (attr == "className") {
|
||||||
el[attr] = attrs[attr];
|
el[attr] = attrs[attr];
|
||||||
} else {
|
} else {
|
||||||
el.setAttribute(attr, attrs[attr]);
|
el.setAttribute(attr, attrs[attr]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
var showPassed, showSkipped;
|
var showPassed, showSkipped;
|
||||||
|
|
||||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||||
this.createDom('div', { className: 'banner' },
|
this.createDom('div', { className: 'banner' },
|
||||||
this.createDom('div', { className: 'logo' },
|
this.createDom('div', { className: 'logo' },
|
||||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
||||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||||
this.createDom('div', { className: 'options' },
|
this.createDom('div', { className: 'options' },
|
||||||
"Show ",
|
"Show ",
|
||||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||||
);
|
);
|
||||||
|
|
||||||
this.document.body.appendChild(this.outerDiv);
|
this.document.body.appendChild(this.outerDiv);
|
||||||
|
|
||||||
var suites = runner.suites();
|
var suites = runner.suites();
|
||||||
for (var i = 0; i < suites.length; i++) {
|
for (var i = 0; i < suites.length; i++) {
|
||||||
var suite = suites[i];
|
var suite = suites[i];
|
||||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||||
this.suiteDivs[suite.id] = suiteDiv;
|
this.suiteDivs[suite.id] = suiteDiv;
|
||||||
var parentDiv = this.outerDiv;
|
var parentDiv = this.outerDiv;
|
||||||
if (suite.parentSuite) {
|
if (suite.parentSuite) {
|
||||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||||
}
|
}
|
||||||
parentDiv.appendChild(suiteDiv);
|
parentDiv.appendChild(suiteDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startedAt = new Date();
|
this.startedAt = new Date();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
showPassed.onclick = function(evt) {
|
showPassed.onclick = function(evt) {
|
||||||
if (showPassed.checked) {
|
if (showPassed.checked) {
|
||||||
self.outerDiv.className += ' show-passed';
|
self.outerDiv.className += ' show-passed';
|
||||||
} else {
|
} else {
|
||||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
showSkipped.onclick = function(evt) {
|
showSkipped.onclick = function(evt) {
|
||||||
if (showSkipped.checked) {
|
if (showSkipped.checked) {
|
||||||
self.outerDiv.className += ' show-skipped';
|
self.outerDiv.className += ' show-skipped';
|
||||||
} else {
|
} else {
|
||||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||||
var results = runner.results();
|
var results = runner.results();
|
||||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||||
this.runnerDiv.setAttribute("class", className);
|
this.runnerDiv.setAttribute("class", className);
|
||||||
//do it twice for IE
|
//do it twice for IE
|
||||||
this.runnerDiv.setAttribute("className", className);
|
this.runnerDiv.setAttribute("className", className);
|
||||||
var specs = runner.specs();
|
var specs = runner.specs();
|
||||||
var specCount = 0;
|
var specCount = 0;
|
||||||
for (var i = 0; i < specs.length; i++) {
|
for (var i = 0; i < specs.length; i++) {
|
||||||
if (this.specFilter(specs[i])) {
|
if (this.specFilter(specs[i])) {
|
||||||
specCount++;
|
specCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||||
|
|
||||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
this.suiteDivs[suite.id].className += " " + status;
|
this.suiteDivs[suite.id].className += " " + status;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||||
if (this.logRunningSpecs) {
|
if (this.logRunningSpecs) {
|
||||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||||
var results = spec.results();
|
var results = spec.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.skipped) {
|
if (results.skipped) {
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||||
this.createDom('a', {
|
this.createDom('a', {
|
||||||
className: 'description',
|
className: 'description',
|
||||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||||
title: spec.getFullName()
|
title: spec.getFullName()
|
||||||
}, spec.description));
|
}, spec.description));
|
||||||
|
|
||||||
|
|
||||||
var resultItems = results.getItems();
|
var resultItems = results.getItems();
|
||||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||||
for (var i = 0; i < resultItems.length; i++) {
|
for (var i = 0; i < resultItems.length; i++) {
|
||||||
var result = resultItems[i];
|
var result = resultItems[i];
|
||||||
|
|
||||||
if (result.type == 'log') {
|
if (result.type == 'log') {
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||||
|
|
||||||
if (result.trace.stack) {
|
if (result.trace.stack) {
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messagesDiv.childNodes.length > 0) {
|
if (messagesDiv.childNodes.length > 0) {
|
||||||
specDiv.appendChild(messagesDiv);
|
specDiv.appendChild(messagesDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.log = function() {
|
jasmine.TrivialReporter.prototype.log = function() {
|
||||||
var console = jasmine.getGlobal().console;
|
var console = jasmine.getGlobal().console;
|
||||||
if (console && console.log) {
|
if (console && console.log) {
|
||||||
if (console.log.apply) {
|
if (console.log.apply) {
|
||||||
console.log.apply(console, arguments);
|
console.log.apply(console, arguments);
|
||||||
} else {
|
} else {
|
||||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||||
return this.document.location;
|
return this.document.location;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||||
var paramMap = {};
|
var paramMap = {};
|
||||||
var params = this.getLocation().search.substring(1).split('&');
|
var params = this.getLocation().search.substring(1).split('&');
|
||||||
for (var i = 0; i < params.length; i++) {
|
for (var i = 0; i < params.length; i++) {
|
||||||
var p = params[i].split('=');
|
var p = params[i].split('=');
|
||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paramMap["spec"]) return true;
|
if (!paramMap["spec"]) return true;
|
||||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||||
};
|
};
|
0
src/test/javascript/lib/jasmine-1.0.2/jasmine-jquery-rhino.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine-jquery-rhino.js
Executable file → Normal file
0
src/test/javascript/lib/jasmine-1.0.2/jasmine-jquery-rhino.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine-jquery-rhino.js
Executable file → Normal file
128
src/test/javascript/lib/jasmine-1.0.2/jasmine.console_reporter.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.console_reporter.js
Executable file → Normal file
128
src/test/javascript/lib/jasmine-1.0.2/jasmine.console_reporter.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.console_reporter.js
Executable file → Normal file
|
@ -1,64 +1,64 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if (! jasmine) {
|
if (! jasmine) {
|
||||||
throw new Exception("jasmine library does not exist in global namespace!");
|
throw new Exception("jasmine library does not exist in global namespace!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic reporter that outputs spec results to the browser console.
|
* Basic reporter that outputs spec results to the browser console.
|
||||||
* Useful if you need to test an html page and don't want the TrivialReporter
|
* Useful if you need to test an html page and don't want the TrivialReporter
|
||||||
* markup mucking things up.
|
* markup mucking things up.
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
*
|
*
|
||||||
* jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
* jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
||||||
* jasmine.getEnv().execute();
|
* jasmine.getEnv().execute();
|
||||||
*/
|
*/
|
||||||
var ConsoleReporter = function() {
|
var ConsoleReporter = function() {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.finished = false;
|
this.finished = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConsoleReporter.prototype = {
|
ConsoleReporter.prototype = {
|
||||||
reportRunnerResults: function(runner) {
|
reportRunnerResults: function(runner) {
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
this.log("Runner Finished.");
|
this.log("Runner Finished.");
|
||||||
},
|
},
|
||||||
|
|
||||||
reportRunnerStarting: function(runner) {
|
reportRunnerStarting: function(runner) {
|
||||||
this.started = true;
|
this.started = true;
|
||||||
this.log("Runner Started.");
|
this.log("Runner Started.");
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecResults: function(spec) {
|
reportSpecResults: function(spec) {
|
||||||
var resultText = "Failed.";
|
var resultText = "Failed.";
|
||||||
|
|
||||||
if (spec.results().passed()) {
|
if (spec.results().passed()) {
|
||||||
resultText = "Passed.";
|
resultText = "Passed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log(resultText);
|
this.log(resultText);
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecStarting: function(spec) {
|
reportSpecStarting: function(spec) {
|
||||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {
|
reportSuiteResults: function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
|
|
||||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.");
|
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.");
|
||||||
},
|
},
|
||||||
|
|
||||||
log: function(str) {
|
log: function(str) {
|
||||||
var console = jasmine.getGlobal().console;
|
var console = jasmine.getGlobal().console;
|
||||||
|
|
||||||
if (console && console.log) {
|
if (console && console.log) {
|
||||||
console.log(str);
|
console.log(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// export public
|
// export public
|
||||||
jasmine.ConsoleReporter = ConsoleReporter;
|
jasmine.ConsoleReporter = ConsoleReporter;
|
||||||
})();
|
})();
|
332
src/test/javascript/lib/jasmine-1.0.2/jasmine.css → src/main/resources/js/lib/jasmine-1.0.2/jasmine.css
Executable file → Normal file
332
src/test/javascript/lib/jasmine-1.0.2/jasmine.css → src/main/resources/js/lib/jasmine-1.0.2/jasmine.css
Executable file → Normal file
|
@ -1,166 +1,166 @@
|
||||||
body {
|
body {
|
||||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||||
color: #303;
|
color: #303;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
.run_spec {
|
.run_spec {
|
||||||
float:right;
|
float:right;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jasmine_reporter {
|
.jasmine_reporter {
|
||||||
margin: 0 5px;
|
margin: 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner {
|
.banner {
|
||||||
color: #303;
|
color: #303;
|
||||||
background-color: #fef;
|
background-color: #fef;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
float: left;
|
float: left;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo .version {
|
.logo .version {
|
||||||
font-size: .6em;
|
font-size: .6em;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.runner.running {
|
.runner.running {
|
||||||
background-color: yellow;
|
background-color: yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.options {
|
.options {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.suite {
|
.suite {
|
||||||
border: 1px outset gray;
|
border: 1px outset gray;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suite .suite {
|
.suite .suite {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suite.passed {
|
.suite.passed {
|
||||||
background-color: #dfd;
|
background-color: #dfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suite.failed {
|
.suite.failed {
|
||||||
background-color: #fdd;
|
background-color: #fdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spec {
|
.spec {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spec.failed, .spec.passed, .spec.skipped {
|
.spec.failed, .spec.passed, .spec.skipped {
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spec.failed {
|
.spec.failed {
|
||||||
background-color: #fbb;
|
background-color: #fbb;
|
||||||
border-color: red;
|
border-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spec.passed {
|
.spec.passed {
|
||||||
background-color: #bfb;
|
background-color: #bfb;
|
||||||
border-color: green;
|
border-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spec.skipped {
|
.spec.skipped {
|
||||||
background-color: #bbb;
|
background-color: #bbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.messages {
|
.messages {
|
||||||
border-left: 1px dashed gray;
|
border-left: 1px dashed gray;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.passed {
|
.passed {
|
||||||
background-color: #cfc;
|
background-color: #cfc;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.failed {
|
.failed {
|
||||||
background-color: #fbb;
|
background-color: #fbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skipped {
|
.skipped {
|
||||||
color: #777;
|
color: #777;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*.resultMessage {*/
|
/*.resultMessage {*/
|
||||||
/*white-space: pre;*/
|
/*white-space: pre;*/
|
||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
.resultMessage span.result {
|
.resultMessage span.result {
|
||||||
display: block;
|
display: block;
|
||||||
line-height: 2em;
|
line-height: 2em;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.resultMessage .mismatch {
|
.resultMessage .mismatch {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stackTrace {
|
.stackTrace {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
max-height: 5em;
|
max-height: 5em;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border: 1px inset red;
|
border: 1px inset red;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
background: #eef;
|
background: #eef;
|
||||||
}
|
}
|
||||||
|
|
||||||
.finished-at {
|
.finished-at {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
font-size: .6em;
|
font-size: .6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.show-passed .passed,
|
.show-passed .passed,
|
||||||
.show-skipped .skipped {
|
.show-skipped .skipped {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#jasmine_content {
|
#jasmine_content {
|
||||||
position:fixed;
|
position:fixed;
|
||||||
right: 100%;
|
right: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.runner {
|
.runner {
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
display: block;
|
display: block;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
padding: 2px 0 2px 10px;
|
padding: 2px 0 2px 10px;
|
||||||
}
|
}
|
|
@ -1,53 +1,53 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if (!jasmine) {
|
if (!jasmine) {
|
||||||
throw new Exception("jasmine library does not exist in global namespace!");
|
throw new Exception("jasmine library does not exist in global namespace!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks up into the JUnit TestRunner system to allow Jasmine tests to run in Eclipse!
|
* Hooks up into the JUnit TestRunner system to allow Jasmine tests to run in Eclipse!
|
||||||
* Also sets a "done" flag on the spec itself since there is nothing like it in Jasmine
|
* Also sets a "done" flag on the spec itself since there is nothing like it in Jasmine
|
||||||
*/
|
*/
|
||||||
var DelegatorJUnitReporter = function() {
|
var DelegatorJUnitReporter = function() {
|
||||||
this.javaReporter = jasmine.DelegatorJUnitReporter.javaReporter;
|
this.javaReporter = jasmine.DelegatorJUnitReporter.javaReporter;
|
||||||
};
|
};
|
||||||
|
|
||||||
DelegatorJUnitReporter.prototype = {
|
DelegatorJUnitReporter.prototype = {
|
||||||
reportRunnerStarting: function(runner) {
|
reportRunnerStarting: function(runner) {
|
||||||
if(this.javaReporter) {
|
if(this.javaReporter) {
|
||||||
this.javaReporter.reportRunnerStarting(runner);
|
this.javaReporter.reportRunnerStarting(runner);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecStarting: function(spec) {
|
reportSpecStarting: function(spec) {
|
||||||
spec.done = false;
|
spec.done = false;
|
||||||
|
|
||||||
if(this.javaReporter) {
|
if(this.javaReporter) {
|
||||||
this.javaReporter.reportSpecStarting(spec);
|
this.javaReporter.reportSpecStarting(spec);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecResults: function(spec) {
|
reportSpecResults: function(spec) {
|
||||||
spec.done = true;
|
spec.done = true;
|
||||||
|
|
||||||
if(this.javaReporter) {
|
if(this.javaReporter) {
|
||||||
this.javaReporter.reportSpecResults(spec);
|
this.javaReporter.reportSpecResults(spec);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {
|
reportSuiteResults: function(suite) {
|
||||||
if(this.javaReporter) {
|
if(this.javaReporter) {
|
||||||
this.javaReporter.reportSuiteResults(suite);
|
this.javaReporter.reportSuiteResults(suite);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reportRunnerResults: function(runner) {
|
reportRunnerResults: function(runner) {
|
||||||
if(this.javaReporter) {
|
if(this.javaReporter) {
|
||||||
this.javaReporter.reportRunnerResults(runner);
|
this.javaReporter.reportRunnerResults(runner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// export public
|
// export public
|
||||||
jasmine.DelegatorJUnitReporter = DelegatorJUnitReporter;
|
jasmine.DelegatorJUnitReporter = DelegatorJUnitReporter;
|
||||||
})();
|
})();
|
4842
src/test/javascript/lib/jasmine-1.0.2/jasmine.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.js
Executable file → Normal file
4842
src/test/javascript/lib/jasmine-1.0.2/jasmine.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.js
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
408
src/test/javascript/lib/jasmine-1.0.2/jasmine.junit_reporter.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.junit_reporter.js
Executable file → Normal file
408
src/test/javascript/lib/jasmine-1.0.2/jasmine.junit_reporter.js → src/main/resources/js/lib/jasmine-1.0.2/jasmine.junit_reporter.js
Executable file → Normal file
|
@ -1,204 +1,204 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if (! jasmine) {
|
if (! jasmine) {
|
||||||
throw new Exception("jasmine library does not exist in global namespace!");
|
throw new Exception("jasmine library does not exist in global namespace!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function elapsed(startTime, endTime) {
|
function elapsed(startTime, endTime) {
|
||||||
return (endTime - startTime)/1000;
|
return (endTime - startTime)/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ISODateString(d) {
|
function ISODateString(d) {
|
||||||
function pad(n) { return n < 10 ? '0'+n : n; }
|
function pad(n) { return n < 10 ? '0'+n : n; }
|
||||||
|
|
||||||
return d.getFullYear() + '-'
|
return d.getFullYear() + '-'
|
||||||
+ pad(d.getMonth()+1) +'-'
|
+ pad(d.getMonth()+1) +'-'
|
||||||
+ pad(d.getDate()) + 'T'
|
+ pad(d.getDate()) + 'T'
|
||||||
+ pad(d.getHours()) + ':'
|
+ pad(d.getHours()) + ':'
|
||||||
+ pad(d.getMinutes()) + ':'
|
+ pad(d.getMinutes()) + ':'
|
||||||
+ pad(d.getSeconds());
|
+ pad(d.getSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
function trim(str) {
|
function trim(str) {
|
||||||
return str.replace(/^\s+/, "" ).replace(/\s+$/, "" );
|
return str.replace(/^\s+/, "" ).replace(/\s+$/, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeInvalidXmlChars(str) {
|
function escapeInvalidXmlChars(str) {
|
||||||
return str.replace(/\&/g, "&")
|
return str.replace(/\&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/\>/g, ">")
|
.replace(/\>/g, ">")
|
||||||
.replace(/\"/g, """)
|
.replace(/\"/g, """)
|
||||||
.replace(/\'/g, "'");
|
.replace(/\'/g, "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates JUnit XML for the given spec run.
|
* Generates JUnit XML for the given spec run.
|
||||||
* Allows the test results to be used in java based CI
|
* Allows the test results to be used in java based CI
|
||||||
* systems like CruiseControl and Hudson.
|
* systems like CruiseControl and Hudson.
|
||||||
*
|
*
|
||||||
* @param {string} savePath where to save the files
|
* @param {string} savePath where to save the files
|
||||||
* @param {boolean} consolidate whether to save nested describes within the
|
* @param {boolean} consolidate whether to save nested describes within the
|
||||||
* same file as their parent; default: true
|
* same file as their parent; default: true
|
||||||
* @param {boolean} useDotNotation whether to separate suite names with
|
* @param {boolean} useDotNotation whether to separate suite names with
|
||||||
* dots rather than spaces (ie "Class.init" not
|
* dots rather than spaces (ie "Class.init" not
|
||||||
* "Class init"); default: true
|
* "Class init"); default: true
|
||||||
*/
|
*/
|
||||||
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation) {
|
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation) {
|
||||||
this.savePath = savePath || '';
|
this.savePath = savePath || '';
|
||||||
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
|
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
|
||||||
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
|
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
JUnitXmlReporter.prototype = {
|
JUnitXmlReporter.prototype = {
|
||||||
reportRunnerStarting: function(runner) {
|
reportRunnerStarting: function(runner) {
|
||||||
this.log("Runner Started.");
|
this.log("Runner Started.");
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecStarting: function(spec) {
|
reportSpecStarting: function(spec) {
|
||||||
spec.startTime = new Date();
|
spec.startTime = new Date();
|
||||||
|
|
||||||
if (! spec.suite.startTime) {
|
if (! spec.suite.startTime) {
|
||||||
spec.suite.startTime = spec.startTime;
|
spec.suite.startTime = spec.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSpecResults: function(spec) {
|
reportSpecResults: function(spec) {
|
||||||
var results = spec.results();
|
var results = spec.results();
|
||||||
spec.didFail = !results.passed();
|
spec.didFail = !results.passed();
|
||||||
spec.status = spec.didFail ? 'Failed.' : 'Passed.';
|
spec.status = spec.didFail ? 'Failed.' : 'Passed.';
|
||||||
if (results.skipped) {
|
if (results.skipped) {
|
||||||
spec.status = 'Skipped.';
|
spec.status = 'Skipped.';
|
||||||
}
|
}
|
||||||
this.log(spec.status);
|
this.log(spec.status);
|
||||||
|
|
||||||
spec.duration = elapsed(spec.startTime, new Date());
|
spec.duration = elapsed(spec.startTime, new Date());
|
||||||
spec.output = '<testcase classname="' + this.getFullName(spec.suite) +
|
spec.output = '<testcase classname="' + this.getFullName(spec.suite) +
|
||||||
'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
|
'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
|
||||||
|
|
||||||
var failure = "";
|
var failure = "";
|
||||||
var failures = 0;
|
var failures = 0;
|
||||||
var resultItems = results.getItems();
|
var resultItems = results.getItems();
|
||||||
for (var i = 0; i < resultItems.length; i++) {
|
for (var i = 0; i < resultItems.length; i++) {
|
||||||
var result = resultItems[i];
|
var result = resultItems[i];
|
||||||
|
|
||||||
if (result.type == 'expect' && result.passed && !result.passed()) {
|
if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||||
failures += 1;
|
failures += 1;
|
||||||
failure += (failures + ": " + escapeInvalidXmlChars(result.trace ? result.trace.getStackTrace() : result.message) + " ");
|
failure += (failures + ": " + escapeInvalidXmlChars(result.trace ? result.trace.getStackTrace() : result.message) + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failure) {
|
if (failure) {
|
||||||
spec.output += "<failure>" + trim(failure) + "</failure>";
|
spec.output += "<failure>" + trim(failure) + "</failure>";
|
||||||
}
|
}
|
||||||
spec.output += "</testcase>";
|
spec.output += "</testcase>";
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {
|
reportSuiteResults: function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
var specs = suite.specs();
|
var specs = suite.specs();
|
||||||
var specOutput = "";
|
var specOutput = "";
|
||||||
// for JUnit results, let's only include directly failed tests (not nested suites')
|
// for JUnit results, let's only include directly failed tests (not nested suites')
|
||||||
var failedCount = 0;
|
var failedCount = 0;
|
||||||
|
|
||||||
suite.status = results.passed() ? 'Passed.' : 'Failed.';
|
suite.status = results.passed() ? 'Passed.' : 'Failed.';
|
||||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||||
suite.status = 'Skipped.';
|
suite.status = 'Skipped.';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a suite has no (active?) specs, reportSpecStarting is never called
|
// if a suite has no (active?) specs, reportSpecStarting is never called
|
||||||
// and thus the suite has no startTime -- account for that here
|
// and thus the suite has no startTime -- account for that here
|
||||||
suite.startTime = suite.startTime || new Date();
|
suite.startTime = suite.startTime || new Date();
|
||||||
suite.duration = elapsed(suite.startTime, new Date());
|
suite.duration = elapsed(suite.startTime, new Date());
|
||||||
|
|
||||||
for (var i = 0; i < specs.length; i++) {
|
for (var i = 0; i < specs.length; i++) {
|
||||||
failedCount += specs[i].didFail ? 1 : 0;
|
failedCount += specs[i].didFail ? 1 : 0;
|
||||||
specOutput += "\n " + specs[i].output;
|
specOutput += "\n " + specs[i].output;
|
||||||
}
|
}
|
||||||
suite.output = '\n<testsuite name="' + this.getFullName(suite) +
|
suite.output = '\n<testsuite name="' + this.getFullName(suite) +
|
||||||
'" errors="0" tests="' + specs.length + '" failures="' + failedCount +
|
'" errors="0" tests="' + specs.length + '" failures="' + failedCount +
|
||||||
'" time="' + suite.duration + '" timestamp="' + ISODateString(suite.startTime) + '">';
|
'" time="' + suite.duration + '" timestamp="' + ISODateString(suite.startTime) + '">';
|
||||||
suite.output += specOutput;
|
suite.output += specOutput;
|
||||||
suite.output += "\n</testsuite>";
|
suite.output += "\n</testsuite>";
|
||||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " expectations passed.");
|
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " expectations passed.");
|
||||||
},
|
},
|
||||||
|
|
||||||
reportRunnerResults: function(runner) {
|
reportRunnerResults: function(runner) {
|
||||||
this.log("Runner Finished.");
|
this.log("Runner Finished.");
|
||||||
var suites = runner.suites();
|
var suites = runner.suites();
|
||||||
for (var i = 0; i < suites.length; i++) {
|
for (var i = 0; i < suites.length; i++) {
|
||||||
var suite = suites[i];
|
var suite = suites[i];
|
||||||
var fileName = 'TEST-' + this.getFullName(suite, true) + '.xml';
|
var fileName = 'TEST-' + this.getFullName(suite, true) + '.xml';
|
||||||
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||||
// if we are consolidating, only write out top-level suites
|
// if we are consolidating, only write out top-level suites
|
||||||
if (this.consolidate && suite.parentSuite) {
|
if (this.consolidate && suite.parentSuite) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (this.consolidate) {
|
else if (this.consolidate) {
|
||||||
output += "\n<testsuites>";
|
output += "\n<testsuites>";
|
||||||
output += this.getNestedOutput(suite);
|
output += this.getNestedOutput(suite);
|
||||||
output += "\n</testsuites>";
|
output += "\n</testsuites>";
|
||||||
this.writeFile(this.savePath + fileName, output);
|
this.writeFile(this.savePath + fileName, output);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output += suite.output;
|
output += suite.output;
|
||||||
this.writeFile(this.savePath + fileName, output);
|
this.writeFile(this.savePath + fileName, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getNestedOutput: function(suite) {
|
getNestedOutput: function(suite) {
|
||||||
var output = suite.output;
|
var output = suite.output;
|
||||||
for (var i = 0; i < suite.suites().length; i++) {
|
for (var i = 0; i < suite.suites().length; i++) {
|
||||||
output += this.getNestedOutput(suite.suites()[i]);
|
output += this.getNestedOutput(suite.suites()[i]);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
writeFile: function(filename, text) {
|
writeFile: function(filename, text) {
|
||||||
// Rhino
|
// Rhino
|
||||||
try {
|
try {
|
||||||
var out = new java.io.BufferedWriter(new java.io.FileWriter(filename));
|
var out = new java.io.BufferedWriter(new java.io.FileWriter(filename));
|
||||||
out.write(text);
|
out.write(text);
|
||||||
out.close();
|
out.close();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
// PhantomJS, via pyphantomjs and the saveToFile plugin
|
// PhantomJS, via pyphantomjs and the saveToFile plugin
|
||||||
// http://dev.umaclan.com/projects/pyphantomjs/wiki/Plugins#Save-to-File
|
// http://dev.umaclan.com/projects/pyphantomjs/wiki/Plugins#Save-to-File
|
||||||
try {
|
try {
|
||||||
phantom.saveToFile(text, filename);
|
phantom.saveToFile(text, filename);
|
||||||
} catch (f) {
|
} catch (f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getFullName: function(suite, isFilename) {
|
getFullName: function(suite, isFilename) {
|
||||||
var fullName;
|
var fullName;
|
||||||
if (this.useDotNotation) {
|
if (this.useDotNotation) {
|
||||||
fullName = suite.description;
|
fullName = suite.description;
|
||||||
for (var parentSuite = suite.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = suite.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
fullName = parentSuite.description + '.' + fullName;
|
fullName = parentSuite.description + '.' + fullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fullName = suite.getFullName();
|
fullName = suite.getFullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either remove or escape invalid XML characters
|
// Either remove or escape invalid XML characters
|
||||||
if (isFilename) {
|
if (isFilename) {
|
||||||
return fullName.replace(/[^\w]/g, "");
|
return fullName.replace(/[^\w]/g, "");
|
||||||
}
|
}
|
||||||
return escapeInvalidXmlChars(fullName);
|
return escapeInvalidXmlChars(fullName);
|
||||||
},
|
},
|
||||||
|
|
||||||
log: function(str) {
|
log: function(str) {
|
||||||
var console = jasmine.getGlobal().console;
|
var console = jasmine.getGlobal().console;
|
||||||
|
|
||||||
if (console && console.log) {
|
if (console && console.log) {
|
||||||
console.log(str);
|
console.log(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// export public
|
// export public
|
||||||
jasmine.JUnitXmlReporter = JUnitXmlReporter;
|
jasmine.JUnitXmlReporter = JUnitXmlReporter;
|
||||||
})();
|
})();
|
46
src/test/javascript/lib/specRunner.tpl → src/main/resources/js/lib/specRunner.tpl
Executable file → Normal file
46
src/test/javascript/lib/specRunner.tpl → src/main/resources/js/lib/specRunner.tpl
Executable file → Normal file
|
@ -1,23 +1,23 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<title>Jasmine Test Runner</title>
|
||||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||||
|
|
||||||
<!-- dit zijn de productie source js files: -->
|
<!-- dit zijn de productie source js files: -->
|
||||||
<!--SourceFileIncludes-->
|
<!--SourceFileIncludes-->
|
||||||
|
|
||||||
<!-- dit zijn de jasmine spec js files: -->
|
<!-- dit zijn de jasmine spec js files: -->
|
||||||
<!--SpecFileIncludes-->
|
<!--SpecFileIncludes-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||||
jasmine.getEnv().execute();
|
jasmine.getEnv().execute();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -13,7 +13,7 @@ public class EnvUtilsTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void loadJasmineJQueryMatchers(RhinoContext context) {
|
public void loadJasmineJQueryMatchers(RhinoContext context) {
|
||||||
context.load("src/test/javascript/lib/jasmine-1.0.2/jasmine-jquery-rhino.js");
|
context.loadFromClasspath("js/lib/jasmine-1.0.2/jasmine-jquery-rhino.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
0
src/test/java/be/klak/junit/jasmine/DescriptionsRecursiveTreeInRunnerTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/DescriptionsRecursiveTreeInRunnerTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/DescriptionsWithMultipleSpecFilesTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/DescriptionsWithMultipleSpecFilesTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/JasmineSuiteGeneratesRunnerTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/JasmineSuiteGeneratesRunnerTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/JasmineTestRunnerBeforeAndAfterTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/JasmineTestRunnerBeforeAndAfterTest.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineSuiteGeneratorClassWithRunner.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineSuiteGeneratorClassWithRunner.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineSuiteGeneratorClassWithoutRunner.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineSuiteGeneratorClassWithoutRunner.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerBeforeAndAfterClass.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerBeforeAndAfterClass.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerBeforeAndAfterSuperClass.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerBeforeAndAfterSuperClass.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerExceptionInJSCode.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerExceptionInJSCode.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerExceptionInSpec.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerExceptionInSpec.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerFailingSpec.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerFailingSpec.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerSuccessSpec.java
Executable file → Normal file
0
src/test/java/be/klak/junit/jasmine/classes/JasmineTestRunnerSuccessSpec.java
Executable file → Normal file
|
@ -80,4 +80,14 @@ public class RhinoContextTest {
|
||||||
assertThat(context.evalJS("loaded")).isEqualTo(true);
|
assertThat(context.evalJS("loaded")).isEqualTo(true);
|
||||||
assertThat(context.evalJS("loadedTwo")).isEqualTo(true);
|
assertThat(context.evalJS("loadedTwo")).isEqualTo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{{ loadsJSFilesFromClasspath
|
||||||
|
@Test
|
||||||
|
public void loadsJSFilesFromClasspath() {
|
||||||
|
RhinoContext context = new RhinoContext();
|
||||||
|
context.loadFromClasspath("js/lib/loadsJSFilesFromClasspathTarget.js");
|
||||||
|
|
||||||
|
assertThat(context.evalJS("target.theAnswer")).isEqualTo("forty two");
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
(function(){var j=Object.prototype.hasOwnProperty;if(!Array.isArray)Array.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"};if(!Array.prototype.forEach)Array.prototype.forEach=function(a,c){for(var b=this.length>>>0,d=0;d<b;d++)d in this&&a.call(c,this[d],d,this)};if(!Array.prototype.map)Array.prototype.map=function(a,c){var b=this.length>>>0;if(typeof a!="function")throw new TypeError;for(var d=Array(b),e=0;e<b;e++)if(e in this)d[e]=a.call(c,this[e],e,this);return d};
|
|
||||||
if(!Array.prototype.filter)Array.prototype.filter=function(a,c){for(var b=[],d=0;d<this.length;d++)a.call(c,this[d])&&b.push(this[d]);return b};if(!Array.prototype.every)Array.prototype.every=function(a,c){for(var b=0;b<this.length;b++)if(!a.call(c,this[b]))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(a,c){for(var b=0;b<this.length;b++)if(a.call(c,this[b]))return true;return false};if(!Array.prototype.reduce)Array.prototype.reduce=function(a){var c=this.length>>>
|
|
||||||
0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var b=0;if(arguments.length>=2)var d=arguments[1];else{do{if(b in this){d=this[b++];break}if(++b>=c)throw new TypeError;}while(1)}for(;b<c;b++)if(b in this)d=a.call(null,d,this[b],b,this);return d};if(!Array.prototype.reduceRight)Array.prototype.reduceRight=function(a){var c=this.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;c=c-1;if(arguments.length>=
|
|
||||||
2)var b=arguments[1];else{do{if(c in this){b=this[c--];break}if(--c<0)throw new TypeError;}while(1)}for(;c>=0;c--)if(c in this)b=a.call(null,b,this[c],c,this);return b};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a,c){var b=this.length;if(!b)return-1;var d=c||0;if(d>=b)return-1;if(d<0)d+=b;for(;d<b;d++)if(j.call(this,d))if(a===this[d])return d;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=function(a,c){var b=this.length;if(!b)return-1;var d=c||b;if(d<0)d+=
|
|
||||||
b;for(d=Math.min(d,b-1);d>=0;d--)if(j.call(this,d))if(a===this[d])return d;return-1};if(!Object.getPrototypeOf)Object.getPrototypeOf=function(a){return a.__proto__||a.constructor.prototype};if(!Object.getOwnPropertyDescriptor)Object.getOwnPropertyDescriptor=function(){return{}};if(!Object.getOwnPropertyNames)Object.getOwnPropertyNames=function(a){return Object.keys(a)};if(!Object.create)Object.create=function(a,c){var b;if(a===null)b={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+
|
|
||||||
typeof a+"] != 'object'");b=function(){};b.prototype=a;b=new b}typeof c!=="undefined"&&Object.defineProperties(b,c);return b};if(!Object.defineProperty)Object.defineProperty=function(a,c,b){if(typeof b=="object"&&a.__defineGetter__){if(j.call(b,"value")){if(!a.__lookupGetter__(c)&&!a.__lookupSetter__(c))a[c]=b.value;if(j.call(b,"get")||j.call(b,"set"))throw new TypeError("Object doesn't support this action");}else typeof b.get=="function"&&a.__defineGetter__(c,b.get);typeof b.set=="function"&&a.__defineSetter__(c,
|
|
||||||
b.set)}return a};if(!Object.defineProperties)Object.defineProperties=function(a,c){for(var b in c)j.call(c,b)&&Object.defineProperty(a,b,c[b]);return a};if(!Object.seal)Object.seal=function(a){return a};if(!Object.freeze)Object.freeze=function(a){return a};try{Object.freeze(function(){})}catch(u){Object.freeze=function(a){return function(c){return typeof c=="function"?c:a(c)}}(Object.freeze)}if(!Object.preventExtensions)Object.preventExtensions=function(a){return a};if(!Object.isSealed)Object.isSealed=
|
|
||||||
function(){return false};if(!Object.isFrozen)Object.isFrozen=function(){return false};if(!Object.isExtensible)Object.isExtensible=function(){return true};if(!Object.keys){var m=true,n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=n.length,q;for(q in{toString:null})m=false;Object.keys=function(a){if(typeof a!=="object"&&typeof a!=="function"||a===null)throw new TypeError("Object.keys called on a non-object");var c=[],b;for(b in a)j.call(a,
|
|
||||||
b)&&c.push(b);if(m)for(b=0;b<p;b++){var d=n[b];j.call(a,d)&&c.push(d)}return c}}if(!Date.prototype.toISOString)Date.prototype.toISOString=function(){return this.getFullYear()+"-"+(this.getMonth()+1)+"-"+this.getDate()+"T"+this.getHours()+":"+this.getMinutes()+":"+this.getSeconds()+"Z"};if(!Date.now)Date.now=function(){return(new Date).getTime()};if(!Date.prototype.toJSON)Date.prototype.toJSON=function(){if(typeof this.toISOString!="function")throw new TypeError;return this.toISOString()};if(isNaN(Date.parse("T00:00")))Date=
|
|
||||||
function(a){var c=function(e,f,h,g,k,o,r){var i=arguments.length;if(this instanceof a){i=i===1&&String(e)===e?new a(c.parse(e)):i>=7?new a(e,f,h,g,k,o,r):i>=6?new a(e,f,h,g,k,o):i>=5?new a(e,f,h,g,k):i>=4?new a(e,f,h,g):i>=3?new a(e,f,h):i>=2?new a(e,f):i>=1?new a(e):new a;i.constructor=c;return i}return a.apply(this,arguments)},b=RegExp("^(?:((?:[+-]\\d\\d)?\\d\\d\\d\\d)(?:-(\\d\\d)(?:-(\\d\\d))?)?)?(?:T(\\d\\d):(\\d\\d)(?::(\\d\\d)(?:\\.(\\d\\d\\d))?)?)?(?:Z|([+-])(\\d\\d):(\\d\\d))?$"),d;for(d in a)c[d]=
|
|
||||||
a[d];c.now=a.now;c.UTC=a.UTC;c.prototype=a.prototype;c.prototype.constructor=c;c.parse=function(e){var f=b.exec(e);if(f){f.shift();for(var h=f[0]===undefined,g=0;g<10;g++)if(g!==7){f[g]=+(f[g]||(g<3?1:0));g===1&&f[g]--}if(h)return((f[3]*60+f[4])*60+f[5])*1E3+f[6];h=(f[8]*60+f[9])*60*1E3;if(f[6]==="-")h=-h;return a.UTC.apply(this,f.slice(0,7))+h}return a.parse.apply(this,arguments)};return c}(Date);var l=Array.prototype.slice;if(!Function.prototype.bind)Function.prototype.bind=function(a){var c=this;
|
|
||||||
if(typeof c.apply!="function"||typeof c.call!="function")return new TypeError;var b=l.call(arguments),d=function(){if(this instanceof d){var e=Object.create(c.prototype);c.apply(e,b.concat(l.call(arguments)));return e}else return c.call.apply(c,b.concat(l.call(arguments)))};d.bound=c;d.boundTo=a;d.boundArgs=b;d.length=typeof c=="function"?Math.max(c.length-b.length,0):0;return d};if(!String.prototype.trim){var s=/^\s\s*/,t=/\s\s*$/;String.prototype.trim=function(){return String(this).replace(s,"").replace(t,
|
|
||||||
"")}}})();
|
|
|
@ -1,27 +1,27 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<title>Jasmine Test Runner</title>
|
||||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||||
|
|
||||||
<!-- dit zijn de productie source js files: -->
|
<!-- dit zijn de productie source js files: -->
|
||||||
<script type='text/javascript' src='./../../../main/webapp/js/source1.js'></script>
|
<script type='text/javascript' src='./../../../main/webapp/js/source1.js'></script>
|
||||||
<script type='text/javascript' src='./../../../main/webapp/js/source2.js'></script>
|
<script type='text/javascript' src='./../../../main/webapp/js/source2.js'></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- dit zijn de jasmine spec js files: -->
|
<!-- dit zijn de jasmine spec js files: -->
|
||||||
<script type='text/javascript' src='./../specs/spec1.js'></script>
|
<script type='text/javascript' src='./../specs/spec1.js'></script>
|
||||||
<script type='text/javascript' src='./../specs/spec2.js'></script>
|
<script type='text/javascript' src='./../specs/spec2.js'></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||||
jasmine.getEnv().execute();
|
jasmine.getEnv().execute();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
// loadsJSFilesFromClasspathTarget.js
|
||||||
|
var target = {
|
||||||
|
theAnswer: "forty two"
|
||||||
|
};
|
Reference in New Issue