1 | package tudelft.utilities.j2p;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 |
|
---|
5 | import java.io.File;
|
---|
6 | import java.io.FileNotFoundException;
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.nio.file.Paths;
|
---|
9 | import java.util.Arrays;
|
---|
10 |
|
---|
11 | import org.junit.Before;
|
---|
12 | import org.junit.Test;
|
---|
13 |
|
---|
14 | import tudelft.utilities.j2p.t.TranslationException;
|
---|
15 | import tudelft.utilities.logging.Reporter;
|
---|
16 | import tudelft.utilities.logging.SavingReporter;
|
---|
17 | import tudelft.utilities.pyrunner.PythonError;
|
---|
18 | import tudelft.utilities.pyrunner.PythonVenv;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * A more complex package involving multiple files.
|
---|
22 | */
|
---|
23 | public class ActionsUseTest {
|
---|
24 |
|
---|
25 | PyProgram program;
|
---|
26 |
|
---|
27 | @Before
|
---|
28 | public void before() throws TranslationException {
|
---|
29 | program = PyProgram.fromDirectories(
|
---|
30 | Arrays.asList(Paths.get("src/test/javaactions")));
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Test
|
---|
34 | public void test() throws IOException, ClassNotFoundException {
|
---|
35 | System.out.println(program);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Test
|
---|
39 | public void runFromZip() throws FileNotFoundException, IOException,
|
---|
40 | InterruptedException, PythonError {
|
---|
41 | File zipfile = program.getZip();
|
---|
42 | // File zipfile = zip(translate(TESTDIR + FULLNAME), new File(FULLNAME));
|
---|
43 | System.out.println("zip file at " + zipfile);
|
---|
44 |
|
---|
45 | Reporter reporter = new SavingReporter("test");
|
---|
46 | PythonVenv venv = new PythonVenv(zipfile, reporter);
|
---|
47 | String res = venv.call(
|
---|
48 | Arrays.asList("-m", "testcode.actions.ActionsUse"), 10000);
|
---|
49 | System.out.println(res);
|
---|
50 | assertEquals("serializeAcceptTest\n"
|
---|
51 | + "{\"Accept\":{\"actor\":\"party1\",\"bid\":\"issuevalues\"}}\n"
|
---|
52 | + "deserializeAcceptTest\n" + "Accept[party1,issuevalues]\n"
|
---|
53 | + "AlltestsOK\n", res.replace(" ", ""));
|
---|
54 | // as in Java but true->True and pyson inserts some extra whitespace
|
---|
55 | }
|
---|
56 |
|
---|
57 | }
|
---|