harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r420513 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/java/nio/ test/java/common/org/apache/harmony/tests/java/nio/
Date Mon, 10 Jul 2006 12:49:55 GMT
Author: gharley
Date: Mon Jul 10 05:49:54 2006
New Revision: 420513

URL: http://svn.apache.org/viewvc?rev=420513&view=rev
Log:
HARMONY 810 : [nio] refactor nio buffer test step 4 - FloatBuffer tests

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectFloatBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapFloatBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyFloatBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapFloatBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedFloatBufferTest.java   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatArrayBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.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/FloatBufferTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatArrayBuffer.java?rev=420513&r1=420512&r2=420513&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatArrayBuffer.java Mon Jul 10 05:49:54 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 FloatBuffer get(float[] dest, int off, int len) {
-        if (off < 0 || len < 0 || off + len > dest.length) {
+        int length = dest.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/main/java/java/nio/FloatBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java?rev=420513&r1=420512&r2=420513&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java Mon Jul 10 05:49:54 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.
@@ -294,7 +294,8 @@
 	 *                <code>remaining()</code>
 	 */
 	public FloatBuffer get(float[] dest, int off, int len) {
-        if (off < 0 || len < 0 || (long)off + (long)len > dest.length) {
+        int length = dest.length;
+        if (off < 0 || len < 0 || (long)off + (long)len > length) {
             throw new IndexOutOfBoundsException();
         }
         
@@ -449,7 +450,8 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public FloatBuffer put(float[] 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();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java?rev=420513&r1=420512&r2=420513&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java Mon Jul 10 05:49:54 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 FloatBuffer put(int index, float c) {
 		throw new ReadOnlyBufferException();
 	}
+    
+    public FloatBuffer put(FloatBuffer buf) {
+        throw new ReadOnlyBufferException();
+    }
 
     public final FloatBuffer put(float[] src, int off, int len) {
         throw new ReadOnlyBufferException();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java?rev=420513&r1=420512&r2=420513&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java Mon Jul 10 05:49:54 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.
@@ -104,7 +104,8 @@
 	}
 
     public FloatBuffer put(float[] 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=420513&r1=420512&r2=420513&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 Mon Jul 10 05:49:54 2006
@@ -31,45 +31,51 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("Tests for java.nio");
         //$JUnit-BEGIN$
-        suite.addTestSuite(InvalidMarkExceptionTest.class);
-        suite.addTestSuite(ReadOnlyCharBufferTest.class);
-        suite.addTestSuite(IntBufferTest.class);
-        suite.addTestSuite(SliceWrappedByteBufferTest.class);
-        suite.addTestSuite(ByteOrderTest.class);
-        suite.addTestSuite(WrappedCharBufferTest1.class);
-        suite.addTestSuite(ReadOnlyHeapDoubleBufferTest.class);
-        suite.addTestSuite(LongBufferTest.class);
-        suite.addTestSuite(HeapByteBufferTest.class);
-        suite.addTestSuite(ReadOnlyWrappedDoubleBufferTest.class);
+        suite.addTestSuite(ByteBufferTest.class);
+        suite.addTestSuite(BufferOverflowExceptionTest.class);
         suite.addTestSuite(ReadOnlyDirectByteBufferTest.class);
-        suite.addTestSuite(SliceDirectByteBufferTest.class);
-        suite.addTestSuite(ReadOnlyWrappedCharBufferTest1.class);
+        suite.addTestSuite(ReadOnlyBufferExceptionTest.class);
+        suite.addTestSuite(ReadOnlyHeapDoubleBufferTest.class);
+        suite.addTestSuite(CharBufferTest.class);
+        suite.addTestSuite(DoubleBufferTest.class);
+        suite.addTestSuite(ReadOnlyWrappedFloatBufferTest.class);
         suite.addTestSuite(WrappedDoubleBufferTest.class);
         suite.addTestSuite(WrappedCharBufferTest2.class);
+        suite.addTestSuite(ReadOnlyFloatBufferTest.class);
+        suite.addTestSuite(ByteOrderTest.class);
+        suite.addTestSuite(WrappedFloatBufferTest.class);
         suite.addTestSuite(ShortBufferTest.class);
-        suite.addTestSuite(BufferUnderflowExceptionTest.class);
-        suite.addTestSuite(FloatBufferTest.class);
-        suite.addTestSuite(DuplicateDirectByteBufferTest.class);
-        suite.addTestSuite(DirectCharBufferTest.class);
-        suite.addTestSuite(ByteBufferTest.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(AbstractBufferTest.class);
+        suite.addTestSuite(ReadOnlyCharBufferTest.class);
+        suite.addTestSuite(DuplicateHeapByteBufferTest.class);
+        suite.addTestSuite(SliceHeapByteBufferTest.class);
+        suite.addTestSuite(InvalidMarkExceptionTest.class);
+        suite.addTestSuite(DirectDoubleBufferTest.class);
+        suite.addTestSuite(ReadOnlyHeapByteBufferTest.class);
+        suite.addTestSuite(LongBufferTest.class);
+        suite.addTestSuite(DuplicateWrappedByteBufferTest.class);
         suite.addTestSuite(HeapDoubleBufferTest.class);
         suite.addTestSuite(DirectByteBufferTest.class);
-        suite.addTestSuite(BufferOverflowExceptionTest.class);
-        suite.addTestSuite(BufferTest.class);
-        suite.addTestSuite(DuplicateWrappedByteBufferTest.class);
-        suite.addTestSuite(WrappedByteBufferTest.class);
+        suite.addTestSuite(ReadOnlyWrappedCharBufferTest1.class);
         suite.addTestSuite(ReadOnlyDoubleBufferTest.class);
-        suite.addTestSuite(ReadOnlyBufferExceptionTest.class);
-        suite.addTestSuite(DoubleBufferTest.class);
-        suite.addTestSuite(CharBufferTest.class);
-        suite.addTestSuite(HeapCharBufferTest.class);
-        suite.addTestSuite(DuplicateHeapByteBufferTest.class);
-        suite.addTestSuite(ReadOnlyHeapByteBufferTest.class);
+        suite.addTestSuite(FloatBufferTest.class);
+        suite.addTestSuite(IntBufferTest.class);
         suite.addTestSuite(ReadOnlyHeapCharBufferTest.class);
-        suite.addTestSuite(SliceHeapByteBufferTest.class);
-        suite.addTestSuite(DirectDoubleBufferTest.class);
+        suite.addTestSuite(ReadOnlyHeapFloatBufferTest.class);
+        suite.addTestSuite(WrappedByteBufferTest.class);
+        suite.addTestSuite(BufferUnderflowExceptionTest.class);
+        suite.addTestSuite(DuplicateDirectByteBufferTest.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/DirectFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/DirectFloatBufferTest.java Mon Jul 10 05:49:54 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 DirectFloatBufferTest extends FloatBufferTest {
+    public void setUp(){
+        buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asFloatBuffer();
+        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/DirectFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/FloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/FloatBufferTest.java?rev=420513&r1=420512&r2=420513&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/FloatBufferTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/FloatBufferTest.java Mon Jul 10 05:49:54 2006
@@ -17,130 +17,68 @@
 
 import java.nio.BufferOverflowException;
 import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.InvalidMarkException;
-import java.nio.ReadOnlyBufferException;
-
-import junit.framework.TestCase;
 
 /**
  * Tests java.nio.FloatBuffer
  * 
  */
-public class FloatBufferTest extends TestCase {
+public class FloatBufferTest extends AbstractBufferTest {
+    
+    protected static final int SMALL_TEST_LENGTH = 5;
+
+    protected static final int BUFFER_LENGTH = 20;
+
+    protected FloatBuffer buf;
 
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(FloatBufferTest.class);
+    protected void setUp() throws Exception {
+        buf = FloatBuffer.allocate(BUFFER_LENGTH);
+        loadTestData1(buf);
+        baseBuf = buf;
     }
 
-    public static void testFloatBufferInstance(FloatBuffer buf) {
-        // test Buffer functions
-        BufferTest.testBufferInstance(buf);
-
-        // test FloatBuffer functions
-        testHashCode(buf);
-        testEquals(buf);
-        testToString(buf);
-        testSlice(buf);
-        testDuplicate(buf);
-        testAsReadOnlyBuffer(buf);
-        testGet(buf);
-        testPutfloat(buf);
-        testGetint(buf);
-        testPutintfloat(buf);
-        testGetfloatArrayintint(buf);
-        testGetfloatArray(buf);
-        testPutFloatBuffer(buf);
-        testPutfloatArrayintint(buf);
-        testPutfloatArray(buf);
-        testHasArray(buf);
-        testArray(buf);
-        testArrayOffset(buf);
-        testCompact(buf);
-        testIsDirect(buf);
-        testCompareTo(buf);
-        testOrder(buf);
+    protected void tearDown() throws Exception {
+        buf = null;
+        baseBuf = null;
     }
 
-    public static void testArray(FloatBuffer buf) {
-        if (buf.hasArray()) {
-            float array[] = buf.array();
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+    public void testArray() {
+        float 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.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
-                }
-            }
-        }
+        loadTestData2(buf);
+        assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
     }
 
-    public static void testArrayOffset(FloatBuffer buf) {
-        if (buf.hasArray()) {
-            float array[] = buf.array();
-            assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+    public void testArrayOffset() {
+        float 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(FloatBuffer buf) {
+    public void testAsReadOnlyBuffer() {
         buf.clear();
         buf.mark();
         buf.position(buf.limit());
@@ -164,16 +102,7 @@
         assertEquals(buf.position(), 0);
     }
 
-    public static void testCompact(FloatBuffer 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();
@@ -225,33 +154,37 @@
         }
     }
 
-    public static void testCompareTo(FloatBuffer buf) {
+    public void testCompareTo() {
+        try {
+            buf.compareTo(null);    
+            fail("Should throw NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        
         // compare to self
         assertEquals(0, buf.compareTo(buf));
 
         // normal cases
-        if (!buf.isReadOnly()) {
-            assertTrue(buf.capacity() > 5);
-            buf.clear();
-            FloatBuffer other = FloatBuffer.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();
+        FloatBuffer other = FloatBuffer.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(FloatBuffer buf) {
+    public void testDuplicate() {
         buf.clear();
         buf.mark();
         buf.position(buf.limit());
@@ -283,7 +216,7 @@
         }
     }
 
-    public static void testEquals(FloatBuffer buf) {
+    public void testEquals() {
         // equal to self
         assertTrue(buf.equals(buf));
         FloatBuffer readonly = buf.asReadOnlyBuffer();
@@ -308,7 +241,7 @@
     /*
      * Class under test for float get()
      */
-    public static void testGet(FloatBuffer buf) {
+    public void testGet() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -325,7 +258,7 @@
     /*
      * Class under test for java.nio.FloatBuffer get(float[])
      */
-    public static void testGetfloatArray(FloatBuffer buf) {
+    public void testGetfloatArray() {
         float array[] = new float[1];
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
@@ -340,12 +273,20 @@
         } catch (BufferUnderflowException e) {
             // expected
         }
+        try {
+            buf.position(buf.limit());
+            buf.get((float[])null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+        buf.get(new float[0]);
     }
 
     /*
      * Class under test for java.nio.FloatBuffer get(float[], int, int)
      */
-    public static void testGetfloatArrayintint(FloatBuffer buf) {
+    public void testGetfloatArrayintint() {
         buf.clear();
         float array[] = new float[buf.capacity()];
 
@@ -377,11 +318,29 @@
             // expected
         }
         try {
+            buf.get((float[])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 +353,7 @@
     /*
      * Class under test for float get(int)
      */
-    public static void testGetint(FloatBuffer buf) {
+    public void testGetint() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -414,32 +373,11 @@
         }
     }
 
-    public static void testHasArray(FloatBuffer 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(FloatBuffer buf) {
+    public void testHashCode() {
         buf.clear();
         FloatBuffer readonly = buf.asReadOnlyBuffer();
         FloatBuffer duplicate = buf.duplicate();
@@ -450,11 +388,11 @@
         assertTrue(buf.hashCode() != duplicate.hashCode());
     }
 
-    public static void testIsDirect(FloatBuffer buf) {
-        buf.isDirect();
+    public void testIsDirect() {
+        assertFalse(buf.isDirect());
     }
 
-    public static void testOrder(FloatBuffer buf) {
+    public void testOrder() {
         buf.order();
         if (buf.hasArray()) {
             assertEquals(ByteOrder.nativeOrder(), buf.order());
@@ -464,18 +402,7 @@
     /*
      * Class under test for java.nio.FloatBuffer put(float)
      */
-    public static void testPutfloat(FloatBuffer buf) {
-        if (buf.isReadOnly()) {
-            try {
-                buf.clear();
-                buf.put(0);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
+    public void testPutfloat() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), i);
@@ -494,18 +421,8 @@
     /*
      * Class under test for java.nio.FloatBuffer put(float[])
      */
-    public static void testPutfloatArray(FloatBuffer buf) {
+    public void testPutfloatArray() {
         float array[] = new float[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 +437,21 @@
         } catch (BufferOverflowException e) {
             // expected
         }
+        try {
+            buf.position(buf.limit());
+            buf.put((float[])null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     /*
      * Class under test for java.nio.FloatBuffer put(float[], int, int)
      */
-    public static void testPutfloatArrayintint(FloatBuffer buf) {
+    public void testPutfloatArrayintint() {
         buf.clear();
         float array[] = new float[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 float[buf.capacity() + 1], 0, buf.capacity() + 1);
             fail("Should throw Exception"); //$NON-NLS-1$
@@ -566,11 +480,29 @@
             // expected
         }
         try {
+            buf.put((float[])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 +515,8 @@
     /*
      * Class under test for java.nio.FloatBuffer put(java.nio.FloatBuffer)
      */
-    public static void testPutFloatBuffer(FloatBuffer buf) {
+    public void testPutFloatBuffer() {
         FloatBuffer other = FloatBuffer.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,7 +529,14 @@
         } catch (BufferOverflowException e) {
             // expected
         }
-
+        try {
+            buf.flip();
+            buf.put((FloatBuffer)null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+        buf.clear();
         loadTestData2(other);
         other.clear();
         buf.clear();
@@ -622,17 +550,7 @@
     /*
      * Class under test for java.nio.FloatBuffer put(int, float)
      */
-    public static void testPutintfloat(FloatBuffer buf) {
-        if (buf.isReadOnly()) {
-            try {
-                buf.put(0, 0);
-                fail("Should throw Exception"); //$NON-NLS-1$
-            } catch (ReadOnlyBufferException e) {
-                // expected
-            }
-            return;
-        }
-
+    public void testPutintfloat() {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.position(), 0);
@@ -654,7 +572,7 @@
         }
     }
 
-    public static void testSlice(FloatBuffer buf) {
+    public void testSlice() {
         assertTrue(buf.capacity() > 5);
         buf.position(1);
         buf.limit(buf.capacity() - 1);
@@ -682,7 +600,7 @@
         }
     }
 
-    public static void testToString(FloatBuffer buf) {
+    public void testToString() {
         String str = buf.toString();
         assertTrue(str.indexOf("Float") >= 0 || str.indexOf("float") >= 0);
         assertTrue(str.indexOf("" + buf.position()) >= 0);
@@ -690,47 +608,47 @@
         assertTrue(str.indexOf("" + buf.capacity()) >= 0);
     }
 
-    private static void loadTestData1(float array[], int offset, int length) {
+    void loadTestData1(float array[], int offset, int length) {
         for (int i = 0; i < length; i++) {
             array[offset + i] = (float) i;
         }
     }
 
-    private static void loadTestData2(float array[], int offset, int length) {
+    void loadTestData2(float array[], int offset, int length) {
         for (int i = 0; i < length; i++) {
             array[offset + i] = (float) length - i;
         }
     }
 
-    private static void loadTestData1(FloatBuffer buf) {
+    void loadTestData1(FloatBuffer buf) {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             buf.put(i, (float) i);
         }
     }
 
-    private static void loadTestData2(FloatBuffer buf) {
+    void loadTestData2(FloatBuffer buf) {
         buf.clear();
         for (int i = 0; i < buf.capacity(); i++) {
             buf.put(i, (float) buf.capacity() - i);
         }
     }
 
-    private static void assertContentEquals(FloatBuffer buf, float array[],
+    void assertContentEquals(FloatBuffer buf, float array[],
             int offset, int length) {
         for (int i = 0; i < length; i++) {
             assertEquals(buf.get(i), array[offset + i], 0.01);
         }
     }
 
-    private static void assertContentEquals(FloatBuffer buf, FloatBuffer other) {
+    void assertContentEquals(FloatBuffer buf, FloatBuffer other) {
         assertEquals(buf.capacity(), other.capacity());
         for (int i = 0; i < buf.capacity(); i++) {
             assertEquals(buf.get(i), other.get(i), 0.01);
         }
     }
 
-    private static void assertContentLikeTestData1(FloatBuffer buf,
+    void assertContentLikeTestData1(FloatBuffer buf,
             int startIndex, float startValue, int length) {
         float value = startValue;
         for (int i = 0; i < length; i++) {
@@ -738,108 +656,4 @@
             value = value + 1.0f;
         }
     }
-
-    public void testAllocatedFloatBuffer() {
-        try {
-            FloatBuffer.allocate(-1);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IllegalArgumentException e) {
-            // expected 
-        }
-        FloatBuffer buf = FloatBuffer.allocate(16);
-        testFloatBufferInstanceThoroughly(buf);
-    }
-
-    public void testWrappedFloatBuffer() {
-        FloatBuffer buf = FloatBuffer.wrap(new float[16]);
-        testFloatBufferInstanceThoroughly(buf);
-    }
-
-    public void testWrappedFloatBuffer2() {
-        float array[] = new float[20];
-        try {
-            FloatBuffer.wrap(array, -1, 0);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            FloatBuffer.wrap(array, 21, 0);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            FloatBuffer.wrap(array, 0, -1);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-        try {
-            FloatBuffer.wrap(array, 0, 21);
-            fail("Should throw Exception"); //$NON-NLS-1$
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-
-        FloatBuffer buf = FloatBuffer.wrap(array, 2, 16);
-        assertEquals(buf.position(), 2);
-        assertEquals(buf.limit(), 18);
-        assertEquals(buf.capacity(), 20);
-        testFloatBufferInstanceThoroughly(buf);
-    }
-
-    /**
-     * @tests java.nio.FloatBuffer.wrap(float[],int,int)
-     */
-    public void testWrappedFloatBuffer_null_array() {
-        // Regression for HARMONY-264
-        float array[] = null;
-        try {
-            FloatBuffer.wrap(array, -1, 0);
-            fail("Should throw NPE"); //$NON-NLS-1$
-        } catch (NullPointerException e) {
-        }
-    }
-
-    public void testByteBufferAsFloatBuffer() {
-        FloatBuffer buf = ByteBuffer.allocate(160).asFloatBuffer();
-        testFloatBufferInstanceThoroughly(buf);
-    }
-
-    private void testFloatBufferInstanceThoroughly(FloatBuffer buf) {
-        assertTrue(buf.capacity() > 15);
-        buf.clear();
-        loadTestData1(buf);
-
-        buf.limit(15).position(1);
-        testFloatBufferInstance(buf);
-        testFloatBufferInstance(buf.duplicate());
-        testFloatBufferInstance(buf.asReadOnlyBuffer());
-        buf.limit(15).position(1);
-        testFloatBufferInstance(buf.slice());
-
-        FloatBuffer duplicate = buf.duplicate();
-        duplicate.limit(15).position(1);
-        testFloatBufferInstance(duplicate.duplicate());
-        testFloatBufferInstance(duplicate.asReadOnlyBuffer());
-        duplicate.limit(15).position(1);
-        testFloatBufferInstance(duplicate.slice());
-
-        FloatBuffer readonly = buf.asReadOnlyBuffer();
-        readonly.limit(15).position(1);
-        testFloatBufferInstance(readonly.duplicate());
-        testFloatBufferInstance(readonly.asReadOnlyBuffer());
-        readonly.limit(15).position(1);
-        testFloatBufferInstance(readonly.slice());
-
-        buf.limit(15).position(1);
-        FloatBuffer slice = buf.slice();
-        slice.limit(10).position(1);
-        testFloatBufferInstance(slice.duplicate());
-        testFloatBufferInstance(slice.asReadOnlyBuffer());
-        slice.limit(10).position(1);
-        testFloatBufferInstance(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/HeapFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/HeapFloatBufferTest.java Mon Jul 10 05:49:54 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.FloatBuffer;
+
+public class HeapFloatBufferTest extends FloatBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = FloatBuffer.allocate(BUFFER_LENGTH); 
+        loadTestData1(buf);
+        baseBuf = buf;
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        buf = null;
+        baseBuf = null;
+    }
+    
+    public void testAllocatedFloatBuffer_IllegalArg() {
+        try {
+            FloatBuffer.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/HeapFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyFloatBufferTest.java Mon Jul 10 05:49:54 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.FloatBuffer;
+import java.nio.ReadOnlyBufferException;
+
+public class ReadOnlyFloatBufferTest extends FloatBufferTest {
+    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() {
+        FloatBuffer 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 testPutfloat() {
+        try {
+            buf.put(0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+    }
+
+    public void testPutfloatArray() {
+        float array[] = new float[1];
+        try {
+            buf.put(array);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((float[]) null);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    public void testPutfloatArrayintint() {
+        float array[] = new float[1];
+        try {
+            buf.put(array, 0, array.length);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((float[]) null, 0, 1);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(new float[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 testPutFloatBuffer() {
+        FloatBuffer other = FloatBuffer.allocate(1);
+        try {
+            buf.put(other);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put((FloatBuffer) 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 testPutintfloat() {
+        try {
+            buf.put(0, (float) 0);
+            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+        } catch (ReadOnlyBufferException e) {
+            // expected
+        }
+        try {
+            buf.put(-1, (float) 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/ReadOnlyFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyHeapFloatBufferTest.java Mon Jul 10 05:49:54 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.FloatBuffer;
+
+public class ReadOnlyHeapFloatBufferTest extends ReadOnlyFloatBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = FloatBuffer.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/ReadOnlyHeapFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java Mon Jul 10 05:49:54 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.FloatBuffer;
+
+public class ReadOnlyWrappedFloatBufferTest extends ReadOnlyFloatBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = FloatBuffer.wrap(new float[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/ReadOnlyWrappedFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedFloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedFloatBufferTest.java?rev=420513&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedFloatBufferTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/WrappedFloatBufferTest.java Mon Jul 10 05:49:54 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.FloatBuffer;
+
+public class WrappedFloatBufferTest extends FloatBufferTest {
+    protected void setUp() throws Exception {
+        super.setUp();
+        buf = FloatBuffer.wrap(new float[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 testWrappedFloatBuffer_IllegalArg() {
+        float array[] = new float[20];
+        try {
+            FloatBuffer.wrap(array, -1, 0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap(array, 21, 0);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap(array, 0, -1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap(array, 0, 21);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap(array, Integer.MAX_VALUE, 1);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap(array, 1, Integer.MAX_VALUE);
+            fail("Should throw Exception"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+        try {
+            FloatBuffer.wrap((float[])null, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+
+        FloatBuffer buf = FloatBuffer.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/WrappedFloatBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message