1dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes/* Licensed to the Apache Software Foundation (ASF) under one or more
2dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * contributor license agreements.  See the NOTICE file distributed with
3dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * this work for additional information regarding copyright ownership.
4dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * The ASF licenses this file to You under the Apache License, Version 2.0
5dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * (the "License"); you may not use this file except in compliance with
6dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * the License.  You may obtain a copy of the License at
7dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes *
8dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes *     http://www.apache.org/licenses/LICENSE-2.0
9dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes *
10dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * Unless required by applicable law or agreed to in writing, software
11dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
12dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * See the License for the specific language governing permissions and
14dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes * limitations under the License.
15dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes */
16e5fea3d504609d22337a5311d3ce0e72314bceeeNarayan Kamathpackage org.apache.harmony.tests.java.nio;
17dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
18dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughesimport java.nio.CharBuffer;
19dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughesimport java.nio.ReadOnlyBufferException;
20dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
21dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughespublic class ReadOnlyCharBufferTest extends CharBufferTest {
22dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
23dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    protected void setUp() throws Exception {
24dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        super.setUp();
25dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        loadTestData1(buf);
26dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        buf = buf.asReadOnlyBuffer();
27dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        baseBuf = buf;
28dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
29dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
30dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    protected void tearDown() throws Exception {
31dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        buf = null;
32dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        baseBuf = null;
33dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        super.tearDown();
34dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
35dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
36dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testIsReadOnly() {
37dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        assertTrue(buf.isReadOnly());
38dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
39dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
40dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testHasArray() {
41dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        assertFalse(buf.hasArray());
42dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
43dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
44dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testArray() {
45dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
46dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.array();
47dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
48dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
49dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
50dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
51dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
52dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testHashCode() {
53dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        CharBuffer duplicate = buf.duplicate();
54dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        assertEquals(buf.hashCode(), duplicate.hashCode());
55dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
56dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
57dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testArrayOffset() {
58dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
59dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.arrayOffset();
60dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
61dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (UnsupportedOperationException e) {
62dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
63dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
64dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
65dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testCompact() {
66dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
67dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.compact();
68dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
69dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
70dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
71dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
72dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
73dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
74dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutchar() {
75dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
76dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((char) 0);
77dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
78dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
79dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
80dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
81dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
82dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
83dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutcharArray() {
84dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        char array[] = new char[1];
85dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
86dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(array);
87dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
88dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
89dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
90dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
91dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
92dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((char[]) null);
93dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
94dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (NullPointerException e) {
95dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
96dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
97dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
98dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
99dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutcharArrayintint() {
100dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        char array[] = new char[1];
101dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
102dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(array, 0, array.length);
103dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
104dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
105dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
106dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
107dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
108dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((char[]) null, 0, 1);
109dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
110dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
111dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
112dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
113dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
114dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(new char[buf.capacity() + 1], 0, buf.capacity() + 1);
115dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
116dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
117dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
118dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
119dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
120dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(array, -1, array.length);
121dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
122dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
123dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
124dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
125dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
126dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
127dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutCharBuffer() {
128dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        CharBuffer other = CharBuffer.allocate(1);
129dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
130dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(other);
131dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
132dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
133dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
134dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
135dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
136dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((CharBuffer) null);
137dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
138dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
139dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
140dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
141dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
142dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(buf);
1433f7495294d8b27c00ff647773fcac75afe10c629Serguei Katkov            fail("Should throw IllegalArgumentException"); //$NON-NLS-1$
1443f7495294d8b27c00ff647773fcac75afe10c629Serguei Katkov        } catch (IllegalArgumentException e) {
145dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
146dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
147dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
148dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
149dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutintchar() {
150dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
151dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(0, (char) 0);
152dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
153dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
154dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
155dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
156dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
157dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(-1, (char) 0);
158dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
159dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
160dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
161dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
162dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
163dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
164dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutStringintint() {
165dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        buf.clear();
166dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        String str = String.valueOf(new char[buf.capacity()]);
167dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
168dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(str, 0, str.length());
169dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
170dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
171dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
172dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
173dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
174dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((String) null, 0, 0);
175dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
176dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException expected) {
177dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (NullPointerException expected) {
178dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
179dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
180dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(str, -1, str.length());
181dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
182d2ace8625cf007b9f1b9f16a022d92cad3045257Narayan Kamath        } catch (IndexOutOfBoundsException expected) {
183dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (NullPointerException expected) {
184dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
185dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        String longStr = String.valueOf(new char[buf.capacity()+1]);
186dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
187dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(longStr, 0, longStr.length());
188dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
189dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
190dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
191dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
192dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
193dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes
194dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    public void testPutString() {
195dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        String str = " ";
196dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
197dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put(str);
198dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
199dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (ReadOnlyBufferException e) {
200dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
201dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
202dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        try {
203dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            buf.put((String)null);
204dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            fail("Should throw Exception"); //$NON-NLS-1$
205dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        } catch (NullPointerException e) {
206dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes            // expected
207dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes        }
208dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes    }
209dce2b2fa9d6b26414a8d5a55918e4d7ca2ab1baaElliott Hughes}
210