]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.gnuplot.tests;
2
3 import java.io.IOException;
4 import java.net.URL;
5 import java.net.URLDecoder;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
8
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;
14
15 public class GnuplotTest {
16
17     private Path dataPath;
18     private Path plot;
19     private Path stdout;
20     private Path stderr;
21     private Path stdout2;
22     private Path stderr2;
23
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();
30     }
31
32     @Before
33     public void before() throws IOException {
34         dataPath = getDir();
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");
40     }
41
42     @After
43     public void after() {
44     }
45
46     @Test
47     public void testGnuplot() throws IOException {
48         Gnuplot.detect().execute(dataPath, stdout, stderr, plot);
49     }
50
51     @Test
52     public void testGnuplotSession() throws IOException {
53         try (GnuplotSession session = Gnuplot.detect().newSession(dataPath, stdout2, stderr2)) {
54             session.evaluateFile(plot);
55         }
56     }
57
58 }