]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSessionWithModules.java
(refs #7374) Created CommandSessionWithModules
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / TestCommandSessionWithModules.java
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSessionWithModules.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSessionWithModules.java
new file mode 100644 (file)
index 0000000..9e8c14e
--- /dev/null
@@ -0,0 +1,31 @@
+package org.simantics.scl.compiler.tests;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.simantics.scl.compiler.commands.CommandSessionWithModules;
+import org.simantics.scl.osgi.SCLOsgi;
+
+public class TestCommandSessionWithModules {
+    @Test
+    public void testCommandSessionWithModules() {
+        CommandSessionWithModules session = new CommandSessionWithModules(SCLOsgi.MODULE_REPOSITORY);
+        session.putModule("My/Test/Module", "someValue = 13");
+        
+        {
+            StringWriter writer = new StringWriter();
+            session.runCommands(new StringReader("import \"My/Test/Module\"\nsomeValue"), writer);
+            Assert.assertEquals("13\n", writer.toString());
+        }
+        
+        session.putModule("My/Test/Module", "someValue = 14");
+        
+        {
+            StringWriter writer = new StringWriter();
+            session.runCommands(new StringReader("someValue\nsomeValue+1"), writer);
+            Assert.assertEquals("14\n15\n", writer.toString());
+        }
+    }
+}