source: simplerunner/src/test/java/geniusweb/simplerunner/SessionRunnerE2ETest.java@ 30

Last change on this file since 30 was 30, checked in by bart, 3 years ago

Fixed memory leak. MOPAC2. removed jcenter build dependencies

File size: 2.2 KB
Line 
1package geniusweb.simplerunner;
2
3import static org.junit.Assert.assertTrue;
4
5import java.io.IOException;
6import java.nio.charset.StandardCharsets;
7import java.nio.file.Files;
8import java.nio.file.Paths;
9import java.util.Arrays;
10import java.util.Collection;
11
12import org.junit.Before;
13import org.junit.Test;
14import org.junit.runner.RunWith;
15import org.junit.runners.Parameterized;
16import org.junit.runners.Parameterized.Parameters;
17
18import com.fasterxml.jackson.databind.ObjectMapper;
19
20import geniusweb.protocol.NegoSettings;
21import tudelft.utilities.logging.ReportToLogger;
22import tudelft.utilities.logging.Reporter;
23
24/**
25 * E2E test doing a full real run of a session with real agents and protocol.
26 * NOTICE This will exercise a full system to errors here may point far outside
27 * this module.
28 */
29@RunWith(Parameterized.class)
30public class SessionRunnerE2ETest {
31 private static final int TEST_RUNTIME = 5000;
32 private final ObjectMapper jackson = new ObjectMapper();
33 private NegoRunner runner;
34 private Reporter logger = new ReportToLogger("test");
35 private String filename;
36
37 @Parameters
38 public static Collection<Object[]> data() {
39 return Arrays
40 .asList(new Object[][] { { "src/test/resources/settings.json" },
41 { "src/test/resources/settings2.json" },
42 { "src/test/resources/shaoptoursettings.json" },
43 { "src/test/resources/mopac.json" },
44 { "src/test/resources/tournament.json" } });
45 }
46
47 public SessionRunnerE2ETest(String file) {
48 this.filename = file;
49 }
50
51 @Before
52 public void before() throws IOException {
53 System.out.println("Running from file " + filename);
54 String serialized = new String(Files.readAllBytes(Paths.get(filename)),
55 StandardCharsets.UTF_8);
56 NegoSettings settings = jackson.readValue(serialized,
57 NegoSettings.class);
58
59 runner = new NegoRunner(settings, new ClassPathConnectionFactory(),
60 logger, TEST_RUNTIME);
61
62 }
63
64 @Test
65 public void smokeTest() throws IOException {
66 }
67
68 @Test
69 public void runTest() throws IOException {
70 runner.run();
71 assertTrue(runner.isProperlyStopped());
72 System.out.println("Final state:\n" + runner.getProtocol().getState());
73 }
74
75 @Test
76 public void runTestMainFunction() throws IOException {
77 NegoRunner.main(new String[] { filename });
78 }
79}
Note: See TracBrowser for help on using the repository browser.