1 package org.simantics.gnuplot.tests;
3 import java.io.IOException;
5 import java.net.URLDecoder;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.simantics.gnuplot.Gnuplot;
13 import org.simantics.gnuplot.GnuplotSession;
15 public class GnuplotTest {
17 private Path dataPath;
24 private Path getDir() throws IOException {
25 URL path = getClass().getResource(".");
26 // Avoid the beginning '/'
27 String p = path.getPath().substring(1);
28 String dp = URLDecoder.decode(p, "UTF-8");
29 return Paths.get(dp).toAbsolutePath();
33 public void before() throws IOException {
35 plot = dataPath.resolve("hexagons.plt");
36 stdout = dataPath.resolve("hexagons.svg");
37 stderr = dataPath.resolve("hexagons.stderr.txt");
38 stdout2 = dataPath.resolve("hexagons2.svg");
39 stderr2 = dataPath.resolve("hexagons2.stderr.txt");
47 public void testGnuplot() throws IOException {
48 Gnuplot.detect().execute(dataPath, stdout, stderr, plot);
52 public void testGnuplotSession() throws IOException {
53 try (GnuplotSession session = Gnuplot.detect().newSession(dataPath, stdout2, stderr2)) {
54 session.evaluateFile(plot);