CertificateAdapter extends XmlAdapter<String, Certificate> { @Override public Certificate unmarshal(String v) throws Exception { Certificate cert = Certificate.parse(new ByteArrayInputStream(ArrayConverter.hexStringToByteArray(v.replaceAll( "\\s+", "")))); return cert; }  @Override Certificate unmarshal(String v); @Override String marshal(Certificate v);  }
@Test(expected = Exception.class) public void testUnmarshalException() throws Exception { certificateAdapter.unmarshal("Not a certificate String."); }