@Test public void testReadOnly() { GuardedByteArray bytes = new GuardedByteArray(new byte[] { 0x00, 0x01, 0x02 }); assertFalse(bytes.isReadOnly()); bytes.makeReadOnly(); assertTrue(bytes.isReadOnly()); assertTrue(Arrays.equals(new byte[] { 0x00, 0x01, 0x02 }, decryptToBytes(bytes))); try { bytes.appendByte((byte) 0x03); fail("expected exception"); } catch (IllegalStateException e) { /* ignore */ } bytes = bytes.copy(); assertTrue(Arrays.equals(new byte[] { 0x00, 0x01, 0x02 }, decryptToBytes(bytes))); bytes.appendByte((byte) 0x03); assertTrue(Arrays.equals(new byte[] { 0x00, 0x01, 0x02, 0x03 }, decryptToBytes(bytes))); }
str.isReadOnly(); fail("expected exception"); } catch (IllegalStateException e) {