diff options
Diffstat (limited to 'test/bindings/java/org/uscxml/tests')
-rw-r--r-- | test/bindings/java/org/uscxml/tests/BasicExample.java | 43 | ||||
-rw-r--r-- | test/bindings/java/org/uscxml/tests/JexlDataModelTest.java (renamed from test/bindings/java/org/uscxml/tests/DataModelExample.java) | 56 | ||||
-rw-r--r-- | test/bindings/java/org/uscxml/tests/MonitorExample.java | 46 | ||||
-rw-r--r-- | test/bindings/java/org/uscxml/tests/helper/TestMonitor.java | 76 |
4 files changed, 29 insertions, 192 deletions
diff --git a/test/bindings/java/org/uscxml/tests/BasicExample.java b/test/bindings/java/org/uscxml/tests/BasicExample.java deleted file mode 100644 index 32899e5..0000000 --- a/test/bindings/java/org/uscxml/tests/BasicExample.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.uscxml.tests; - -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(); - } - } - -} diff --git a/test/bindings/java/org/uscxml/tests/DataModelExample.java b/test/bindings/java/org/uscxml/tests/JexlDataModelTest.java index db46a18..bb681b0 100644 --- a/test/bindings/java/org/uscxml/tests/DataModelExample.java +++ b/test/bindings/java/org/uscxml/tests/JexlDataModelTest.java @@ -8,51 +8,53 @@ import org.uscxml.Interpreter; import org.uscxml.InterpreterException; import org.uscxml.InterpreterState; import org.uscxml.dm.jexl.JEXLDataModel; -import org.uscxml.tests.helper.TestMonitor; +import org.uscxml.helper.TestMonitor; -public class DataModelExample { +public class JexlDataModelTest { public static void main(String[] args) { - String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; + 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(); + String testUri = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl/test144.scxml"; + + 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(); System.out.println(testName); - + Interpreter scxml = Interpreter.fromURL(testName); -// scxml.setMonitor(tm); - - while(scxml.step() != InterpreterState.USCXML_FINISHED) {} - + 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); } - - } catch (InterpreterException | MalformedURLException e) { - e.printStackTrace(); } + System.exit(0); } } diff --git a/test/bindings/java/org/uscxml/tests/MonitorExample.java b/test/bindings/java/org/uscxml/tests/MonitorExample.java deleted file mode 100644 index 2f0689a..0000000 --- a/test/bindings/java/org/uscxml/tests/MonitorExample.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.uscxml.tests; - -import org.uscxml.Interpreter; -import org.uscxml.InterpreterException; -import org.uscxml.InterpreterState; -import org.uscxml.tests.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.setMonitor(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: - case USCXML_MICROSTEPPED: - case USCXML_MACROSTEPPED: - case USCXML_CANCELLED: - break; - default: - break; - } - } - - } catch (InterpreterException e) { - e.printStackTrace(); - } - } - -} diff --git a/test/bindings/java/org/uscxml/tests/helper/TestMonitor.java b/test/bindings/java/org/uscxml/tests/helper/TestMonitor.java deleted file mode 100644 index 9266847..0000000 --- a/test/bindings/java/org/uscxml/tests/helper/TestMonitor.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.uscxml.tests.helper; - -import org.uscxml.InterpreterIssue; -import org.uscxml.InterpreterMonitor; -import org.uscxml.StringList; - -public class TestMonitor extends InterpreterMonitor { - - public TestMonitor() {} - - @Override - public void beforeExitingState(String stateId, String xpath, String stateXML) { - System.out.println("beforeExitingState: " + stateId + " " + xpath + " " + stateXML); - } - - @Override - public void afterExitingState(String stateId, String xpath, String stateXML) { - System.out.println("afterExitingState: " + stateId + " " + xpath + " " + stateXML); - } - - @Override - public void beforeExecutingContent(String tagName, String xpath, String contentXML) { - System.out.println("afterExecutingContent: " + tagName + " " + xpath + " " + contentXML); - } - - @Override - public void afterExecutingContent(String tagName, String xpath, String contentXML) { - System.out.println("afterExecutingContent: " + tagName + " " + xpath + " " + contentXML); - } - - @Override - public void beforeUninvoking(String xpath, String invokeid, String invokerXML) { - System.out.println("beforeUninvoking: " + xpath + " " + invokeid + " " + invokerXML); - } - - @Override - public void afterUninvoking(String xpath, String invokeid, String invokerXML) { - System.out.println("beforeUninvoking: " + xpath + " " + invokeid + " " + invokerXML); - } - - @Override - public void beforeTakingTransition(String xpath, String source, StringList targets, String transitionXML) { - System.out.println("beforeTakingTransition: " + xpath + " " + source + " " + targets + " " + transitionXML); - } - - @Override - public void afterTakingTransition(String xpath, String source, StringList targets, String transitionXML) { - System.out.println("afterTakingTransition: " + xpath + " " + source + " " + targets + " " + transitionXML); - } - - @Override - public void beforeEnteringState(String stateId, String xpath, String stateXML) { - System.out.println("beforeEnteringState: " + stateId + " " + xpath + " " + stateXML); - } - - @Override - public void afterEnteringState(String stateId, String xpath, String stateXML) { - System.out.println("afterEnteringState: " + stateId + " " + xpath + " " + stateXML); - } - - @Override - public void beforeInvoking(String xpath, String invokeid, String invokerXML) { - System.out.println("beforeInvoking: " + xpath + " " + invokeid + " " + invokerXML); - } - - @Override - public void afterInvoking(String xpath, String invokeid, String invokerXML) { - System.out.println("afterInvoking: " + xpath + " " + invokeid + " " + invokerXML); - } - - @Override - public void reportIssue(InterpreterIssue issue) { - System.out.println(issue); - } - -} |