diff options
author | juehv <heuschkel@tk.tu-darmstadt.de> | 2016-11-30 15:02:24 (GMT) |
---|---|---|
committer | juehv <heuschkel@tk.tu-darmstadt.de> | 2016-11-30 15:02:24 (GMT) |
commit | 3852c03e80bdf2bdbf5b33f01fdac6a960fb1d7d (patch) | |
tree | bed8c335bce3900b445c70b4fc66c4f410705d0c | |
parent | 40a1a137263715b7d0f17e8a897d79afa75b82b5 (diff) | |
parent | 044fefae99320aa575523eab90032f9e9d8b498c (diff) | |
download | uscxml-3852c03e80bdf2bdbf5b33f01fdac6a960fb1d7d.zip uscxml-3852c03e80bdf2bdbf5b33f01fdac6a960fb1d7d.tar.gz uscxml-3852c03e80bdf2bdbf5b33f01fdac6a960fb1d7d.tar.bz2 |
Merge branch 'master' of github.com:tklab-tud/uscxml
19 files changed, 794 insertions, 1 deletions
@@ -8,7 +8,6 @@ contrib/prebuilt/linux* contrib/prebuilt/windows* contrib/prebuilt/ios* contrib/prebuilt/android* -contrib/java/bin* contrib/java/*.log package/linux* diff --git a/contrib/java/bindings/build.properties b/contrib/java/bindings/build.properties new file mode 100644 index 0000000..dd0fe62 --- /dev/null +++ b/contrib/java/bindings/build.properties @@ -0,0 +1,9 @@ +# Default path on Windows (maybe with an '(x86)' in there for good measure) +#umundo.jar=C:\\Program Files\\uMundo\\share\\umundo\\lib\\umundo.jar + +# Default path on MacOSX and Linux +uscxml.library.path=/usr/local/share/uscxml/bindings/java +uscxml.jar=/usr/local/share/uscxml/bindings/uscxml.jar + +jexl.jar=libs/commons-jexl3-3.0.jar +logging.jar=libs/commons-logging-1.2.jar
\ No newline at end of file diff --git a/contrib/java/bindings/build.xml b/contrib/java/bindings/build.xml new file mode 100644 index 0000000..19d7817 --- /dev/null +++ b/contrib/java/bindings/build.xml @@ -0,0 +1,42 @@ +<project name="java-tests" default="test-w3c">
+
+ <property environment="env"/>
+
+ <property file="build.properties" />
+ <property name="src" value="." />
+ <property name="bin" value="bin" />
+ <!-- <property name="test.file" value="..." /> -->
+
+ <!-- Allow to override actual value with environment .. yes ant sucks -->
+ <condition property="real.uscxml.jar" value="${env.USCXML_JAVA_JAR}" else="${uscxml.jar}">
+ <isset property="env.USCXML_JAVA_JAR" />
+ </condition>
+
+ <target name="clean">
+ <delete dir="${bin}" />
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${bin}" />
+ <javac destdir="${bin}" debuglevel="lines,vars,source" debug="on"
+ encoding="utf-8" includeantruntime="false">
+ <src path="${src}" />
+ <classpath>
+ <pathelement location="${real.uscxml.jar}" />
+ <pathelement location="${jexl.jar}" />
+ <pathelement location="${logging.jar}" />
+ </classpath>
+ <include name="**/*.java" />
+ </javac>
+ </target>
+
+ <target name="test-w3c">
+ <antcall target="test-w3c-jexl" />
+ </target>
+
+ <target name="test-w3c-jexl" depends="compile">
+ <java classpath="${real.uscxml.jar}:${jexl.jar}:${logging.jar}:${bin}" classname="org.uscxml.tests.JexlDataModelTest">
+ <arg value="${test.file}"/>
+ </java>
+ </target>
+</project>
\ No newline at end of file diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java new file mode 100644 index 0000000..a0208c9 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java @@ -0,0 +1,7 @@ +package org.uscxml.apache.commons.scxml2; + +import org.uscxml.DataModel; + +public class Context { + public DataModel dm = null; +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java new file mode 100644 index 0000000..5bd5642 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java @@ -0,0 +1,7 @@ +package org.uscxml.apache.commons.scxml2; + +public abstract class Evaluator { + + public abstract Context newContext(Object object); + +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java new file mode 100644 index 0000000..127bed3 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java @@ -0,0 +1,19 @@ +package org.uscxml.apache.commons.scxml2; + +import org.uscxml.Factory; +import org.uscxml.dm.jexl.JexlDataModel; + +public class JexlEvaluator extends Evaluator { + + public JexlEvaluator() { + + } + + @Override + public Context newContext(Object object) { + // TODO Auto-generated method stub + Context ctx = new Context(); + ctx.dm = new JexlDataModel(); + return ctx; + } +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java new file mode 100644 index 0000000..67e5b1f --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java @@ -0,0 +1,8 @@ +package org.uscxml.apache.commons.scxml2; + +import java.net.URL; + +public class SCXML { + public URL url = null; + +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java new file mode 100644 index 0000000..704e897 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java @@ -0,0 +1,49 @@ +package org.uscxml.apache.commons.scxml2; + +import java.net.URL; + +import org.uscxml.ActionLanguage; +import org.uscxml.Factory; +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.InterpreterState; +import org.uscxml.helper.TestMonitor; + +public class SCXMLExecutor { + + public Interpreter interpreter = null; + public URL sourceURL = null; + public ActionLanguage al = new ActionLanguage(); + + public SCXMLExecutor(Evaluator evaluator, Object object, SimpleErrorReporter simpleErrorReporter) { + // TODO Auto-generated constructor stub + } + + public void setStateMachine(SCXML scxml) { + sourceURL = scxml.url; + } + + public void setRootContext(Context rootContext) { + al.setDataModel(rootContext.dm); + } + + public void go() { + try { + interpreter = Interpreter.fromURL(sourceURL.toString()); + interpreter.setActionLanguage(al); + + TestMonitor tm = new TestMonitor(); + interpreter.addMonitor(tm); + + InterpreterState state = InterpreterState.USCXML_UNDEF; + while(state != InterpreterState.USCXML_FINISHED) { + interpreter.step(); + } + + } catch (InterpreterException e) { + e.printStackTrace(); + } + + } + +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java new file mode 100644 index 0000000..45c2a54 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java @@ -0,0 +1,13 @@ +package org.uscxml.apache.commons.scxml2; + +import java.net.URL; + +public class SCXMLReader { + + public static SCXML read(URL scxml) { + SCXML foo = new SCXML(); + foo.url = scxml; + return foo; + } + +} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java new file mode 100644 index 0000000..06187f8 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java @@ -0,0 +1,5 @@ +package org.uscxml.apache.commons.scxml2; + +public class SimpleErrorReporter { + +} diff --git a/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java b/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java new file mode 100644 index 0000000..4cf3de4 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java @@ -0,0 +1,45 @@ +package org.uscxml.examples; + +import java.net.URL; + +//import org.uscxml.apache.commons.scxml2.*; +import org.apache.commons.scxml2.*; +import org.apache.commons.scxml2.env.SimpleErrorReporter; +import org.apache.commons.scxml2.env.jexl.JexlEvaluator; +import org.apache.commons.scxml2.io.SCXMLReader; +import org.apache.commons.scxml2.model.SCXML; + +public class ApacheCommonsAPI { + + // SCXML model source URL + private static final URL SCXML = ApacheCommonsAPI.class.getResource("hello-world.xml"); + + public static void main(String [] args) throws Exception { + String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + if (System.getenv().containsKey("USCXML_JAVA_LIB")) { + uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); + } + + System.load(uSCXMLLibPath); + + + // evaluator instance which is used by SCXML engine to evaluate expressions in SCXML + Evaluator evaluator = new JexlEvaluator(); + // engine to execute the scxml instance + SCXMLExecutor executor = new SCXMLExecutor(evaluator, null, new SimpleErrorReporter()); + + // parse SCXML URL into SCXML model + SCXML scxml = SCXMLReader.read(SCXML); + // set state machine (scxml instance) to execute + executor.setStateMachine(scxml); + + // create root context storing variables and being used by evaluator + Context rootContext = evaluator.newContext(null); + // set the root context for the engine + executor.setRootContext(rootContext); + + // initiate the execution of the state machine + executor.go(); + } + +} diff --git a/contrib/java/bindings/org/uscxml/examples/BasicExample.java b/contrib/java/bindings/org/uscxml/examples/BasicExample.java new file mode 100644 index 0000000..129a116 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/examples/BasicExample.java @@ -0,0 +1,46 @@ +package org.uscxml.examples; + +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.InterpreterState; + +public class BasicExample { + + public static void main(String[] args) { + + String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + if (System.getenv().containsKey("USCXML_JAVA_LIB")) { + uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); + } + + System.load(uSCXMLLibPath); + + try { + Interpreter scxml = Interpreter.fromURL("https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/null/test436.scxml"); + InterpreterState state = InterpreterState.USCXML_UNDEF; + while((state = scxml.step()) != InterpreterState.USCXML_FINISHED) { + switch (state) { + case USCXML_FINISHED: + case USCXML_UNDEF: + case USCXML_IDLE: + case USCXML_INITIALIZED: + case USCXML_INSTANTIATED: + case USCXML_MICROSTEPPED: + case USCXML_MACROSTEPPED: + case USCXML_CANCELLED: + break; + default: + break; + } + } + System.out.println("Machine finished"); + + } catch (InterpreterException e) { + e.printStackTrace(); + System.exit(-1); + } + System.exit(0); + + } + +} diff --git a/contrib/java/bindings/org/uscxml/examples/DataModelExample.java b/contrib/java/bindings/org/uscxml/examples/DataModelExample.java new file mode 100644 index 0000000..bba64eb --- /dev/null +++ b/contrib/java/bindings/org/uscxml/examples/DataModelExample.java @@ -0,0 +1,60 @@ +package org.uscxml.examples; + +import java.io.File; +import java.net.MalformedURLException; + +import org.uscxml.Factory; +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.InterpreterState; +import org.uscxml.dm.jexl.JexlDataModel; +import org.uscxml.helper.TestMonitor; + +public class DataModelExample { + + public static void main(String[] args) { + String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + if (System.getenv().containsKey("USCXML_JAVA_LIB")) { + uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); + } + + System.load(uSCXMLLibPath); + + JexlDataModel jdm = new JexlDataModel(); + Factory.getInstance().registerDataModel(jdm);; + + TestMonitor tm = new TestMonitor(); + + File folder = new File("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl"); + File[] listOfFiles = folder.listFiles(); + + try { + for (File file : listOfFiles) { + if (!file.getName().endsWith(".scxml")) + continue; + String testName = file.toURI().toURL().toString(); + System.out.println(testName); + + Interpreter scxml = Interpreter.fromURL(testName); +// scxml.setMonitor(tm); + + while(scxml.step() != InterpreterState.USCXML_FINISHED) {} + + if (!scxml.isInState("pass")) { + System.out.println("FAIL: " + testName); + + throw new RuntimeException(); + } + System.out.println("SUCCESS"); + + } + + } catch (InterpreterException | MalformedURLException e) { + e.printStackTrace(); + System.exit(-1); + } + System.exit(0); + + } + +} diff --git a/contrib/java/bindings/org/uscxml/examples/MonitorExample.java b/contrib/java/bindings/org/uscxml/examples/MonitorExample.java new file mode 100644 index 0000000..dc4cffa --- /dev/null +++ b/contrib/java/bindings/org/uscxml/examples/MonitorExample.java @@ -0,0 +1,55 @@ +package org.uscxml.examples; + +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.InterpreterState; +import org.uscxml.StringVector; +import org.uscxml.helper.TestMonitor; + + +public class MonitorExample { + + public static void main(String[] args) { + + String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + if (System.getenv().containsKey("USCXML_JAVA_LIB")) { + uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); + } + + System.load(uSCXMLLibPath); + + try { + TestMonitor tm = new TestMonitor(); + Interpreter scxml = Interpreter.fromURL("https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/null/test436.scxml"); + scxml.addMonitor(tm); + InterpreterState state = InterpreterState.USCXML_UNDEF; + while((state = scxml.step()) != InterpreterState.USCXML_FINISHED) { + switch (state) { + case USCXML_FINISHED: + case USCXML_UNDEF: + case USCXML_IDLE: + case USCXML_INITIALIZED: + case USCXML_INSTANTIATED: + break; + case USCXML_MICROSTEPPED: + case USCXML_MACROSTEPPED: + StringVector states = scxml.getConfiguration(); + for (int i = 0; i < states.size(); i++) { + System.out.print(states.get(i) + " "); + } + System.out.println(); + case USCXML_CANCELLED: + break; + default: + break; + } + } + + } catch (InterpreterException e) { + e.printStackTrace(); + System.exit(-1); + } + System.exit(0); + } + +} diff --git a/contrib/java/bindings/org/uscxml/examples/hello-world.xml b/contrib/java/bindings/org/uscxml/examples/hello-world.xml new file mode 100644 index 0000000..3ac168c --- /dev/null +++ b/contrib/java/bindings/org/uscxml/examples/hello-world.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" ?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with this + work for additional information regarding copyright ownership. The ASF + licenses this file to You under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law + or agreed to in writing, software distributed under the License is + distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the specific language + governing permissions and limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initial="hello"> + + <final id="hello"> + <onentry> + <log expr="'Hello, World!'" /> + </onentry> + </final> + +</scxml>
\ No newline at end of file diff --git a/contrib/java/bindings/org/uscxml/gen/StateChart.java b/contrib/java/bindings/org/uscxml/gen/StateChart.java new file mode 100644 index 0000000..e8c7f69 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/gen/StateChart.java @@ -0,0 +1,221 @@ +package org.uscxml.gen; + +import java.util.BitSet; +import java.util.Deque; +import java.util.List; +import java.util.Map; + +import org.uscxml.InterpreterException; + +/** Base class for generated StateCharts */ + +public abstract class StateChart { + + public enum InterpreterState { + USCXML_FINISHED, + USCXML_UNDEF, + USCXML_IDLE, + USCXML_INITIALIZED, + USCXML_INSTANTIATED, + USCXML_MICROSTEPPED, + USCXML_MACROSTEPPED, + USCXML_CANCELLED + } + + public enum StateType { + USCXML_STATE_ATOMIC, + USCXML_STATE_PARALLEL, + USCXML_STATE_COMPOUND, + USCXML_STATE_FINAL, + USCXML_STATE_HISTORY_DEEP, + USCXML_STATE_HISTORY_SHALLOW, + USCXML_STATE_INITIAL, + USCXML_STATE_HAS_HISTORY + } + + public enum TransitionType { + USCXML_TRANS_SPONTANEOUS, + USCXML_TRANS_TARGETLESS, + USCXML_TRANS_INTERNAL, + USCXML_TRANS_HISTORY, + USCXML_TRANS_INITIAL + } + + public abstract class State { + String name; + int parent; + BitSet children; + BitSet completion; + BitSet ancestors; + Data data; + StateType type; + + public abstract void onEntry() throws InterpreterException; + public abstract void onExit() throws InterpreterException; + public abstract void invoke() throws InterpreterException; + } + + public abstract class Transition { + int source; + BitSet target; + String event; + String condition; + TransitionType type; + BitSet conflicts; + BitSet exitSet; + + public abstract boolean isEnabled(); + public abstract void onTransition(); + } + + public class Data { + String id; + String src; + String expr; + String content; + } + + public class Assign { + String location; + String expr; + String content; + } + + public class Foreach { + String array; + String item; + String index; + } + + public class Param { + String name; + String expr; + String location; + } + + public class DoneData { + int source; + String content; + String contentExpr; + List<Param> params; + } + + public abstract class Invoke { + StateChart machine; + String type; + String typeExpr; + String src; + String srcExpr; + String id; + String idlocation; + String sourceName; + String namelist; + boolean autoForward; + String content; + String contentExpr; + List<Param> params; + + public abstract void finalize(); + } + + public class Send { + String event; + String eventExpr; + String target; + String targetExpr; + String type; + String typeExpr; + String id; + String idlocation; + String delay; + String delayExpr; + String namelist; + String content; + String contentExpr; + List<Param> params; + } + + public List<Transition> transitions; + public List<State> states; + + public Deque<Object> externalQueue; + public Deque<Object> internalQueue; + + protected InterpreterState state = InterpreterState.USCXML_UNDEF; + protected Object event; + + protected BitSet flags; + protected BitSet config; + protected BitSet history; + protected BitSet invocations; + protected BitSet initializedData; + + protected Map<String, Integer> stateNamesToIndex; + + public InterpreterState step() throws org.uscxml.InterpreterException { + return step(0); + } + + public InterpreterState step(long blockMs) throws org.uscxml.InterpreterException { + /** Here you would implement microstep(T) as in the book chapter */ + + + /** Just to silence the compiler warning */ + if (true) throw new InterpreterException("", ""); + return state; + } + + public void cancel() { + state = InterpreterState.USCXML_CANCELLED; + } + + public void reset() { + history.clear(); + config.clear(); + flags.clear(); + // @TODO: uninvoke any invokers + invocations.clear(); + } + + public InterpreterState getState() { return state; } + + public boolean isInState(String stateId) { + if (!stateNamesToIndex.containsKey(stateId)) + return false; + return config.get((int) stateNamesToIndex.get(stateId)); + } + + public void receive(Object event) { + externalQueue.addLast(event); + } + + protected Object dequeueInternal() { + try { + return internalQueue.removeLast(); + } catch(Exception e) { + return null; + } + } + + protected Object dequeueExternal() { + try { + return externalQueue.removeLast(); + } catch(Exception e) { + return null; + } + } + + public abstract void execContentLog(); + public abstract void execContentRaise(); + public abstract void execContentSend(); + public abstract void execContentForeachInit(); + public abstract void execContentForeachNext(); + public abstract void execContentForeachDone(); + public abstract void execContentAssign(); + public abstract void execContentInit(); + public abstract void execContentCancel(); + public abstract void execContentScript(); + + public abstract void invoke(); + +}
\ No newline at end of file diff --git a/contrib/java/bindings/org/uscxml/gen/TestStateChartBase.java b/contrib/java/bindings/org/uscxml/gen/TestStateChartBase.java new file mode 100644 index 0000000..c5cc141 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/gen/TestStateChartBase.java @@ -0,0 +1,20 @@ +package org.uscxml.gen; + +/** + Generated from source: + file:///Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl/test191.scxml +*/ + + +import java.util.ArrayList; +import java.util.HashMap; + +public abstract class TestStateChartBase extends StateChart { + + public TestStateChartBase() { + transitions = new ArrayList<Transition>(); + states = new ArrayList<State>(); + stateNamesToIndex = new HashMap<String, Integer>(); + /* TODO: initialize all members */ + } +} diff --git a/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java b/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java new file mode 100644 index 0000000..da79d37 --- /dev/null +++ b/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java @@ -0,0 +1,73 @@ +package org.uscxml.tests; + +import java.io.File; +import java.net.MalformedURLException; + +import org.uscxml.ActionLanguage; +import org.uscxml.Factory; +import org.uscxml.Interpreter; +import org.uscxml.InterpreterException; +import org.uscxml.InterpreterState; +import org.uscxml.dm.jexl.JexlDataModel; +import org.uscxml.helper.StopWatch; +import org.uscxml.helper.TestMonitor; + +public class JexlDataModelTest { + + public static void main(String[] args) { + String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + if (System.getenv().containsKey("USCXML_JAVA_LIB")) { + uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); + } + + System.load(uSCXMLLibPath); +// String testUri = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl/test144.scxml"; +// String testUri = "/Users/sradomski/Desktop/stopwatch.xml"; + + +// if (args.length > 0) { +// testUri = args[0]; +// } + + { + JexlDataModel jdm = new JexlDataModel(); +// Factory.getInstance().registerDataModel(jdm); + + + TestMonitor tm = new TestMonitor(); + + try { +// File testFile = new File(testUri); +// String testName = testFile.toURI().toURL().toString(); + String testName = "https://raw.githubusercontent.com/woonsan/commons-scxml-examples/master/stopwatch/src/main/resources/com/github/woonsan/commons/scxml/examples/stopwatch/stopwatch.xml"; + System.out.println(testName); + + Interpreter scxml = Interpreter.fromURL(testName); + + jdm.ctx.set("stopWatch", new StopWatch()); + + ActionLanguage al = new ActionLanguage(); + al.setDataModel(jdm); + scxml.setActionLanguage(al); + + scxml.addMonitor(tm); + + while (scxml.step() != InterpreterState.USCXML_FINISHED) { + } + + if (!scxml.isInState("pass")) { + System.out.println("FAIL: " + testName); + throw new RuntimeException(); + } + System.out.println("SUCCESS"); + + } catch (InterpreterException e) { + e.printStackTrace(); + System.exit(-1); + } + } + + System.exit(0); + } + +} diff --git a/contrib/java/bindings/org/uscxml/tests/gen/TestStateChart.java b/contrib/java/bindings/org/uscxml/tests/gen/TestStateChart.java new file mode 100644 index 0000000..7c5bd2c --- /dev/null +++ b/contrib/java/bindings/org/uscxml/tests/gen/TestStateChart.java @@ -0,0 +1,90 @@ +package org.uscxml.tests.gen; + +import org.uscxml.InterpreterException; +import org.uscxml.gen.StateChart; +import org.uscxml.gen.TestStateChartBase; + +public class TestStateChart extends TestStateChartBase { + + @Override + public void execContentLog() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentRaise() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentSend() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentForeachInit() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentForeachNext() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentForeachDone() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentAssign() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentInit() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentCancel() { + // TODO Auto-generated method stub + + } + + @Override + public void execContentScript() { + // TODO Auto-generated method stub + + } + + @Override + public void invoke() { + // TODO Auto-generated method stub + + } + + public static void main(String[] args) { + TestStateChart machine = new TestStateChart(); + try { + while(machine.step() != StateChart.InterpreterState.USCXML_FINISHED) { + // here we could inspect the state chart after a step + } + // when we arrive here, the state chart is finished + assert(machine.isInState("pass")); + System.out.println("PASSED"); + System.exit(0); // EXIT_SUCCESS + } catch (InterpreterException e) { + System.out.println("FAILED"); + System.exit(-1); // EXIT_FAILURE + } + } +} |