Trustin,
Thanks for the fix.
It seems that there is some problem is fix -- I tried in same way few
days ago and while I ran JUnit test case, it is failing. I had used
same lines( as in the fix submitted). I am using Sun JDK 1.5.0_06.
Here is my JUNit test case for this:
Sorry for not intimating you earlier, as I was busy. I tried to debug
the issue, but could not get time, so I thought that I would fix it
later and submit to you later.
Here is JUnit test code:
---------------------------------------------------------------------------------
diff -r 1de4311bf6d4 -r 829764d00d6a
core/src/test/java/org/apache/mina/common/ByteBufferTest.java
--- a/core/src/test/java/org/apache/mina/common/ByteBufferTest.java Sun
Jun 11 22:27:35 2006 +0530
+++ b/core/src/test/java/org/apache/mina/common/ByteBufferTest.java Sun
Jun 11 23:36:20 2006 +0530
@@ -778,4 +778,44 @@ public class ByteBufferTest extends Test
// OK
}
}
+
+ public void testArray() throws Exception
+ {
+ final int SIZE=16;
+ ByteBuffer buf = ByteBuffer.allocate(SIZE);
+ for(int i=0;i<SIZE;i++){
+ buf.put((byte)i);
+ }
+
+ byte[] backingBuffer = buf.array();
+ for(int i=0;i<SIZE;i++){
+ int c=buf.get(i);
+ assertEquals(c,i);
+ }
+
+ }
+
+ public void testArrayOffset() throws Exception
+ {
+ final int SIZE=16;
+ ByteBuffer buf = ByteBuffer.allocate(SIZE);
+ for(int i=0;i<SIZE;i++){
+ buf.put((byte)i);
+ }
+
+ int offset = buf.arrayOffset();
+ assertEquals(offset,0);
+
+ byte[] array = new byte[SIZE];
+ int OFFSET = 5;
+ int len = SIZE-OFFSET;
+ ByteBuffer buf2 = ByteBuffer.wrap(array,OFFSET,len);
+ for(int i=0;i<len;i++){
+ buf2.put((byte)i);
+ }
+
+ offset = buf2.arrayOffset();
+ assertEquals(offset,OFFSET);
+ }
+
}
----------------------------------------------------------------------
Here is JUNIT error report:
X:\opt\java\mina-0.9.4>java -classpath x:\opt\jar\junit.jar;x:\opt\java\mina-0.9
.4\core\target\classes\;x:\opt\java\mina-0.9.4\core\target\test-classes org.apac
he.mina.common.ByteBufferTest
........................E.E
Time: 4.953
There were 2 errors:
1) testArray(org.apache.mina.common.ByteBufferTest)java.lang.UnsupportedOperatio
nException
at java.nio.ByteBuffer.array(ByteBuffer.java:939)
at org.apache.mina.common.PooledByteBufferAllocator$PooledByteBuffer.arr
ay(PooledByteBufferAllocator.java:815)
at org.apache.mina.common.ByteBufferTest.testArray(ByteBufferTest.java:7
90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at org.apache.mina.common.ByteBufferTest.main(ByteBufferTest.java:45)
2) testArrayOffset(org.apache.mina.common.ByteBufferTest)java.lang.UnsupportedOp
erationException
at java.nio.ByteBuffer.arrayOffset(ByteBuffer.java:967)
at org.apache.mina.common.PooledByteBufferAllocator$PooledByteBuffer.arr
ayOffset(PooledByteBufferAllocator.java:820)
at org.apache.mina.common.ByteBufferTest.testArrayOffset(ByteBufferTest.
java:806)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at org.apache.mina.common.ByteBufferTest.main(ByteBufferTest.java:45)
FAILURES!!!
Tests run: 25, Failures: 0, Errors: 2
---------------------------------------------------------------------
thanks & regards
mahadevan
On 6/26/06, Trustin Lee (JIRA) <[EMAIL PROTECTED]> wrote:
[ http://issues.apache.org/jira/browse/DIRMINA-220?page=all ]
Trustin Lee closed DIRMINA-220:
-------------------------------
Resolution: Fixed
Assign To: Trustin Lee
Fixed.
> ByteBuffer.array() and ByteBuffer.arrayOffset()
> -----------------------------------------------
>
> Key: DIRMINA-220
> URL: http://issues.apache.org/jira/browse/DIRMINA-220
> Project: Directory MINA
> Type: New Feature
> Reporter: Trustin Lee
> Assignee: Trustin Lee
> Fix For: 0.9.5
>
> G.S.S. Mahadevan reported that these two methods are missing in our
ByteBuffer class.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira