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

Last change on this file since 770 was 744, checked in by wouter, 13 months ago

#254 PyProgram now throws TranslationException. Ignore broken test in tudunit-t

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.fromDirectory(Paths.get("src/test/javaactions"));
30 }
31
32 @Test
33 public void test() throws IOException, ClassNotFoundException {
34 System.out.println(program);
35 }
36
37 @Test
38 public void runFromZip() throws FileNotFoundException, IOException,
39 InterruptedException, PythonError {
40 File zipfile = program.getZip();
41 // File zipfile = zip(translate(TESTDIR + FULLNAME), new File(FULLNAME));
42 System.out.println("zip file at " + zipfile);
43
44 Reporter reporter = new SavingReporter("test");
45 PythonVenv venv = new PythonVenv(zipfile, reporter);
46 String res = venv.call(
47 Arrays.asList("-m", "testcode.actions.ActionsUse"), 10000);
48 System.out.println(res);
49 assertEquals("serializeAcceptTest\n"
50 + "{\"Accept\":{\"actor\":\"party1\",\"bid\":\"issuevalues\"}}\n"
51 + "deserializeAcceptTest\n" + "Accept[party1,issuevalues]\n"
52 + "AlltestsOK\n", res.replace(" ", ""));
53 // as in Java but true->True and pyson inserts some extra whitespace
54 }
55
56}
Note: See TracBrowser for help on using the repository browser.