@Test
  public void testDefaultMethodForEncryptDecrypt() throws Exception {
    CryptoService<SecretKeySpec> cryptoService = new MockCryptoService();
    String key = ((MockCryptoService) cryptoService).getKey();
    SecretKeySpec secretKeySpec = new SecretKeySpec(Hex.decode(key), "AES");
    for (int i = 0; i < 5; i++) {
      ByteBuf toEncryptByteBuf = createByteBuf();
      ByteBuffer toEncrypt = fromByteBufToByteBuffer(toEncryptByteBuf);
      ByteBuf encryptedBytesByteBuf = cryptoService.encrypt(toEncryptByteBuf, secretKeySpec);
      ByteBuffer encryptedBytes = cryptoService.encrypt(toEncrypt, secretKeySpec);

      Assert.assertTrue(encryptedBytesByteBuf.hasArray());
      Assert.assertEquals(encryptedBytes.remaining(), encryptedBytesByteBuf.readableBytes());
      Assert.assertEquals(toEncryptByteBuf.readableBytes(), 0);
      Assert.assertEquals(toEncrypt.remaining(), 0);
      byte[] arrayFromByteBuf = new byte[encryptedBytesByteBuf.readableBytes()];
      encryptedBytesByteBuf.getBytes(encryptedBytesByteBuf.readerIndex(), arrayFromByteBuf);
      Assert.assertArrayEquals(encryptedBytes.array(), arrayFromByteBuf);

      ByteBuf toDecryptByteBuf = maybeConvertToComposite(encryptedBytesByteBuf);
      ByteBuffer toDecrypt = encryptedBytes;
      ByteBuf decryptedBytesByteBuf = cryptoService.decrypt(toDecryptByteBuf, secretKeySpec);
      ByteBuffer decryptedBytes = cryptoService.decrypt(encryptedBytes, secretKeySpec);

      Assert.assertTrue(decryptedBytesByteBuf.hasArray());
      Assert.assertEquals(decryptedBytes.remaining(), decryptedBytesByteBuf.readableBytes());
      Assert.assertEquals(toDecryptByteBuf.readableBytes(), 0);
      Assert.assertEquals(toDecrypt.remaining(), 0);
      arrayFromByteBuf = new byte[decryptedBytesByteBuf.readableBytes()];
      decryptedBytesByteBuf.getBytes(decryptedBytesByteBuf.readerIndex(), arrayFromByteBuf);
      Assert.assertArrayEquals(decryptedBytes.array(), arrayFromByteBuf);

      toEncryptByteBuf.release();
      encryptedBytesByteBuf.release();
      toDecryptByteBuf.release();
      decryptedBytesByteBuf.release();
    }
  }
Test the default methods for those implementations that don't implement the default methods.
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/CryptoServiceTest.java