source: protocol/src/test/java/geniusweb/protocol/ProtocolExceptionTest.java@ 44

Last change on this file since 44 was 44, checked in by bart, 2 years ago

Added time-dependent parties for python and simpleRunner-GUI for java

File size: 1.4 KB
Line 
1package geniusweb.protocol;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6
7import org.junit.Before;
8import org.junit.Ignore;
9import org.junit.Test;
10
11import com.fasterxml.jackson.core.JsonProcessingException;
12import com.fasterxml.jackson.databind.ObjectMapper;
13import com.fasterxml.jackson.databind.util.ObjectBuffer;
14
15import geniusweb.actions.PartyId;
16
17public class ProtocolExceptionTest {
18 private ObjectBuffer jackson = new ObjectBuffer();
19 private Exception exception;
20 private String asString1 = "{\"cause\":null,\"stackTrace\":[],\"party\":\"party1\",\"message\":\"party1:test\",\"localizedMessage\":\"party1:test\",\"suppressed\":[]}";
21
22 @Before
23 public void before() {
24 try {
25 throw new ProtocolException("test", new PartyId("party1"));
26 // int x = 1 / 0;
27 } catch (Exception e) {
28 this.exception = e;
29 System.out.println(e);
30 }
31 }
32
33 @Test
34 public void testSerialize() throws JsonProcessingException {
35
36 ObjectMapper jackson = new ObjectMapper();
37 System.out.println(jackson.writeValueAsString(exception));
38 assertEquals(asString1, jackson.writeValueAsString(exception));
39
40 }
41
42 // ProtocolExceptions can not be deserialized now
43 @Ignore
44 @Test
45 public void testDeserialize() throws IOException {
46
47 ObjectMapper jackson = new ObjectMapper();
48 Exception read = jackson.readValue(asString1, ProtocolException.class);
49 assertEquals(exception, read);
50 }
51
52}
Note: See TracBrowser for help on using the repository browser.