java_src/src/test/java/com/google/crypto/tink/KeysetHandleTest.java
/** Tests that when encryption failed an exception is thrown. */
Tests that when encryption failed an exception is thrown.
Tests that when encryption failed an exception is thrown .
@Test
  public void write_withFaultyAead_shouldThrow() throws Exception {
    KeysetHandle handle = KeysetHandle.generateNew(KeyTemplates.get("HMAC_SHA256_256BITTAG"));
    TestUtil.DummyAead faultyAead = new TestUtil.DummyAead();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    KeysetWriter writer = BinaryKeysetWriter.withOutputStream(outputStream);
    assertThrows(GeneralSecurityException.class, () -> handle.write(writer, faultyAead));
  }
@ Test public void write_withFaultyAead_shouldThrow ( ) throws Exception { KeysetHandle handle = KeysetHandle . generateNew ( KeyTemplates . get ( "HMAC_SHA256_256BITTAG" ) ) ; TestUtil . DummyAead faultyAead = new TestUtil . DummyAead ( ) ; ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; KeysetWriter writer = BinaryKeysetWriter . withOutputStream ( outputStream ) ; assertThrows ( GeneralSecurityException . class , ( ) -> handle . write ( writer , faultyAead ) ) ; }
Tests that when encryption failed an exception is thrown.
Tests that when encryption failed an exception is thrown .