1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.apache.harmony.nio.tests.java.nio;
17
18import dalvik.annotation.TestLevel;
19import dalvik.annotation.TestTargetNew;
20import dalvik.annotation.TestTargetClass;
21
22import java.nio.ByteBuffer;
23import java.nio.ByteOrder;
24
25@TestTargetClass(java.nio.FloatBuffer.class)
26public class DirectFloatBufferTest extends FloatBufferTest {
27    public void setUp(){
28        capacity = BUFFER_LENGTH;
29        buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asFloatBuffer();
30        loadTestData1(buf);
31        baseBuf = buf;
32    }
33
34    public void tearDown(){
35        buf = null;
36        baseBuf = null;
37    }
38
39    @TestTargetNew(
40        level = TestLevel.PARTIAL_COMPLETE,
41        notes = "Verifies hasArray method for direct FloatBuffer.",
42        method = "hasArray",
43        args = {}
44    )
45    public void testHasArray() {
46        assertFalse(buf.hasArray());
47    }
48
49    @TestTargetNew(
50        level = TestLevel.PARTIAL_COMPLETE,
51        notes = "Verifies array method for direct FloatBuffer.",
52        method = "array",
53        args = {}
54    )
55    public void testArray() {
56        try {
57            buf.array();
58            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
59        } catch (UnsupportedOperationException e) {
60        }
61    }
62
63    @TestTargetNew(
64        level = TestLevel.PARTIAL_COMPLETE,
65        notes = "Verifies arrayOffset method for direct FloatBuffer.",
66        method = "arrayOffset",
67        args = {}
68    )
69    public void testArrayOffset() {
70        try {
71            buf.arrayOffset();
72            fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
73        } catch (UnsupportedOperationException e) {
74            //expected
75        }
76    }
77
78    @TestTargetNew(
79        level = TestLevel.PARTIAL_COMPLETE,
80        notes = "Verifies isDirect method for direct FloatBuffer.",
81        method = "isDirect",
82        args = {}
83    )
84    public void testIsDirect() {
85        assertTrue(buf.isDirect());
86    }
87
88    @TestTargetNew(
89        level = TestLevel.PARTIAL_COMPLETE,
90        notes = "Verifies order method for direct FloatBuffer.",
91        method = "order",
92        args = {}
93    )
94    public void testOrder() {
95        assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
96    }
97}
98