harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r421233 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/java/nio/ test/java/common/org/apache/harmony/tests/java/nio/
Date Wed, 12 Jul 2006 11:03:04 GMT
Author: gharley
Date: Wed Jul 12 04:03:03 2006
New Revision: 421233

URL: http://svn.apache.org/viewvc?rev=421233&view=rev
Log:
HARMONY 822 : [nio] refactor nio buffer test step 5 - IntBuffer tests

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntArrayBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/IntBufferTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntArrayBuffer.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntArrayBuffer.java Wed Jul 12 04:03:03 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,7 +64,8 @@
 	}
 
     public final IntBuffer get(int[] dest, int off, int len) {
-        if (off < 0 || len < 0 || len + off > dest.length) {
+        int length = dest.length;
+        if (off < 0 || len < 0 || (long)len + (long)off > length) {
             throw new IndexOutOfBoundsException();
         }       
         if (len > remaining()) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java Wed Jul 12 04:03:03 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -305,7 +305,8 @@
 	 *                <code>remaining()</code>
 	 */
 	public IntBuffer get(int[] dest, int off, int len) {
-        if (off < 0 || len < 0 || (long)len + (long)off > dest.length) {
+        int length = dest.length;
+        if (off < 0 || len < 0 || (long)len + (long)off > length) {
             throw new IndexOutOfBoundsException();
         }
 		if (len > remaining()) {
@@ -462,7 +463,8 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public IntBuffer put(int[] src, int off, int len) {
-        if (off < 0 || len < 0 || (long)len + (long)off > src.length) {
+        int length = src.length;
+        if (off < 0 || len < 0 || (long)len + (long)off > length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java Wed Jul 12 04:03:03 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,6 +79,10 @@
 	public IntBuffer put(int index, int c) {
 		throw new ReadOnlyBufferException();
 	}
+    
+    public IntBuffer put(IntBuffer buf) {
+        throw new ReadOnlyBufferException();
+    }
 
     public final IntBuffer put(int[] src, int off, int len) {
         throw new ReadOnlyBufferException();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java Wed Jul 12 04:03:03 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -101,7 +101,8 @@
 	}
 
     public IntBuffer put(int[] src, int off, int len) {
-        if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
+        int length = src.length;
+        if (off < 0 || len < 0 || (long)off + (long)len > length) {
             throw new IndexOutOfBoundsException();
         }
         if (len > remaining()) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/AllTests.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/AllTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/AllTests.java Wed Jul 12 04:03:03 2006
@@ -31,50 +31,56 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("Tests for java.nio");
         //$JUnit-BEGIN$
-        suite.addTestSuite(ByteBufferTest.class);
         suite.addTestSuite(BufferOverflowExceptionTest.class);
-        suite.addTestSuite(ReadOnlyDirectByteBufferTest.class);
-        suite.addTestSuite(ReadOnlyBufferExceptionTest.class);
-        suite.addTestSuite(ReadOnlyHeapDoubleBufferTest.class);
         suite.addTestSuite(CharBufferTest.class);
-        suite.addTestSuite(DoubleBufferTest.class);
-        suite.addTestSuite(ReadOnlyWrappedFloatBufferTest.class);
+        suite.addTestSuite(ReadOnlyHeapIntBufferTest.class);
+        suite.addTestSuite(HeapIntBufferTest.class);
         suite.addTestSuite(WrappedDoubleBufferTest.class);
         suite.addTestSuite(WrappedCharBufferTest2.class);
-        suite.addTestSuite(ReadOnlyFloatBufferTest.class);
         suite.addTestSuite(ByteOrderTest.class);
+        suite.addTestSuite(ReadOnlyFloatBufferTest.class);
         suite.addTestSuite(WrappedFloatBufferTest.class);
-        suite.addTestSuite(ShortBufferTest.class);
-        suite.addTestSuite(DirectFloatBufferTest.class);
-        suite.addTestSuite(BufferTest.class);
         suite.addTestSuite(ReadOnlyWrappedByteBufferTest.class);
-        suite.addTestSuite(SliceWrappedByteBufferTest.class);
-        suite.addTestSuite(DirectCharBufferTest.class);
-        suite.addTestSuite(SliceDirectByteBufferTest.class);
         suite.addTestSuite(HeapFloatBufferTest.class);
         suite.addTestSuite(WrappedCharBufferTest1.class);
-        suite.addTestSuite(ReadOnlyWrappedDoubleBufferTest.class);
-        suite.addTestSuite(HeapByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyWrappedIntBufferTest.class);
         suite.addTestSuite(AbstractBufferTest.class);
         suite.addTestSuite(ReadOnlyCharBufferTest.class);
-        suite.addTestSuite(DuplicateHeapByteBufferTest.class);
         suite.addTestSuite(SliceHeapByteBufferTest.class);
+        suite.addTestSuite(LongBufferTest.class);
+        suite.addTestSuite(DuplicateWrappedByteBufferTest.class);
+        suite.addTestSuite(FloatBufferTest.class);
+        suite.addTestSuite(ReadOnlyHeapCharBufferTest.class);
+        suite.addTestSuite(ByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyBufferExceptionTest.class);
+        suite.addTestSuite(ReadOnlyDirectByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyHeapDoubleBufferTest.class);
+        suite.addTestSuite(DoubleBufferTest.class);
+        suite.addTestSuite(ReadOnlyWrappedFloatBufferTest.class);
+        suite.addTestSuite(BufferTest.class);
+        suite.addTestSuite(DirectFloatBufferTest.class);
+        suite.addTestSuite(ShortBufferTest.class);
+        suite.addTestSuite(SliceWrappedByteBufferTest.class);
+        suite.addTestSuite(DirectCharBufferTest.class);
+        suite.addTestSuite(SliceDirectByteBufferTest.class);
+        suite.addTestSuite(DirectIntBufferTest.class);
+        suite.addTestSuite(HeapByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyWrappedDoubleBufferTest.class);
+        suite.addTestSuite(DuplicateHeapByteBufferTest.class);
         suite.addTestSuite(InvalidMarkExceptionTest.class);
         suite.addTestSuite(DirectDoubleBufferTest.class);
         suite.addTestSuite(ReadOnlyHeapByteBufferTest.class);
-        suite.addTestSuite(LongBufferTest.class);
-        suite.addTestSuite(DuplicateWrappedByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyIntBufferTest.class);
         suite.addTestSuite(HeapDoubleBufferTest.class);
         suite.addTestSuite(DirectByteBufferTest.class);
         suite.addTestSuite(ReadOnlyWrappedCharBufferTest1.class);
-        suite.addTestSuite(ReadOnlyDoubleBufferTest.class);
-        suite.addTestSuite(FloatBufferTest.class);
         suite.addTestSuite(IntBufferTest.class);
-        suite.addTestSuite(ReadOnlyHeapCharBufferTest.class);
+        suite.addTestSuite(ReadOnlyDoubleBufferTest.class);
         suite.addTestSuite(ReadOnlyHeapFloatBufferTest.class);
-        suite.addTestSuite(WrappedByteBufferTest.class);
         suite.addTestSuite(BufferUnderflowExceptionTest.class);
+        suite.addTestSuite(WrappedByteBufferTest.class);
         suite.addTestSuite(DuplicateDirectByteBufferTest.class);
+        suite.addTestSuite(WrappedIntBufferTest.class);
         suite.addTestSuite(HeapCharBufferTest.class);
         //$JUnit-END$
         return suite;

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,60 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class DirectIntBufferTest extends IntBufferTest {
+    public void setUp(){
+        buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asIntBuffer();
+        loadTestData1(buf);
+        baseBuf = buf;
+    }
+    
+    public void tearDown(){
+        buf = null;
+        baseBuf = null;
+    }
+    
+    public void testHasArray() {
+        assertFalse(buf.hasArray());
+    }
+
+    public void testArray() {
+        try {
+            buf.array();
+            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
+        } catch (UnsupportedOperationException e) {
+        }
+    }
+    
+    public void testArrayOffset() {
+        try {
+            buf.arrayOffset();
+            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
+        } catch (UnsupportedOperationException e) {
+            //expected
+        }
+    }
+
+    public void testIsDirect() {
+        assertTrue(buf.isDirect());
+    }
+    
+    public void testOrder() {
+        assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,41 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.IntBuffer;
+
+public class HeapIntBufferTest extends IntBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = IntBuffer.allocate(BUFFER_LENGTH); 
+        loadTestData1(buf);
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        buf = null;
+        baseBuf = null;
+    }
+    
+    public void testAllocatedIntBuffer_IllegalArg() {
+        try {
+            IntBuffer.allocate(-1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/IntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/IntBufferTest.java?rev=421233&r1=421232&r2=421233&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/IntBufferTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/IntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -17,130 +17,69 @@
 
 import java.nio.BufferOverflowException;
 import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.IntBuffer;
 import java.nio.InvalidMarkException;
-import java.nio.ReadOnlyBufferException;
-
-import junit.framework.TestCase;
 
 /**
  * Tests java.nio.IntBuffer
  * 
  */
-public class IntBufferTest extends TestCase {
+public class IntBufferTest extends AbstractBufferTest {
+    
+    
+    protected static final int SMALL_TEST_LENGTH = 5;
+
+    protected static final int BUFFER_LENGTH = 20;
+
+    protected IntBuffer buf;
 
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(IntBufferTest.class);
+    protected void setUp() throws Exception {
+        buf = IntBuffer.allocate(BUFFER_LENGTH);
+        loadTestData1(buf);
+        baseBuf = buf;
     }
 
-    public static void testIntBufferInstance(IntBuffer buf) {
-        // test Buffer functions
-        BufferTest.testBufferInstance(buf);
-
-        // test IntBuffer functions
-        testHashCode(buf);
-        testEquals(buf);
-        testToString(buf);
-        testSlice(buf);
-        testDuplicate(buf);
-        testAsReadOnlyBuffer(buf);
-        testGet(buf);
-        testPutint(buf);
-        testGetint(buf);
-        testPutintint(buf);
-        testGetintArrayintint(buf);
-        testGetintArray(buf);
-        testPutIntBuffer(buf);
-        testPutintArrayintint(buf);
-        testPutintArray(buf);
-        testHasArray(buf);
-        testArray(buf);
-        testArrayOffset(buf);
-        testCompact(buf);
-        testIsDirect(buf);
-        testCompareTo(buf);
-        testOrder(buf);
-    }
-
-    public static void testArray(IntBuffer buf) {
-        if (buf.hasArray()) {
-            int array[] = buf.array();
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+    protected void tearDown() throws Exception {
+        buf = null;
+        baseBuf = null;
+    }
 
-            loadTestData1(array, buf.arrayOffset(), buf.capacity());
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+    public void testArray() {
+        int array[] = buf.array();
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData2(array, buf.arrayOffset(), buf.capacity());
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+        loadTestData1(array, buf.arrayOffset(), buf.capacity());
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData1(buf);
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+        loadTestData2(array, buf.arrayOffset(), buf.capacity());
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData2(buf);
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-        } else {
-            if (buf.isReadOnly()) {
-                try {
-                    buf.array();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                    // Note:can not tell when to throw 
-                    // UnsupportedOperationException
-                    // or ReadOnlyBufferException, so catch all.
-                }
-            } else {
-                try {
-                    buf.array();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                }
-            }
-        }
+        loadTestData1(buf);
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+
+        loadTestData2(buf);
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
     }
 
-    public static void testArrayOffset(IntBuffer buf) {
-        if (buf.hasArray()) {
-            int array[] = buf.array();
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+    public  void testArrayOffset() {
+        int array[] = buf.array();
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData1(array, buf.arrayOffset(), buf.capacity());
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+        loadTestData1(array, buf.arrayOffset(), buf.capacity());
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData2(array, buf.arrayOffset(), buf.capacity());
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+        loadTestData2(array, buf.arrayOffset(), buf.capacity());
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData1(buf);
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+        loadTestData1(buf);
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
 
-            loadTestData2(buf);
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-        } else {
-            if (buf.isReadOnly()) {
-                try {
-                    buf.arrayOffset();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                    // Note:can not tell when to throw 
-                    // UnsupportedOperationException
-                    // or ReadOnlyBufferException, so catch all.
-                }
-            } else {
-                try {
-                    buf.arrayOffset();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                }
-            }
-        }
-    }
+        loadTestData2(buf);
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+     }
 
-    public static void testAsReadOnlyBuffer(IntBuffer buf) {
+    public  void testAsReadOnlyBuffer() {
         buf.clear();
         buf.mark();
         buf.position(buf.limit());
@@ -164,17 +103,7 @@
         assertEquals(buf.position(), 0);
     }
 
-    public static void testCompact(IntBuffer buf) {
-        if (buf.isReadOnly()) {
-            try {
-                buf.compact();
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
+    public  void testCompact() {
         // case: buffer is full
         buf.clear();
         buf.mark();
@@ -225,33 +154,30 @@
         }
     }
 
-    public static void testCompareTo(IntBuffer buf) {
+    public  void testCompareTo() {
         // compare to self
         assertEquals(0, buf.compareTo(buf));
 
         // normal cases
-        if (!buf.isReadOnly()) {
-            assertTrue(buf.capacity() > 5);
-            buf.clear();
-            IntBuffer other = IntBuffer.allocate(buf.capacity());
-            loadTestData1(buf);
-            loadTestData1(other);
-            assertEquals(0, buf.compareTo(other));
-            assertEquals(0, other.compareTo(buf));
-            buf.position(1);
-            assertTrue(buf.compareTo(other) > 0);
-            assertTrue(other.compareTo(buf) < 0);
-            other.position(2);
-            assertTrue(buf.compareTo(other) < 0);
-            assertTrue(other.compareTo(buf) > 0);
-            buf.position(2);
-            other.limit(5);
-            assertTrue(buf.compareTo(other) > 0);
-            assertTrue(other.compareTo(buf) < 0);
-        }
+        assertTrue(buf.capacity() > 5);
+        buf.clear();
+        IntBuffer other = IntBuffer.allocate(buf.capacity());
+        loadTestData1(other);
+        assertEquals(0, buf.compareTo(other));
+        assertEquals(0, other.compareTo(buf));
+        buf.position(1);
+        assertTrue(buf.compareTo(other) > 0);
+        assertTrue(other.compareTo(buf) < 0);
+        other.position(2);
+        assertTrue(buf.compareTo(other) < 0);
+        assertTrue(other.compareTo(buf) > 0);
+        buf.position(2);
+        other.limit(5);
+        assertTrue(buf.compareTo(other) > 0);
+        assertTrue(other.compareTo(buf) < 0);
     }
 
-    public static void testDuplicate(IntBuffer buf) {
+    public  void testDuplicate() {
         buf.clear();
         buf.mark();
         buf.position(buf.limit());
@@ -283,7 +209,7 @@
         }
     }
 
-    public static void testEquals(IntBuffer buf) {
+    public  void testEquals() {
         // equal to self
         assertTrue(buf.equals(buf));
         IntBuffer readonly = buf.asReadOnlyBuffer();
@@ -308,7 +234,7 @@
     /*
      * Class under test for int get()
      */
-    public static void testGet(IntBuffer buf) {
+    public  void testGet() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -325,7 +251,7 @@
     /*
      * Class under test for java.nio.IntBuffer get(int[])
      */
-    public static void testGetintArray(IntBuffer buf) {
+    public  void testGetintArray() {
         int array[] = new int[1];
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
@@ -340,12 +266,18 @@
         } catch (BufferUnderflowException e) {
             // expected
         }
+        try {
+            buf.get((int[])null);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     /*
      * Class under test for java.nio.IntBuffer get(int[], int, int)
      */
-    public static void testGetintArrayintint(IntBuffer buf) {
+    public  void testGetintArrayintint() {
         buf.clear();
         int array[] = new int[buf.capacity()];
 
@@ -377,11 +309,29 @@
             // expected
         }
         try {
+            buf.get((int[])null, 2, -1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
             buf.get(array, 2, array.length);
             fail("Should throw Exception"); //$NON-NLS-1$
         } catch (IndexOutOfBoundsException e) {
             // expected
         }
+        try {
+            buf.get(array, 1, Integer.MAX_VALUE);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            buf.get(array, Integer.MAX_VALUE, 1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
         assertEquals(buf.position(), 0);
 
         buf.clear();
@@ -394,7 +344,7 @@
     /*
      * Class under test for int get(int)
      */
-    public static void testGetint(IntBuffer buf) {
+    public  void testGetint() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -414,32 +364,11 @@
         }
     }
 
-    public static void testHasArray(IntBuffer buf) {
-        if (buf.hasArray()) {
-            assertNotNull(buf.array());
-        } else {
-            if (buf.isReadOnly()) {
-                try {
-                    buf.array();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                    // Note:can not tell when to throw 
-                    // UnsupportedOperationException
-                    // or ReadOnlyBufferException, so catch all.
-                }
-            } else {
-                try {
-                    buf.array();
-                    fail("Should throw Exception"); //$NON-NLS-1$
-                } catch (UnsupportedOperationException e) {
-                    // expected
-                }
-            }
-        }
+    public  void testHasArray() {
+        assertNotNull(buf.array());
     }
 
-    public static void testHashCode(IntBuffer buf) {
+    public  void testHashCode() {
         buf.clear();
         IntBuffer readonly = buf.asReadOnlyBuffer();
         IntBuffer duplicate = buf.duplicate();
@@ -450,32 +379,19 @@
         assertTrue(buf.hashCode() != duplicate.hashCode());
     }
 
-    public static void testIsDirect(IntBuffer buf) {
-        buf.isDirect();
+    public  void testIsDirect() {
+        assertFalse(buf.isDirect());
     }
 
-    public static void testOrder(IntBuffer buf) {
+    public  void testOrder() {
         buf.order();
-        if (buf.hasArray()) {
-            assertEquals(ByteOrder.nativeOrder(), buf.order());
-        }
+        assertEquals(ByteOrder.nativeOrder(), buf.order());
     }
 
     /*
      * Class under test for java.nio.IntBuffer put(int)
      */
-    public static void testPutint(IntBuffer buf) {
-        if (buf.isReadOnly()) {
-            try {
-                buf.clear();
-                buf.put(0);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
+    public  void testPutint() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -494,18 +410,8 @@
     /*
      * Class under test for java.nio.IntBuffer put(int[])
      */
-    public static void testPutintArray(IntBuffer buf) {
+    public  void testPutintArray() {
         int array[] = new int[1];
-        if (buf.isReadOnly()) {
-            try {
-                buf.put(array);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -520,24 +426,21 @@
         } catch (BufferOverflowException e) {
             // expected
         }
+        try {
+            buf.position(buf.limit());
+            buf.put((int[])null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     /*
      * Class under test for java.nio.IntBuffer put(int[], int, int)
      */
-    public static void testPutintArrayintint(IntBuffer buf) {
+    public  void testPutintArrayintint() {
         buf.clear();
         int array[] = new int[buf.capacity()];
-        if (buf.isReadOnly()) {
-            try {
-                buf.put(array, 0, array.length);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
         try {
             buf.put(new int[buf.capacity() + 1], 0, buf.capacity() + 1);
             fail("Should throw Exception"); //$NON-NLS-1$
@@ -566,11 +469,29 @@
             // expected
         }
         try {
+            buf.put((int[])null, 0, -1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
             buf.put(array, 2, array.length);
             fail("Should throw Exception"); //$NON-NLS-1$
         } catch (IndexOutOfBoundsException e) {
             // expected
         }
+        try {
+            buf.put(array, Integer.MAX_VALUE, 1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            buf.put(array, 1, Integer.MAX_VALUE);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
         assertEquals(buf.position(), 0);
 
         loadTestData2(array, 0, array.length);
@@ -583,19 +504,8 @@
     /*
      * Class under test for java.nio.IntBuffer put(java.nio.IntBuffer)
      */
-    public static void testPutIntBuffer(IntBuffer buf) {
+    public  void testPutIntBuffer() {
         IntBuffer other = IntBuffer.allocate(buf.capacity());
-        if (buf.isReadOnly()) {
-            try {
-                buf.clear();
-                buf.put(other);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
         try {
             buf.put(buf);
             fail("Should throw Exception"); //$NON-NLS-1$
@@ -608,6 +518,13 @@
         } catch (BufferOverflowException e) {
             // expected
         }
+        try {
+            buf.flip();
+            buf.put((IntBuffer)null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
 
         loadTestData2(other);
         other.clear();
@@ -622,17 +539,7 @@
     /*
      * Class under test for java.nio.IntBuffer put(int, int)
      */
-    public static void testPutintint(IntBuffer buf) {
-        if (buf.isReadOnly()) {
-            try {
-                buf.put(0, 0);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
+    public  void testPutintint() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), 0);
@@ -654,7 +561,7 @@
         }
     }
 
-    public static void testSlice(IntBuffer buf) {
+    public  void testSlice() {
         assertTrue(buf.capacity() > 5);
         buf.position(1);
         buf.limit(buf.capacity() - 1);
@@ -682,7 +589,7 @@
         }
     }
 
-    public static void testToString(IntBuffer buf) {
+    public  void testToString() {
         String str = buf.toString();
         assertTrue(str.indexOf("Int") >= 0 || str.indexOf("int") >= 0);
         assertTrue(str.indexOf("" + buf.position()) >= 0);
@@ -690,47 +597,47 @@
         assertTrue(str.indexOf("" + buf.capacity()) >= 0);
     }
 
-    private static void loadTestData1(int array[], int offset, int length) {
+      void loadTestData1(int array[], int offset, int length) {
         for (int i = 0; i < length; i++) {
             array[offset + i] = (int) i;
         }
     }
 
-    private static void loadTestData2(int array[], int offset, int length) {
+      void loadTestData2(int array[], int offset, int length) {
         for (int i = 0; i < length; i++) {
             array[offset + i] = (int) length - i;
         }
     }
 
-    private static void loadTestData1(IntBuffer buf) {
+      void loadTestData1(IntBuffer buf) {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             buf.put(i, (int) i);
         }
     }
 
-    private static void loadTestData2(IntBuffer buf) {
+      void loadTestData2(IntBuffer buf) {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             buf.put(i, (int) buf.capacity() - i);
         }
     }
 
-    private static void assertContentEquals(IntBuffer buf, int array[],
+      void assertContentEquals(IntBuffer buf, int array[],
             int offset, int length) {
         for (int i = 0; i < length; i++) {
             assertEquals(buf.get(i), array[offset + i]);
         }
     }
 
-    private static void assertContentEquals(IntBuffer buf, IntBuffer other) {
+      void assertContentEquals(IntBuffer buf, IntBuffer other) {
         assertEquals(buf.capacity(), other.capacity());
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.get(i), other.get(i));
         }
     }
 
-    private static void assertContentLikeTestData1(IntBuffer buf,
+      void assertContentLikeTestData1(IntBuffer buf,
             int startIndex, int startValue, int length) {
         int value = startValue;
         for (int i = 0; i < length; i++) {
@@ -738,108 +645,4 @@
             value = value + 1;
         }
     }
-
-    public void testAllocatedIntBuffer() {
-        try {
-            IntBuffer.allocate(-1);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IllegalArgumentException e) {
-            // expected 
-        }
-        IntBuffer buf = IntBuffer.allocate(16);
-        testIntBufferInstanceThoroughly(buf);
-    }
-
-    public void testWrappedIntBuffer() {
-        IntBuffer buf = IntBuffer.wrap(new int[16]);
-        testIntBufferInstanceThoroughly(buf);
-    }
-
-    public void testWrappedIntBuffer2() {
-        int array[] = new int[20];
-        try {
-            IntBuffer.wrap(array, -1, 0);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            IntBuffer.wrap(array, 21, 0);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            IntBuffer.wrap(array, 0, -1);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            IntBuffer.wrap(array, 0, 21);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-
-        IntBuffer buf = IntBuffer.wrap(array, 2, 16);
-        assertEquals(buf.position(), 2);
-        assertEquals(buf.limit(), 18);
-        assertEquals(buf.capacity(), 20);
-        testIntBufferInstanceThoroughly(buf);
-    }
-
-    /**
-     * @tests java.nio.IntBuffer.wrap(int[],int,int)
-     */
-    public void testWrappedIntBuffer_null_array() {
-        // Regression for HARMONY-264
-        int array[] = null;
-        try {
-            IntBuffer.wrap(array, -1, 0);
-            fail("Should throw NPE"); //$NON-NLS-1$
-        } catch (NullPointerException e) {
-        }
-    }
-
-    public void testByteBufferAsIntBuffer() {
-        IntBuffer buf = ByteBuffer.allocate(160).asIntBuffer();
-        testIntBufferInstanceThoroughly(buf);
-    }
-
-    private void testIntBufferInstanceThoroughly(IntBuffer buf) {
-        assertTrue(buf.capacity() > 15);
-        buf.clear();
-        loadTestData1(buf);
-
-        buf.limit(15).position(1);
-        testIntBufferInstance(buf);
-        testIntBufferInstance(buf.duplicate());
-        testIntBufferInstance(buf.asReadOnlyBuffer());
-        buf.limit(15).position(1);
-        testIntBufferInstance(buf.slice());
-
-        IntBuffer duplicate = buf.duplicate();
-        duplicate.limit(15).position(1);
-        testIntBufferInstance(duplicate.duplicate());
-        testIntBufferInstance(duplicate.asReadOnlyBuffer());
-        duplicate.limit(15).position(1);
-        testIntBufferInstance(duplicate.slice());
-
-        IntBuffer readonly = buf.asReadOnlyBuffer();
-        readonly.limit(15).position(1);
-        testIntBufferInstance(readonly.duplicate());
-        testIntBufferInstance(readonly.asReadOnlyBuffer());
-        readonly.limit(15).position(1);
-        testIntBufferInstance(readonly.slice());
-
-        buf.limit(15).position(1);
-        IntBuffer slice = buf.slice();
-        slice.limit(10).position(1);
-        testIntBufferInstance(slice.duplicate());
-        testIntBufferInstance(slice.asReadOnlyBuffer());
-        slice.limit(10).position(1);
-        testIntBufferInstance(slice.slice());
-    }
-
-}
\ No newline at end of file
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,31 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.IntBuffer;
+
+public class ReadOnlyHeapIntBufferTest extends ReadOnlyIntBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = IntBuffer.allocate(BUFFER_LENGTH);
+        super.loadTestData1(buf);
+        buf = buf.asReadOnlyBuffer();
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,160 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.IntBuffer;
+import java.nio.ReadOnlyBufferException;
+
+public class ReadOnlyIntBufferTest extends IntBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = buf.asReadOnlyBuffer();
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testIsReadOnly() {
+        assertTrue(buf.isReadOnly());
+    }
+
+    public void testHasArray() {
+        assertFalse(buf.hasArray());
+    }
+
+    public void testArray() {
+        try {
+            buf.array();
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            //expected
+        }
+    }
+
+    public void testHashCode() {
+        IntBuffer duplicate = buf.duplicate();
+        assertEquals(buf.hashCode(), duplicate.hashCode());
+    }
+
+    public void testArrayOffset() {
+        try {
+            buf.arrayOffset();
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (UnsupportedOperationException e) {
+            //expected
+        }
+    }
+
+    public void testCompact() {
+        try {
+            buf.compact();
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+
+    public void testPutint() {
+        try {
+            buf.put(0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+
+    public void testPutintArray() {
+        int array[] = new int[1];
+        try {
+            buf.put(array);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((int[]) null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    public void testPutintArrayintint() {
+        int array[] = new int[1];
+        try {
+            buf.put(array, 0, array.length);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((int[]) null, -1, 1);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(new int[buf.capacity() + 1], 0, buf.capacity() + 1);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(array, -1, array.length);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+
+    public void testPutIntBuffer() {
+        IntBuffer other = IntBuffer.allocate(1);
+        try {
+            buf.put(other);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((IntBuffer) null);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(buf);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+
+    public void testPutintint() {
+        try {
+            buf.put(0, (int) 0);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(-1, (int) 0);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,31 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.IntBuffer;
+
+public class ReadOnlyWrappedIntBufferTest extends ReadOnlyIntBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = IntBuffer.wrap(new int[BUFFER_LENGTH]);
+        super.loadTestData1(buf);
+        buf = buf.asReadOnlyBuffer();
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java?rev=421233&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java Wed Jul 12 04:03:03 2006
@@ -0,0 +1,86 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.tests.java.nio;
+
+import java.nio.IntBuffer;
+
+public class WrappedIntBufferTest extends IntBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = IntBuffer.wrap(new int[BUFFER_LENGTH]);
+        loadTestData1(buf);
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        baseBuf = null;
+        buf = null;
+    }
+
+    /**
+     * @tests java.nio.CharBuffer#allocate(char[],int,int)
+     * 
+     */
+    public void testWrappedIntBuffer_IllegalArg() {
+        int array[] = new int[20];
+        try {
+            IntBuffer.wrap(array, -1, 0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap(array, 21, 0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap(array, 0, -1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap(array, 0, 21);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap(array, Integer.MAX_VALUE, 1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap(array, 1, Integer.MAX_VALUE);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            IntBuffer.wrap((int[])null, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+
+        IntBuffer buf = IntBuffer.wrap(array, 2, 16);
+        assertEquals(buf.position(), 2);
+        assertEquals(buf.limit(), 18);
+        assertEquals(buf.capacity(), 20);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedIntBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message