source: references/src/test/java/geniusweb/references/PartyRefTest.java@ 43

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

Added python timedependent parties (conceder, hardliner, etc)

File size: 2.0 KB
RevLine 
[43]1package geniusweb.references;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.net.URI;
7import java.net.URISyntaxException;
8import java.util.Arrays;
9import java.util.List;
10
11import org.junit.Before;
12import org.junit.Test;
13
14import com.fasterxml.jackson.core.JsonParseException;
15import com.fasterxml.jackson.core.JsonProcessingException;
16import com.fasterxml.jackson.databind.JsonMappingException;
17import com.fasterxml.jackson.databind.ObjectMapper;
18
19import geniusweb.references.PartyRef;
20import tudelft.utilities.junit.GeneralTests;
21
22public class PartyRefTest extends GeneralTests<PartyRef> {
23
24 private PartyRef party1, party1a, party2, party3;
25 private String asJson = "\"ws:localhost/party1\"";
26
27 @Before
28 public void before() throws URISyntaxException {
29 party1 = new PartyRef(new URI("ws:localhost/party1"));
30 party1a = new PartyRef(new URI("ws:localhost/party1"));
31 party2 = new PartyRef(new URI("ws:localhost/party2"));
32 party3 = new PartyRef(new URI("http:localhost/party3"));
33
34 }
35
36 @Override
37 public List<List<PartyRef>> getGeneralTestData() {
38 return Arrays.asList(Arrays.asList(party1, party1a),
39 Arrays.asList(party2), Arrays.asList(party3));
40 }
41
42 @Override
43 public List<String> getGeneralTestStrings() {
44 return Arrays.asList("PartyRef.*party1.*", "PartyRef.*party2.*",
45 "PartyRef.*party3.*");
46 }
47
48 @Test
49 public void smokeTest() throws URISyntaxException {
50 new PartyRef(new URI("ws:localhost"));
51 }
52
53 @Test(expected = IllegalArgumentException.class)
54 public void nullTest() throws URISyntaxException {
55 new PartyRef((URI) null);
56 }
57
58 @Test
59 public void testSerialize() throws JsonProcessingException {
60 ObjectMapper jackson = new ObjectMapper();
61
62 String json = jackson.writeValueAsString(party1);
63 System.out.println(json);
64 assertEquals(asJson, json);
65 }
66
67 @Test
68 public void testDeserialize()
69 throws JsonParseException, JsonMappingException, IOException {
70 ObjectMapper jackson = new ObjectMapper();
71 PartyRef p = jackson.readValue(asJson, PartyRef.class);
72 System.out.println(p);
73 assertEquals(party1, p);
74 }
75
76}
Note: See TracBrowser for help on using the repository browser.