From d43164830403245353080f5d6f838ed9f56d9a35 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 18 Nov 2013 09:48:03 +0100 Subject: 3.0-SNAPSHOT (Will be first open source version) New StateMachine desc IssueID #28 --- src/test/java/MainTest.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/MainTest.java b/src/test/java/MainTest.java index c292df9..309f0cf 100644 --- a/src/test/java/MainTest.java +++ b/src/test/java/MainTest.java @@ -5,6 +5,7 @@ import java.util.StringTokenizer; import org.custommonkey.xmlunit.XMLUnit; import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; import com.c2kernel.persistency.outcome.OutcomeValidator; import com.c2kernel.persistency.outcome.Schema; import com.c2kernel.persistency.outcome.SchemaValidator; @@ -16,7 +17,12 @@ import com.c2kernel.utils.Resource; public class MainTest { - + public static void main(String[] args) throws Exception { + MainTest me = new MainTest(); + me.testBootItems(); + me.testScriptParsing(); + me.testStateMachine(); + } public MainTest() throws Exception { Logger.addLogStream(System.out, 1); @@ -32,6 +38,7 @@ public class MainTest { validators.put("CA", new OutcomeValidator(getSchema("CompositeActivityDef", 0, "boot/OD/CompositeActivityDef.xsd"))); validators.put("EA", new OutcomeValidator(getSchema("ElementaryActivityDef", 0, "boot/OD/ElementaryActivityDef.xsd"))); validators.put("SC", new OutcomeValidator(getSchema("Script", 0, "boot/OD/Script.xsd"))); + validators.put("SM", new OutcomeValidator(getSchema("StateMachine", 0, "boot/OD/StateMachine.xsd"))); validators.put("OD", new SchemaValidator()); String bootItems = FileStringUtility.url2String(Resource.getKernelResourceURL("boot/allbootitems.txt")); @@ -51,7 +58,7 @@ public class MainTest { } assert errors.length()==0; - if (itemType.equals("CA") || itemType.equals("EA")) { + if (itemType.equals("CA") || itemType.equals("EA") || itemType.equals("SM")) { Logger.msg(1, "Remarshalling "+thisItem); long then = System.currentTimeMillis(); Object unmarshalled = Gateway.getMarshaller().unmarshall(data); @@ -62,7 +69,7 @@ public class MainTest { castorTime+=(now-then); errors = validator.validate(remarshalled); if (errors.length() > 0) { - Logger.error("Remarshalled resource "+thisItem+" has errors :"+errors); + Logger.error("Remarshalled resource "+thisItem+" has errors :"+errors+"\nRemarshalled form:\n"+remarshalled); } assert errors.length()==0; @@ -103,4 +110,12 @@ public class MainTest { assert result instanceof String; assert ((String)result).equals("TestTest"); } + + public void testStateMachine() throws Exception { + Logger.msg("Validating test state machine"); + String smXml = FileStringUtility.url2String(MainTest.class.getResource("TestStateMachine.xml")); + StateMachine sm = (StateMachine)Gateway.getMarshaller().unmarshall(smXml); + sm.validate(); + assert sm.isCoherent(); + } } -- cgit v1.2.3