summaryrefslogtreecommitdiff
path: root/src/test/java/MainTest.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-07-28 12:30:16 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-07-28 12:30:16 +0200
commit1028dee4dfcd89e914d66d4fe92aaa8fcfbfd494 (patch)
treef3c7fec136ab12f74639b0d95426e743cdb2dfcd /src/test/java/MainTest.java
parentf37883c23f9032ace7e0e780fa0e641859863c0c (diff)
Support pre-compilation of scripts if supported by the engine. Also does
this during testing to catch script syntax errors during build. Client shell detects these error and declares them pre-execution. Conflicts: src/main/java/com/c2kernel/scripting/Script.java src/test/java/MainTest.java
Diffstat (limited to 'src/test/java/MainTest.java')
-rw-r--r--src/test/java/MainTest.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/test/java/MainTest.java b/src/test/java/MainTest.java
index 26898ac..431c4c0 100644
--- a/src/test/java/MainTest.java
+++ b/src/test/java/MainTest.java
@@ -12,6 +12,7 @@ import com.c2kernel.persistency.outcome.SchemaValidator;
import com.c2kernel.process.Gateway;
import com.c2kernel.scripting.Script;
import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.scripting.ScriptParsingException;
import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Logger;
@@ -58,7 +59,6 @@ public class MainTest {
String bootItems = FileStringUtility.url2String(Gateway.getResource().getKernelResourceURL("boot/allbootitems.txt"));
StringTokenizer str = new StringTokenizer(bootItems, "\n\r");
- long castorTime=0;
while (str.hasMoreTokens()) {
String thisItem = str.nextToken();
Logger.msg(1, "Validating "+thisItem);
@@ -79,7 +79,6 @@ public class MainTest {
String remarshalled = Gateway.getMarshaller().marshall(unmarshalled);
long now = System.currentTimeMillis();
Logger.msg("Marshall/remarshall of "+thisItem+" took "+(now-then)+"ms");
- castorTime+=(now-then);
errors = validator.validate(remarshalled);
assert errors.length()==0 : "Remarshalled resource "+thisItem+" has errors :"+errors+"\nRemarshalled form:\n"+remarshalled;
@@ -91,8 +90,12 @@ public class MainTest {
// }
// assert xmlDiff.identical();
}
- }
- Logger.msg("Total Castor marshall time: "+castorTime+"ms");
+
+ if (itemType.equals("SC")) {
+ Logger.msg(1, "Parsing script "+thisItem);
+ new Script(thisItem, 0, data);
+ }
+ }
}
private static Schema getSchema(String name, int version, String resPath) throws ObjectNotFoundException {
@@ -104,11 +107,10 @@ public class MainTest {
String testScriptString = FileStringUtility.url2String(MainTest.class.getResource("TestScript.xml"));
String errors = valid.validate(testScriptString);
assert errors.length()==0 : "Test script not valid to schema: "+errors;
-
- Script testScript = new Script(testScriptString);
+
+ Script testScript = new Script("TestScript", 0, testScriptString);
assert testScript.getInputParams().size()==1 : "Script input param count wrong";
assert testScript.getInputParams().get("test")!=null : "Could not retrieve script input param value";
-
testScript.setInputParamValue("test", "Test");
assert testScript.getInputParams().get("test").getInitialised() : "Script is not initialized when it should be";