|
From: David S. <sa...@mi...> - 2007-09-12 03:27:22
|
Hello, all.
I'm trying to understand the Buffer classes and how they work. Why
does a readonly View on a Buffer allows poking? Here's a test I'd
expect to either pass, or fail when poke() is called:
@Test
public void compactView() {
ByteArrayBuffer buffer = new ByteArrayBuffer("abc".getBytes(), 0, 3,
Buffer.READWRITE);
doEvilThings(buffer.asReadOnlyBuffer());
assertEquals("abc", buffer.toString());
}
private void doEvilThings(Buffer immutable) {
immutable.poke(2, new ByteArrayBuffer("d"));
}
Instead, it fails on the assertion:
org.junit.ComparisonFailure: expected:<ab[c]> but was:<ab[d]>
at org.junit.Assert.assertEquals(Assert.java:99)
at org.junit.Assert.assertEquals(Assert.java:117)
at net.saff.jetty.theories.BufferTheories.compactView(BufferTheories.java:90)
Is this intentional, because I'm misunderstanding what "readonly"
means? Thanks,
David Saff
|