Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-05-24 09:33:04 -0400
committerFlorian Waibel2015-05-24 09:33:04 -0400
commit0cd4a03c06f08c4f696603891504847131ca2ee9 (patch)
tree7d07da76a9534651811354e79d04906726426f42
parent091427045553a8e81510a61d156b938fa6fcc5c6 (diff)
downloadorg.eclipse.virgo.kernel-0cd4a03c06f08c4f696603891504847131ca2ee9.tar.gz
org.eclipse.virgo.kernel-0cd4a03c06f08c4f696603891504847131ca2ee9.tar.xz
org.eclipse.virgo.kernel-0cd4a03c06f08c4f696603891504847131ca2ee9.zip
Code cleanup in test classes
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/objects/Util.java204
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java24
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Server.java43
3 files changed, 133 insertions, 138 deletions
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/objects/Util.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/objects/Util.java
index 5ff9818c..c60b5697 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/objects/Util.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/objects/Util.java
@@ -8,6 +8,7 @@
* Contributors:
* VMware Inc. - initial contribution
*******************************************************************************/
+
package org.eclipse.virgo.management.console.stubs.objects;
import org.mozilla.javascript.Context;
@@ -22,10 +23,10 @@ import org.mozilla.javascript.ScriptableObject;
public class Util {
private final Context CONTEXT;
-
- private final ScriptableObject SCOPE;
-
- private boolean pageReady = false;
+
+ private final ScriptableObject SCOPE;
+
+ private boolean pageReady = false;
private String[] lastMakeTableRows = null;
@@ -37,116 +38,113 @@ public class Util {
private Function lastQueryCallBack = null;
- private Function lastQueryErrorCallBack = null;
-
private Scriptable lastBulkQuery = null;
private Function lastBulkQueryCallBack = null;
private Function lastBulkQueryErrorCallBack = null;
- private Function async;
-
- private String lastScriptLoaded;
-
- public static int fxTime = 200;
-
- public Util(Context context, ScriptableObject SCOPE) {
- this.CONTEXT = context;
- this.SCOPE = SCOPE;
- }
-
- // Stub methods
-
- public void pageReady(){
- this.pageReady = true;
- }
-
- public Object getHost(){
- return Context.javaToJS("hostPrefix", SCOPE);
- }
-
- public Object getHostAndAdminPath(){
- return Context.javaToJS("hostPrefix", SCOPE);
- }
-
- public Object readObjectName(String mbeanName){
- return new MBean(mbeanName);
- }
-
- public void loadScript(Object scriptName, Object async){
- this.lastScriptLoaded = (String) scriptName;
- this.async = (Function) async;
- }
-
- public Object makeTable(Scriptable properties) {
- Object[] headers = (Object[]) Context.jsToJava(ScriptableObject.getProperty(properties, "headers"), Object[].class);
- this.lastMakeTableHeaders = new String[headers.length];
- for (int i = 0; i < headers.length; i++) {
- this.lastMakeTableHeaders[i] = (String) Context.jsToJava(ScriptableObject.getProperty((Scriptable) headers[i], "title"), String.class);
- }
-
- this.lastMakeTableRows = (String[]) Context.jsToJava(ScriptableObject.getProperty(properties, "rows"), String[].class);
-
- Function elementConstructor = (Function) SCOPE.get("Element", SCOPE);
- Object[] args = new Object[]{properties};
+ private Function async;
+
+ private String lastScriptLoaded;
+
+ public static int fxTime = 200;
+
+ public Util(Context context, ScriptableObject SCOPE) {
+ this.CONTEXT = context;
+ this.SCOPE = SCOPE;
+ }
+
+ // Stub methods
+
+ public void pageReady() {
+ this.pageReady = true;
+ }
+
+ public Object getHost() {
+ return Context.javaToJS("hostPrefix", SCOPE);
+ }
+
+ public Object getHostAndAdminPath() {
+ return Context.javaToJS("hostPrefix", SCOPE);
+ }
+
+ public Object readObjectName(String mbeanName) {
+ return new MBean(mbeanName);
+ }
+
+ public void loadScript(Object scriptName, Object async) {
+ this.lastScriptLoaded = (String) scriptName;
+ this.async = (Function) async;
+ }
+
+ public Object makeTable(Scriptable properties) {
+ Object[] headers = (Object[]) Context.jsToJava(ScriptableObject.getProperty(properties, "headers"), Object[].class);
+ this.lastMakeTableHeaders = new String[headers.length];
+ for (int i = 0; i < headers.length; i++) {
+ this.lastMakeTableHeaders[i] = (String) Context.jsToJava(ScriptableObject.getProperty((Scriptable) headers[i], "title"), String.class);
+ }
+
+ this.lastMakeTableRows = (String[]) Context.jsToJava(ScriptableObject.getProperty(properties, "rows"), String[].class);
+
+ Function elementConstructor = (Function) SCOPE.get("Element", SCOPE);
+ Object[] args = new Object[] { properties };
Scriptable table = elementConstructor.construct(Context.getCurrentContext(), SCOPE, args);
this.lastMakeTableTable = table;
return table;
- }
-
- public Object makeDiv(String clazz) {
- Function elementConstructor = (Function) SCOPE.get("Element", SCOPE);
- Object[] args = new Object[]{clazz};
+ }
+
+ public Object makeDiv(String clazz) {
+ Function elementConstructor = (Function) SCOPE.get("Element", SCOPE);
+ Object[] args = new Object[] { clazz };
return elementConstructor.construct(this.CONTEXT, SCOPE, args);
- }
-
- public void doQuery(String query, Function callBack) {
- this.lastQuery = query;
- this.lastQueryCallBack = callBack;
- // this.lastQueryErrorCallBack = errorCallBack;
- }
-
- public void doBulkQuery(Scriptable query, Function callBack, Function errorCallBack) {
- this.lastBulkQuery = query;
- this.lastBulkQueryCallBack = callBack;
- this.lastBulkQueryErrorCallBack = errorCallBack;
- }
-
- // Test methods
-
- public void clean(){
- this.pageReady = false;
- this.lastMakeTableRows = null;
- this.lastMakeTableHeaders = null;
- this.lastMakeTableTable = null;
- this.lastQuery = null;
- this.lastQueryCallBack = null;
- this.lastQueryErrorCallBack = null;
- this.lastBulkQuery = null;
- this.lastBulkQueryCallBack = null;
- this.lastBulkQueryErrorCallBack = null;
- }
-
- public boolean isPageReady(){
- return pageReady;
- }
+ }
+
+ public void doQuery(String query, Function callBack) {
+ this.lastQuery = query;
+ this.lastQueryCallBack = callBack;
+ // this.lastQueryErrorCallBack = errorCallBack;
+ }
+
+ public void doBulkQuery(Scriptable query, Function callBack, Function errorCallBack) {
+ this.lastBulkQuery = query;
+ this.lastBulkQueryCallBack = callBack;
+ this.lastBulkQueryErrorCallBack = errorCallBack;
+ }
+
+ // Test methods
+
+ public void clean() {
+ this.pageReady = false;
+ this.lastMakeTableRows = null;
+ this.lastMakeTableHeaders = null;
+ this.lastMakeTableTable = null;
+ this.lastQuery = null;
+ this.lastQueryCallBack = null;
+ this.lastBulkQuery = null;
+ this.lastBulkQueryCallBack = null;
+ this.lastBulkQueryErrorCallBack = null;
+ }
+
+ public boolean isPageReady() {
+ return pageReady;
+ }
public Function getLoadScriptAsync() {
return this.async;
}
-
- public String[] getLastMakeTableHeaders() {
- return this.lastMakeTableHeaders;
- }
-
- public String[] getLastMakeTableRows() {
- return this.lastMakeTableRows;
- }
-
- public Scriptable getLastMakeTableTable() {
- return this.lastMakeTableTable;
- }
+
+ public String[] getLastMakeTableHeaders() {
+ return this.lastMakeTableHeaders;
+ }
+
+ public String[] getLastMakeTableRows() {
+ return this.lastMakeTableRows;
+ }
+
+ public Scriptable getLastMakeTableTable() {
+ return this.lastMakeTableTable;
+ }
public String getLastQuery() {
return lastQuery;
@@ -156,10 +154,6 @@ public class Util {
return lastQueryCallBack;
}
- public Function getLastQueryErrorCallBack() {
- return lastQueryErrorCallBack;
- }
-
public Scriptable getLastBulkQuery() {
return lastBulkQuery;
}
@@ -175,5 +169,5 @@ public class Util {
public String getLastScriptLoaded() {
return lastScriptLoaded;
}
-
+
}
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
index 8c4230ac..ff829335 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
@@ -32,11 +32,11 @@ public class Element extends ParentStub {
private static List<String> CONSTRUCTOR_ARGUMENT_TRACE = new ArrayList<String>();
- private static Element LAST_REPLACEMENT;
+ private Element lastReplacement;
- private static Element LAST_APPENDED;
+ private Element lastAppended;
- private static Function READY;
+ private Function ready;
private final String constructorArgument;
@@ -69,16 +69,16 @@ public class Element extends ParentStub {
}
public void jsFunction_ready(Function readyFunction){
- READY = readyFunction;
+ ready = readyFunction;
}
public ScriptableObject jsFunction_replaceWith(Element replacement){
- LAST_REPLACEMENT = replacement;
+ lastReplacement = replacement;
return this;
}
public ScriptableObject jsFunction_append(Element toAppend){
- LAST_APPENDED = toAppend;
+ lastAppended = toAppend;
return this;
}
@@ -139,8 +139,8 @@ public class Element extends ParentStub {
// Test helper methods
- public static Function getReadyFunction(){
- return READY;
+ public Function getReadyFunction(){
+ return ready;
}
public List<String> getClasses(){
@@ -151,12 +151,12 @@ public class Element extends ParentStub {
return CONSTRUCTOR_ARGUMENT_TRACE;
}
- public static Element getLastReplacement() {
- return LAST_REPLACEMENT;
+ public Element getLastReplacement() {
+ return lastReplacement;
}
- public static Element getLastAppended() {
- return LAST_APPENDED;
+ public Element getLastAppended() {
+ return lastAppended;
}
public String getConstructorArgument() {
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Server.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Server.java
index 595f2a8b..41cab361 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Server.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Server.java
@@ -8,6 +8,7 @@
* Contributors:
* VMware Inc. - initial contribution
*******************************************************************************/
+
package org.eclipse.virgo.management.console.stubs.types;
import org.mozilla.javascript.Function;
@@ -16,25 +17,25 @@ import org.mozilla.javascript.Function;
*
*
*/
-public class Server extends ParentStub{
-
- private static final long serialVersionUID = 1L;
-
- private static Function callbackFunction;
-
- public Server() {
- }
-
- // Stub methods
-
- public void jsFunction_getServerOverview(Function callbackFunction){
- Server.callbackFunction = callbackFunction;
- }
-
- // Test methods
-
- public static Function getCallbackFunction() {
- return Server.callbackFunction;
- }
-
+public class Server extends ParentStub {
+
+ private static final long serialVersionUID = 1L;
+
+ private Function callbackFunction;
+
+ public Server() {
+ }
+
+ // Stub methods
+
+ public void jsFunction_getServerOverview(Function callbackFunction) {
+ this.callbackFunction = callbackFunction;
+ }
+
+ // Test methods
+
+ public Function getCallbackFunction() {
+ return this.callbackFunction;
+ }
+
}

Back to the top