From 7234fd04b63e69756670e3605a4e778cbe6cf871 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 28 Jul 2014 12:23:52 +0200 Subject: 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. --- src/test/java/MainTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/test/java/MainTest.java') diff --git a/src/test/java/MainTest.java b/src/test/java/MainTest.java index 0d35cd6..7809c25 100644 --- a/src/test/java/MainTest.java +++ b/src/test/java/MainTest.java @@ -10,6 +10,7 @@ import com.c2kernel.persistency.outcome.Schema; import com.c2kernel.persistency.outcome.SchemaValidator; import com.c2kernel.process.Gateway; import com.c2kernel.scripting.Script; +import com.c2kernel.scripting.ScriptParsingException; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; import com.c2kernel.utils.Resource; @@ -36,7 +37,6 @@ public class MainTest { String bootItems = FileStringUtility.url2String(Resource.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); @@ -59,7 +59,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); if (errors.length() > 0) { Logger.error("Remarshalled resource "+thisItem+" has errors :"+errors); @@ -74,8 +73,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 { @@ -91,7 +94,7 @@ public class MainTest { } assert errors.length()==0; - Script testScript = new Script(testScriptString); + Script testScript = new Script("TestScript", 0, testScriptString); assert testScript.getInputParams().size()==1; assert testScript.getInputParams().get("test")!=null; -- cgit v1.2.3