1 package com.atlassian.vcache.marshallers;
2
3 import com.atlassian.vcache.MarshallerException;
4
5 import org.junit.Test;
6
7 import static org.hamcrest.CoreMatchers.equalTo;
8 import static org.hamcrest.CoreMatchers.notNullValue;
9 import static org.junit.Assert.assertThat;
10
11 public class StringMarshallerTest
12 {
13
14 @Test(expected = MarshallerException.class)
15 public void testIllegalString() throws MarshallerException
16 {
17 final StringMarshaller sm = new StringMarshaller();
18 final String instr = "Illegal string because of unicode character -> \uD800";
19 final byte[] raw = sm.marshall(instr);
20 }
21
22 @Test
23 public void testLegalString() throws MarshallerException
24 {
25 final StringMarshaller sm = new StringMarshaller();
26 final String instr = "Josie likes Football";
27 final byte[] raw = sm.marshall(instr);
28
29 assertThat(raw, notNullValue());
30
31 final String outstr = sm.unmarshall(raw);
32
33 assertThat(outstr, notNullValue());
34 assertThat(outstr, equalTo(instr));
35 }
36 }