HashTypeAdaptor extends XmlAdapter<String, HashType> { @Override public HashType unmarshal(String str) throws Exception { return HashType.valueOf(str.toUpperCase()); }  @Override HashType unmarshal(String str); @Override String marshal(HashType hashType);  }
@Test public void returnsAValidHashTypeWithLowerCaseText() throws Exception { HashTypeAdaptor hashTypeAdaptor = new HashTypeAdaptor(); assertThat(hashTypeAdaptor.unmarshal("sha1"), is(equalTo(HashType.SHA1))); }
@Test public void returnsAValidHashTypeWithUpperCaseText() throws Exception { HashTypeAdaptor hashTypeAdaptor = new HashTypeAdaptor(); assertThat(hashTypeAdaptor.unmarshal("SHA1"), is(equalTo(HashType.SHA1))); }
@Test(expected = IllegalArgumentException.class) public void throwsAnIllegalArgumentExceptionIfHashTypeIsInvalid() throws Exception { HashTypeAdaptor hashTypeAdaptor = new HashTypeAdaptor(); hashTypeAdaptor.unmarshal("FOO"); }