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.Test;
|
---|
12 |
|
---|
13 | import tudelft.utilities.logging.Reporter;
|
---|
14 | import tudelft.utilities.logging.SavingReporter;
|
---|
15 | import tudelft.utilities.pyrunner.PythonError;
|
---|
16 | import tudelft.utilities.pyrunner.PythonVenv;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * A more complex package involving multiple files.
|
---|
20 | */
|
---|
21 | public class ActionsUseTest {
|
---|
22 |
|
---|
23 | PyProgram program = PyProgram
|
---|
24 | .fromDirectory(Paths.get("src/test/javaactions"));
|
---|
25 |
|
---|
26 | @Test
|
---|
27 | public void test() throws IOException, ClassNotFoundException {
|
---|
28 | System.out.println(program);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Test
|
---|
32 | public void runFromZip() throws FileNotFoundException, IOException,
|
---|
33 | InterruptedException, PythonError {
|
---|
34 | File zipfile = program.getZip();
|
---|
35 | // File zipfile = zip(translate(TESTDIR + FULLNAME), new File(FULLNAME));
|
---|
36 | System.out.println("zip file at " + zipfile);
|
---|
37 |
|
---|
38 | Reporter reporter = new SavingReporter("test");
|
---|
39 | PythonVenv venv = new PythonVenv(zipfile, reporter);
|
---|
40 | String res = venv.call(
|
---|
41 | Arrays.asList("-m", "testcode.actions.ActionsUse"), 10000);
|
---|
42 | System.out.println(res);
|
---|
43 | assertEquals("serializeAcceptTest\n"
|
---|
44 | + "{\"Accept\":{\"actor\":\"party1\",\"bid\":\"issuevalues\"}}\n"
|
---|
45 | + "deserializeAcceptTest\n" + "Accept[party1,issuevalues]\n"
|
---|
46 | + "AlltestsOK\n", res.replace(" ", ""));
|
---|
47 | // as in Java but true->True and pyson inserts some extra whitespace
|
---|
48 | }
|
---|
49 |
|
---|
50 | }
|
---|