@Test
public void newKey_MessageLite_throwsInvalidKeySize() throws Exception {

  KeyManager<Aead> keyManager = new KeyManagerImpl<>(new TestKeyTypeManager(), Aead.class);
  try {
    // Note: newKey expects AesGcmKeyFormat, not AesGcmKey.
    keyManager.newKey((MessageLite) AesGcmKeyFormat.getDefaultInstance());
    fail("expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertThat(e.toString()).contains("validateKeyFormat(AesGcmKeyFormat) failed");
  }
}