EncryptingSerializerDeserializer implements SerializerDeserializer { void initKey(String key) { try { byte[] keyArray = key.getBytes("UTF-8"); MessageDigest sha = MessageDigest.getInstance("SHA-256"); keyArray = sha.digest(keyArray); keyArray = Arrays.copyOf(keyArray, 16); secretKey = new SecretKeySpec(keyArray, "AES"); } catch (Exception e) { throw new IllegalStateException(e); } } EncryptingSerializerDeserializer();  EncryptingSerializerDeserializer(SerializerDeserializer wrapped); @Override byte[] serialize(Object value); @Override Object deserialize(byte[] data); @Override void setSessionManager(SessionManager sessionManager);  }
@Test public void testBadKey() { EncryptingSerializerDeserializer serializer = new EncryptingSerializerDeserializer(); exception.expectCause(isA(NullPointerException.class)); serializer.initKey(null); }