From 1028dee4dfcd89e914d66d4fe92aaa8fcfbfd494 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 28 Jul 2014 12:30:16 +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. Conflicts: src/main/java/com/c2kernel/scripting/Script.java src/test/java/MainTest.java --- src/test/java/MainTest.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/test') 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"; -- cgit v1.2.3