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

Last change on this file since 889 was 889, checked in by wouter, 5 months ago

#309 create init.py files in all created subdirs

File size: 1.6 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.Before;
12import org.junit.Test;
13
14import tudelft.utilities.j2p.t.TranslationException;
15import tudelft.utilities.logging.Reporter;
16import tudelft.utilities.logging.SavingReporter;
17import tudelft.utilities.pyrunner.PythonError;
18import tudelft.utilities.pyrunner.PythonVenv;
19
20/**
21 * A more complex package involving multiple files.
22 */
23public 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}
Note: See TracBrowser for help on using the repository browser.