source: java2python/jackson-t/src/test/java/tudelft/utilities/j2p/ActionsUseTest.java@ 510

Last change on this file since 510 was 510, checked in by wouter, 17 months ago

Use SavingReporter to clean up code

File size: 1.5 KB
Line 
1package tudelft.utilities.j2p;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.File;
6import java.io.FileNotFoundException;
7import java.io.IOException;
8import java.nio.file.Paths;
9import java.util.Arrays;
10
11import org.junit.Test;
12
13import tudelft.utilities.logging.Reporter;
14import tudelft.utilities.logging.SavingReporter;
15import tudelft.utilities.pyrunner.PythonError;
16import tudelft.utilities.pyrunner.PythonVenv;
17
18/**
19 * A more complex package involving multiple files.
20 */
21public 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}
Note: See TracBrowser for help on using the repository browser.