Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2014-01-28 15:50:36 -0500
committerFlorian Waibel2014-01-28 15:51:54 -0500
commitdc2904a19ff0e39accadd55c4b0ab9092bcc330f (patch)
tree7c6c439c34c497bb25d16c7961497a50f918fdc3 /org.eclipse.virgo.management.console
parent30460ed1a2a01ea944cdfa0401d32b4e888257cb (diff)
downloadorg.eclipse.virgo.kernel-dc2904a19ff0e39accadd55c4b0ab9092bcc330f.tar.gz
org.eclipse.virgo.kernel-dc2904a19ff0e39accadd55c4b0ab9092bcc330f.tar.xz
org.eclipse.virgo.kernel-dc2904a19ff0e39accadd55c4b0ab9092bcc330f.zip
390017 - Increases robustness of JSTests
Diffstat (limited to 'org.eclipse.virgo.management.console')
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js4
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/AbstractJSTests.java22
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java9
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ConfigurationsJSTests.java5
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/DumpsJSTests.java10
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/RepositoriesJSTests.java8
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/WiringsJSTests.java10
7 files changed, 39 insertions, 29 deletions
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js b/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
index 58e504fc..9ac9c523 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
@@ -10,13 +10,13 @@
*******************************************************************************/
-var uploadManager = new UploadManager();
/**
* Script to be loaded in to the head of the artifacts view
*/
function pageinit(){
+ uploadManager = new UploadManager();
$('#upload-target-id').load(uploadManager.deployComplete);
$('#add-upload-box').click(uploadManager.addUploadBox);
$('#minus-upload-box').click(uploadManager.minusUploadBox);
@@ -426,7 +426,7 @@ var FullArtifact = function(metaData, objectName) {
};
-function UploadManager() {
+var UploadManager = function() {
var self = this;
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/AbstractJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/AbstractJSTests.java
index 750bfba5..58c9259e 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/AbstractJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/AbstractJSTests.java
@@ -23,9 +23,8 @@ import org.eclipse.virgo.management.console.stubs.objects.Util;
import org.eclipse.virgo.management.console.stubs.objects.Window;
import org.eclipse.virgo.management.console.stubs.types.Element;
import org.eclipse.virgo.management.console.stubs.types.Server;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
+import org.junit.After;
+import org.junit.Before;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.FunctionObject;
@@ -38,16 +37,16 @@ import org.mozilla.javascript.ScriptableObject;
*/
public abstract class AbstractJSTests {
- protected static Context context;
+ protected Context context;
- protected static ScriptableObject scope;
+ protected ScriptableObject scope;
protected static String alertMsg;
- protected static Util commonUtil = null;
+ protected Util commonUtil = null;
- @BeforeClass
- public static void setUp() throws ScriptException, IOException, IllegalAccessException, InstantiationException, InvocationTargetException, SecurityException, NoSuchMethodException{
+ @Before
+ public void setUp() throws ScriptException, IOException, IllegalAccessException, InstantiationException, InvocationTargetException, SecurityException, NoSuchMethodException{
context = Context.enter();
scope = context.initStandardObjects();
@@ -66,12 +65,13 @@ public abstract class AbstractJSTests {
FunctionObject alertFunction = new FunctionObject("alert", AbstractJSTests.class.getDeclaredMethod("alert", String.class), scope);
ScriptableObject.putProperty(scope, alertFunction.getFunctionName(), alertFunction);
}
-
- @AfterClass
- public static void closeDown(){
+
+ @After
+ public void closeDown(){
Context.exit();
}
+ // callback from JS function doesn't work with non static field
public static void alert(String msg){
System.out.println(msg);
alertMsg = msg;
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
index 2ec7942d..166736b6 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
@@ -21,6 +21,7 @@ import javax.script.ScriptException;
import org.eclipse.virgo.management.console.stubs.objects.Dollar;
import org.eclipse.virgo.management.console.stubs.types.Element;
+import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
@@ -34,8 +35,8 @@ import org.mozilla.javascript.ScriptableObject;
*/
public class ArtifactsJSTests extends AbstractJSTests {
- @Test
- public void testPageinit() throws ScriptException, IOException, NoSuchMethodException {
+ @Before
+ public void setUpArtifactsJS() throws ScriptException, IOException, NoSuchMethodException {
addCommonObjects();
readFile("src/main/webapp/js/artifacts.js");
@@ -80,19 +81,15 @@ public class ArtifactsJSTests extends AbstractJSTests {
@Test
public void testTreeTopLevelTwisty() throws IOException {
- commonUtil.clean();
ScriptableObject tree = (ScriptableObject) scope.get("tree", scope);
ScriptableObject.callMethod(tree, "nodeTwistyClicked", new Object[] { getTestTopLevelEventData() });
- assertEquals("<li />", Dollar.getDollarLookup());
assertEquals("search/org.eclipse.virgo.kernel:type=ArtifactModel,*", commonUtil.getLastQuery());
}
@Test
public void testTreeTwisty() throws IOException {
- commonUtil.clean();
ScriptableObject tree = (ScriptableObject) scope.get("tree", scope);
ScriptableObject.callMethod(tree, "nodeTwistyClicked", new Object[] { getTestOtherLevelEventData() });
- assertEquals("<li />", Dollar.getDollarLookup());
assertEquals("read/objectName", commonUtil.getLastQuery());
}
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ConfigurationsJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ConfigurationsJSTests.java
index efeee6a7..d28715eb 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ConfigurationsJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ConfigurationsJSTests.java
@@ -21,6 +21,7 @@ import javax.script.ScriptException;
import org.eclipse.virgo.management.console.stubs.objects.ObjectName;
import org.eclipse.virgo.management.console.stubs.types.Element;
+import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
@@ -40,8 +41,8 @@ public class ConfigurationsJSTests extends AbstractJSTests {
* @throws IOException
* @throws NoSuchMethodException
*/
- @Test
- public void testPageinit() throws ScriptException, IOException, NoSuchMethodException{
+ @Before
+ public void setUpConfigurationsJS() throws ScriptException, IOException, NoSuchMethodException{
addCommonObjects();
readFile("src/main/webapp/js/configurations.js");
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/DumpsJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/DumpsJSTests.java
index ac3f595d..82090419 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/DumpsJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/DumpsJSTests.java
@@ -21,6 +21,7 @@ import javax.script.ScriptException;
import org.eclipse.virgo.management.console.stubs.objects.Dollar;
import org.eclipse.virgo.management.console.stubs.types.Element;
+import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
@@ -37,8 +38,8 @@ public class DumpsJSTests extends AbstractJSTests {
private static final String DUMPS_URL = "hostPrefix/jolokia/read/org.eclipse.virgo.kernel:type=Medic,name=DumpInspector/Dumps";
- @Test
- public void testPageinit() throws ScriptException, IOException, NoSuchMethodException {
+ @Before
+ public void setUpDumpsJS() throws ScriptException, IOException, NoSuchMethodException {
// Common setup that will be used by other test methods.
readFile("src/main/webapp/js/dumps.js");
@@ -46,7 +47,10 @@ public class DumpsJSTests extends AbstractJSTests {
addCommonObjects();
invokePageInit();
-
+ }
+
+ @Test
+ public void testPageInit() throws IOException {
Map<String, Function> successByUrl = Dollar.getAndClearAjaxSuccessByUrl();
assertTrue(successByUrl.containsKey(DUMPDIR_URL));
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/RepositoriesJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/RepositoriesJSTests.java
index 3fbbd44d..6514e806 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/RepositoriesJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/RepositoriesJSTests.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import javax.script.ScriptException;
import org.eclipse.virgo.management.console.stubs.objects.Dollar;
+import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
@@ -33,8 +34,8 @@ import org.mozilla.javascript.ScriptableObject;
*/
public class RepositoriesJSTests extends AbstractJSTests {
- @Test
- public void testPageinit() throws ScriptException, IOException, NoSuchMethodException {
+ @Before
+ public void setUpRepositoriesJS() throws ScriptException, IOException, NoSuchMethodException {
// Common setup that will be used by other test methods.
readFile("src/main/webapp/js/repositories.js");
@@ -42,7 +43,10 @@ public class RepositoriesJSTests extends AbstractJSTests {
addCommonObjects();
invokePageInit();
+ }
+ @Test
+ public void testPageInit() throws IOException {
assertNotNull(Dollar.getAjaxSuccess());
Dollar.getAjaxSuccess().call(context, scope, scope, new Object[] { getTestData() });
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/WiringsJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/WiringsJSTests.java
index d9fb613f..383f9657 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/WiringsJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/WiringsJSTests.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import javax.script.ScriptException;
+import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
@@ -30,15 +31,18 @@ import org.mozilla.javascript.Scriptable;
*/
public class WiringsJSTests extends AbstractJSTests {
- @Test
- public void testPageinit() throws ScriptException, IOException, NoSuchMethodException{
+ @Before
+ public void setUpWirings() throws ScriptException, IOException, NoSuchMethodException{
addCommonObjects();
readFile("src/main/webapp/js/wirings.js");
createTestLayoutManager();
createRaphael();
invokePageInit();
-
+ }
+
+ @Test
+ public void testPageInit() throws IOException {
assertEquals("bundlesGui", commonUtil.getLastScriptLoaded());
assertNotNull(commonUtil.getLoadScriptAsync());
commonUtil.getLoadScriptAsync().call(context, scope, scope, new Object[]{});

Back to the top