summaryrefslogtreecommitdiffstats
path: root/contrib/java/src/org/uscxml/tests
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/java/src/org/uscxml/tests')
-rw-r--r--contrib/java/src/org/uscxml/tests/TestData.java2
-rw-r--r--contrib/java/src/org/uscxml/tests/TestDataModel.java65
-rw-r--r--contrib/java/src/org/uscxml/tests/TestInvoker.java14
-rw-r--r--contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java13
-rw-r--r--contrib/java/src/org/uscxml/tests/TestW3CECMA.java35
5 files changed, 84 insertions, 45 deletions
diff --git a/contrib/java/src/org/uscxml/tests/TestData.java b/contrib/java/src/org/uscxml/tests/TestData.java
index cb2fc0b..fc8deda 100644
--- a/contrib/java/src/org/uscxml/tests/TestData.java
+++ b/contrib/java/src/org/uscxml/tests/TestData.java
@@ -4,7 +4,7 @@ import org.uscxml.Data;
import org.uscxml.DataNative;
public class TestData {
-
+
public static void main(String[] args) {
System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib");
{
diff --git a/contrib/java/src/org/uscxml/tests/TestDataModel.java b/contrib/java/src/org/uscxml/tests/TestDataModel.java
index 90f4a7a..e813d66 100644
--- a/contrib/java/src/org/uscxml/tests/TestDataModel.java
+++ b/contrib/java/src/org/uscxml/tests/TestDataModel.java
@@ -8,9 +8,8 @@ import org.uscxml.Interpreter;
import org.uscxml.JavaDataModel;
import org.uscxml.StringSet;
-
public class TestDataModel extends JavaDataModel {
-
+
@Override
public JavaDataModel create(Interpreter interpreter) {
/**
@@ -23,8 +22,8 @@ public class TestDataModel extends JavaDataModel {
@Override
public StringSet getNames() {
/**
- * Register with the following names for the datamodel attribute
- * at the scxml element. <scxml datamodel="one of these">
+ * Register with the following names for the datamodel attribute at the
+ * scxml element. <scxml datamodel="one of these">
*/
System.out.println("getNames");
StringSet ss = new StringSet();
@@ -35,8 +34,8 @@ public class TestDataModel extends JavaDataModel {
@Override
public boolean validate(String location, String schema) {
/**
- * Validate the datamodel. This make more sense for XML datamodels
- * and is pretty much unused but required as per draft.
+ * Validate the datamodel. This make more sense for XML datamodels and
+ * is pretty much unused but required as per draft.
*/
System.out.println("validate " + location + " " + schema);
return true;
@@ -45,8 +44,8 @@ public class TestDataModel extends JavaDataModel {
@Override
public void setEvent(Event event) {
/**
- * Make the current event available as the variable _event
- * in the datamodel.
+ * Make the current event available as the variable _event in the
+ * datamodel.
*/
System.out.println("setEvent " + event);
}
@@ -54,8 +53,8 @@ public class TestDataModel extends JavaDataModel {
@Override
public DataNative getStringAsData(String content) {
/**
- * Evaluate the string as a value expression and
- * transform it into a JSON-like Data structure
+ * Evaluate the string as a value expression and transform it into a
+ * JSON-like Data structure
*/
System.out.println("getStringAsData " + content);
Data data = new Data();
@@ -65,28 +64,30 @@ public class TestDataModel extends JavaDataModel {
@Override
public long getLength(String expr) {
/**
- * Return the length of the expression if it were an
- * array, used by foreach element.
+ * Return the length of the expression if it were an array, used by
+ * foreach element.
*/
System.out.println("getLength " + expr);
return 0;
}
@Override
- public void setForeach(String item, String array, String index, long iteration) {
+ public void setForeach(String item, String array, String index,
+ long iteration) {
/**
- * Prepare an iteration of the foreach element, by setting the variable in index
- * to the current iteration and setting the variable in item to the current item
- * from array.
+ * Prepare an iteration of the foreach element, by setting the variable
+ * in index to the current iteration and setting the variable in item to
+ * the current item from array.
*/
- System.out.println("setForeach " + item + " " + index + " " + iteration);
+ System.out
+ .println("setForeach " + item + " " + index + " " + iteration);
}
@Override
public void eval(String scriptElem, String expr) {
/**
- * Evaluate the given expression in the datamodel.
- * This is used foremost with script elements.
+ * Evaluate the given expression in the datamodel. This is used foremost
+ * with script elements.
*/
System.out.println("eval " + scriptElem + " " + expr);
}
@@ -94,7 +95,7 @@ public class TestDataModel extends JavaDataModel {
@Override
public String evalAsString(String expr) {
/**
- * Evaluate the expression as a string e.g. for the log element.
+ * Evaluate the expression as a string e.g. for the log element.
*/
System.out.println("evalAsString " + expr);
return "";
@@ -103,8 +104,8 @@ public class TestDataModel extends JavaDataModel {
@Override
public boolean evalAsBool(String expr) {
/**
- * Evaluate the expression as a boolean for cond attributes in
- * if and transition elements.
+ * Evaluate the expression as a boolean for cond attributes in if and
+ * transition elements.
*/
System.out.println("evalAsBool " + expr);
return true;
@@ -113,9 +114,9 @@ public class TestDataModel extends JavaDataModel {
@Override
public boolean isDeclared(String expr) {
/**
- * The interpreter is supposed to raise an error if we assign
- * to an undeclared variable. This method is used to check whether
- * a location from assign is declared.
+ * The interpreter is supposed to raise an error if we assign to an
+ * undeclared variable. This method is used to check whether a location
+ * from assign is declared.
*/
System.out.println("isDeclared " + expr);
return true;
@@ -134,7 +135,8 @@ public class TestDataModel extends JavaDataModel {
/**
* Called when we evaluate assign elements
*/
- System.out.println("assign " + assignElem + " " + location + " " + content);
+ System.out.println("assign " + assignElem + " " + location + " "
+ + content);
}
/**
@@ -143,16 +145,17 @@ public class TestDataModel extends JavaDataModel {
public static void main(String[] args) {
// load JNI library from build directory
System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
-
+
// register java datamodel at factory
- TestDataModel datamodel = new TestDataModel();
+ TestDataModel datamodel = new TestDataModel();
Factory.getInstance().registerDataModel(datamodel);
-
+
// instantiate interpreter with document from file
- Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/java/test-java-datamodel.scxml");
+ Interpreter interpreter = Interpreter
+ .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/java/test-java-datamodel.scxml");
// wait until interpreter has finished
- while(true)
+ while (true)
interpreter.interpret();
}
diff --git a/contrib/java/src/org/uscxml/tests/TestInvoker.java b/contrib/java/src/org/uscxml/tests/TestInvoker.java
index 8f68c6b..7807cda 100644
--- a/contrib/java/src/org/uscxml/tests/TestInvoker.java
+++ b/contrib/java/src/org/uscxml/tests/TestInvoker.java
@@ -10,7 +10,6 @@ import org.uscxml.JavaInvoker;
import org.uscxml.SendRequest;
import org.uscxml.StringSet;
-
public class TestInvoker extends JavaInvoker {
@Override
@@ -38,7 +37,7 @@ public class TestInvoker extends JavaInvoker {
System.out.println(req.getData());
System.out.println(req.getXML());
-
+
Event ev = new Event();
ev.setName("foo");
returnEvent(ev);
@@ -54,12 +53,13 @@ public class TestInvoker extends JavaInvoker {
*/
public static void main(String[] args) {
System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib");
-
- TestInvoker invoker = new TestInvoker();
+
+ TestInvoker invoker = new TestInvoker();
Factory.getInstance().registerInvoker(invoker);
-
- Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/test-java-invoker.scxml");
- while(true)
+
+ Interpreter interpreter = Interpreter
+ .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/samples/uscxml/test-java-invoker.scxml");
+ while (true)
interpreter.interpret();
}
diff --git a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java b/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java
index 3621a19..7399c94 100644
--- a/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java
+++ b/contrib/java/src/org/uscxml/tests/TestJavaScriptDataModel.java
@@ -2,23 +2,24 @@ package org.uscxml.tests;
import org.uscxml.Factory;
import org.uscxml.Interpreter;
-import org.uscxml.ECMAScriptDataModel;
+import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel;
public class TestJavaScriptDataModel {
public static void main(String[] args) {
// load JNI library from build directory
System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
-
+
// register java datamodel at factory
- ECMAScriptDataModel datamodel = new ECMAScriptDataModel();
+ ECMAScriptDataModel datamodel = new ECMAScriptDataModel();
Factory.getInstance().registerDataModel(datamodel);
-
+
// instantiate interpreter with document from file
- Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/java/test-ecmascript-datamodel.scxml");
+ Interpreter interpreter = Interpreter
+ .fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/java/test-ecmascript-datamodel.scxml");
// wait until interpreter has finished
- while(true)
+ while (true)
interpreter.interpret();
}
diff --git a/contrib/java/src/org/uscxml/tests/TestW3CECMA.java b/contrib/java/src/org/uscxml/tests/TestW3CECMA.java
new file mode 100644
index 0000000..2b2a36e
--- /dev/null
+++ b/contrib/java/src/org/uscxml/tests/TestW3CECMA.java
@@ -0,0 +1,35 @@
+package org.uscxml.tests;
+
+import java.io.File;
+
+import org.uscxml.Factory;
+import org.uscxml.Interpreter;
+import org.uscxml.datamodel.ecmascript.ECMAScriptDataModel;
+
+public class TestW3CECMA {
+
+ public static String testDir = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma";
+
+ public static void main(String[] args) {
+ System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
+
+ ECMAScriptDataModel datamodel = new ECMAScriptDataModel();
+ Factory.getInstance().registerDataModel(datamodel);
+
+ Interpreter interpreter = Interpreter.fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma/test176.scxml");
+ interpreter.interpret();
+ System.exit(0);
+
+// File dir = new File(testDir);
+// File[] filesList = dir.listFiles();
+// for (File file : filesList) {
+// if (file.isFile() && file.getName().endsWith(".scxml")) {
+// System.out.println("### " + file.getName() + " #####");
+// Interpreter interpreter = Interpreter.fromURI(file.getAbsolutePath());
+// interpreter.interpret();
+// }
+// }
+
+ }
+
+}