@Test
  public void getLegacyPrimitive_usesRegistryWhenNoConfigurationProvided()
      throws Exception {
    KeysetHandle keysetHandle =
        KeysetHandle.newBuilder()
            .addEntry(KeysetHandle.importKey(rawKey).withRandomId().makePrimary())
            .build();
    KeyData rawKeyData =
        KeyData.newBuilder()
            .setValue(
                com.google.crypto.tink.proto.HmacKey.newBuilder()
                    .setParams(
                        HmacParams.newBuilder()
                            .setHash(com.google.crypto.tink.proto.HashType.SHA256)
                            .setTagSize(HMAC_TAG_SIZE)
                            .build())
                    .setKeyValue(
                        ByteString.copyFrom(
                            rawKey.getKeyBytes().toByteArray(InsecureSecretKeyAccess.get())))
                    .build()
                    .toByteString())
            .setTypeUrl(keysetHandle.getKeysetInfo().getKeyInfo(0).getTypeUrl())
            .setKeyMaterialType(KeyMaterialType.SYMMETRIC)
            .build();

    byte[] plaintext = "plaintext".getBytes(UTF_8);

    Mac registryMac = Registry.getPrimitive(rawKeyData, Mac.class);
    Mac keysetHandleMac = keysetHandle.getPrimitive(Mac.class);

    assertThat(keysetHandleMac.computeMac(plaintext)).isEqualTo(registryMac.computeMac(plaintext));
  }
Tests that key parsing via the serialization registry works as expected.

<p>NOTE: This adds a parser to the MutableSerializationRegistry, which no other test uses.
java_src/src/test/java/com/google/crypto/tink/KeysetHandleTest.java