]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java
Added missing plug-ins from old SVN repository trunk
[simantics/platform.git] / bundles / org.simantics.gnuplot / test / org / simantics / gnuplot / tests / GnuplotTest.java
diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java
new file mode 100644 (file)
index 0000000..ccc1444
--- /dev/null
@@ -0,0 +1,58 @@
+package org.simantics.gnuplot.tests;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.simantics.gnuplot.Gnuplot;
+import org.simantics.gnuplot.GnuplotSession;
+
+public class GnuplotTest {
+
+    private Path dataPath;
+    private Path plot;
+    private Path stdout;
+    private Path stderr;
+    private Path stdout2;
+    private Path stderr2;
+
+    private Path getDir() throws IOException {
+        URL path = getClass().getResource(".");
+        // Avoid the beginning '/'
+        String p = path.getPath().substring(1);
+        String dp = URLDecoder.decode(p, "UTF-8");
+        return Paths.get(dp).toAbsolutePath();
+    }
+
+    @Before
+    public void before() throws IOException {
+        dataPath = getDir();
+        plot = dataPath.resolve("hexagons.plt");
+        stdout = dataPath.resolve("hexagons.svg");
+        stderr = dataPath.resolve("hexagons.stderr.txt");
+        stdout2 = dataPath.resolve("hexagons2.svg");
+        stderr2 = dataPath.resolve("hexagons2.stderr.txt");
+    }
+
+    @After
+    public void after() {
+    }
+
+    @Test
+    public void testGnuplot() throws IOException {
+        Gnuplot.detect().execute(dataPath, stdout, stderr, plot);
+    }
+
+    @Test
+    public void testGnuplotSession() throws IOException {
+        try (GnuplotSession session = Gnuplot.detect().newSession(dataPath, stdout2, stderr2)) {
+            session.evaluateFile(plot);
+        }
+    }
+
+}
\ No newline at end of file