View Javadoc

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