--- /dev/null
+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