1 | package geniusweb.simplerunner;
|
---|
2 |
|
---|
3 | import java.io.IOException;
|
---|
4 | import java.nio.charset.StandardCharsets;
|
---|
5 | import java.nio.file.Files;
|
---|
6 | import java.nio.file.Paths;
|
---|
7 | import java.util.Arrays;
|
---|
8 | import java.util.Collection;
|
---|
9 |
|
---|
10 | import org.junit.Before;
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.junit.runner.RunWith;
|
---|
13 | import org.junit.runners.Parameterized;
|
---|
14 | import org.junit.runners.Parameterized.Parameters;
|
---|
15 |
|
---|
16 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
17 |
|
---|
18 | import geniusweb.protocol.session.SessionSettings;
|
---|
19 | import tudelft.utilities.logging.ReportToLogger;
|
---|
20 | import tudelft.utilities.logging.Reporter;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * E2E test doing a full real run of a session with real agents and protocol.
|
---|
24 | * NOTICE This will exercise a full system to errors here may point far outside
|
---|
25 | * this module.
|
---|
26 | */
|
---|
27 | @RunWith(Parameterized.class)
|
---|
28 | public class SessionRunnerE2ETest {
|
---|
29 | private final ObjectMapper jackson = new ObjectMapper();
|
---|
30 | private NegoRunner runner;
|
---|
31 | private Reporter logger = new ReportToLogger("test");
|
---|
32 | private String filename;
|
---|
33 |
|
---|
34 | @Parameters
|
---|
35 | public static Collection<Object[]> data() {
|
---|
36 | return Arrays.asList(
|
---|
37 | new Object[][] { { "src/test/resources/settings.json" }, { "src/test/resources/settings2.json" } });
|
---|
38 | }
|
---|
39 |
|
---|
40 | public SessionRunnerE2ETest(String file) {
|
---|
41 | this.filename = file;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Before
|
---|
45 | public void before() throws IOException {
|
---|
46 | String serialized = new String(Files.readAllBytes(Paths.get(filename)), StandardCharsets.UTF_8);
|
---|
47 | SessionSettings settings = jackson.readValue(serialized, SessionSettings.class);
|
---|
48 |
|
---|
49 | runner = new NegoRunner(settings, new ClassPathConnectionFactory(), logger);
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Test
|
---|
54 | public void smokeTest() throws IOException {
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Test
|
---|
58 | public void runTest() throws IOException {
|
---|
59 | runner.run();
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Test
|
---|
63 | public void runTestMainFunction() throws IOException {
|
---|
64 | NegoRunner.main(new String[] { filename });
|
---|
65 | }
|
---|
66 | }
|
---|