View Javadoc

1   package io.atlassian.fugue;
2   
3   import org.junit.Test;
4   
5   import java.io.IOException;
6   import java.io.NotSerializableException;
7   
8   import static io.atlassian.fugue.Serializer.toBytes;
9   import static io.atlassian.fugue.Serializer.toObject;
10  import static org.hamcrest.Matchers.equalTo;
11  import static org.junit.Assert.assertThat;
12  
13  public class PairSerializationTest {
14    @Test public void serialize() throws IOException {
15      final Pair<Integer, Integer> pair = Pair.pair(1, 2);
16      assertThat(Serializer.<Pair<Integer, Integer>> toObject(toBytes(pair)), equalTo(pair));
17    }
18  
19    @Test(expected = NotSerializableException.class) public void serializeWithNonSerializableLeft() throws IOException {
20      toObject(toBytes(Pair.pair(Serializer.Unserializable.instance(), 2)));
21    }
22  
23    @Test(expected = NotSerializableException.class) public void serializeWithNonSerializableRight() throws IOException {
24      toObject(toBytes(Pair.pair(1, Serializer.Unserializable.instance())));
25    }
26  }