summaryrefslogtreecommitdiffstats
path: root/nio
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
commitdd828f42a5c83b4270d4fbf6fce2da1878f1e84a (patch)
treefdd4b68fa1020f2b6426034c94823419a7236200 /nio
parentfdb2704414a9ed92394ada0d1395e4db86889465 (diff)
downloadlibcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.zip
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.gz
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'nio')
-rw-r--r--nio/src/main/java/java/nio/Buffer.java159
-rw-r--r--nio/src/main/java/java/nio/BufferOverflowException.java8
-rw-r--r--nio/src/main/java/java/nio/BufferUnderflowException.java8
-rw-r--r--nio/src/main/java/java/nio/ByteBuffer.java983
-rw-r--r--nio/src/main/java/java/nio/ByteOrder.java21
-rw-r--r--nio/src/main/java/java/nio/CharBuffer.java635
-rw-r--r--nio/src/main/java/java/nio/DoubleBuffer.java472
-rw-r--r--nio/src/main/java/java/nio/FloatBuffer.java459
-rw-r--r--nio/src/main/java/java/nio/IntBuffer.java417
-rw-r--r--nio/src/main/java/java/nio/InvalidMarkException.java9
-rw-r--r--nio/src/main/java/java/nio/LongBuffer.java423
-rw-r--r--nio/src/main/java/java/nio/MappedByteBuffer.java40
-rw-r--r--nio/src/main/java/java/nio/MappedByteBufferAdapter.java118
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyBufferException.java9
-rw-r--r--nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java4
-rw-r--r--nio/src/main/java/java/nio/ShortBuffer.java413
-rw-r--r--nio/src/main/java/java/nio/channels/AlreadyConnectedException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/AsynchronousCloseException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/ByteChannel.java3
-rw-r--r--nio/src/main/java/java/nio/channels/CancelledKeyException.java7
-rw-r--r--nio/src/main/java/java/nio/channels/Channel.java35
-rw-r--r--nio/src/main/java/java/nio/channels/Channels.java103
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedByInterruptException.java16
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedChannelException.java9
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedSelectorException.java9
-rw-r--r--nio/src/main/java/java/nio/channels/ConnectionPendingException.java9
-rw-r--r--nio/src/main/java/java/nio/channels/DatagramChannel.java400
-rw-r--r--nio/src/main/java/java/nio/channels/FileChannel.java634
-rw-r--r--nio/src/main/java/java/nio/channels/FileLock.java133
-rw-r--r--nio/src/main/java/java/nio/channels/FileLockInterruptionException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/GatheringByteChannel.java92
-rw-r--r--nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java10
-rw-r--r--nio/src/main/java/java/nio/channels/IllegalSelectorException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/InterruptibleChannel.java40
-rw-r--r--nio/src/main/java/java/nio/channels/NoConnectionPendingException.java11
-rw-r--r--nio/src/main/java/java/nio/channels/NonReadableChannelException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/NonWritableChannelException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/NotYetBoundException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/NotYetConnectedException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/OverlappingFileLockException.java9
-rw-r--r--nio/src/main/java/java/nio/channels/Pipe.java50
-rw-r--r--nio/src/main/java/java/nio/channels/ReadableByteChannel.java43
-rw-r--r--nio/src/main/java/java/nio/channels/ScatteringByteChannel.java93
-rw-r--r--nio/src/main/java/java/nio/channels/SelectableChannel.java153
-rw-r--r--nio/src/main/java/java/nio/channels/SelectionKey.java154
-rw-r--r--nio/src/main/java/java/nio/channels/Selector.java143
-rw-r--r--nio/src/main/java/java/nio/channels/ServerSocketChannel.java101
-rw-r--r--nio/src/main/java/java/nio/channels/SocketChannel.java493
-rw-r--r--nio/src/main/java/java/nio/channels/UnresolvedAddressException.java8
-rw-r--r--nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java7
-rw-r--r--nio/src/main/java/java/nio/channels/WritableByteChannel.java13
-rw-r--r--nio/src/main/java/java/nio/channels/package.html3
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java78
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java124
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java28
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelector.java68
-rw-r--r--nio/src/main/java/java/nio/channels/spi/SelectorProvider.java100
-rw-r--r--nio/src/main/java/java/nio/channels/spi/package.html1
-rw-r--r--nio/src/main/java/java/nio/package.html11
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java3
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java12
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java9
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java4
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java12
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java21
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java134
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java1
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java158
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java579
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java27
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java456
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java45
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java56
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java56
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java56
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java56
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java57
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java56
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java267
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java2
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java5
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java5
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java262
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java17
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java16
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java16
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java16
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java16
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java16
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java247
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java247
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java150
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java138
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java35
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java116
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java117
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java35
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java6
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java117
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java117
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java116
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java36
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java6
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java7
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java247
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java5
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java5
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java5
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java45
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java48
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java196
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java1304
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java70
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java1064
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java79
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java34
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java15
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java150
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java151
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java255
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java172
-rwxr-xr-xnio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java960
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java136
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java24
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java89
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java25
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java68
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java25
167 files changed, 13544 insertions, 3760 deletions
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java
index 200246c..9e870e4 100644
--- a/nio/src/main/java/java/nio/Buffer.java
+++ b/nio/src/main/java/java/nio/Buffer.java
@@ -4,9 +4,9 @@
* The ASF licenses this file to You 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.
@@ -20,25 +20,25 @@ package java.nio;
/**
* A buffer is a list of elements of a specific primitive type.
* <p>
- * A buffer can be described by following properties:
+ * A buffer can be described by the following properties:
* <ul>
- * <li>Capacity, is the number of elements a buffer can hold. Capacity is no
- * less than zero and never changes.</li>
- * <li>Position, is a cursor of this buffer. Elements are read or write at the
- * position if you do not specify an index explicitly. Position is no less than
- * zero and no greater than the limit.</li>
- * <li>Limit controls the scope of accessible elements. You can only read or
+ * <li>Capacity: the number of elements a buffer can hold. Capacity may not be
+ * negative and never changes.</li>
+ * <li>Position: a cursor of this buffer. Elements are read or written at the
+ * position if you do not specify an index explicitly. Position may not be
+ * negative and not greater than the limit.</li>
+ * <li>Limit: controls the scope of accessible elements. You can only read or
* write elements from index zero to <code>limit - 1</code>. Accessing
- * elements out of the scope will cause exception. Limit is no less than zero
- * and no greater than capacity.</li>
- * <li>Mark, is used to remember the current position, so that you can reset
- * the position later. Mark is no less than zero and no greater than position.</li>
- * <li>A buffer can be readonly or read-write. Trying to modify the elements of
- * a readonly buffer will cause <code>ReadOnlyBufferException</code>, while
- * changing the position, limit and mark of a readonly buffer is OK.</li>
+ * elements out of the scope will cause an exception. Limit may not be negative
+ * and not greater than capacity.</li>
+ * <li>Mark: used to remember the current position, so that you can reset the
+ * position later. Mark may not be negative and no greater than position.</li>
+ * <li>A buffer can be read-only or read-write. Trying to modify the elements
+ * of a read-only buffer will cause a <code>ReadOnlyBufferException</code>,
+ * while changing the position, limit and mark of a read-only buffer is OK.</li>
* <li>A buffer can be direct or indirect. A direct buffer will try its best to
- * take advantage of native memory APIs and it may not stay in java heap, thus
- * not affected by GC.</li>
+ * take advantage of native memory APIs and it may not stay in the Java heap,
+ * thus it is not affected by garbage collection.</li>
* </ul>
* </p>
* <p>
@@ -46,7 +46,8 @@ package java.nio;
* required, then the callers are responsible to take care of the
* synchronization issues.
* </p>
- *
+ *
+ * @since Android 1.0
*/
public abstract class Buffer {
@@ -61,13 +62,13 @@ public abstract class Buffer {
final int capacity;
/**
- * <code>limit - 1</code> is the last element that can be read or write.
+ * <code>limit - 1</code> is the last element that can be read or written.
* Limit must be no less than zero and no greater than <code>capacity</code>.
*/
int limit;
/**
- * Mark is the position will be set when <code>reset()</code> is called.
+ * Mark is where position will be set when <code>reset()</code> is called.
* Mark is not set by default. Mark is always no less than zero and no
* greater than <code>position</code>.
*/
@@ -116,7 +117,7 @@ public abstract class Buffer {
* Construct a buffer with the specified capacity.
*
* @param capacity
- * The capacity of this buffer
+ * the capacity of this buffer.
*/
Buffer(int capacity) {
super();
@@ -128,8 +129,9 @@ public abstract class Buffer {
/**
* Returns the capacity of this buffer.
- *
- * @return The number of elements that are contained in this buffer.
+ *
+ * @return the number of elements that are contained in this buffer.
+ * @since Android 1.0
*/
public final int capacity() {
return capacity;
@@ -138,12 +140,14 @@ public abstract class Buffer {
/**
* Clears this buffer.
* <p>
- * While the content of this buffer is not changed the following internal
- * changes take place : the current position is reset back to the start of the buffer,
- * the value of the buffer limit is made equal to the capacity and mark is unset.
+ * While the content of this buffer is not changed, the following internal
+ * changes take place: the current position is reset back to the start of
+ * the buffer, the value of the buffer limit is made equal to the capacity
+ * and mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
+ * @since Android 1.0
*/
public final Buffer clear() {
position = 0;
@@ -161,8 +165,9 @@ public abstract class Buffer {
* <p>
* The content of this buffer is not changed.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
+ * @since Android 1.0
*/
public final Buffer flip() {
limit = position;
@@ -172,28 +177,31 @@ public abstract class Buffer {
}
/**
- * Returns true if there are remaining element(s) in this buffer.
- * <p>
- * Or more precisely, returns <code>position &lt; limit</code>.
- * </p>
- *
- * @return True if there are remaining element(s) in this buffer.
+ * Indicates if there are elements remaining in this buffer, that is if
+ * {@code position < limit}.
+ *
+ * @return {@code true} if there are elements remaining in this buffer,
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasRemaining() {
return position < limit;
}
/**
- * Returns whether this buffer is readonly or not.
- *
- * @return Whether this buffer is readonly or not.
+ * Indicates whether this buffer is read-only.
+ *
+ * @return {@code true} if this buffer is read-only, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public abstract boolean isReadOnly();
/**
* Returns the limit of this buffer.
- *
- * @return The limit of this buffer.
+ *
+ * @return the limit of this buffer.
+ * @since Android 1.0
*/
public final int limit() {
return limit;
@@ -207,13 +215,14 @@ public abstract class Buffer {
* been adjusted to be equivalent to <code>newLimit</code>. If the mark
* is set and is greater than the new limit, then it is cleared.
* </p>
- *
+ *
* @param newLimit
- * The new limit, must be no less than zero and no greater than
- * capacity
- * @return This buffer
+ * the new limit, must not be negative and not greater than
+ * capacity.
+ * @return this buffer.
* @exception IllegalArgumentException
- * If <code>newLimit</code> is invalid.
+ * if <code>newLimit</code> is invalid.
+ * @since Android 1.0
*/
public final Buffer limit(int newLimit) {
if (newLimit < 0 || newLimit > capacity) {
@@ -231,10 +240,11 @@ public abstract class Buffer {
}
/**
- * Mark the current position, so that the position may return to this point
+ * Marks the current position, so that the position may return to this point
* later by calling <code>reset()</code>.
- *
- * @return This buffer
+ *
+ * @return this buffer.
+ * @since Android 1.0
*/
public final Buffer mark() {
mark = position;
@@ -243,8 +253,9 @@ public abstract class Buffer {
/**
* Returns the position of this buffer.
- *
- * @return The value of this buffer's current position.
+ *
+ * @return the value of this buffer's current position.
+ * @since Android 1.0
*/
public final int position() {
return position;
@@ -253,16 +264,17 @@ public abstract class Buffer {
/**
* Sets the position of this buffer.
* <p>
- * If the mark is set and is greater than the new position, then it is
+ * If the mark is set and it is greater than the new position, then it is
* cleared.
* </p>
- *
+ *
* @param newPosition
- * The new position, must be no less than zero and no greater
- * than limit
- * @return This buffer
+ * the new position, must be not negative and not greater than
+ * limit.
+ * @return this buffer.
* @exception IllegalArgumentException
- * If <code>newPosition</code> is invalid
+ * if <code>newPosition</code> is invalid.
+ * @since Android 1.0
*/
public final Buffer position(int newPosition) {
if (newPosition < 0 || newPosition > limit) {
@@ -277,23 +289,23 @@ public abstract class Buffer {
}
/**
- * Returns the number of remaining elements in this buffer.
- * <p>
- * Or more precisely, returns <code>limit - position</code>.
- * </p>
- *
- * @return The number of remaining elements in this buffer.
+ * Returns the number of remaining elements in this buffer, that is
+ * {@code limit - position}.
+ *
+ * @return the number of remaining elements in this buffer.
+ * @since Android 1.0
*/
public final int remaining() {
return limit - position;
}
/**
- * Reset the position of this buffer to the <code>mark</code>.
- *
- * @return This buffer
+ * Resets the position of this buffer to the <code>mark</code>.
+ *
+ * @return this buffer.
* @exception InvalidMarkException
- * If the mark is not set
+ * if the mark is not set.
+ * @since Android 1.0
*/
public final Buffer reset() {
if (mark == UNSET_MARK) {
@@ -306,13 +318,12 @@ public abstract class Buffer {
/**
* Rewinds this buffer.
* <p>
- * The position is set to zero, and the mark is cleared.
+ * The position is set to zero, and the mark is cleared. The content of this
+ * buffer is not changed.
* </p>
- * <p>
- * The content of this buffer is not changed.
- * </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
+ * @since Android 1.0
*/
public final Buffer rewind() {
position = 0;
diff --git a/nio/src/main/java/java/nio/BufferOverflowException.java b/nio/src/main/java/java/nio/BufferOverflowException.java
index 9dc6330..a9ec60d 100644
--- a/nio/src/main/java/java/nio/BufferOverflowException.java
+++ b/nio/src/main/java/java/nio/BufferOverflowException.java
@@ -18,10 +18,10 @@ package java.nio;
/**
- * A <code>BufferOverflowException</code> is thrown when you try to write
- * elements to a buffer, but there is not enough remaining space in the
- * buffer.
+ * A <code>BufferOverflowException</code> is thrown when elements are written
+ * to a buffer but there is not enough remaining space in the buffer.
*
+ * @since Android 1.0
*/
public class BufferOverflowException extends RuntimeException {
@@ -29,6 +29,8 @@ public class BufferOverflowException extends RuntimeException {
/**
* Constructs a <code>BufferOverflowException</code>.
+ *
+ * @since Android 1.0
*/
public BufferOverflowException() {
super();
diff --git a/nio/src/main/java/java/nio/BufferUnderflowException.java b/nio/src/main/java/java/nio/BufferUnderflowException.java
index fe56555..f15a8db 100644
--- a/nio/src/main/java/java/nio/BufferUnderflowException.java
+++ b/nio/src/main/java/java/nio/BufferUnderflowException.java
@@ -18,10 +18,10 @@ package java.nio;
/**
- * A <code>BufferUnderflowException</code> is thrown when you try to read
- * elements from a buffer, but there is not enough remaining elements in the
- * buffer.
+ * A <code>BufferUnderflowException</code> is thrown when elements are read
+ * from a buffer but there are not enough remaining elements in the buffer.
*
+ * @since Android 1.0
*/
public class BufferUnderflowException extends RuntimeException {
@@ -29,6 +29,8 @@ public class BufferUnderflowException extends RuntimeException {
/**
* Constructs a <code>BufferUnderflowException</code>.
+ *
+ * @since Android 1.0
*/
public BufferUnderflowException() {
super();
diff --git a/nio/src/main/java/java/nio/ByteBuffer.java b/nio/src/main/java/java/nio/ByteBuffer.java
index 7a14ad9..a033298 100644
--- a/nio/src/main/java/java/nio/ByteBuffer.java
+++ b/nio/src/main/java/java/nio/ByteBuffer.java
@@ -21,9 +21,10 @@ package java.nio;
import org.apache.harmony.luni.platform.Endianness;
/**
- * A buffer of <code>byte</code>s.
+ * A buffer for bytes.
* <p>
- * A byte buffer can be created in either of the following ways:
+ * A byte buffer can be created in either one of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new byte array and create a buffer
* based on it;</li>
@@ -32,19 +33,19 @@ import org.apache.harmony.luni.platform.Endianness;
* <li>{@link #wrap(byte[]) Wrap} an existing byte array to create a new
* buffer.</li>
* </ul>
- * </p>
- *
+ * @since Android 1.0
*/
public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer> {
/**
- * Creates a byte buffer based on a new allocated byte array.
- *
+ * Creates a byte buffer based on a newly allocated byte array.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created byte buffer
+ * the capacity of the new buffer
+ * @return the created byte buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity < 0}.
+ * @since Android 1.0
*/
public static ByteBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -54,13 +55,14 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Creates a direct byte buffer based on a new allocated memory block.
- *
+ * Creates a direct byte buffer based on a newly allocated memory block.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created byte buffer
+ * the capacity of the new buffer
+ * @return the created byte buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity < 0}.
+ * @since Android 1.0
*/
public static ByteBuffer allocateDirect(int capacity) {
if (capacity < 0) {
@@ -73,34 +75,37 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* Creates a new byte buffer by wrapping the given byte array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.</p>
- *
- * @param array The byte array which the new buffer will be based on
- * @return The created byte buffer
+ * {@code wrap(array, 0, array.length)}.
+ * </p>
+ *
+ * @param array
+ * the byte array which the new buffer will be based on
+ * @return the created byte buffer.
+ * @since Android 1.0
*/
public static ByteBuffer wrap(byte[] array) {
return BufferFactory.newByteBuffer(array);
}
/**
- * Creates new a byte buffer by wrapping the given byte array.
+ * Creates a new byte buffer by wrapping the given byte array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The byte array which the new buffer will be based on
+ * the byte array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created byte buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created byte buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static ByteBuffer wrap(byte[] array, int start, int len) {
int length = array.length;
@@ -116,14 +121,16 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * The byte order of this buffer, default is <code>BIG_ENDIAN</code>.
+ * The byte order of this buffer, default is {@code BIG_ENDIAN}.
*/
Endianness order = Endianness.BIG_ENDIAN;
/**
- * Constructs a <code>ByteBuffer</code> with given capacity.
- *
- * @param capacity The capacity of the buffer
+ * Constructs a {@code ByteBuffer} with given capacity.
+ *
+ * @param capacity
+ * the capacity of the buffer.
+ * @since Android 1.0
*/
ByteBuffer(int capacity) {
super(capacity);
@@ -133,13 +140,14 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Returns the byte array which this buffer is based on, if there's one.
- *
- * @return The byte array which this buffer is based on
+ * Returns the byte array which this buffer is based on, if there is one.
+ *
+ * @return the byte array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on a readonly array
+ * if this buffer is based on a read-only array.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final byte[] array() {
return protectedArray();
@@ -147,31 +155,34 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
/**
* Returns the offset of the byte array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
- * The offset is the index of the array corresponds to the zero position of
- * the buffer.
+ * The offset is the index of the array which corresponds to the zero
+ * position of the buffer.
* </p>
- *
- * @return The offset of the byte array which this buffer is based on
+ *
+ * @return the offset of the byte array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on a readonly array
+ * if this buffer is based on a read-only array.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override Object _array() {
+ @Override
+ Object _array() {
if (hasArray()) {
return array();
}
return null;
}
- @Override int _arrayOffset() {
+ @Override
+ int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
}
@@ -180,154 +191,172 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
// END android-added
/**
- * Returns a char buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a char buffer which is based on the remaining content of this
+ * byte buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by two, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A char buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a char buffer which is based on the content of this byte buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer asCharBuffer();
/**
- * Returns a double buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a double buffer which is based on the remaining content of this
+ * byte buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by eight, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A double buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a double buffer which is based on the content of this byte
+ * buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer asDoubleBuffer();
/**
- * Returns a float buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a float buffer which is based on the remaining content of this
+ * byte buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by four, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A float buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a float buffer which is based on the content of this byte buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer asFloatBuffer();
/**
- * Returns a int buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a int buffer which is based on the remaining content of this byte
+ * buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by four, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A int buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a int buffer which is based on the content of this byte buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer asIntBuffer();
/**
- * Returns a long buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a long buffer which is based on the remaining content of this
+ * byte buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by eight, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A long buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a long buffer which is based on the content of this byte buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer asLongBuffer();
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this
- * buffer is readonly itself. The new buffer's position, limit, capacity
- * and mark are the same as this buffer.</p>
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * this buffer's change of content will be visible to the new buffer.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A readonly version of this buffer.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
+ * </p>
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer asReadOnlyBuffer();
/**
- * Returns a short buffer which is based on the remaining content of
- * this byte buffer.
+ * Returns a short buffer which is based on the remaining content of this
+ * byte buffer.
* <p>
- * The new buffer's position is zero, its limit and capacity is
- * the number of remaining bytes divided by two, and its mark is not set.
- * The new buffer's readonly property and byte order are same as this
- * buffer. The new buffer is direct, if this byte buffer is direct.</p>
+ * The new buffer's position is zero, its limit and capacity is the number
+ * of remaining bytes divided by two, and its mark is not set. The new
+ * buffer's read-only property and byte order are the same as this buffer's.
+ * The new buffer is direct if this byte buffer is direct.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A short buffer which is based on the content of
- * this byte buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a short buffer which is based on the content of this byte buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer asShortBuffer();
/**
* Compacts this byte buffer.
* <p>
- * The remaining <code>byte</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
+ * The remaining bytes will be moved to the head of the
+ * buffer, starting from position zero. Then the position is set to
+ * {@code remaining()}; the limit is set to capacity; the mark is
* cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer compact();
/**
- * Compare the remaining <code>byte</code>s of this buffer to another
- * byte buffer's remaining <code>byte</code>s.
- *
+ * Compares the remaining bytes of this buffer to another byte buffer's
+ * remaining bytes.
+ *
* @param otherBuffer
- * Another byte buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another byte buffer.
+ * @return a negative value if this is less than {@code other}; 0 if this
+ * equals to {@code other}; a positive value if this is greater
+ * than {@code other}.
* @exception ClassCastException
- * If <code>other</code> is not a byte buffer
+ * if {@code other} is not a byte buffer.
+ * @since Android 1.0
*/
public int compareTo(ByteBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -349,31 +378,36 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
- * The duplicated buffer's position, limit, capacity and mark are the
- * same as this buffer. The duplicated buffer's readonly property and
- * byte order are same as this buffer too.</p>
+ * The duplicated buffer's position, limit, capacity and mark are the same
+ * as this buffer's. The duplicated buffer's read-only property and byte
+ * order are the same as this buffer's too.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer duplicate();
/**
- * Tests whether this byte buffer equals to another object.
- * <p>
- * If <code>other</code> is not a byte buffer, then false is returned.</p>
+ * Checks whether this byte buffer is equal to another object.
* <p>
- * Two byte buffers are equals if, and only if, their remaining
- * <code>byte</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.</p>
- *
- * @param other the object to compare against
- * @return Whether this byte buffer equals to another object.
+ * If {@code other} is not a byte buffer then {@code false} is returned. Two
+ * byte buffers are equal if and only if their remaining bytes are exactly
+ * the same. Position, limit, capacity and mark are not considered.
+ * </p>
+ *
+ * @param other
+ * the object to compare with this byte buffer.
+ * @return {@code true} if this byte buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof ByteBuffer)) {
@@ -396,54 +430,53 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Returns the byte at the current position and increase the position by 1.
- *
- * @return The byte at the current position.
+ * Returns the byte at the current position and increases the position by 1.
+ *
+ * @return the byte at the current position.
* @exception BufferUnderflowException
- * If the position is equal or greater than limit
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract byte get();
/**
- * Reads <code>byte</code>s from the current position into the specified
- * byte array and increase the position by the number of <code>byte</code>s
- * read.
+ * Reads bytes from the current position into the specified byte array and
+ * increases the position by the number of bytes read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination byte array
- * @return This buffer
+ * the destination byte array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public ByteBuffer get(byte[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>byte</code>s from the current position into the specified
- * byte array, starting from the specified offset, and increase the position
- * by the number of <code>byte</code>s read.
- *
+ * Reads bytes from the current position into the specified byte array,
+ * starting at the specified offset, and increases the position by the
+ * number of bytes read.
+ *
* @param dest
- * The target byte array
+ * the target byte array.
* @param off
- * The offset of the byte array, must be no less than zero and no
- * greater than <code>dest.length</code>
+ * the offset of the byte array, must not be negative and
+ * not greater than {@code dest.length}.
* @param len
- * The number of <code>byte</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of bytes to read, must not be negative and not
+ * greater than {@code dest.length - off}
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public ByteBuffer get(byte[] dest, int off, int len) {
int length = dest.length;
@@ -461,214 +494,229 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Returns a byte at the specified index, and the position is not changed.
- *
- * @param index The index, must be no less than zero and less than limit
- * @return A byte at the specified index.
- * @exception IndexOutOfBoundsException If index is invalid
+ * Returns the byte at the specified index and does not change the position.
+ *
+ * @param index
+ * the index, must not be negative and less than limit.
+ * @return the byte at the specified index.
+ * @exception IndexOutOfBoundsException
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract byte get(int index);
/**
- * Returns the char at the current position and increase the position by 2.
+ * Returns the char at the current position and increases the position by 2.
* <p>
- * The 2 bytes start from the current position are composed into a char
- * according to current byte order and returned. The position increases by
- * 2.
+ * The 2 bytes starting at the current position are composed into a char
+ * according to the current byte order and returned.
* </p>
- *
- * @return The char at the current position.
+ *
+ * @return the char at the current position.
* @exception BufferUnderflowException
- * If the position is greater than <code>limit - 2</code>
+ * if the position is greater than {@code limit - 2}.
+ * @since Android 1.0
*/
public abstract char getChar();
/**
* Returns the char at the specified index.
* <p>
- * The 2 bytes start from the specified index are composed into a char
- * according to current byte order and returned. The position is not
+ * The 2 bytes starting from the specified index are composed into a char
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 2</code>
- * @return The char at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 2}.
+ * @return the char at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract char getChar(int index);
/**
- * Returns the double at the current position and increase the position by
+ * Returns the double at the current position and increases the position by
* 8.
* <p>
- * The 8 bytes start from the current position are composed into a double
- * according to current byte order and returned. The position increases by
- * 8.
+ * The 8 bytes starting from the current position are composed into a double
+ * according to the current byte order and returned.
* </p>
- *
- * @return The double at the current position.
+ *
+ * @return the double at the current position.
* @exception BufferUnderflowException
- * If the position is greater than <code>limit - 8</code>
+ * if the position is greater than {@code limit - 8}.
+ * @since Android 1.0
*/
public abstract double getDouble();
/**
* Returns the double at the specified index.
* <p>
- * The 8 bytes start from the specified index are composed into a double
- * according to current byte order and returned. The position is not
+ * The 8 bytes starting at the specified index are composed into a double
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 8</code>
- * @return The double at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 8}.
+ * @return the double at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract double getDouble(int index);
/**
- * Returns the float at the current position and increase the position by 4.
- * <p>
- * The 4 bytes start from the current position are composed into a float
- * according to current byte order and returned. The position increases by
+ * Returns the float at the current position and increases the position by
* 4.
+ * <p>
+ * The 4 bytes starting at the current position are composed into a float
+ * according to the current byte order and returned.
* </p>
- *
- * @return The float at the current position.
+ *
+ * @return the float at the current position.
* @exception BufferUnderflowException
- * If the position is greater than <code>limit - 4</code>
+ * if the position is greater than {@code limit - 4}.
+ * @since Android 1.0
*/
public abstract float getFloat();
/**
* Returns the float at the specified index.
* <p>
- * The 4 bytes start from the specified index are composed into a float
- * according to current byte order and returned. The position is not
+ * The 4 bytes starting at the specified index are composed into a float
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 4</code>
- * @return The float at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 4}.
+ * @return the float at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract float getFloat(int index);
/**
- * Returns the int at the current position and increase the position by 4.
+ * Returns the int at the current position and increases the position by 4.
* <p>
- * The 4 bytes start from the current position are composed into a int
- * according to current byte order and returned.
- * The position increases by 4.</p>
- *
- * @return The int at the current position.
- * @exception BufferUnderflowException If the position is greater than <code>limit - 4</code>
+ * The 4 bytes starting at the current position are composed into a int
+ * according to the current byte order and returned.
+ * </p>
+ *
+ * @return the int at the current position.
+ * @exception BufferUnderflowException
+ * if the position is greater than {@code limit - 4}.
+ * @since Android 1.0
*/
public abstract int getInt();
/**
* Returns the int at the specified index.
* <p>
- * The 4 bytes start from the specified index are composed into a int
- * according to current byte order and returned. The position is not
+ * The 4 bytes starting at the specified index are composed into a int
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 4</code>
- * @return The int at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 4}.
+ * @return the int at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract int getInt(int index);
/**
- * Returns the long at the current position and increase the position by 8.
+ * Returns the long at the current position and increases the position by 8.
* <p>
- * The 8 bytes start from the current position are composed into a long
- * according to current byte order and returned. The position increases by
- * 8.
+ * The 8 bytes starting at the current position are composed into a long
+ * according to the current byte order and returned.
* </p>
- *
- * @return The long at the current position.
+ *
+ * @return the long at the current position.
* @exception BufferUnderflowException
- * If the position is greater than <code>limit - 8</code>
+ * if the position is greater than {@code limit - 8}.
+ * @since Android 1.0
*/
public abstract long getLong();
/**
* Returns the long at the specified index.
* <p>
- * The 8 bytes start from the specified index are composed into a long
- * according to current byte order and returned. The position is not
+ * The 8 bytes starting at the specified index are composed into a long
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
*
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 8</code>
- * @return The long at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 8}.
+ * @return the long at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract long getLong(int index);
/**
- * Returns the short at the current position and increase the position by 2.
+ * Returns the short at the current position and increases the position by 2.
* <p>
- * The 2 bytes start from the current position are composed into a short
- * according to current byte order and returned.
- * The position increases by 2.</p>
- *
- * @return The short at the current position.
- * @exception BufferUnderflowException If the position is greater than <code>limit - 2</code>
+ * The 2 bytes starting at the current position are composed into a short
+ * according to the current byte order and returned.
+ * </p>
+ *
+ * @return the short at the current position.
+ * @exception BufferUnderflowException
+ * if the position is greater than {@code limit - 2}.
+ * @since Android 1.0
*/
public abstract short getShort();
/**
* Returns the short at the specified index.
* <p>
- * The 2 bytes start from the specified index are composed into a short
- * according to current byte order and returned. The position is not
+ * The 2 bytes starting at the specified index are composed into a short
+ * according to the current byte order and returned. The position is not
* changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 2</code>
- * @return The short at the specified index.
+ * the index, must not be negative and equal or less than
+ * {@code limit - 2}.
+ * @return the short at the specified index.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
+ * @since Android 1.0
*/
public abstract short getShort(int index);
/**
- * Returns whether this buffer is based on a byte array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.</p>
- *
- * @return Whether this buffer is based on a byte array and is read/write.
+ * Indicates whether this buffer is based on a byte array and provides
+ * read/write access.
+ *
+ * @return {@code true} if this buffer is based on a byte array and provides
+ * read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>byte</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.</p>
- *
- * @return The hash code calculated from the remaining <code>byte</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining bytes.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -680,24 +728,24 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Returns true if this buffer is direct.
- * <p>
- * A byte buffer is direct, if it is based on a byte buffer and the byte
- * buffer is direct.
- * </p>
- *
- * @return True if this buffer is direct.
+ * Indicates whether this buffer is direct.
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>byte</code>s from/to other primitive types.
+ * Returns the byte order used by this buffer when converting bytes from/to
+ * other primitive types.
* <p>
- * The default byte order of byte buffer is always BIG_ENDIAN.</p>
- *
- * @return The byte order used by this buffer when converting
- * <code>byte</code>s from/to other primitive types.
+ * The default byte order of byte buffer is always
+ * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
+ * </p>
+ *
+ * @return the byte order used by this buffer when converting bytes from/to
+ * other primitive types.
+ * @since Android 1.0
*/
public final ByteOrder order() {
return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN
@@ -706,12 +754,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
/**
* Sets the byte order of this buffer.
- *
+ *
* @param byteOrder
- * The byte order to set. If <code>null</code> then the order
+ * the byte order to set. If {@code null} then the order
* will be {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}.
- * @return This buffer
+ * @return this buffer.
* @see ByteOrder
+ * @since Android 1.0
*/
public final ByteBuffer order(ByteOrder byteOrder) {
return orderImpl(byteOrder);
@@ -724,84 +773,86 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Child class implements this method to realize <code>array()</code>.
- *
- * @return see <code>array()</code>
+ * Child class implements this method to realize {@code array()}.
+ *
+ * @see #array()
+ * @since Android 1.0
*/
abstract byte[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
- *
- * @return see <code>arrayOffset()</code>
+ * Child class implements this method to realize {@code arrayOffset()}.
+ *
+ * @see #arrayOffset()
+ * @since Android 1.0
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
- *
- * @return see <code>hasArray()</code>
+ * Child class implements this method to realize {@code hasArray()}.
+ *
+ * @see #hasArray()
+ * @since Android 1.0
*/
abstract boolean protectedHasArray();
/**
- * Writes the given byte to the current position and increase the position
+ * Writes the given byte to the current position and increases the position
* by 1.
- *
+ *
* @param b
- * The byte to write
- * @return This buffer
+ * the byte to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer put(byte b);
/**
- * Writes <code>byte</code>s in the given byte array to the current
- * position and increase the position by the number of <code>byte</code>s
- * written.
+ * Writes bytes in the given byte array to the current position and
+ * increases the position by the number of bytes written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source byte array
- * @return This buffer
+ * the source byte array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final ByteBuffer put(byte[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>byte</code>s in the given byte array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>byte</code>s written.
- *
+ * Writes bytes in the given byte array, starting from the specified offset,
+ * to the current position and increases the position by the number of bytes
+ * written.
+ *
* @param src
- * The source byte array
+ * the source byte array.
* @param off
- * The offset of byte array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of byte array, must not be negative and not greater
+ * than {@code src.length}.
* @param len
- * The number of <code>byte</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of bytes to write, must not be negative and not
+ * greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public ByteBuffer put(byte[] src, int off, int len) {
int length = src.length;
@@ -819,20 +870,21 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Writes all the remaining <code>byte</code>s of the <code>src</code>
- * byte buffer to this buffer's current position, and increase both buffers'
- * position by the number of <code>byte</code>s copied.
- *
+ * Writes all the remaining bytes of the {@code src} byte buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of bytes copied.
+ *
* @param src
- * The source byte buffer
- * @return This buffer
+ * the source byte buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public ByteBuffer put(ByteBuffer src) {
if (src == this) {
@@ -848,264 +900,281 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
}
/**
- * Write a byte to the specified index of this buffer and the position is
- * not changed.
- *
+ * Write a byte to the specified index of this buffer without changing the
+ * position.
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param b
- * The byte to write
- * @return This buffer
+ * the byte to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer put(int index, byte b);
/**
- * Writes the given char to the current position and increase the position
+ * Writes the given char to the current position and increases the position
* by 2.
* <p>
* The char is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The char to write
- * @return This buffer
+ * the char to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 2</code>
+ * if position is greater than {@code limit - 2}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putChar(char value);
/**
- * Write a char to the specified index of this buffer.
+ * Writes the given char to the specified index of this buffer.
* <p>
* The char is converted to bytes using the current byte order. The position
* is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 2</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 2}.
* @param value
- * The char to write
- * @return This buffer
+ * the char to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putChar(int index, char value);
/**
- * Writes the given double to the current position and increase the position
+ * Writes the given double to the current position and increases the position
* by 8.
* <p>
* The double is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The double to write
- * @return This buffer
+ * the double to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 8</code>
+ * if position is greater than {@code limit - 8}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putDouble(double value);
/**
- * Write a double to the specified index of this buffer.
+ * Writes the given double to the specified index of this buffer.
* <p>
* The double is converted to bytes using the current byte order. The
* position is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 8</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 8}.
* @param value
- * The double to write
- * @return This buffer
+ * the double to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putDouble(int index, double value);
/**
- * Writes the given float to the current position and increase the position
+ * Writes the given float to the current position and increases the position
* by 4.
* <p>
* The float is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The float to write
- * @return This buffer
+ * the float to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 4</code>
+ * if position is greater than {@code limit - 4}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putFloat(float value);
/**
- * Write a float to the specified index of this buffer.
+ * Writes the given float to the specified index of this buffer.
* <p>
* The float is converted to bytes using the current byte order. The
* position is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 4</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 4}.
* @param value
- * The float to write
- * @return This buffer
+ * the float to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putFloat(int index, float value);
/**
- * Writes the given int to the current position and increase the position by
+ * Writes the given int to the current position and increases the position by
* 4.
* <p>
* The int is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The int to write
- * @return This buffer
+ * the int to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 4</code>
+ * if position is greater than {@code limit - 4}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putInt(int value);
/**
- * Write a int to the specified index of this buffer.
+ * Writes the given int to the specified index of this buffer.
* <p>
* The int is converted to bytes using the current byte order. The position
* is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 4</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 4}.
* @param value
- * The int to write
- * @return This buffer
+ * the int to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putInt(int index, int value);
/**
- * Writes the given long to the current position and increase the position
+ * Writes the given long to the current position and increases the position
* by 8.
* <p>
* The long is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The long to write
- * @return This buffer
+ * the long to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 8</code>
+ * if position is greater than {@code limit - 8}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putLong(long value);
/**
- * Write a long to the specified index of this buffer.
+ * Writes the given long to the specified index of this buffer.
* <p>
* The long is converted to bytes using the current byte order. The position
* is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 8</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 8}.
* @param value
- * The long to write
- * @return This buffer
+ * the long to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putLong(int index, long value);
/**
- * Writes the given short to the current position and increase the position
+ * Writes the given short to the current position and increases the position
* by 2.
* <p>
* The short is converted to bytes using the current byte order.
* </p>
- *
+ *
* @param value
- * The short to write
- * @return This buffer
+ * the short to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is greater than <code>limit - 2</code>
+ * if position is greater than {@code limit - 2}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putShort(short value);
/**
- * Write a short to the specified index of this buffer.
+ * Writes the given short to the specified index of this buffer.
* <p>
* The short is converted to bytes using the current byte order. The
* position is not changed.
* </p>
- *
+ *
* @param index
- * The index, must be no less than zero and equal or less than
- * <code>limit - 2</code>
+ * the index, must not be negative and equal or less than
+ * {@code limit - 2}.
* @param value
- * The short to write
- * @return This buffer
+ * the short to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If <code>index</code> is invalid
+ * if {@code index} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer putShort(int index, short value);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
* The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be
- * 0, limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.</p>
+ * {@code remaining()}, and it's zero position will correspond to
+ * this buffer's current position. The new buffer's position will be 0,
+ * limit will be its capacity, and its mark is cleared. The new buffer's
+ * read-only property and byte order are the same as this buffer's.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract ByteBuffer slice();
/**
- * Returns a string represents the state of this byte buffer.
- *
- * @return A string represents the state of this byte buffer.
+ * Returns a string representing the state of this byte buffer.
+ *
+ * @return a string representing the state of this byte buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
diff --git a/nio/src/main/java/java/nio/ByteOrder.java b/nio/src/main/java/java/nio/ByteOrder.java
index 4ae6a96..870216f 100644
--- a/nio/src/main/java/java/nio/ByteOrder.java
+++ b/nio/src/main/java/java/nio/ByteOrder.java
@@ -20,18 +20,23 @@ package java.nio;
import org.apache.harmony.luni.platform.Platform;
/**
- * Holds byte order constants.
+ * Defines byte order constants.
*
+ * @since Android 1.0
*/
public final class ByteOrder {
/**
* This constant represents big endian.
+ *
+ * @since Android 1.0
*/
public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); //$NON-NLS-1$
/**
* This constant represents little endian.
+ *
+ * @since Android 1.0
*/
public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); //$NON-NLS-1$
@@ -48,8 +53,9 @@ public final class ByteOrder {
/**
* Returns the current platform byte order.
*
- * @return the byte order object, which is either identical to LITTLE_ENDIAN
- * or BIG_ENDIAN.
+ * @return the byte order object, which is either LITTLE_ENDIAN or
+ * BIG_ENDIAN.
+ * @since Android 1.0
*/
public static ByteOrder nativeOrder() {
return NATIVE_ORDER;
@@ -62,10 +68,13 @@ public final class ByteOrder {
this.name = name;
}
- /*
- * (non-Javadoc)
+ /**
+ * Returns a string that describes this object.
*
- * @see java.lang.Object#toString()
+ * @return "BIG_ENDIAN" for {@link #BIG_ENDIAN ByteOrder.BIG_ENDIAN}
+ * objects, "LITTLE_ENDIAN" for
+ * {@link #LITTLE_ENDIAN ByteOrder.LITTLE_ENDIAN} objects.
+ * @since Android 1.0
*/
public String toString() {
return name;
diff --git a/nio/src/main/java/java/nio/CharBuffer.java b/nio/src/main/java/java/nio/CharBuffer.java
index 2c12e8e..289965a 100644
--- a/nio/src/main/java/java/nio/CharBuffer.java
+++ b/nio/src/main/java/java/nio/CharBuffer.java
@@ -20,9 +20,10 @@ package java.nio;
import java.io.IOException;
/**
- * A buffer of <code>char</code>s.
+ * A buffer of chars.
* <p>
- * A char buffer can be created in either of the following ways:
+ * A char buffer can be created in either one of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new char array and create a buffer
* based on it;</li>
@@ -33,20 +34,21 @@ import java.io.IOException;
* <li>Use {@link java.nio.ByteBuffer#asCharBuffer() ByteBuffer.asCharBuffer}
* to create a char buffer based on a byte buffer.</li>
* </ul>
- * </p>
- *
+ *
+ * @since Android 1.0
*/
public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer>,
CharSequence, Appendable, Readable {
/**
- * Creates a char buffer based on a new allocated char array.
- *
+ * Creates a char buffer based on a newly allocated char array.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created char buffer
+ * the capacity of the new buffer.
+ * @return the created char buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static CharBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -59,36 +61,37 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* Creates a new char buffer by wrapping the given char array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.
+ * {@code wrap(array, 0, array.length)}.
* </p>
- *
+ *
* @param array
- * The char array which the new buffer will be based on
- * @return The created char buffer
+ * the char array which the new buffer will be based on.
+ * @return the created char buffer.
+ * @since Android 1.0
*/
public static CharBuffer wrap(char[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a char buffer by wrapping the given char array.
+ * Creates a new char buffer by wrapping the given char array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The char array which the new buffer will be based on
+ * the char array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created char buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created char buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static CharBuffer wrap(char[] array, int start, int len) {
int length = array.length;
@@ -108,12 +111,13 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* Creates a new char buffer by wrapping the given char sequence.
* <p>
* Calling this method has the same effect as
- * <code>wrap(chseq, 0, chseq.length())</code>.
+ * {@code wrap(chseq, 0, chseq.length())}.
* </p>
- *
+ *
* @param chseq
- * The char sequence which the new buffer will be based on
- * @return The created char buffer
+ * the char sequence which the new buffer will be based on.
+ * @return the created char buffer.
+ * @since Android 1.0
*/
public static CharBuffer wrap(CharSequence chseq) {
return BufferFactory.newCharBuffer(chseq);
@@ -122,23 +126,23 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Creates a new char buffer by wrapping the given char sequence.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>end</code>, capacity will be the length of the char sequence.
- * The new buffer is readonly.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code end}, capacity will be the length of the char sequence. The new
+ * buffer is read-only.
* </p>
- *
+ *
* @param chseq
- * The char sequence which the new buffer will be based on
+ * the char sequence which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>chseq.length()</code>
+ * the start index, must not be negative and not greater than
+ * {@code chseq.length()}.
* @param end
- * The end index, must be no less than <code>start</code> and
- * no greater than <code>chseq.length()</code>
- * @return The created char buffer
+ * the end index, must be no less than {@code start} and no
+ * greater than {@code chseq.length()}.
+ * @return the created char buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>end</code> is
- * invalid
+ * if either {@code start} or {@code end} is invalid.
+ * @since Android 1.0
*/
public static CharBuffer wrap(CharSequence chseq, int start, int end) {
if (chseq == null) {
@@ -147,7 +151,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
if (start < 0 || end < start || end > chseq.length()) {
throw new IndexOutOfBoundsException();
}
-
+
CharBuffer result = BufferFactory.newCharBuffer(chseq);
result.position = start;
result.limit = end;
@@ -155,10 +159,11 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Constructs a <code>CharBuffer</code> with given capacity.
- *
+ * Constructs a {@code CharBuffer} with given capacity.
+ *
* @param capacity
- * The capacity of the buffer
+ * the capacity of the buffer.
+ * @since Android 1.0
*/
CharBuffer(int capacity) {
super(capacity);
@@ -168,13 +173,14 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns the char array which this buffer is based on, if there's one.
- *
- * @return The char array which this buffer is based on
+ * Returns the char array which this buffer is based on, if there is one.
+ *
+ * @return the char array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final char[] array() {
return protectedArray();
@@ -182,31 +188,34 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Returns the offset of the char array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
* The offset is the index of the array corresponds to the zero position of
* the buffer.
* </p>
- *
- * @return The offset of the char array which this buffer is based on
+ *
+ * @return the offset of the char array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override Object _array() {
+ @Override
+ Object _array() {
if (hasArray()) {
return array();
}
return null;
}
- @Override int _arrayOffset() {
+ @Override
+ int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
}
@@ -215,34 +224,36 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this buffer
- * is readonly itself. The new buffer's position, limit, capacity and mark
- * are the same as this buffer.
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means this buffer's
- * change of content will be visible to the new buffer. The two buffer's
- * position, limit and mark are independent.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
* </p>
- *
- * @return A readonly version of this buffer.
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer asReadOnlyBuffer();
/**
* Returns the character located at the specified index in the buffer. The
* index value is referenced from the current buffer position.
- *
+ *
* @param index
- * The index referenced from the current buffer position. It must
+ * the index referenced from the current buffer position. It must
* not be less than zero but less than the value obtained from a
- * call to <code>remaining()</code>
+ * call to {@code remaining()}.
* @return the character located at the specified index (referenced from the
* current position) in the buffer.
* @exception IndexOutOfBoundsException
- * If the index is invalid
+ * if the index is invalid.
+ * @since Android 1.0
*/
public final char charAt(int index) {
if (index < 0 || index >= remaining()) {
@@ -254,29 +265,30 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Compacts this char buffer.
* <p>
- * The remaining <code>char</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining chars will be moved to the head of the buffer,
+ * starting from position zero. Then the position is set to
+ * {@code remaining()}; the limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer compact();
/**
- * Compare the remaining <code>char</code>s of this buffer to another
- * char buffer's remaining <code>char</code>s.
- *
+ * Compare the remaining chars of this buffer to another char
+ * buffer's remaining chars.
+ *
* @param otherBuffer
- * Another char buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another char buffer.
+ * @return a negative value if this is less than {@code otherBuffer}; 0 if
+ * this equals to {@code otherBuffer}; a positive value if this is
+ * greater than {@code otherBuffer}.
* @exception ClassCastException
- * If <code>other</code> is not a char buffer
+ * if {@code otherBuffer} is not a char buffer.
+ * @since Android 1.0
*/
public int compareTo(CharBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -298,36 +310,36 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
- * The duplicated buffer's position, limit, capacity and mark are the same
- * as this buffer. The duplicated buffer's readonly property and byte order
- * are same as this buffer too.
+ * The duplicated buffer's initial position, limit, capacity and mark are
+ * the same as this buffer's. The duplicated buffer's read-only property and
+ * byte order are the same as this buffer's, too.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer duplicate();
/**
- * Tests whether this char buffer equals to another object.
+ * Checks whether this char buffer is equal to another object.
* <p>
- * If <code>other</code> is not a char buffer, then false is returned.
+ * If {@code other} is not a char buffer then {@code false} is returned. Two
+ * char buffers are equal if and only if their remaining chars are exactly
+ * the same. Position, limit, capacity and mark are not considered.
* </p>
- * <p>
- * Two char buffers are equals if, and only if, their remaining
- * <code>char</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.
- * </p>
- *
+ *
* @param other
- * the object to be compared against
- * @return Whether this char buffer equals to another object.
+ * the object to compare with this char buffer.
+ * @return {@code true} if this char buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof CharBuffer)) {
@@ -350,61 +362,60 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns the char at the current position and increase the position by 1.
- *
- * @return The char at the current position.
+ * Returns the char at the current position and increases the position by 1.
+ *
+ * @return the char at the current position.
* @exception BufferUnderflowException
- * If the position is equal or greater than limit
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract char get();
/**
- * Reads <code>char</code>s from the current position into the specified
- * char array and increase the position by the number of <code>char</code>s
- * read.
+ * Reads chars from the current position into the specified char array and
+ * increases the position by the number of chars read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination char array
- * @return This buffer
+ * the destination char array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public CharBuffer get(char[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>char</code>s from the current position into the specified
- * char array, starting from the specified offset, and increase the position
- * by the number of <code>char</code>s read.
- *
+ * Reads chars from the current position into the specified char array,
+ * starting from the specified offset, and increases the position by the
+ * number of chars read.
+ *
* @param dest
- * The target char array
+ * the target char array.
* @param off
- * The offset of the char array, must be no less than zero and no
- * greater than <code>dest.length</code>
+ * the offset of the char array, must not be negative and not
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>char</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * The number of chars to read, must be no less than zero and no
+ * greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public CharBuffer get(char[] dest, int off, int len) {
int length = dest.length;
if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -415,35 +426,34 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns a char at the specified index, and the position is not changed.
- *
+ * Returns a char at the specified index; the position is not changed.
+ *
* @param index
- * The index, must be no less than zero and less than limit
- * @return A char at the specified index.
+ * the index, must not be negative and less than limit.
+ * @return a char at the specified index.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract char get(int index);
/**
- * Returns whether this buffer is based on a char array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.
- * </p>
- *
- * @return Whether this buffer is based on a char array and is read/write.
+ * Indicates whether this buffer is based on a char array and is read/write.
+ *
+ * @return {@code true} if this buffer is based on a byte array and provides
+ * read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>char</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.
- * </p>
- *
- * @return The hash code calculated from the remaining <code>char</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining chars.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -455,128 +465,128 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns true if this buffer is direct.
- * <p>
- * A direct buffer will try its best to take advantage of native memory APIs
- * and it may not stay in java heap, thus not affected by GC.
- * </p>
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A char buffer is direct, if it is based on a byte buffer and the byte
+ * A char buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
* </p>
- *
- * @return True if this buffer is direct.
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the number of remaining <code>char</code>s.
- *
- * @return The number of remaining <code>char</code>s.
+ * Returns the number of remaining chars.
+ *
+ * @return the number of remaining chars.
+ * @since Android 1.0
*/
public final int length() {
return remaining();
}
/**
- * Returns the byte order used by this buffer when converting
- * <code>char</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting chars from/to
+ * bytes.
* <p>
- * If this buffer is not based on a byte buffer, then always return the
- * platform's native byte order.
+ * If this buffer is not based on a byte buffer, then this always returns
+ * the platform's native byte order.
* </p>
- *
- * @return The byte order used by this buffer when converting
- * <code>char</code>s from/to <code>byte</code>s.
+ *
+ * @return the byte order used by this buffer when converting chars from/to
+ * bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @see #array()
*/
abstract char[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @see #arrayOffset()
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @see #hasArray()
*/
abstract boolean protectedHasArray();
/**
- * Writes the given char to the current position and increase the position
+ * Writes the given char to the current position and increases the position
* by 1.
- *
+ *
* @param c
- * The char to write
- * @return This buffer
+ * the char to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer put(char c);
/**
- * Writes <code>char</code>s in the given char array to the current
- * position and increase the position by the number of <code>char</code>s
- * written.
+ * Writes chars from the given char array to the current position and
+ * increases the position by the number of chars written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source char array
- * @return This buffer
+ * the source char array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final CharBuffer put(char[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>char</code>s in the given char array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>char</code>s written.
- *
+ * Writes chars from the given char array, starting from the specified offset,
+ * to the current position and increases the position by the number of chars
+ * written.
+ *
* @param src
- * The source char array
+ * the source char array.
* @param off
- * The offset of char array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of char array, must not be negative and not greater
+ * than {@code src.length}.
* @param len
- * The number of <code>char</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of chars to write, must be no less than zero and no
+ * greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer put(char[] src, int off, int len) {
int length = src.length;
if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -587,20 +597,21 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Writes all the remaining <code>char</code>s of the <code>src</code>
- * char buffer to this buffer's current position, and increase both buffers'
- * position by the number of <code>char</code>s copied.
- *
+ * Writes all the remaining chars of the {@code src} char buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of chars copied.
+ *
* @param src
- * The source char buffer
- * @return This buffer
+ * the source char buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer put(CharBuffer src) {
if (src == this) {
@@ -609,7 +620,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
if (src.remaining() > remaining()) {
throw new BufferOverflowException();
}
-
+
char[] contents = new char[src.remaining()];
src.get(contents);
put(contents);
@@ -617,73 +628,70 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Write a char to the specified index of this buffer and the position is
- * not changed.
- *
+ * Writes a char to the specified index of this buffer; the position is not
+ * changed.
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must be no less than zero and less than the limit.
* @param c
- * The char to write
- * @return This buffer
+ * the char to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer put(int index, char c);
/**
- * Write all <code>char</code>s of the give string to the current
- * position of this buffer, and increase the position by the length of
- * string.
+ * Writes all chars of the given string to the current position of this
+ * buffer, and increases the position by the length of string.
* <p>
* Calling this method has the same effect as
- * <code>put(str, 0, str.length())</code>.
+ * {@code put(str, 0, str.length())}.
* </p>
- *
+ *
* @param str
- * The string to write
- * @return This buffer
+ * the string to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than the length of
- * string
+ * if {@code remaining()} is less than the length of string.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final CharBuffer put(String str) {
return put(str, 0, str.length());
}
/**
- * Write <code>char</code>s of the given string to the current position
- * of this buffer, and increase the position by the number of
- * <code>char</code>s written.
- *
+ * Writes chars of the given string to the current position of this buffer,
+ * and increases the position by the number of chars written.
+ *
* @param str
- * The string to write
+ * the string to write.
* @param start
- * The first char to write, must be no less than zero and no
- * greater than <code>str.length()</code>
+ * the first char to write, must not be negative and not greater
+ * than {@code str.length()}.
* @param end
- * The last char to write (excluding), must be less than
- * <code>start</code> and no greater than
- * <code>str.length()</code>
- * @return This buffer
+ * the last char to write (excluding), must be less than
+ * {@code start} and not greater than {@code str.length()}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining</code> is less than
- * <code>end - start</code>
+ * if {@code remaining()} is less than {@code end - start}.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>end</code> is
- * invalid
+ * if either {@code start} or {@code end} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer put(String str, int start, int end) {
int length = str.length();
if (start < 0 || end < start || end > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (end - start > remaining()) {
throw new BufferOverflowException();
}
@@ -694,63 +702,63 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be 0,
- * limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * same as this buffer.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract CharBuffer slice();
/**
- * Returns a new char buffer represents a sub-sequence of this buffer's
+ * Returns a new char buffer representing a sub-sequence of this buffer's
* current remaining content.
* <p>
- * The new buffer's position will be <code>position() + start</code>,
- * limit will be <code>position() + end</code>, capacity will be same as
- * this buffer. The new buffer's readonly property and byte order are same
- * as this buffer.
+ * The new buffer's position will be {@code position() + start}, limit will
+ * be {@code position() + end}, capacity will be the same as this buffer.
+ * The new buffer's read-only property and byte order are the same as this
+ * buffer.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
+ *
* @param start
- * The start index of the sub-sequence, referenced from the
+ * the start index of the sub-sequence, referenced from the
* current buffer position. Must not be less than zero and not
* greater than the value obtained from a call to
- * <code>remaining()</code>.
+ * {@code remaining()}.
* @param end
- * The end index of the sub-sequence, referenced from the current
- * buffer position. Must not be less than <code>start</code>
- * and not be greater than the value obtained from a call to
- * <code>remaining()</code>
- * @return A new char buffer represents a sub-sequence of this buffer's
+ * the end index of the sub-sequence, referenced from the current
+ * buffer position. Must not be less than {@code start} and not
+ * be greater than the value obtained from a call to
+ * {@code remaining()}.
+ * @return a new char buffer represents a sub-sequence of this buffer's
* current remaining content.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>end</code> is
- * invalid
+ * if either {@code start} or {@code end} is invalid.
+ * @since Android 1.0
*/
public abstract CharSequence subSequence(int start, int end);
/**
- * Returns a string represents the current remaining <code>char</code>s
- * of this buffer.
- *
- * @return A string represents the current remaining <code>char</code>s
- * of this buffer.
+ * Returns a string representing the current remaining chars of this buffer.
+ *
+ * @return a string representing the current remaining chars of this buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer strbuf = new StringBuffer();
@@ -761,14 +769,40 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * @see Appendable#append(char)
+ * Writes the given char to the current position and increases the position
+ * by 1.
+ *
+ * @param c
+ * the char to write.
+ * @return this buffer.
+ * @exception BufferOverflowException
+ * if position is equal or greater than limit.
+ * @exception ReadOnlyBufferException
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer append(char c){
return put(c);
}
/**
- * @see Appendable#append(CharSequence)
+ * Writes all chars of the given character sequence {@code csq} to the
+ * current position of this buffer, and increases the position by the length
+ * of the csq.
+ * <p>
+ * Calling this method has the same effect as {@code append(csq.toString())}.
+ * </p>
+ * If the {@code CharSequence} is {@code null} the string "null" will be
+ * written to the buffer.
+ *
+ * @param csq
+ * the {@code CharSequence} to write.
+ * @return this buffer.
+ * @exception BufferOverflowException
+ * if {@code remaining()} is less than the length of csq.
+ * @exception ReadOnlyBufferException
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer append(CharSequence csq){
if (csq != null) {
@@ -778,7 +812,25 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * @see Appendable#append(CharSequence, int, int)
+ * Writes chars of the given {@code CharSequence} to the current position of
+ * this buffer, and increases the position by the number of chars written.
+ *
+ * @param csq
+ * the {@code CharSequence} to write.
+ * @param start
+ * the first char to write, must not be negative and not greater
+ * than {@code csq.length()}.
+ * @param end
+ * the last char to write (excluding), must be less than
+ * {@code start} and not greater than {@code csq.length()}.
+ * @return this buffer.
+ * @exception BufferOverflowException
+ * if {@code remaining()} is less than {@code end - start}.
+ * @exception IndexOutOfBoundsException
+ * if either {@code start} or {@code end} is invalid.
+ * @exception ReadOnlyBufferException
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public CharBuffer append(CharSequence csq, int start, int end){
if (csq == null) {
@@ -792,7 +844,22 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
}
/**
- * @see Readable#read(CharBuffer)
+ * Reads characters from this buffer and puts them into {@code target}. The
+ * number of chars that are copied is either the number of remaining chars
+ * in this buffer or the number of remaining chars in {@code target},
+ * whichever is smaller.
+ *
+ * @param target
+ * the target char buffer.
+ * @throws IllegalArgumentException
+ * if {@code target} is this buffer.
+ * @throws IOException
+ * if an I/O error occurs.
+ * @throws ReadOnlyBufferException
+ * if no changes may be made to the contents of {@code target}.
+ * @return the number of chars copied or -1 if there are no chars left to be
+ * read from this buffer.
+ * @since Android 1.0
*/
public int read(CharBuffer target) throws IOException {
if(target == this){
@@ -806,5 +873,5 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
get(chars);
target.put(chars);
return result;
- }
+ }
}
diff --git a/nio/src/main/java/java/nio/DoubleBuffer.java b/nio/src/main/java/java/nio/DoubleBuffer.java
index f08188c..b3c261d 100644
--- a/nio/src/main/java/java/nio/DoubleBuffer.java
+++ b/nio/src/main/java/java/nio/DoubleBuffer.java
@@ -18,9 +18,10 @@
package java.nio;
/**
- * A buffer of <code>double</code>s.
+ * A buffer of doubles.
* <p>
- * A double buffer can be created in either of the following ways:
+ * A double buffer can be created in either one of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new double array and create a buffer
* based on it;</li>
@@ -30,16 +31,20 @@ package java.nio;
* {@link java.nio.ByteBuffer#asDoubleBuffer() ByteBuffer.asDoubleBuffer} to
* create a double buffer based on a byte buffer.</li>
* </ul>
- * </p>
+ *
+ * @since Android 1.0
*/
public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBuffer> {
/**
- * Creates a double buffer based on a new allocated double array.
- *
- * @param capacity The capacity of the new buffer
- * @return The created double buffer
- * @throws IllegalArgumentException If <code>capacity</code> is less than zero
+ * Creates a double buffer based on a newly allocated double array.
+ *
+ * @param capacity
+ * the capacity of the new buffer.
+ * @return the created double buffer.
+ * @throws IllegalArgumentException
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static DoubleBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -52,34 +57,37 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* Creates a new double buffer by wrapping the given double array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.</p>
- *
- * @param array The double array which the new buffer will be based on
- * @return The created double buffer
+ * {@code wrap(array, 0, array.length)}.
+ * </p>
+ *
+ * @param array
+ * the double array which the new buffer will be based on.
+ * @return the created double buffer.
+ * @since Android 1.0
*/
public static DoubleBuffer wrap(double[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a double buffer by wrapping the given double array.
+ * Creates a new double buffer by wrapping the given double array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The double array which the new buffer will be based on
+ * the double array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created double buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created double buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static DoubleBuffer wrap(double[] array, int start, int len) {
int length = array.length;
@@ -95,9 +103,10 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Constructs a <code>DoubleBuffer</code> with given capacity.
- *
- * @param capacity The capacity of the buffer
+ * Constructs a {@code DoubleBuffer} with given capacity.
+ *
+ * @param capacity
+ * the capacity of the buffer.
*/
DoubleBuffer(int capacity) {
super(capacity);
@@ -107,13 +116,14 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Returns the double array which this buffer is based on, if there's one.
- *
- * @return The double array which this buffer is based on
+ * Returns the double array which this buffer is based on, if there is one.
+ *
+ * @return the double array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final double[] array() {
return protectedArray();
@@ -121,31 +131,34 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
/**
* Returns the offset of the double array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
- * The offset is the index of the array corresponds to the zero position of
- * the buffer.
+ * The offset is the index of the array corresponding to the zero position
+ * of the buffer.
* </p>
- *
- * @return The offset of the double array which this buffer is based on
+ *
+ * @return the offset of the double array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override Object _array() {
+ @Override
+ Object _array() {
if (hasArray()) {
return array();
}
return null;
}
- @Override int _arrayOffset() {
+ @Override
+ int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
}
@@ -154,92 +167,105 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this
- * buffer is readonly itself. The new buffer's position, limit, capacity
- * and mark are the same as this buffer.</p>
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer's.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * this buffer's change of content will be visible to the new buffer.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A readonly version of this buffer.
+ * The new buffer shares its content with this buffer, which means that this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
+ * </p>
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer asReadOnlyBuffer();
/**
* Compacts this double buffer.
* <p>
- * The remaining <code>double</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining doubles will be moved to the head of the buffer, staring
+ * from position zero. Then the position is set to {@code remaining()}; the
+ * limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer compact();
/**
- * Compare the remaining <code>double</code>s of this buffer to another
- * double buffer's remaining <code>double</code>s.
- *
+ * Compare the remaining doubles of this buffer to another double buffer's
+ * remaining doubles.
+ *
* @param otherBuffer
- * Another double buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another double buffer.
+ * @return a negative value if this is less than {@code other}; 0 if this
+ * equals to {@code other}; a positive value if this is greater
+ * than {@code other}.
* @exception ClassCastException
- * If <code>other</code> is not a double buffer
+ * if {@code other} is not a double buffer.
+ * @since Android 1.0
*/
public int compareTo(DoubleBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- double thisByte, otherByte;
+ // BEGIN android-changed
+ double thisDouble, otherDouble;
while (compareRemaining > 0) {
- thisByte = get(thisPos);
- otherByte = otherBuffer.get(otherPos);
- if (thisByte != otherByte) {
- return thisByte < otherByte ? -1 : 1;
+ thisDouble = get(thisPos);
+ otherDouble = otherBuffer.get(otherPos);
+ // checks for double and NaN inequality
+ if ((thisDouble != otherDouble)
+ && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) {
+ return thisDouble < otherDouble ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
+ // END android-changed
return remaining() - otherBuffer.remaining();
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
- * The duplicated buffer's position, limit, capacity and mark are the
- * same as this buffer. The duplicated buffer's readonly property and
- * byte order are same as this buffer too.</p>
+ * The duplicated buffer's position, limit, capacity and mark are the same
+ * as this buffer's. The duplicated buffer's read-only property and byte
+ * order are the same as this buffer's, too.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer duplicate();
/**
- * Tests whether this double buffer equals to another object.
+ * Checks whether this double buffer is equal to another object.
* <p>
- * If <code>other</code> is not a double buffer, then false is returned.</p>
- * <p>
- * Two double buffers are equals if, and only if, their remaining
- * <code>double</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.</p>
- *
- * @param other the object to be compared against
- * @return Whether this double buffer equals to another object.
+ * If {@code other} is not a double buffer then {@code false} is returned.
+ * Two double buffers are equal if and only if their remaining doubles are
+ * exactly the same. Position, limit, capacity and mark are not considered.
+ * </p>
+ *
+ * @param other
+ * the object to compare with this double buffer.
+ * @return {@code true} if this double buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof DoubleBuffer)) {
@@ -262,60 +288,61 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Returns the double at the current position and increase the position by 1.
- *
- * @return The double at the current position.
- * @exception BufferUnderflowException If the position is equal or greater than limit
+ * Returns the double at the current position and increases the position by
+ * 1.
+ *
+ * @return the double at the current position.
+ * @exception BufferUnderflowException
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract double get();
/**
- * Reads <code>double</code>s from the current position into the
- * specified double array and increase the position by the number of
- * <code>double</code>s read.
+ * Reads doubles from the current position into the specified double array
+ * and increases the position by the number of doubles read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination double array
- * @return This buffer
+ * the destination double array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public DoubleBuffer get(double[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>double</code>s from the current position into the
- * specified double array, starting from the specified offset, and increase
- * the position by the number of <code>double</code>s read.
- *
+ * Reads doubles from the current position into the specified double array,
+ * starting from the specified offset, and increases the position by the
+ * number of doubles read.
+ *
* @param dest
- * The target double array
+ * the target double array.
* @param off
- * The offset of the double array, must be no less than zero and
- * no greater than <code>dest.length</code>
+ * the offset of the double array, must not be negative and not
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>double</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of doubles to read, must be no less than zero and
+ * not greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public DoubleBuffer get(double[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -326,31 +353,35 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Returns a double at the specified index, and the position is not changed.
- *
- * @param index The index, must be no less than zero and less than limit
- * @return A double at the specified index.
- * @exception IndexOutOfBoundsException If index is invalid
+ * Returns a double at the specified index; the position is not changed.
+ *
+ * @param index
+ * the index, must not be negative and less than limit.
+ * @return a double at the specified index.
+ * @exception IndexOutOfBoundsException
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract double get(int index);
/**
- * Returns whether this buffer is based on a double array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.</p>
- *
- * @return Whether this buffer is based on a double array and is read/write.
+ * Indicates whether this buffer is based on a double array and is
+ * read/write.
+ *
+ * @return {@code true} if this buffer is based on a double array and
+ * provides read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>double</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.</p>
- *
- * @return The hash code calculated from the remaining <code>double</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining chars.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -364,117 +395,118 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Returns true if this buffer is direct.
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A direct buffer will try its best to take advantage of native memory
- * APIs and it may not stay in java heap, thus not affected by GC.</p>
- * <p>
- * A double buffer is direct, if it is based on a byte buffer and the byte
- * buffer is direct.</p>
- *
- * @return True if this buffer is direct.
+ * A double buffer is direct if it is based on a byte buffer and the byte
+ * buffer is direct.
+ * </p>
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>double</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting doubles
+ * from/to bytes.
* <p>
- * If this buffer is not based on a byte buffer, then always return the
- * platform's native byte order.</p>
- *
- * @return The byte order used by this buffer when converting
- * <code>double</code>s from/to <code>byte</code>s.
+ * If this buffer is not based on a byte buffer, then this always returns
+ * the platform's native byte order.
+ * </p>
+ *
+ * @return the byte order used by this buffer when converting doubles
+ * from/to bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @see #array()
*/
abstract double[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @see #arrayOffset()
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @see #hasArray()
*/
abstract boolean protectedHasArray();
/**
- * Writes the given double to the current position and increase the position
- * by 1.
- *
+ * Writes the given double to the current position and increases the
+ * position by 1.
+ *
* @param d
- * The double to write
- * @return This buffer
+ * the double to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer put(double d);
/**
- * Writes <code>double</code>s in the given double array to the current
- * position and increase the position by the number of <code>double</code>s
- * written.
+ * Writes doubles from the given double array to the current position and
+ * increases the position by the number of doubles written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source double array
- * @return This buffer
+ * the source double array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final DoubleBuffer put(double[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>double</code>s in the given double array, starting from
- * the specified offset, to the current position and increase the position
- * by the number of <code>double</code>s written.
- *
+ * Writes doubles from the given double array, starting from the specified
+ * offset, to the current position and increases the position by the number
+ * of doubles written.
+ *
* @param src
- * The source double array
+ * the source double array.
* @param off
- * The offset of double array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of double array, must not be negative and not
+ * greater than {@code src.length}.
* @param len
- * The number of <code>double</code>s to write, must be no
- * less than zero and no greater than
- * <code>src.length - off</code>
- * @return This buffer
+ * the number of doubles to write, must be no less than zero and
+ * not greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public DoubleBuffer put(double[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -485,20 +517,21 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
}
/**
- * Writes all the remaining <code>double</code>s of the <code>src</code>
- * double buffer to this buffer's current position, and increase both
- * buffers' position by the number of <code>double</code>s copied.
- *
+ * Writes all the remaining doubles of the {@code src} double buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of doubles copied.
+ *
* @param src
- * The source double buffer
- * @return This buffer
+ * the source double buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public DoubleBuffer put(DoubleBuffer src) {
if (src == this) {
@@ -516,40 +549,45 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
/**
* Write a double to the specified index of this buffer and the position is
* not changed.
- *
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param d
- * The double to write
- * @return This buffer
+ * the double to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer put(int index, double d);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be
- * 0, limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.</p>
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * the same as this buffer's.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract DoubleBuffer slice();
/**
- * Returns a string represents the state of this double buffer.
- *
- * @return A string represents the state of this double buffer.
+ * Returns a string representing the state of this double buffer.
+ *
+ * @return A string representing the state of this double buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
@@ -558,7 +596,7 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
buf.append(capacity());
buf.append(" position="); //$NON-NLS-1$
buf.append(position());
- buf.append(" limit="); //$NON-NLS-1$
+ buf.append(" limit="); //$NON-NLS-1$
buf.append(limit());
return buf.toString();
}
diff --git a/nio/src/main/java/java/nio/FloatBuffer.java b/nio/src/main/java/java/nio/FloatBuffer.java
index c695d13..f7ee917 100644
--- a/nio/src/main/java/java/nio/FloatBuffer.java
+++ b/nio/src/main/java/java/nio/FloatBuffer.java
@@ -18,9 +18,10 @@
package java.nio;
/**
- * A buffer of <code>float</code>s.
+ * A buffer of floats.
* <p>
* A float buffer can be created in either of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new float array and create a buffer
* based on it;</li>
@@ -29,17 +30,20 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asFloatBuffer() ByteBuffer.asFloatBuffer}
* to create a float buffer based on a byte buffer.</li>
* </ul>
- * </p>
- *
+ *
+ * @since Android 1.0
*/
public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuffer> {
/**
- * Creates a float buffer based on a new allocated float array.
- *
- * @param capacity The capacity of the new buffer
- * @return The created float buffer
- * @throws IllegalArgumentException If <code>capacity</code> is less than zero
+ * Creates a float buffer based on a newly allocated float array.
+ *
+ * @param capacity
+ * the capacity of the new buffer.
+ * @return the created float buffer.
+ * @throws IllegalArgumentException
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static FloatBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -52,34 +56,39 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* Creates a new float buffer by wrapping the given float array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.</p>
- *
- * @param array The float array which the new buffer will be based on
- * @return The created float buffer
+ * {@code wrap(array, 0, array.length)}.
+ * </p>
+ *
+ * @param array
+ * the float array which the new buffer will be based on.
+ * @return the created float buffer.
+ * @since Android 1.0
*/
public static FloatBuffer wrap(float[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a float buffer by wrapping the given float array.
+ * Creates a new float buffer by wrapping the given float array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The float array which the new buffer will be based on
+ * the float array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created float buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created float buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @exception NullPointerException
+ * if {@code array} is null.
+ * @since Android 1.0
*/
public static FloatBuffer wrap(float[] array, int start, int len) {
if (array == null) {
@@ -97,7 +106,7 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Constructs a <code>FloatBuffer</code> with given capacity.
+ * Constructs a {@code FloatBuffer} with given capacity.
*
* @param capacity The capacity of the buffer
*/
@@ -109,13 +118,14 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Returns the float array which this buffer is based on, if there's one.
- *
- * @return The float array which this buffer is based on
+ * Returns the float array which this buffer is based on, if there is one.
+ *
+ * @return the float array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final float[] array() {
return protectedArray();
@@ -123,17 +133,18 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
/**
* Returns the offset of the float array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
- * The offset is the index of the array corresponds to the zero position of
- * the buffer.
+ * The offset is the index of the array and corresponds to the zero position
+ * of the buffer.
* </p>
- *
- * @return The offset of the float array which this buffer is based on
+ *
+ * @return the offset of the float array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -156,92 +167,105 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this
- * buffer is readonly itself. The new buffer's position, limit, capacity
- * and mark are the same as this buffer.</p>
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * this buffer's change of content will be visible to the new buffer.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A readonly version of this buffer.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
+ * </p>
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer asReadOnlyBuffer();
/**
* Compacts this float buffer.
* <p>
- * The remaining <code>float</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining floats will be moved to the head of the buffer, starting
+ * from position zero. Then the position is set to {@code remaining()}; the
+ * limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer compact();
/**
- * Compare the remaining <code>float</code>s of this buffer to another
- * float buffer's remaining <code>float</code>s.
- *
+ * Compare the remaining floats of this buffer to another float buffer's
+ * remaining floats.
+ *
* @param otherBuffer
- * Another float buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another float buffer.
+ * @return a negative value if this is less than {@code otherBuffer}; 0 if
+ * this equals to {@code otherBuffer}; a positive value if this is
+ * greater than {@code otherBuffer}.
* @exception ClassCastException
- * If <code>other</code> is not a float buffer
+ * if {@code otherBuffer} is not a float buffer.
+ * @since Android 1.0
*/
public int compareTo(FloatBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- float thisByte, otherByte;
+ // BEGIN android-changed
+ float thisFloat, otherFloat;
while (compareRemaining > 0) {
- thisByte = get(thisPos);
- otherByte = otherBuffer.get(otherPos);
- if (thisByte != otherByte) {
- return thisByte < otherByte ? -1 : 1;
+ thisFloat = get(thisPos);
+ otherFloat = otherBuffer.get(otherPos);
+ // checks for float and NaN inequality
+ if ((thisFloat != otherFloat)
+ && ((thisFloat == thisFloat) || (otherFloat == otherFloat))) {
+ return thisFloat < otherFloat ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
+ // END android-changed
return remaining() - otherBuffer.remaining();
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
- * The duplicated buffer's position, limit, capacity and mark are the
- * same as this buffer. The duplicated buffer's readonly property and
- * byte order are same as this buffer too.</p>
+ * The duplicated buffer's position, limit, capacity and mark are the same
+ * as this buffer. The duplicated buffer's read-only property and byte order
+ * are same as this buffer too.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer duplicate();
/**
- * Tests whether this float buffer equals to another object.
+ * Checks whether this float buffer is equal to another object.
* <p>
- * If <code>other</code> is not a float buffer, then false is returned.</p>
- * <p>
- * Two float buffers are equals if, and only if, their remaining
- * <code>float</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.</p>
- *
- * @param other the object to be compared against
- * @return Whether this float buffer equals to another object.
+ * If {@code other} is not a float buffer then {@code false} is returned.
+ * Two float buffers are equal if and only if their remaining floats are
+ * exactly the same. Position, limit, capacity and mark are not considered.
+ * </p>
+ *
+ * @param other
+ * the object to compare with this float buffer.
+ * @return {@code true} if this float buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof FloatBuffer)) {
@@ -264,60 +288,61 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Returns the float at the current position and increase the position by 1.
- *
- * @return The float at the current position.
- * @exception BufferUnderflowException If the position is equal or greater than limit
+ * Returns the float at the current position and increases the position by
+ * 1.
+ *
+ * @return the float at the current position.
+ * @exception BufferUnderflowException
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract float get();
/**
- * Reads <code>float</code>s from the current position into the specified
- * float array and increase the position by the number of <code>float</code>s
- * read.
+ * Reads floats from the current position into the specified float array and
+ * increases the position by the number of floats read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination float array
- * @return This buffer
+ * the destination float array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public FloatBuffer get(float[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>float</code>s from the current position into the specified
- * float array, starting from the specified offset, and increase the
- * position by the number of <code>float</code>s read.
- *
+ * Reads floats from the current position into the specified float array,
+ * starting from the specified offset, and increases the position by the
+ * number of floats read.
+ *
* @param dest
- * The target float array
+ * the target float array.
* @param off
- * The offset of the float array, must be no less than zero and
- * no greater than <code>dest.length</code>
+ * the offset of the float array, must not be negative and no
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>float</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of floats to read, must be no less than zero and no
+ * greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public FloatBuffer get(float[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -328,31 +353,35 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Returns a float at the specified index, and the position is not changed.
- *
- * @param index The index, must be no less than zero and less than limit
- * @return A float at the specified index.
- * @exception IndexOutOfBoundsException If index is invalid
+ * Returns a float at the specified index; the position is not changed.
+ *
+ * @param index
+ * the index, must not be negative and less than limit.
+ * @return a float at the specified index.
+ * @exception IndexOutOfBoundsException
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract float get(int index);
/**
- * Returns whether this buffer is based on a float array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.</p>
- *
- * @return Whether this buffer is based on a float array and is read/write.
+ * Indicates whether this buffer is based on a float array and is
+ * read/write.
+ *
+ * @return {@code true} if this buffer is based on a float array and
+ * provides read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>float</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.</p>
- *
- * @return The hash code calculated from the remaining <code>float</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining floats.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -364,116 +393,118 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Returns true if this buffer is direct.
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A direct buffer will try its best to take advantage of native memory
- * APIs and it may not stay in java heap, thus not affected by GC.</p>
- * <p>
- * A float buffer is direct, if it is based on a byte buffer and the byte
- * buffer is direct.</p>
- *
- * @return True if this buffer is direct.
+ * A float buffer is direct if it is based on a byte buffer and the byte
+ * buffer is direct.
+ * </p>
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>float</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting floats from/to
+ * bytes.
* <p>
* If this buffer is not based on a byte buffer, then always return the
- * platform's native byte order.</p>
- *
- * @return The byte order used by this buffer when converting
- * <code>float</code>s from/to <code>byte</code>s.
+ * platform's native byte order.
+ * </p>
+ *
+ * @return the byte order used by this buffer when converting floats from/to
+ * bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @return see {@code array()}
*/
abstract float[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @return see {@code arrayOffset()}
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @return see {@code hasArray()}
*/
abstract boolean protectedHasArray();
/**
- * Writes the given float to the current position and increase the position
+ * Writes the given float to the current position and increases the position
* by 1.
- *
+ *
* @param f
- * The float to write
- * @return This buffer
+ * the float to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer put(float f);
/**
- * Writes <code>float</code>s in the given float array to the current
- * position and increase the position by the number of <code>float</code>s
- * written.
+ * Writes floats from the given float array to the current position and
+ * increases the position by the number of floats written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source float array
- * @return This buffer
+ * the source float array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final FloatBuffer put(float[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>float</code>s in the given float array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>float</code>s written.
- *
+ * Writes floats from the given float array, starting from the specified
+ * offset, to the current position and increases the position by the number
+ * of floats written.
+ *
* @param src
- * The source float array
+ * the source float array.
* @param off
- * The offset of float array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of float array, must not be negative and not
+ * greater than {@code src.length}.
* @param len
- * The number of <code>float</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of floats to write, must be no less than zero and
+ * no greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public FloatBuffer put(float[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -484,20 +515,21 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Writes all the remaining <code>float</code>s of the <code>src</code>
- * float buffer to this buffer's current position, and increase both
- * buffers' position by the number of <code>float</code>s copied.
- *
+ * Writes all the remaining floats of the {@code src} float buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of floats copied.
+ *
* @param src
- * The source float buffer
- * @return This buffer
+ * the source float buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public FloatBuffer put(FloatBuffer src) {
if (src == this) {
@@ -513,42 +545,47 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
}
/**
- * Write a float to the specified index of this buffer and the position is
- * not changed.
- *
+ * Writes a float to the specified index of this buffer; the position is not
+ * changed.
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param f
- * The float to write
- * @return This buffer
+ * the float to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer put(int index, float f);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be
- * 0, limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.</p>
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * same as this buffer's.
+ * </p>
* <p>
- * The new buffer shares content with this buffer, which means
- * either buffer's change of content will be visible to the other.
- * The two buffer's position, limit and mark are independent.</p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ * The new buffer shares its content with this buffer, which means either
+ * buffer's change of content will be visible to the other. The two buffer's
+ * position, limit and mark are independent.
+ * </p>
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract FloatBuffer slice();
/**
- * Returns a string represents the state of this float buffer.
- *
- * @return A string represents the state of this float buffer.
+ * Returns a string representing the state of this float buffer.
+ *
+ * @return a string representing the state of this float buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
diff --git a/nio/src/main/java/java/nio/IntBuffer.java b/nio/src/main/java/java/nio/IntBuffer.java
index ba7ac18..7a19dfd 100644
--- a/nio/src/main/java/java/nio/IntBuffer.java
+++ b/nio/src/main/java/java/nio/IntBuffer.java
@@ -18,9 +18,10 @@
package java.nio;
/**
- * A buffer of <code>int</code>s.
+ * A buffer of ints.
* <p>
* A int buffer can be created in either of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new int array and create a buffer
* based on it;</li>
@@ -28,18 +29,20 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asIntBuffer() ByteBuffer.asIntBuffer} to
* create a int buffer based on a byte buffer.</li>
* </ul>
- * </p>
+ *
+ * @since Android 1.0
*/
public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer> {
/**
- * Creates a int buffer based on a new allocated int array.
- *
+ * Creates an int buffer based on a newly allocated int array.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created int buffer
+ * the capacity of the new buffer.
+ * @return the created int buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static IntBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -52,36 +55,37 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* Creates a new int buffer by wrapping the given int array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.
+ * {@code wrap(array, 0, array.length)}.
* </p>
- *
+ *
* @param array
- * The int array which the new buffer will be based on
- * @return The created int buffer
+ * the int array which the new buffer will be based on.
+ * @return the created int buffer.
+ * @since Android 1.0
*/
public static IntBuffer wrap(int[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a int buffer by wrapping the given int array.
+ * Creates a new int buffer by wrapping the given int array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The int array which the new buffer will be based on
+ * the int array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created int buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created int buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static IntBuffer wrap(int[] array, int start, int len) {
if (array == null) {
@@ -99,10 +103,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Constructs a <code>IntBuffer</code> with given capacity.
+ * Constructs a {@code IntBuffer} with given capacity.
*
* @param capacity
- * The capacity of the buffer
+ * the capacity of the buffer.
*/
IntBuffer(int capacity) {
super(capacity);
@@ -112,13 +116,14 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Returns the int array which this buffer is based on, if there's one.
- *
- * @return The int array which this buffer is based on
+ * Returns the int array which this buffer is based on, if there is one.
+ *
+ * @return the int array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int[] array() {
return protectedArray();
@@ -126,17 +131,18 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
/**
* Returns the offset of the int array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
* The offset is the index of the array corresponds to the zero position of
* the buffer.
* </p>
- *
- * @return The offset of the int array which this buffer is based on
+ *
+ * @return the offset of the int array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -159,99 +165,103 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
* The returned buffer is guaranteed to be a new instance, even this buffer
- * is readonly itself. The new buffer's position, limit, capacity and mark
- * are the same as this buffer.
+ * is read-only itself. The new buffer's position, limit, capacity and mark
+ * are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means this buffer's
- * change of content will be visible to the new buffer. The two buffer's
- * position, limit and mark are independent.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
* </p>
- *
- * @return A readonly version of this buffer.
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer asReadOnlyBuffer();
/**
* Compacts this int buffer.
* <p>
- * The remaining <code>int</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining ints will be moved to the head of the buffer, starting from
+ * position zero. Then the position is set to {@code remaining()}; the
+ * limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer compact();
/**
- * Compare the remaining <code>int</code>s of this buffer to another int
- * buffer's remaining <code>int</code>s.
- *
+ * Compares the remaining ints of this buffer to another int buffer's
+ * remaining ints.
+ *
* @param otherBuffer
- * Another int buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another int buffer.
+ * @return a negative value if this is less than {@code other}; 0 if this
+ * equals to {@code other}; a positive value if this is greater
+ * than {@code other}.
* @exception ClassCastException
- * If <code>other</code> is not a int buffer
+ * if {@code other} is not an int buffer.
+ * @since Android 1.0
*/
public int compareTo(IntBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- int thisByte, otherByte;
+ // BEGIN android-changed
+ int thisInt, otherInt;
while (compareRemaining > 0) {
- thisByte = get(thisPos);
- otherByte = otherBuffer.get(otherPos);
- if (thisByte != otherByte) {
- return thisByte < otherByte ? -1 : 1;
+ thisInt = get(thisPos);
+ otherInt = otherBuffer.get(otherPos);
+ if (thisInt != otherInt) {
+ return thisInt < otherInt ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
+ // END android-changed
return remaining() - otherBuffer.remaining();
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
* The duplicated buffer's position, limit, capacity and mark are the same
- * as this buffer. The duplicated buffer's readonly property and byte order
- * are same as this buffer too.
+ * as this buffer. The duplicated buffer's read-only property and byte order
+ * are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer duplicate();
/**
- * Tests whether this int buffer equals to another object.
- * <p>
- * If <code>other</code> is not a int buffer, then false is returned.
- * </p>
+ * Checks whether this int buffer is equal to another object.
* <p>
- * Two int buffers are equals if, and only if, their remaining
- * <code>int</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.
+ * If {@code other} is not a int buffer then {@code false} is returned. Two
+ * int buffers are equal if and only if their remaining ints are exactly the
+ * same. Position, limit, capacity and mark are not considered.
* </p>
- *
+ *
* @param other
- * the object to be compared against
- * @return Whether this int buffer equals to another object.
+ * the object to compare with this int buffer.
+ * @return {@code true} if this int buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof IntBuffer)) {
@@ -274,54 +284,53 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Returns the int at the current position and increase the position by 1.
- *
- * @return The int at the current position.
+ * Returns the int at the current position and increases the position by 1.
+ *
+ * @return the int at the current position.
* @exception BufferUnderflowException
- * If the position is equal or greater than limit
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract int get();
/**
- * Reads <code>int</code>s from the current position into the specified
- * int array and increase the position by the number of <code>int</code>s
- * read.
+ * Reads ints from the current position into the specified int array and
+ * increases the position by the number of ints read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination int array
- * @return This buffer
+ * the destination int array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public IntBuffer get(int[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>int</code>s from the current position into the specified
- * int array, starting from the specified offset, and increase the position
- * by the number of <code>int</code>s read.
- *
+ * Reads ints from the current position into the specified int array,
+ * starting from the specified offset, and increases the position by the
+ * number of ints read.
+ *
* @param dest
- * The target int array
+ * the target int array.
* @param off
- * The offset of the int array, must be no less than zero and no
- * greater than <code>dest.length</code>
+ * the offset of the int array, must not be negative and not
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>int</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of ints to read, must be no less than zero and not
+ * greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public IntBuffer get(int[] dest, int off, int len) {
int length = dest.length;
@@ -338,35 +347,34 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Returns a int at the specified index, and the position is not changed.
- *
+ * Returns an int at the specified index; the position is not changed.
+ *
* @param index
- * The index, must be no less than zero and less than limit
- * @return A int at the specified index.
+ * the index, must not be negative and less than limit.
+ * @return an int at the specified index.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract int get(int index);
/**
- * Returns whether this buffer is based on a int array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.
- * </p>
- *
- * @return Whether this buffer is based on a int array and is read/write.
+ * Indicates whether this buffer is based on a int array and is read/write.
+ *
+ * @return {@code true} if this buffer is based on a int array and provides
+ * read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>int</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.
- * </p>
- *
- * @return The hash code calculated from the remaining <code>int</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining ints.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -378,115 +386,118 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Returns true if this buffer is direct.
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A int buffer is direct, if it is based on a byte buffer and the byte
+ * An int buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
* </p>
- *
- * @return True if this buffer is direct.
- */
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
+ */
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>int</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting ints from/to
+ * bytes.
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
* </p>
- *
- * @return The byte order used by this buffer when converting
- * <code>int</code>s from/to <code>byte</code>s.
+ *
+ * @return the byte order used by this buffer when converting ints from/to
+ * bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @return see {@code array()}
*/
abstract int[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @return see {@code arrayOffset()}
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @return see {@code hasArray()}
*/
abstract boolean protectedHasArray();
/**
- * Writes the given int to the current position and increase the position by
- * 1.
- *
+ * Writes the given int to the current position and increases the position
+ * by 1.
+ *
* @param i
- * The int to write
- * @return This buffer
+ * the int to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer put(int i);
/**
- * Writes <code>int</code>s in the given int array to the current
- * position and increase the position by the number of <code>int</code>s
- * written.
+ * Writes ints from the given int array to the current position and
+ * increases the position by the number of ints written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source int array
- * @return This buffer
+ * the source int array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final IntBuffer put(int[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>int</code>s in the given int array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>int</code>s written.
- *
+ * Writes ints from the given int array, starting from the specified offset,
+ * to the current position and increases the position by the number of ints
+ * written.
+ *
* @param src
- * The source int array
+ * the source int array.
* @param off
- * The offset of int array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of int array, must not be negative and not greater
+ * than {@code src.length}.
* @param len
- * The number of <code>int</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of ints to write, must be no less than zero and not
+ * greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public IntBuffer put(int[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)len + (long)off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -497,20 +508,21 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Writes all the remaining <code>int</code>s of the <code>src</code>
- * int buffer to this buffer's current position, and increase both buffers'
- * position by the number of <code>int</code>s copied.
- *
+ * Writes all the remaining ints of the {@code src} int buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of ints copied.
+ *
* @param src
- * The source int buffer
- * @return This buffer
+ * the source int buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public IntBuffer put(IntBuffer src) {
if (src == this) {
@@ -526,44 +538,47 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
}
/**
- * Write a int to the specified index of this buffer and the position is not
+ * Write a int to the specified index of this buffer; the position is not
* changed.
- *
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param i
- * The int to write
- * @return This buffer
+ * the int to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer put(int index, int i);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be 0,
- * limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract IntBuffer slice();
/**
- * Returns a string represents the state of this int buffer.
- *
- * @return A string represents the state of this int buffer.
+ * Returns a string represents of the state of this int buffer.
+ *
+ * @return a string represents of the state of this int buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
diff --git a/nio/src/main/java/java/nio/InvalidMarkException.java b/nio/src/main/java/java/nio/InvalidMarkException.java
index 1860576..530d9cf 100644
--- a/nio/src/main/java/java/nio/InvalidMarkException.java
+++ b/nio/src/main/java/java/nio/InvalidMarkException.java
@@ -18,16 +18,19 @@ package java.nio;
/**
- * A <code>InvalidMarkException</code> is thrown when <code>reset()</code>
- * is called on a buffer, but there is no mark set previously.
+ * An {@code InvalidMarkException} is thrown when {@code reset()} is called on a
+ * buffer, but no mark has been set previously.
*
+ * @since Android 1.0
*/
public class InvalidMarkException extends IllegalStateException {
private static final long serialVersionUID = 1698329710438510774L;
/**
- * Constructs an <code>InvalidMarkException</code>.
+ * Constructs an {@code InvalidMarkException}.
+ *
+ * @since Android 1.0
*/
public InvalidMarkException() {
super();
diff --git a/nio/src/main/java/java/nio/LongBuffer.java b/nio/src/main/java/java/nio/LongBuffer.java
index a44f56a..b0bf7ea 100644
--- a/nio/src/main/java/java/nio/LongBuffer.java
+++ b/nio/src/main/java/java/nio/LongBuffer.java
@@ -18,9 +18,10 @@
package java.nio;
/**
- * A buffer of <code>long</code>s.
+ * A buffer of longs.
* <p>
* A long buffer can be created in either of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new long array and create a buffer
* based on it;</li>
@@ -29,18 +30,20 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asLongBuffer() ByteBuffer.asLongBuffer}
* to create a long buffer based on a byte buffer.</li>
* </ul>
- * </p>
+ *
+ * @since Android 1.0
*/
public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer> {
/**
- * Creates a long buffer based on a new allocated long array.
- *
+ * Creates a long buffer based on a newly allocated long array.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created long buffer
+ * the capacity of the new buffer.
+ * @return the created long buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static LongBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -53,36 +56,37 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* Creates a new long buffer by wrapping the given long array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.
+ * {@code wrap(array, 0, array.length)}.
* </p>
- *
+ *
* @param array
- * The long array which the new buffer will be based on
- * @return The created long buffer
+ * the long array which the new buffer will be based on.
+ * @return the created long buffer.
+ * @since Android 1.0
*/
public static LongBuffer wrap(long[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a long buffer by wrapping the given long array.
+ * Creates a new long buffer by wrapping the given long array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The long array which the new buffer will be based on
+ * the long array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created long buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created long buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static LongBuffer wrap(long[] array, int start, int len) {
if (array == null) {
@@ -100,7 +104,7 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Constructs a <code>LongBuffer</code> with given capacity.
+ * Constructs a {@code LongBuffer} with given capacity.
*
* @param capacity
* The capacity of the buffer
@@ -113,13 +117,14 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Returns the long array which this buffer is based on, if there's one.
- *
- * @return The long array which this buffer is based on
+ * Returns the long array which this buffer is based on, if there is one.
+ *
+ * @return the long array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final long[] array() {
return protectedArray();
@@ -127,17 +132,18 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
/**
* Returns the offset of the long array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
- * The offset is the index of the array corresponds to the zero position of
- * the buffer.
+ * The offset is the index of the array and corresponds to the zero position
+ * of the buffer.
* </p>
- *
- * @return The offset of the long array which this buffer is based on
+ *
+ * @return the offset of the long array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -160,99 +166,103 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this buffer
- * is readonly itself. The new buffer's position, limit, capacity and mark
- * are the same as this buffer.
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means this buffer's
- * change of content will be visible to the new buffer. The two buffer's
- * position, limit and mark are independent.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
* </p>
- *
- * @return A readonly version of this buffer.
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer asReadOnlyBuffer();
/**
* Compacts this long buffer.
* <p>
- * The remaining <code>long</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining longs will be moved to the head of the buffer, staring from
+ * position zero. Then the position is set to {@code remaining()}; the
+ * limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer compact();
/**
- * Compare the remaining <code>long</code>s of this buffer to another
- * long buffer's remaining <code>long</code>s.
- *
+ * Compare the remaining longs of this buffer to another long buffer's
+ * remaining longs.
+ *
* @param otherBuffer
- * Another long buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another long buffer.
+ * @return a negative value if this is less than {@code otherBuffer}; 0 if
+ * this equals to {@code otherBuffer}; a positive value if this is
+ * greater than {@code otherBuffer}
* @exception ClassCastException
- * If <code>other</code> is not a long buffer
+ * if {@code otherBuffer} is not a long buffer.
+ * @since Android 1.0
*/
public int compareTo(LongBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- long thisByte, otherByte;
+ // BEGIN android-changed
+ long thisLong, otherLong;
while (compareRemaining > 0) {
- thisByte = get(thisPos);
- otherByte = otherBuffer.get(otherPos);
- if (thisByte != otherByte) {
- return thisByte < otherByte ? -1 : 1;
+ thisLong = get(thisPos);
+ otherLong = otherBuffer.get(otherPos);
+ if (thisLong != otherLong) {
+ return thisLong < otherLong ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
+ // END android-changed
return remaining() - otherBuffer.remaining();
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
* The duplicated buffer's position, limit, capacity and mark are the same
- * as this buffer. The duplicated buffer's readonly property and byte order
- * are same as this buffer too.
+ * as this buffer. The duplicated buffer's read-only property and byte order
+ * are same as this buffer's, too.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer duplicate();
/**
- * Tests whether this long buffer equals to another object.
- * <p>
- * If <code>other</code> is not a long buffer, then false is returned.
- * </p>
+ * Checks whether this long buffer is equal to another object.
* <p>
- * Two long buffers are equals if, and only if, their remaining
- * <code>long</code>s are exactly the same. Position, limit, capacity and
- * mark are not considered.
+ * If {@code other} is not a long buffer then {@code false} is returned. Two
+ * long buffers are equal if and only if their remaining longs are exactly
+ * the same. Position, limit, capacity and mark are not considered.
* </p>
- *
+ *
* @param other
- * the object to be compared against
- * @return Whether this long buffer equals to another object.
+ * the object to compare with this long buffer.
+ * @return {@code true} if this long buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof LongBuffer)) {
@@ -276,60 +286,59 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
/**
* Returns the long at the current position and increase the position by 1.
- *
- * @return The long at the current position.
+ *
+ * @return the long at the current position.
* @exception BufferUnderflowException
- * If the position is equal or greater than limit
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract long get();
/**
- * Reads <code>long</code>s from the current position into the specified
- * long array and increase the position by the number of <code>long</code>s
- * read.
+ * Reads longs from the current position into the specified long array and
+ * increases the position by the number of longs read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination long array
- * @return This buffer
+ * the destination long array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public LongBuffer get(long[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>long</code>s from the current position into the specified
- * long array, starting from the specified offset, and increase the position
- * by the number of <code>long</code>s read.
- *
+ * Reads longs from the current position into the specified long array,
+ * starting from the specified offset, and increase the position by the
+ * number of longs read.
+ *
* @param dest
- * The target long array
+ * the target long array.
* @param off
- * The offset of the long array, must be no less than zero and no
- * greater than <code>dest.length</code>
+ * the offset of the long array, must not be negative and not
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>long</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of longs to read, must be no less than zero and not
+ * greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public LongBuffer get(long[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)len + (long)off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -340,35 +349,34 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Returns a long at the specified index, and the position is not changed.
- *
+ * Returns the long at the specified index; the position is not changed.
+ *
* @param index
- * The index, must be no less than zero and less than limit
- * @return A long at the specified index.
+ * the index, must not be negative and less than limit.
+ * @return the long at the specified index.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract long get(int index);
/**
- * Returns whether this buffer is based on a long array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.
- * </p>
- *
- * @return Whether this buffer is based on a long array and is read/write.
+ * Indicates whether this buffer is based on a long array and is read/write.
+ *
+ * @return {@code true} if this buffer is based on a long array and provides
+ * read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>long</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.
- * </p>
- *
- * @return The hash code calculated from the remaining <code>long</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining longs.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -382,119 +390,118 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Returns true if this buffer is direct.
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A direct buffer will try its best to take advantage of native memory APIs
- * and it may not stay in java heap, thus not affected by GC.
- * </p>
- * <p>
- * A long buffer is direct, if it is based on a byte buffer and the byte
+ * A long buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
* </p>
- *
- * @return True if this buffer is direct.
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>long</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting longs from/to
+ * bytes.
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
* </p>
- *
- * @return The byte order used by this buffer when converting
- * <code>long</code>s from/to <code>byte</code>s.
+ *
+ * @return the byte order used by this buffer when converting longs from/to
+ * bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @return see {@code array()}
*/
abstract long[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @return see {@code arrayOffset()}
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @return see {@code hasArray()}
*/
abstract boolean protectedHasArray();
/**
- * Writes the given long to the current position and increase the position
+ * Writes the given long to the current position and increases the position
* by 1.
- *
+ *
* @param l
- * The long to write
- * @return This buffer
+ * the long to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer put(long l);
/**
- * Writes <code>long</code>s in the given long array to the current
- * position and increase the position by the number of <code>long</code>s
- * written.
+ * Writes longs from the given long array to the current position and
+ * increases the position by the number of longs written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source long array
- * @return This buffer
+ * the source long array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final LongBuffer put(long[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>long</code>s in the given long array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>long</code>s written.
- *
+ * Writes longs from the given long array, starting from the specified
+ * offset, to the current position and increases the position by the number
+ * of longs written.
+ *
* @param src
- * The source long array
+ * the source long array.
* @param off
- * The offset of long array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of long array, must not be negative and not greater
+ * than {@code src.length}.
* @param len
- * The number of <code>long</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of longs to write, must be no less than zero and
+ * not greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public LongBuffer put(long[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)len + (long)off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -505,20 +512,21 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Writes all the remaining <code>long</code>s of the <code>src</code>
- * long buffer to this buffer's current position, and increase both buffers'
- * position by the number of <code>long</code>s copied.
- *
+ * Writes all the remaining longs of the {@code src} long buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of longs copied.
+ *
* @param src
- * The source long buffer
- * @return This buffer
+ * the source long buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public LongBuffer put(LongBuffer src) {
if (src == this) {
@@ -534,44 +542,47 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
}
/**
- * Write a long to the specified index of this buffer and the position is
- * not changed.
- *
+ * Writes a long to the specified index of this buffer; the position is not
+ * changed.
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param l
- * The long to write
- * @return This buffer
+ * the long to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer put(int index, long l);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be 0,
- * limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract LongBuffer slice();
/**
- * Returns a string represents the state of this long buffer.
- *
- * @return A string represents the state of this long buffer.
+ * Returns a string representing the state of this long buffer.
+ *
+ * @return a string representing the state of this long buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
diff --git a/nio/src/main/java/java/nio/MappedByteBuffer.java b/nio/src/main/java/java/nio/MappedByteBuffer.java
index 5c11eae..8f6727d 100644
--- a/nio/src/main/java/java/nio/MappedByteBuffer.java
+++ b/nio/src/main/java/java/nio/MappedByteBuffer.java
@@ -23,21 +23,22 @@ import org.apache.harmony.nio.internal.DirectBuffer;
/**
- * <code>MappedByteBuffer</code> is a special kind of direct byte buffer,
- * which maps a region of file to memory.
+ * {@code MappedByteBuffer} is a special kind of direct byte buffer which maps a
+ * region of file to memory.
* <p>
- * <code>MappedByteBuffer</code> can be created by calling
+ * {@code MappedByteBuffer} can be created by calling
* {@link java.nio.channels.FileChannel#map(java.nio.channels.FileChannel.MapMode, long, long) FileChannel.map}.
* Once created, the mapping between the byte buffer and the file region remains
* valid until the byte buffer is garbage collected.
* </p>
* <p>
- * All or part of a <code>MappedByteBuffer</code>'s content may change or
- * become inaccessible at any time, since the mapped file region can be modified
- * by another thread or process at any time. If this happens, the behavior of
- * the <code>MappedByteBuffer</code> is undefined.
+ * All or part of a {@code MappedByteBuffer}'s content may change or become
+ * inaccessible at any time, since the mapped file region can be modified by
+ * another thread or process at any time. If this happens, the behavior of the
+ * {@code MappedByteBuffer} is undefined.
* </p>
*
+ * @since Android 1.0
*/
public abstract class MappedByteBuffer extends ByteBuffer {
@@ -72,18 +73,24 @@ public abstract class MappedByteBuffer extends ByteBuffer {
}
/**
- * Returns true if this buffer's content is loaded.
+ * Indicates whether this buffer's content is loaded. If the result is true
+ * there is a high probability that the whole buffer memory is currently
+ * loaded in RAM. If it is false it is unsure if it is loaded or not.
*
- * @return True if this buffer's content is loaded.
+ * @return {@code true} if this buffer's content is loaded, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public final boolean isLoaded() {
return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded();
}
/**
- * Loads this buffer's content into memory.
+ * Loads this buffer's content into memory but it is not guaranteed to
+ * succeed.
*
- * @return This buffer
+ * @return this buffer.
+ * @since Android 1.0
*/
public final MappedByteBuffer load() {
((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad();
@@ -91,12 +98,13 @@ public abstract class MappedByteBuffer extends ByteBuffer {
}
/**
- * Writes all changes of the buffer to the mapped file.
+ * Writes all changes of the buffer to the mapped file. If the mapped file
+ * is stored on a local device, it is guaranteed that the changes are
+ * written to the file. No such guarantee is given if the file is located on
+ * a remote device.
*
- * All changes must be written by invoking this method if the mapped file
- * exists on the local device, otherwise the action can not be specified.
- *
- * @return This buffer
+ * @return this buffer.
+ * @since Android 1.0
*/
public final MappedByteBuffer force() {
if (mapMode == IMemorySystem.MMAP_READ_WRITE) {
diff --git a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
index 5533df9..a3f5d7e 100644
--- a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
@@ -15,13 +15,17 @@
* limitations under the License.
*/
+// BEGIN android-note
+// updated to a newer version of harmony
+// END android-note
+
package java.nio;
import org.apache.harmony.luni.platform.PlatformAddress;
import org.apache.harmony.nio.internal.DirectBuffer;
-class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
+final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
private static final int CHAR_SIZE = 2;
@@ -101,10 +105,9 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public byte get() {
- if (this.position == this.limit) {
- throw new BufferUnderflowException();
- }
- return this.wrapped.get(this.position++);
+ byte result = this.wrapped.get();
+ this.position++;
+ return result;
}
public byte get(int index) {
@@ -112,12 +115,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public char getChar() {
- int newPosition = this.position + CHAR_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- char result = this.wrapped.getChar(this.position);
- this.position = newPosition;
+ char result = this.wrapped.getChar();
+ this.position += CHAR_SIZE;
return result;
}
@@ -126,12 +125,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public double getDouble() {
- int newPosition = this.position + DOUBLE_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- double result = this.wrapped.getDouble(this.position);
- this.position = newPosition;
+ double result = this.wrapped.getDouble();
+ this.position += DOUBLE_SIZE;
return result;
}
@@ -144,12 +139,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public float getFloat() {
- int newPosition = this.position + FLOAT_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- float result = this.wrapped.getFloat(this.position);
- this.position = newPosition;
+ float result = this.wrapped.getFloat();
+ this.position += FLOAT_SIZE;
return result;
}
@@ -158,12 +149,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public int getInt() {
- int newPosition = this.position + INTEGER_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- int result = this.wrapped.getInt(this.position);
- this.position = newPosition;
+ int result = this.wrapped.getInt();
+ this.position += INTEGER_SIZE;
return result;
}
@@ -172,12 +159,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public long getLong() {
- int newPosition = this.position + LONG_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- long result = this.wrapped.getLong(this.position);
- this.position = newPosition;
+ long result = this.wrapped.getLong();
+ this.position += LONG_SIZE;
return result;
}
@@ -186,12 +169,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public short getShort() {
- int newPosition = this.position + SHORT_SIZE;
- if (newPosition > this.limit) {
- throw new BufferUnderflowException();
- }
- short result = this.wrapped.getShort(this.position);
- this.position = newPosition;
+ short result = this.wrapped.getShort();
+ this.position += SHORT_SIZE;
return result;
}
@@ -213,10 +192,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer put(byte b) {
- if (this.position == this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.put(this.position++, b);
+ this.wrapped.put(b);
+ this.position++;
return this;
}
@@ -233,12 +210,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putChar(char value) {
- int newPosition = this.position + CHAR_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putChar(this.position, value);
- this.position = newPosition;
+ this.wrapped.putChar(value);
+ this.position += CHAR_SIZE;
return this;
}
@@ -248,12 +221,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putDouble(double value) {
- int newPosition = this.position + DOUBLE_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putDouble(this.position, value);
- this.position = newPosition;
+ this.wrapped.putDouble(value);
+ this.position += DOUBLE_SIZE;
return this;
}
@@ -263,12 +232,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putFloat(float value) {
- int newPosition = this.position + FLOAT_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putFloat(this.position, value);
- this.position = newPosition;
+ this.wrapped.putFloat(value);
+ this.position += FLOAT_SIZE;
return this;
}
@@ -283,12 +248,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putInt(int value) {
- int newPosition = this.position + INTEGER_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putInt(this.position, value);
- this.position = newPosition;
+ this.wrapped.putInt(value);
+ this.position += INTEGER_SIZE;
return this;
}
@@ -298,12 +259,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putLong(long value) {
- int newPosition = this.position + LONG_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putLong(this.position, value);
- this.position = newPosition;
+ this.wrapped.putLong(value);
+ this.position += LONG_SIZE;
return this;
}
@@ -313,12 +270,8 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
}
public ByteBuffer putShort(short value) {
- int newPosition = this.position + SHORT_SIZE;
- if (newPosition > this.limit) {
- throw new BufferOverflowException();
- }
- this.wrapped.putShort(this.position, value);
- this.position = newPosition;
+ this.wrapped.putShort(value);
+ this.position += SHORT_SIZE;
return this;
}
@@ -359,10 +312,7 @@ class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
this.wrapped.free();
}
- // BEGIN android-added
- // copied from newer version of harmony
public int getByteCapacity() {
return wrapped.getByteCapacity();
}
- // END android-added
}
diff --git a/nio/src/main/java/java/nio/ReadOnlyBufferException.java b/nio/src/main/java/java/nio/ReadOnlyBufferException.java
index 990d8ec..62e2d5f 100644
--- a/nio/src/main/java/java/nio/ReadOnlyBufferException.java
+++ b/nio/src/main/java/java/nio/ReadOnlyBufferException.java
@@ -18,16 +18,19 @@ package java.nio;
/**
- * A <code>ReadOnlyBufferException</code> is thrown when some write operation
- * is called on a readonly buffer.
+ * A {@code ReadOnlyBufferException} is thrown when some write operation is
+ * called on a read-only buffer.
*
+ * @since Android 1.0
*/
public class ReadOnlyBufferException extends UnsupportedOperationException {
private static final long serialVersionUID = -1210063976496234090L;
/**
- * Constructs a <code>ReadOnlyBufferException</code>.
+ * Constructs a {@code ReadOnlyBufferException}.
+ *
+ * @since Android 1.0
*/
public ReadOnlyBufferException() {
super();
diff --git a/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java b/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
index 74655b8..95b4ebc 100644
--- a/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
@@ -50,13 +50,13 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
ReadWriteDirectByteBuffer(int capacity) {
super(capacity);
}
-
+
// BEGIN android-added
ReadWriteDirectByteBuffer(int pointer, int capacity) {
this(PlatformAddressFactory.on(pointer, capacity),capacity,0);
}
// END android-added
-
+
ReadWriteDirectByteBuffer(SafeAddress address, int capacity, int offset) {
super(address, capacity, offset);
}
diff --git a/nio/src/main/java/java/nio/ShortBuffer.java b/nio/src/main/java/java/nio/ShortBuffer.java
index 58c2462..39f9ddf 100644
--- a/nio/src/main/java/java/nio/ShortBuffer.java
+++ b/nio/src/main/java/java/nio/ShortBuffer.java
@@ -18,9 +18,10 @@
package java.nio;
/**
- * A buffer of <code>short</code>s.
+ * A buffer of shorts.
* <p>
* A short buffer can be created in either of the following ways:
+ * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new short array and create a buffer
* based on it;</li>
@@ -29,18 +30,20 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asShortBuffer() ByteBuffer.asShortBuffer}
* to create a short buffer based on a byte buffer.</li>
* </ul>
- * </p>
+ *
+ * @since Android 1.0
*/
public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuffer> {
/**
- * Creates a short buffer based on a new allocated short array.
- *
+ * Creates a short buffer based on a newly allocated short array.
+ *
* @param capacity
- * The capacity of the new buffer
- * @return The created short buffer
+ * the capacity of the new buffer.
+ * @return the created short buffer.
* @throws IllegalArgumentException
- * If <code>capacity</code> is less than zero
+ * if {@code capacity} is less than zero.
+ * @since Android 1.0
*/
public static ShortBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -53,36 +56,37 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* Creates a new short buffer by wrapping the given short array.
* <p>
* Calling this method has the same effect as
- * <code>wrap(array, 0, array.length)</code>.
+ * {@code wrap(array, 0, array.length)}.
* </p>
- *
+ *
* @param array
- * The short array which the new buffer will be based on
- * @return The created short buffer
+ * the short array which the new buffer will be based on.
+ * @return the created short buffer.
+ * @since Android 1.0
*/
public static ShortBuffer wrap(short[] array) {
return wrap(array, 0, array.length);
}
/**
- * Creates new a short buffer by wrapping the given short array.
+ * Creates a new short buffer by wrapping the given short array.
* <p>
- * The new buffer's position will be <code>start</code>, limit will be
- * <code>start + len</code>, capacity will be the length of the array.
+ * The new buffer's position will be {@code start}, limit will be
+ * {@code start + len}, capacity will be the length of the array.
* </p>
- *
+ *
* @param array
- * The short array which the new buffer will be based on
+ * the short array which the new buffer will be based on.
* @param start
- * The start index, must be no less than zero and no greater than
- * <code>array.length</code>
+ * the start index, must not be negative and not greater than
+ * {@code array.length}.
* @param len
- * The length, must be no less than zero and no greater than
- * <code>array.length - start</code>
- * @return The created short buffer
+ * the length, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return the created short buffer.
* @exception IndexOutOfBoundsException
- * If either <code>start</code> or <code>len</code> is
- * invalid
+ * if either {@code start} or {@code len} is invalid.
+ * @since Android 1.0
*/
public static ShortBuffer wrap(short[] array, int start, int len) {
if (array == null) {
@@ -100,7 +104,7 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Constructs a <code>ShortBuffer</code> with given capacity.
+ * Constructs a {@code ShortBuffer} with given capacity.
*
* @param capacity
* The capacity of the buffer
@@ -113,13 +117,14 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Returns the short array which this buffer is based on, if there's one.
- *
- * @return The short array which this buffer is based on
+ * Returns the short array which this buffer is based on, if there is one.
+ *
+ * @return the short array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final short[] array() {
return protectedArray();
@@ -127,17 +132,18 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
/**
* Returns the offset of the short array which this buffer is based on, if
- * there's one.
+ * there is one.
* <p>
- * The offset is the index of the array corresponds to the zero position of
- * the buffer.
+ * The offset is the index of the array corresponding to the zero position
+ * of the buffer.
* </p>
- *
- * @return The offset of the short array which this buffer is based on
+ *
+ * @return the offset of the short array which this buffer is based on.
* @exception ReadOnlyBufferException
- * If this buffer is based on an array, but it is readonly
+ * if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
- * If this buffer is not based on an array
+ * if this buffer is not based on an array.
+ * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -160,48 +166,50 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
// END android-added
/**
- * Returns a readonly buffer that shares content with this buffer.
+ * Returns a read-only buffer that shares its content with this buffer.
* <p>
- * The returned buffer is guaranteed to be a new instance, even this buffer
- * is readonly itself. The new buffer's position, limit, capacity and mark
- * are the same as this buffer.
+ * The returned buffer is guaranteed to be a new instance, even if this
+ * buffer is read-only itself. The new buffer's position, limit, capacity
+ * and mark are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means this buffer's
- * change of content will be visible to the new buffer. The two buffer's
- * position, limit and mark are independent.
+ * The new buffer shares its content with this buffer, which means this
+ * buffer's change of content will be visible to the new buffer. The two
+ * buffer's position, limit and mark are independent.
* </p>
- *
- * @return A readonly version of this buffer.
+ *
+ * @return a read-only version of this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer asReadOnlyBuffer();
/**
* Compacts this short buffer.
* <p>
- * The remaining <code>short</code>s will be moved to the head of the
- * buffer, staring from position zero. Then the position is set to
- * <code>remaining()</code>; the limit is set to capacity; the mark is
- * cleared.
+ * The remaining shorts will be moved to the head of the buffer, starting
+ * from position zero. Then the position is set to {@code remaining()}; the
+ * limit is set to capacity; the mark is cleared.
* </p>
- *
- * @return This buffer
+ *
+ * @return this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer compact();
/**
- * Compare the remaining <code>short</code>s of this buffer to another
- * short buffer's remaining <code>short</code>s.
- *
+ * Compare the remaining shorts of this buffer to another short buffer's
+ * remaining shorts.
+ *
* @param otherBuffer
- * Another short buffer
- * @return a negative value if this is less than <code>other</code>; 0 if
- * this equals to <code>other</code>; a positive value if this is
- * greater than <code>other</code>
+ * another short buffer.
+ * @return a negative value if this is less than {@code otherBuffer}; 0 if
+ * this equals to {@code otherBuffer}; a positive value if this is
+ * greater than {@code otherBuffer}.
* @exception ClassCastException
- * If <code>other</code> is not a short buffer
+ * if {@code otherBuffer} is not a short buffer.
+ * @since Android 1.0
*/
public int compareTo(ShortBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -223,36 +231,36 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Returns a duplicated buffer that shares content with this buffer.
+ * Returns a duplicated buffer that shares its content with this buffer.
* <p>
* The duplicated buffer's position, limit, capacity and mark are the same
- * as this buffer. The duplicated buffer's readonly property and byte order
- * are same as this buffer too.
+ * as this buffer. The duplicated buffer's read-only property and byte order
+ * are the same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A duplicated buffer that shares content with this buffer.
+ *
+ * @return a duplicated buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer duplicate();
/**
- * Tests whether this short buffer equals to another object.
- * <p>
- * If <code>other</code> is not a short buffer, then false is returned.
- * </p>
+ * Checks whether this short buffer is equal to another object.
* <p>
- * Two short buffers are equals if, and only if, their remaining
- * <code>short</code>s are exactly the same. Position, limit, capacity
- * and mark are not considered.
+ * If {@code other} is not a short buffer then {@code false} is returned.
+ * Two short buffers are equal if and only if their remaining shorts are
+ * exactly the same. Position, limit, capacity and mark are not considered.
* </p>
- *
+ *
* @param other
- * the object to be compared against
- * @return Whether this short buffer equals to another object.
+ * the object to compare with this short buffer.
+ * @return {@code true} if this short buffer is equal to {@code other},
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean equals(Object other) {
if (!(other instanceof ShortBuffer)) {
@@ -275,54 +283,54 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Returns the short at the current position and increase the position by 1.
- *
- * @return The short at the current position.
+ * Returns the short at the current position and increases the position by
+ * 1.
+ *
+ * @return the short at the current position.
* @exception BufferUnderflowException
- * If the position is equal or greater than limit
+ * if the position is equal or greater than limit.
+ * @since Android 1.0
*/
public abstract short get();
/**
- * Reads <code>short</code>s from the current position into the specified
- * short array and increase the position by the number of <code>short</code>s
- * read.
+ * Reads shorts from the current position into the specified short array and
+ * increases the position by the number of shorts read.
* <p>
* Calling this method has the same effect as
- * <code>get(dest, 0, dest.length)</code>.
+ * {@code get(dest, 0, dest.length)}.
* </p>
- *
+ *
* @param dest
- * The destination short array
- * @return This buffer
+ * the destination short array.
+ * @return this buffer.
* @exception BufferUnderflowException
- * if <code>dest.length</code> is greater than
- * <code>remaining()</code>
+ * if {@code dest.length} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public ShortBuffer get(short[] dest) {
return get(dest, 0, dest.length);
}
/**
- * Reads <code>short</code>s from the current position into the specified
- * short array, starting from the specified offset, and increase the
- * position by the number of <code>short</code>s read.
- *
+ * Reads shorts from the current position into the specified short array,
+ * starting from the specified offset, and increases the position by the
+ * number of shorts read.
+ *
* @param dest
- * The target short array
+ * the target short array.
* @param off
- * The offset of the short array, must be no less than zero and
- * no greater than <code>dest.length</code>
+ * the offset of the short array, must not be negative and not
+ * greater than {@code dest.length}.
* @param len
- * The number of <code>short</code>s to read, must be no less
- * than zero and no greater than <code>dest.length - off</code>
- * @return This buffer
+ * the number of shorts to read, must be no less than zero and
+ * not greater than {@code dest.length - off}.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
- * If <code>len</code> is greater than
- * <code>remaining()</code>
+ * if {@code len} is greater than {@code remaining()}.
+ * @since Android 1.0
*/
public ShortBuffer get(short[] dest, int off, int len) {
int length = dest.length;
@@ -339,35 +347,35 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Returns a short at the specified index, and the position is not changed.
- *
+ * Returns the short at the specified index; the position is not changed.
+ *
* @param index
- * The index, must be no less than zero and less than limit
- * @return A short at the specified index.
+ * the index, must not be negative and less than limit.
+ * @return a short at the specified index.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
+ * @since Android 1.0
*/
public abstract short get(int index);
/**
- * Returns whether this buffer is based on a short array and is read/write.
- * <p>
- * If this buffer is readonly, then false is returned.
- * </p>
- *
- * @return Whether this buffer is based on a short array and is read/write.
+ * Indicates whether this buffer is based on a short array and is
+ * read/write.
+ *
+ * @return {@code true} if this buffer is based on a short array and
+ * provides read/write access, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
}
/**
- * Hash code is calculated from the remaining <code>short</code>s.
- * <p>
- * Position, limit, capacity and mark don't affect the hash code.
- * </p>
- *
- * @return The hash code calculated from the remaining <code>short</code>s.
+ * Calculates this buffer's hash code from the remaining chars. The
+ * position, limit, capacity and mark don't affect the hash code.
+ *
+ * @return the hash code calculated from the remaining shorts.
+ * @since Android 1.0
*/
public int hashCode() {
int myPosition = position;
@@ -379,119 +387,118 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Returns true if this buffer is direct.
+ * Indicates whether this buffer is direct. A direct buffer will try its
+ * best to take advantage of native memory APIs and it may not stay in the
+ * Java heap, so it is not affected by garbage collection.
* <p>
- * A direct buffer will try its best to take advantage of native memory APIs
- * and it may not stay in java heap, thus not affected by GC.
- * </p>
- * <p>
- * A short buffer is direct, if it is based on a byte buffer and the byte
+ * A short buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
* </p>
- *
- * @return True if this buffer is direct.
+ *
+ * @return {@code true} if this buffer is direct, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isDirect();
/**
- * Returns the byte order used by this buffer when converting
- * <code>short</code>s from/to <code>byte</code>s.
+ * Returns the byte order used by this buffer when converting shorts from/to
+ * bytes.
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
* </p>
- *
- * @return The byte order used by this buffer when converting
- * <code>short</code>s from/to <code>byte</code>s.
+ *
+ * @return the byte order used by this buffer when converting shorts from/to
+ * bytes.
+ * @since Android 1.0
*/
public abstract ByteOrder order();
/**
- * Child class implements this method to realize <code>array()</code>.
+ * Child class implements this method to realize {@code array()}.
*
- * @return see <code>array()</code>
+ * @return see {@code array()}
*/
abstract short[] protectedArray();
/**
- * Child class implements this method to realize <code>arrayOffset()</code>.
+ * Child class implements this method to realize {@code arrayOffset()}.
*
- * @return see <code>arrayOffset()</code>
+ * @return see {@code arrayOffset()}
*/
abstract int protectedArrayOffset();
/**
- * Child class implements this method to realize <code>hasArray()</code>.
+ * Child class implements this method to realize {@code hasArray()}.
*
- * @return see <code>hasArray()</code>
+ * @return see {@code hasArray()}
*/
abstract boolean protectedHasArray();
/**
- * Writes the given short to the current position and increase the position
+ * Writes the given short to the current position and increases the position
* by 1.
- *
+ *
* @param s
- * The short to write
- * @return This buffer
+ * the short to write.
+ * @return this buffer.
* @exception BufferOverflowException
- * If position is equal or greater than limit
+ * if position is equal or greater than limit.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer put(short s);
/**
- * Writes <code>short</code>s in the given short array to the current
- * position and increase the position by the number of <code>short</code>s
- * written.
+ * Writes shorts from the given short array to the current position and
+ * increases the position by the number of shorts written.
* <p>
* Calling this method has the same effect as
- * <code>put(src, 0, src.length)</code>.
+ * {@code put(src, 0, src.length)}.
* </p>
- *
+ *
* @param src
- * The source short array
- * @return This buffer
+ * the source short array.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>src.length</code>
+ * if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public final ShortBuffer put(short[] src) {
return put(src, 0, src.length);
}
/**
- * Writes <code>short</code>s in the given short array, starting from the
- * specified offset, to the current position and increase the position by
- * the number of <code>short</code>s written.
- *
+ * Writes shorts from the given short array, starting from the specified
+ * offset, to the current position and increases the position by the number
+ * of shorts written.
+ *
* @param src
- * The source short array
+ * the source short array.
* @param off
- * The offset of short array, must be no less than zero and no
- * greater than <code>src.length</code>
+ * the offset of short array, must not be negative and not
+ * greater than {@code src.length}.
* @param len
- * The number of <code>short</code>s to write, must be no less
- * than zero and no greater than <code>src.length - off</code>
- * @return This buffer
+ * the number of shorts to write, must be no less than zero and
+ * not greater than {@code src.length - off}.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>remaining()</code> is less than
- * <code>len</code>
+ * if {@code remaining()} is less than {@code len}.
* @exception IndexOutOfBoundsException
- * If either <code>off</code> or <code>len</code> is
- * invalid
+ * if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public ShortBuffer put(short[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -502,20 +509,21 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Writes all the remaining <code>short</code>s of the <code>src</code>
- * short buffer to this buffer's current position, and increase both
- * buffers' position by the number of <code>short</code>s copied.
- *
+ * Writes all the remaining shorts of the {@code src} short buffer to this
+ * buffer's current position, and increases both buffers' position by the
+ * number of shorts copied.
+ *
* @param src
- * The source short buffer
- * @return This buffer
+ * the source short buffer.
+ * @return this buffer.
* @exception BufferOverflowException
- * If <code>src.remaining()</code> is greater than this
- * buffer's <code>remaining()</code>
+ * if {@code src.remaining()} is greater than this buffer's
+ * {@code remaining()}.
* @exception IllegalArgumentException
- * If <code>src</code> is this buffer
+ * if {@code src} is this buffer.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public ShortBuffer put(ShortBuffer src) {
if (src == this) {
@@ -531,44 +539,47 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
}
/**
- * Write a short to the specified index of this buffer and the position is
- * not changed.
- *
+ * Writes a short to the specified index of this buffer; the position is not
+ * changed.
+ *
* @param index
- * The index, must be no less than zero and less than the limit
+ * the index, must not be negative and less than the limit.
* @param s
- * The short to write
- * @return This buffer
+ * the short to write.
+ * @return this buffer.
* @exception IndexOutOfBoundsException
- * If index is invalid
+ * if index is invalid.
* @exception ReadOnlyBufferException
- * If no changes may be made to the contents of this buffer
+ * if no changes may be made to the contents of this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer put(int index, short s);
/**
- * Returns a sliced buffer that shares content with this buffer.
+ * Returns a sliced buffer that shares its content with this buffer.
* <p>
- * The sliced buffer's capacity will be this buffer's
- * <code>remaining()</code>, and its zero position will correspond to
- * this buffer's current position. The new buffer's position will be 0,
- * limit will be its capacity, and its mark is unset. The new buffer's
- * readonly property and byte order are same as this buffer.
+ * The sliced buffer's capacity will be this buffer's {@code remaining()},
+ * and its zero position will correspond to this buffer's current position.
+ * The new buffer's position will be 0, limit will be its capacity, and its
+ * mark is cleared. The new buffer's read-only property and byte order are
+ * same as this buffer's.
* </p>
* <p>
- * The new buffer shares content with this buffer, which means either
+ * The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
* </p>
- *
- * @return A sliced buffer that shares content with this buffer.
+ *
+ * @return a sliced buffer that shares its content with this buffer.
+ * @since Android 1.0
*/
public abstract ShortBuffer slice();
/**
- * Returns a string represents the state of this short buffer.
- *
- * @return A string represents the state of this short buffer.
+ * Returns a string representing the state of this short buffer.
+ *
+ * @return a string representing the state of this short buffer.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer buf = new StringBuffer();
diff --git a/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java b/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
index a092dc9..d558492 100644
--- a/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
+++ b/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
@@ -18,15 +18,19 @@ package java.nio.channels;
/**
- * Thrown when an attempt is made to connect a SocketChannel that is already connected.
+ * An {@code AlreadyConnectedException} is thrown when an attempt is made to
+ * connect a SocketChannel that is already connected.
*
+ * @since Android 1.0
*/
public class AlreadyConnectedException extends IllegalStateException {
private static final long serialVersionUID = -7331895245053773357L;
/**
- * Default constructor.
+ * Constructs an {@code AlreadyConnectedException}.
+ *
+ * @since Android 1.0
*/
public AlreadyConnectedException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java b/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
index 2c07ba0..e34d8d0 100644
--- a/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
+++ b/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
@@ -18,15 +18,19 @@ package java.nio.channels;
/**
- * Thrown when the underlying channel for an IO operation is closed by another thread.
+ * An {@code AsynchronousCloseException} is thrown when the underlying channel
+ * for an I/O operation is closed by another thread.
*
+ * @since Android 1.0
*/
public class AsynchronousCloseException extends ClosedChannelException {
private static final long serialVersionUID = 6891178312432313966L;
/**
- * Default constructor
+ * Constructs an {@code AsynchronousCloseException}.
+ *
+ * @since Android 1.0
*/
public AsynchronousCloseException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/ByteChannel.java b/nio/src/main/java/java/nio/channels/ByteChannel.java
index 0c262c0..97f5d23 100644
--- a/nio/src/main/java/java/nio/channels/ByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ByteChannel.java
@@ -24,6 +24,9 @@ package java.nio.channels;
* writable byte channels.
* </p>
*
+ * @see ReadableByteChannel
+ * @see WritableByteChannel
+ * @since Android 1.0
*/
public interface ByteChannel extends ReadableByteChannel, WritableByteChannel {
// No methods defined.
diff --git a/nio/src/main/java/java/nio/channels/CancelledKeyException.java b/nio/src/main/java/java/nio/channels/CancelledKeyException.java
index c448fd8..ebb7c76 100644
--- a/nio/src/main/java/java/nio/channels/CancelledKeyException.java
+++ b/nio/src/main/java/java/nio/channels/CancelledKeyException.java
@@ -18,8 +18,10 @@ package java.nio.channels;
/**
- * Thrown when an invalid selection key is used.
+ * A {@code CancelledKeyException} is thrown when an invalid selection key is
+ * used.
*
+ * @since Android 1.0
*/
public class CancelledKeyException extends IllegalStateException {
@@ -29,8 +31,9 @@ public class CancelledKeyException extends IllegalStateException {
private static final long serialVersionUID = -8438032138028814268L;
/**
- * Default constructor.
+ * Constructs a {@code CancelledKeyException}.
*
+ * @since Android 1.0
*/
public CancelledKeyException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/Channel.java b/nio/src/main/java/java/nio/channels/Channel.java
index da9e715..585ce29 100644
--- a/nio/src/main/java/java/nio/channels/Channel.java
+++ b/nio/src/main/java/java/nio/channels/Channel.java
@@ -21,19 +21,19 @@ import java.io.Closeable;
import java.io.IOException;
/**
- * A channel is a conduit to IO services covering such items as files, sockets,
- * hardware devices, IO ports, or some software component.
+ * A channel is a conduit to I/O services covering such items as files, sockets,
+ * hardware devices, I/O ports or some software component.
* <p>
- * Channels are open upon creation, and can be explicitly closed. Once a channel
- * is closed it cannot be re-opened, and attempts to perform IO operations on
- * the closed channel result in a <code>ClosedChannelException
- * </code>.
+ * Channels are open upon creation, and can be closed explicitly. Once a channel
+ * is closed it cannot be re-opened, and any attempts to perform I/O operations
+ * on the closed channel result in a <code>ClosedChannelException</code>.
* </p>
* <p>
- * Particular implementations or sub-interfaces of Channel dictate whether they
- * are thread-safe or not.
+ * Particular implementations or sub-interfaces of {@code Channel} dictate
+ * whether they are thread-safe or not.
* </p>
*
+ * @since Android 1.0
*/
public interface Channel extends Closeable {
@@ -41,27 +41,28 @@ public interface Channel extends Closeable {
* Returns whether this channel is open or not.
*
* @return true if the channel is open, otherwise returns false.
+ * @since Android 1.0
*/
public boolean isOpen();
/**
- * Closes an open channel.
- *
- * If the channel is already closed this method has no effect. If there is a
- * problem with closing the channel then the method throws an IOException
- * and the exception contains reasons for the failure.
+ * Closes an open channel. If the channel is already closed then this method
+ * has no effect. If there is a problem with closing the channel then the
+ * method throws an IOException and the exception contains reasons for the
+ * failure.
* <p>
* If an attempt is made to perform an operation on a closed channel then a
- * <code>ClosedChannelException</code> will be thrown on that attempt.
+ * {@link ClosedChannelException} will be thrown on that attempt.
* </p>
* <p>
- * If multiple threads attempts to simultaneously close a channel, then only
- * one thread will run the closure code, and others will be blocked until the
- * first returns.
+ * If multiple threads attempt to simultaneously close a channel, then only
+ * one thread will run the closure code, and others will be blocked until
+ * the first returns.
* </p>
*
* @throws IOException
* if a problem occurs closing the channel.
+ * @since Android 1.0
*/
public void close() throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/Channels.java b/nio/src/main/java/java/nio/channels/Channels.java
index 10a301c..fa70dc0 100644
--- a/nio/src/main/java/java/nio/channels/Channels.java
+++ b/nio/src/main/java/java/nio/channels/Channels.java
@@ -33,6 +33,7 @@ import org.apache.harmony.nio.internal.IOUtil;
/**
* This class provides several utilities to get I/O streams from channels.
*
+ * @since Android 1.0
*/
public final class Channels {
@@ -51,44 +52,80 @@ public final class Channels {
// -------------------------------------------------------------------
/**
- * Returns an input stream on the given channel
+ * Returns an input stream on the given channel. The resulting stream has
+ * the following properties:
+ * <ul>
+ * <li>If the stream is closed, then the underlying channel is closed as
+ * well.</li>
+ * <li>It is thread safe.</li>
+ * <li>It throws an {@link IllegalBlockingModeException} if the channel is
+ * in non-blocking mode and {@code read} is called.</li>
+ * <li>Neither {@code mark} nor {@code reset} is supported.</li>
+ * <li>It is not buffered.</li>
+ * </ul>
*
* @param channel
- * The channel to be wrapped in an InputStream.
+ * the channel to be wrapped by an InputStream.
* @return an InputStream that takes bytes from the given byte channel.
+ * @since Android 1.0
*/
public static InputStream newInputStream(ReadableByteChannel channel) {
return new ReadableByteChannelInputStream(channel);
}
/**
- * Returns an output stream on the given channel
+ * Returns an output stream on the given channel. The resulting stream has
+ * the following properties:
+ * <ul>
+ * <li>If the stream is closed, then the underlying channel is closed as
+ * well.</li>
+ * <li>It is thread safe.</li>
+ * <li>It throws an {@link IllegalBlockingModeException} if the channel is
+ * in non-blocking mode and {@code write} is called.</li>
+ * <li>It is not buffered.</li>
+ * </ul>
*
* @param channel
- * the channel to be wrapped in an OutputStream.
+ * the channel to be wrapped by an OutputStream.
* @return an OutputStream that puts bytes onto the given byte channel.
+ * @since Android 1.0
*/
public static OutputStream newOutputStream(WritableByteChannel channel) {
return new WritableByteChannelOutputStream(channel);
}
/**
- * Returns a channel on the given input stream
+ * Returns a readable channel on the given input stream. The resulting
+ * channel has the following properties:
+ * <ul>
+ * <li>If the channel is closed, then the underlying stream is closed as
+ * well.</li>
+ * <li>It is not buffered.</li>
+ * </ul>
*
* @param inputStream
- * the stream to be wrapped in a byte channel.
+ * the stream to be wrapped by a byte channel.
* @return a byte channel that reads bytes from the input stream.
+ * @since Android 1.0
*/
public static ReadableByteChannel newChannel(InputStream inputStream) {
return new ReadableByteChannelImpl(inputStream);
}
/**
- * Returns a channel on the given output stream
+ * Returns a writable channel on the given output stream.
+ *
+ * The resulting channel has following properties:
+ * <ul>
+ * <li>If the channel is closed, then the underlying stream is closed as
+ * well.</li>
+ * <li>It is not buffered.</li>
+ * </ul>
*
* @param outputStream
- * the stream to be wrapped in a byte channel.
+ * the stream to be wrapped by a byte channel.
* @return a byte channel that writes bytes to the output stream.
+ * @since Android 1.0
*/
public static WritableByteChannel newChannel(OutputStream outputStream) {
return new WritableByteChannelImpl(outputStream);
@@ -98,12 +135,14 @@ public final class Channels {
* Returns a reader that decodes bytes from a channel.
*
* @param channel
- * Channel to be read.
+ * the Channel to be read.
* @param decoder
- * Charset decoder to be used.
+ * the Charset decoder to be used.
* @param minBufferCapacity
- * The minimum size of byte buffer, -1 means to use default size.
- * @return The reader.
+ * The minimum size of the byte buffer, -1 means to use the
+ * default size.
+ * @return the reader.
+ * @since Android 1.0
*/
public static Reader newReader(ReadableByteChannel channel,
CharsetDecoder decoder, int minBufferCapacity) {
@@ -113,13 +152,17 @@ public final class Channels {
}
/**
- * Returns a reader that decodes bytes from a channel.
+ * Returns a reader that decodes bytes from a channel. This method creates a
+ * reader with a buffer of default size.
*
* @param channel
- * Channel to be read.
+ * the Channel to be read.
* @param charsetName
- * Name of charset.
- * @return The reader.
+ * the name of the charset.
+ * @return the reader.
+ * @throws java.nio.charset.UnsupportedCharsetException
+ * if the given charset name is not supported.
+ * @since Android 1.0
*/
public static Reader newReader(ReadableByteChannel channel,
String charsetName) {
@@ -127,16 +170,18 @@ public final class Channels {
}
/**
- * Returns a writer that encodes characters by encoder and output bytes to a
- * channel.
+ * Returns a writer that encodes characters with the specified
+ * {@code encoder} and sends the bytes to the specified channel.
*
* @param channel
- * Channel to be written.
+ * the Channel to write to.
* @param encoder
- * Charset decoder to be used.
+ * the CharsetEncoder to be used.
* @param minBufferCapacity
- * The minimum size of byte buffer, -1 means to use default size.
- * @return The writer.
+ * the minimum size of the byte buffer, -1 means to use the
+ * default size.
+ * @return the writer.
+ * @since Android 1.0
*/
public static Writer newWriter(WritableByteChannel channel,
CharsetEncoder encoder, int minBufferCapacity) {
@@ -145,14 +190,18 @@ public final class Channels {
}
/**
- * Returns a writer that encodes characters by encoder and output bytes to a
- * channel.
+ * Returns a writer that encodes characters with the specified
+ * {@code encoder} and sends the bytes to the specified channel. This method
+ * creates a writer with a buffer of default size.
*
* @param channel
- * Channel to be written.
+ * the Channel to be written to.
* @param charsetName
- * Name of charset.
- * @return The writer.
+ * the name of the charset.
+ * @return the writer.
+ * @throws java.nio.charset.UnsupportedCharsetException
+ * if the given charset name is not supported.
+ * @since Android 1.0
*/
public static Writer newWriter(WritableByteChannel channel,
String charsetName) {
diff --git a/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java b/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
index 5c4aa0b..c7d5c6a 100644
--- a/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
@@ -18,20 +18,24 @@ package java.nio.channels;
/**
- * Thrown when a thread is interrupted in a blocking IO operation.
+ * A {@code ClosedByInterruptException} is thrown when a thread is interrupted
+ * in a blocking I/O operation.
* <p>
- * When the thread is interrupted by a call to <code>interrupt()</code>
- * it will close the channel, set the interrupt status of the thread to true,
- * and throw a <code>ClosedByInterruptException</code>.
+ * When the thread is interrupted by a call to {@code interrupt()}, it closes
+ * the channel, sets the interrupt status of the thread to {@code true} and
+ * throws a {@code ClosedByInterruptException}.
+ * </p>
*
+ * @since Android 1.0
*/
public class ClosedByInterruptException extends AsynchronousCloseException {
private static final long serialVersionUID = -4488191543534286750L;
/**
- * Default constructor.
- *
+ * Constructs a {@code ClosedByInterruptException}.
+ *
+ * @since Android 1.0
*/
public ClosedByInterruptException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/ClosedChannelException.java b/nio/src/main/java/java/nio/channels/ClosedChannelException.java
index a2ab1c3..4cf4b38 100644
--- a/nio/src/main/java/java/nio/channels/ClosedChannelException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedChannelException.java
@@ -20,16 +20,19 @@ package java.nio.channels;
import java.io.IOException;
/**
- * This exception is thrown when a channel is closed for the type of operation
- * attempted.
+ * A {@code ClosedChannelException} is thrown when a channel is closed for the
+ * type of operation attempted.
*
+ * @since Android 1.0
*/
public class ClosedChannelException extends IOException {
private static final long serialVersionUID = 882777185433553857L;
/**
- * Default constructor.
+ * Constructs a {@code ClosedChannelException}.
+ *
+ * @since Android 1.0
*/
public ClosedChannelException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/ClosedSelectorException.java b/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
index 62dca07..0fb16d3 100644
--- a/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
@@ -18,16 +18,19 @@ package java.nio.channels;
/**
- * Thrown when an a selector is closed and an IO operation is attempted.
+ * A {@code ClosedSelectorException} is thrown when a {@link Selector selector}
+ * is closed and an I/O operation is attempted.
*
+ * @since Android 1.0
*/
public class ClosedSelectorException extends IllegalStateException {
private static final long serialVersionUID = 6466297122317847835L;
/**
- * Default constructor.
- *
+ * Constructs a {@code ClosedSelectorException}.
+ *
+ * @since Android 1.0
*/
public ClosedSelectorException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/ConnectionPendingException.java b/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
index cf6fd25..c535925 100644
--- a/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
+++ b/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
@@ -18,17 +18,20 @@ package java.nio.channels;
/**
- * Thrown when an attempt is made to connect a SocketChannel that has a
- * non-blocking connection already underway.
+ * A {@code ConnectionPendingException} is thrown when an attempt is made to
+ * connect a {@link SocketChannel} that has a non-blocking connection already
+ * underway.
*
+ * @since Android 1.0
*/
public class ConnectionPendingException extends IllegalStateException {
private static final long serialVersionUID = 2008393366501760879L;
/**
- * Default constructor.
+ * Constructs a {@code ConnectionPendingException}.
*
+ * @since Android 1.0
*/
public ConnectionPendingException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/DatagramChannel.java b/nio/src/main/java/java/nio/channels/DatagramChannel.java
index d5c99e2..534155a 100644
--- a/nio/src/main/java/java/nio/channels/DatagramChannel.java
+++ b/nio/src/main/java/java/nio/channels/DatagramChannel.java
@@ -27,22 +27,23 @@ import java.nio.channels.spi.SelectorProvider;
import org.apache.harmony.luni.platform.Platform;
/**
- * A DatagramChannel is a selectable channel for part abstraction of datagram
- * socket. The <code>socket</code> method of this class can return the related
- * <code>DatagramSocket</code> instance, which can handle the socket.
+ * A {@code DatagramChannel} is a selectable channel that represents a partial
+ * abstraction of a datagram socket. The {@code socket} method of this class can
+ * return the related {@code DatagramSocket} instance, which can handle the
+ * socket.
* <p>
- * A datagram channel is open but not connected when created by
- * <code>open</code> method. After connected, it will keep the connected
- * status before disconnecting or closing. The benefit of a connected channel is
- * the reduced effort of security checks during send and receive. When invoking
- * <code>read</code> or <code>write</code>, a connected channel is
- * required.
+ * A datagram channel is open but not connected when created with the
+ * {@code open()} method. After it is connected, it will keep the connected
+ * status until it is disconnected or closed. The benefit of a connected channel
+ * is the reduced effort of security checks during send and receive. When
+ * invoking {@code read} or {@code write}, a connected channel is required.
* </p>
* <p>
- * Datagram channels are thread-safe, no more than one thread can read or write
- * at given time.
+ * Datagram channels are thread-safe; only one thread can read or write at the
+ * same time.
* </p>
*
+ * @since Android 1.0
*/
public abstract class DatagramChannel extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel {
@@ -52,296 +53,312 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
}
/**
- * Constructor for this class.
+ * Constructs a new {@code DatagramChannel}.
*
* @param selectorProvider
- * A instance of SelectorProvider
+ * an instance of SelectorProvider.
+ * @since Android 1.0
*/
protected DatagramChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
}
/**
- * Create a open and not-connected datagram channel.
+ * Creates an opened and not-connected datagram channel.
* <p>
- * This channel is got by <code>openDatagramChannel</code> method of the
- * default <code>SelectorProvider </code> instance.
+ * This channel is created by calling the <code>openDatagramChannel</code>
+ * method of the default {@link SelectorProvider} instance.
* </p>
*
- * @return The new created channel which is open but not-connected.
+ * @return the new channel which is open but not connected.
* @throws IOException
- * If some IO problem occurs.
+ * if some I/O error occurs.
+ * @since Android 1.0
*/
public static DatagramChannel open() throws IOException {
return SelectorProvider.provider().openDatagramChannel();
}
/**
- * Get the valid operations of this channel. Datagram channels support read
- * and write operation, so this method returns (
+ * Gets the valid operations of this channel. Datagram channels support read
+ * and write operations, so this method returns (
* <code>SelectionKey.OP_READ</code> | <code>SelectionKey.OP_WRITE</code> ).
*
* @see java.nio.channels.SelectableChannel#validOps()
- * @return Valid operations in bit-set.
+ * @return valid operations in bit-set.
+ * @since Android 1.0
*/
public final int validOps() {
return (SelectionKey.OP_READ | SelectionKey.OP_WRITE);
}
/**
- * Return the related datagram socket of this channel, which won't declare
- * public methods that not declared in <code>DatagramSocket</code>.
+ * Returns the related datagram socket of this channel, which does not
+ * define additional public methods to those defined by
+ * {@link DatagramSocket}.
*
- * @return The related DatagramSocket instance.
+ * @return the related DatagramSocket instance.
+ * @since Android 1.0
*/
public abstract DatagramSocket socket();
/**
- * Answer whether this channel's socket is connected or not.
+ * Returns whether this channel's socket is connected or not.
*
- * @return <code>true</code> for this channel's socket is connected;
+ * @return <code>true</code> if this channel's socket is connected;
* <code>false</code> otherwise.
+ * @since Android 1.0
*/
public abstract boolean isConnected();
/**
- * Connect the socket of this channel to a remote address, which is the only
- * communication peer of getting and sending datagrams after connected.
+ * Connects the socket of this channel to a remote address, which is the
+ * only communication peer for getting and sending datagrams after being
+ * connected.
* <p>
- * This method can be called at any moment, and won't affect the processing
- * read and write operation. The connect status won't changed before
- * disconnected and closed.
+ * This method can be called at any time without affecting the read and
+ * write operations being processed at the time the method is called. The
+ * connection status does not change until the channel is disconnected or
+ * closed.
* </p>
* <p>
- * This method just execute the same security checks as the connect method
- * of the <code>DatagramSocket</code> class.
+ * This method executes the same security checks as the connect method of
+ * the {@link DatagramSocket} class.
* </p>
*
* @param address
- * The address to be connected.
- * @return This channel.
+ * the address to be connected to.
+ * @return this channel.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws SecurityException
- * If there is a security manager, and the address is not
- * permitted to access.
+ * if there is a security manager, and the address is not
+ * permitted to be accessed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if some other I/O error occurrs.
+ * @since Android 1.0
*/
public abstract DatagramChannel connect(SocketAddress address)
throws IOException;
/**
- * Disconnect the socket of this channel, which is connected before for
- * getting and sending datagrams.
+ * Disconnects the socket of this channel, which has been connected before
+ * in order to send and receive datagrams.
* <p>
- * This method can be called at any moment, and won't affect the processing
- * read and write operation. It won't has any effect if the socket is not
- * connected or the channel is closed.
+ * This method can be called at any time without affecting the read and
+ * write operations being underway. It does not have any effect if the
+ * socket is not connected or the channel is closed.
* </p>
*
- * @return This channel.
+ * @return this channel.
* @throws IOException
- * Some other IO error occurred.
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract DatagramChannel disconnect() throws IOException;
/**
- * Get a datagram from this channel.
+ * Gets a datagram from this channel.
* <p>
- * This method transfers the datagram from the channel into the target byte
- * buffer and return the address of the datagram, if the datagram is
- * available or will be available as this channel is in blocking mode. This
- * method returns <code>null</code> if the datagram is not available now
- * and the channel is in non-blocking mode. The transfer start at the
- * current position of the buffer, and the residual part of the datagram
- * will be ignored if there is no efficient remaining in the buffer to store
- * the datagram.
+ * This method transfers a datagram from the channel into the target byte
+ * buffer. If this channel is in blocking mode, it waits for the datagram
+ * and returns its address when it is available. If this channel is in
+ * non-blocking mode and no datagram is available, it returns {@code null}
+ * immediately. The transfer starts at the current position of the buffer,
+ * and if there is not enough space remaining in the buffer to store the
+ * datagram then the part of the datagram that does not fit is discarded.
* </p>
* <p>
- * This method can be called at any moment, and will block if there is
- * another thread started a read operation on the channel.
+ * This method can be called at any time and it will block if there is
+ * another thread that has started a read operation on the channel.
* </p>
* <p>
- * This method just execute the same security checks as the receive method
- * of the <code>DatagramSocket</code> class.
+ * This method executes the same security checks as the receive method of
+ * the {@link DatagramSocket} class.
* </p>
*
* @param target
- * The byte buffer to store the received datagram.
- * @return Address of the datagram if the transfer is performed, or null if
- * the channel is in non-blocking mode and the datagram are
- * unavailable.
+ * the byte buffer to store the received datagram.
+ * @return the address of the datagram if the transfer is performed, or null
+ * if the channel is in non-blocking mode and no datagram is
+ * available.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws SecurityException
- * If there is a security manager, and the address is not
- * permitted to access.
+ * if there is a security manager, and the address is not
+ * permitted to be accessed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract SocketAddress receive(ByteBuffer target) throws IOException;
/**
- * Sends out a datagram by the channel.
+ * Sends a datagram through this channel. The datagram consists of the
+ * remaining bytes in {@code source}.
* <p>
- * The precondition of sending is that whether the channel is in blocking
- * mode and enough byte buffer space will be available, or the channel is in
- * non-blocking mode and byte buffer space is enough. The transfer action is
- * just like a regular write operation.
+ * If this channel is in blocking mode then the datagram is sent as soon as
+ * there is enough space in the underlying output buffer. If this channel is
+ * in non-blocking mode then the datagram is only sent if there is enough
+ * space in the underlying output buffer at that moment. The transfer action
+ * is just like a regular write operation.
* </p>
* <p>
- * This method can be called at any moment, and will block if there is
- * another thread started a read operation on the channel.
+ * This method can be called at any time and it will block if another thread
+ * has started a send operation on this channel.
* </p>
* <p>
- * This method just execute the same security checks as the send method of
- * the <code>DatagramSocket</code> class.
+ * This method executes the same security checks as the send method of the
+ * {@link DatagramSocket} class.
* </p>
*
* @param source
- * The byte buffer with the datagram to be sent.
+ * the byte buffer with the datagram to be sent.
* @param address
- * The address to be sent.
- * @return The number of sent bytes. If this method is called, it returns
- * the number of bytes that remaining in the byte buffer. If the
- * channel is in non-blocking mode and no enough space for the
- * datagram in the buffer, it may returns zero.
+ * the destination address for the datagram.
+ * @return the number of bytes sent. This is the number of bytes remaining
+ * in {@code source} or zero if the channel is in non-blocking mode
+ * and there is not enough space for the datagram in the underlying
+ * output buffer.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws SecurityException
- * If there is a security manager, and the address is not
+ * if there is a security manager, and the address is not
* permitted to access.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract int send(ByteBuffer source, SocketAddress address)
throws IOException;
/**
- * Reads datagram from the channel into the byte buffer.
+ * Reads a datagram from this channel into the byte buffer.
* <p>
- * The precondition of calling this method is that the channel is connected
- * and the coming datagram is from the connected address. If the buffer is
- * not enough to store the datagram, the residual part of the datagram is
- * ignored. Otherwise, this method has the same behavior as the read method
- * in the <code>ReadableByteChannel</code> interface.
+ * The precondition for calling this method is that the channel is connected
+ * and the incoming datagram is from the connected address. If the buffer is
+ * not big enough to store the datagram, the part of the datagram that does
+ * not fit in the buffer is discarded. Otherwise, this method has the same
+ * behavior as the {@code read} method in the {@link ReadableByteChannel}
+ * interface.
* </p>
*
* @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
* @param target
- * The byte buffer to store the received datagram.
- * @return Non-negative number as the number of bytes read, or -1 as the
+ * the byte buffer to store the received datagram.
+ * @return a non-negative number as the number of bytes read, or -1 as the
* read operation reaches the end of stream.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract int read(ByteBuffer target) throws IOException;
/**
- * Reads datagram from the channel into the byte buffer.
+ * Reads a datagram from this channel into an array of byte buffers.
* <p>
- * The precondition of calling this method is that the channel is connected
- * and the coming datagram is from the connected address. If the buffer is
- * not enough to store the datagram, the residual part of the datagram is
- * ignored. Otherwise, this method has the same behavior as the read method
- * in the <code>ScatteringByteChannel</code> interface.
+ * The precondition for calling this method is that the channel is connected
+ * and the incoming datagram is from the connected address. If the buffers
+ * do not have enough remaining space to store the datagram, the part of the
+ * datagram that does not fit in the buffers is discarded. Otherwise, this
+ * method has the same behavior as the {@code read} method in the
+ * {@link ScatteringByteChannel} interface.
* </p>
*
* @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
* int, int)
* @param targets
- * The byte buffers to store the received datagram.
+ * the byte buffers to store the received datagram.
* @param offset
- * A non-negative offset in the array of buffer, pointing to the
- * starting buffer to store the byte transferred, must no larger
- * than targets.length.
+ * a non-negative offset in the array of buffers, pointing to the
+ * starting buffer to store the bytes transferred, must not be
+ * bigger than {@code targets.length}.
* @param length
- * A non-negative length to indicate the maximum number of byte
- * to be read, must no larger than targets.length - offset.
- * @return Non-negative number as the number of bytes read, or -1 as the
+ * a non-negative length to indicate the maximum number of
+ * buffers to be filled, must not be bigger than
+ * {@code targets.length - offset}.
+ * @return a non-negative number as the number of bytes read, or -1 if the
* read operation reaches the end of stream.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract long read(ByteBuffer[] targets, int offset, int length)
throws IOException;
/**
- * Reads datagram from the channel into the byte buffer.
+ * Reads a datagram from this channel into an array of byte buffers.
* <p>
- * The precondition of calling this method is that the channel is connected
- * and the coming datagram is from the connected address. If the buffer is
- * not enough to store the datagram, the residual part of the datagram is
- * ignored. Otherwise, this method has the same behavior as the read method
- * in the <code>ScatteringByteChannel</code> interface.
+ * The precondition for calling this method is that the channel is connected
+ * and the incoming datagram is from the connected address. If the buffers
+ * do not have enough remaining space to store the datagram, the part of the
+ * datagram that does not fit in the buffers is discarded. Otherwise, this
+ * method has the same behavior as the {@code read} method in the
+ * {@link ScatteringByteChannel} interface.
* </p>
*
* @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
* @param targets
- * The byte buffers to store the received datagram.
- * @return Non-negative number as the number of bytes read, or -1 as the
+ * the byte buffers to store the received datagram.
+ * @return a non-negative number as the number of bytes read, or -1 if the
* read operation reaches the end of stream.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public synchronized final long read(ByteBuffer[] targets)
throws IOException {
@@ -349,105 +366,106 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
}
/**
- * Write datagram from the byte buffer into the channel.
+ * Writes a datagram from the byte buffer to this channel.
* <p>
* The precondition of calling this method is that the channel is connected
* and the datagram is sent to the connected address. Otherwise, this method
- * has the same behavior as the write method in the
- * <code>WritableByteChannel</code> interface.
+ * has the same behavior as the {@code write} method in the
+ * {@link WritableByteChannel} interface.
* </p>
*
* @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
* @param source
- * The byte buffer as the source of the datagram.
- * @return Non-negative number of bytes written.
+ * the byte buffer as the source of the datagram.
+ * @return a non-negative number of bytes written.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract int write(ByteBuffer source) throws IOException;
/**
- * Write datagram from the byte buffer into the channel.
+ * Writes a datagram from the byte buffers to this channel.
* <p>
* The precondition of calling this method is that the channel is connected
* and the datagram is sent to the connected address. Otherwise, this method
- * has the same behavior as the write method in the
- * <code>GatheringByteChannel</code> interface.
+ * has the same behavior as the {@code write} method in the
+ * {@link GatheringByteChannel} interface.
*
* @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
* int, int)
* @param sources
- * The byte buffers as the source of the datagram.
+ * the byte buffers as the source of the datagram.
* @param offset
- * A non-negative offset in the array of buffer, pointing to the
- * starting buffer to be retrieved, must no larger than
- * sources.length.
+ * a non-negative offset in the array of buffers, pointing to the
+ * starting buffer to be retrieved, must be no larger than
+ * {@code sources.length}.
* @param length
- * A non-negative length to indicate the maximum number of byte
- * to be written, must no larger than sources.length - offset.
- * @return The number of written bytes. If this method is called, it returns
- * the number of bytes that remaining in the byte buffer. If the
- * channel is in non-blocking mode and no enough space for the
- * datagram in the buffer, it may returns zero.
+ * a non-negative length to indicate the maximum number of
+ * buffers to be submitted, must be no bigger than
+ * {@code sources.length - offset}.
+ * @return the number of bytes written. If this method is called, it returns
+ * the number of bytes that where remaining in the byte buffers. If
+ * the channel is in non-blocking mode and there was not enough
+ * space for the datagram in the buffer, it may return zero.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public abstract long write(ByteBuffer[] sources, int offset, int length)
throws IOException;
/**
- * Write datagram from the byte buffer into the channel.
+ * Writes a datagram from the byte buffers to this channel.
* <p>
* The precondition of calling this method is that the channel is connected
* and the datagram is sent to the connected address. Otherwise, this method
* has the same behavior as the write method in the
- * <code>GatheringByteChannel</code> interface.
+ * {@link GatheringByteChannel} interface.
*
* @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
* @param sources
- * The byte buffers as the source of the datagram.
- * @return The number of written bytes. If this method is called, it returns
- * the number of bytes that remaining in the byte buffer. If the
- * channel is in non-blocking mode and no enough space for the
- * datagram in the buffer, it may returns zero.
+ * the byte buffers as the source of the datagram.
+ * @return the number of bytes written. If this method is called, it returns
+ * the number of bytes that where remaining in the byte buffer. If
+ * the channel is in non-blocking mode and there was not enough
+ * space for the datagram in the buffer, it may return zero.
* @throws NotYetConnectedException
- * If the channel is not connected yet.
+ * if the channel is not connected yet.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if the channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while the
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and the channel will be closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * some other I/O error occurs.
+ * @since Android 1.0
*/
public synchronized final long write(ByteBuffer[] sources)
throws IOException {
diff --git a/nio/src/main/java/java/nio/channels/FileChannel.java b/nio/src/main/java/java/nio/channels/FileChannel.java
index 18bf9e2..0518fd3 100644
--- a/nio/src/main/java/java/nio/channels/FileChannel.java
+++ b/nio/src/main/java/java/nio/channels/FileChannel.java
@@ -25,25 +25,25 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
/**
* An abstract channel type for interaction with a platform file.
* <p>
- * A FileChannel defines the methods for reading, writing, memory mapping, and
- * manipulating the logical state of a platform file. This type does not have a
- * method for opening files, since this behaviour has been delegated to the
- * <code>FileInputStream</code>, <code>FileOutputStream</code>, and
- * <code>RandomAccessFile</code> types.
+ * A {@code FileChannel} defines the methods for reading, writing, memory
+ * mapping, and manipulating the logical state of a platform file. This type
+ * does not have a method for opening files, since this behavior has been
+ * delegated to the {@link java.io.FileInputStream},
+ * {@link java.io.FileOutputStream} and {@link java.io.RandomAccessFile} types.
* </p>
* <p>
- * FileChannels created from a FileInputStream, or a RandomAccessFile created in
- * mode "r", are read-only. FileChannels created from a FileOutputStream are
- * write-only. FileChannels created from a RandomAccessFile created in mode "rw"
- * are read/write. FileChannels created from a RandomAccessFile that was opened
- * in append-mode will also be in append-mode -- meaning that each write will be
- * proceeded by a seek to the end of file. Some platforms will seek and write
- * atomically, others will not.
+ * FileChannels created from a {@code FileInputStream} or a
+ * {@code RandomAccessFile} created in mode "r", are read-only. FileChannels
+ * created from a {@code FileOutputStream} are write-only. FileChannels created
+ * from a {@code RandomAccessFile} created in mode "rw" are read/write.
+ * FileChannels created from a {@code RandomAccessFile} that was opened in
+ * append-mode will also be in append-mode -- meaning that each write will be
+ * proceeded by a seek to the end of file.
* </p>
* <p>
- * FileChannels has a virtual pointer into the file which is referred to as a
- * file <em>position</em>. The position can be manipulated by repositioning
- * it within the file, and its current position can be queried.
+ * FileChannels have a virtual pointer into the file which is referred to as a
+ * file <em>position</em>. The position can be manipulated by moving it
+ * within the file, and the current position can be queried.
* </p>
* <p>
* FileChannels also have an associated <em>size</em>. The size of the file
@@ -56,19 +56,19 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
* FileChannels have operations beyond the simple read, write, and close. They
* can also:
* <ul>
- * <li>request that cached data be forced onto the disk</li>
- * <li>lock ranges of bytes associated with the file</li>
+ * <li>request that cached data be forced onto the disk,</li>
+ * <li>lock ranges of bytes associated with the file,</li>
* <li>transfer data directly to another channel in a manner that has the
- * potential to be optimized by the platform</li>
+ * potential to be optimized by the platform,</li>
* <li>memory-mapping files into NIO buffers to provide efficient manipulation
- * of file data</li>
+ * of file data,</li>
* <li>read and write to the file at absolute byte offsets in a fashion that
- * does not modify the current position</li>
+ * does not modify the current position.</li>
* </ul>
* </p>
* <p>
* FileChannels are thread-safe. Only one operation involving manipulation of
- * the file position may be in-flight at once. Subsequent calls to such
+ * the file position may be executed at the same time. Subsequent calls to such
* operations will block, and one of those blocked will be freed to continue
* when the first operation has completed. There is no ordered queue or fairness
* applied to the blocked threads.
@@ -79,32 +79,41 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
* </p>
* <p>
* The logical view of the underlying file is consistent across all FileChannels
- * and IO streams opened on the same file by the same JVM process. Therefore
- * modifications performed via a channel will be visible to the stream, and vice
- * versa; including modifications to the file position, content, size, etc.
+ * and I/O streams opened on the same file by the same virtual machine process.
+ * Therefore, modifications performed via a channel will be visible to the
+ * stream and vice versa; this includes modifications to the file position,
+ * content, size, etc.
* </p>
*
+ * @since Android 1.0
*/
public abstract class FileChannel extends AbstractInterruptibleChannel
implements GatheringByteChannel, ScatteringByteChannel, ByteChannel {
/**
- * A type of file mapping modes.
+ * {@code MapMode} defines file mapping mode constants.
*
+ * @since Android 1.0
*/
public static class MapMode {
/**
* Private mapping mode (equivalent to copy on write).
+ *
+ * @since Android 1.0
*/
public static final MapMode PRIVATE = new MapMode("PRIVATE"); //$NON-NLS-1$
/**
* Read-only mapping mode.
+ *
+ * @since Android 1.0
*/
public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); //$NON-NLS-1$
/**
* Read-write mapping mode.
+ *
+ * @since Android 1.0
*/
public static final MapMode READ_WRITE = new MapMode("READ_WRITE"); //$NON-NLS-1$
@@ -120,10 +129,10 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
}
/**
- * Returns a string version of the mapping mode useful for debugging
- * etc.
+ * Returns a string version of the mapping mode.
*
- * @return the mode string.
+ * @return this map mode as string.
+ * @since Android 1.0
*/
public String toString() {
return displayName;
@@ -132,20 +141,22 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
/**
* Protected default constructor.
+ *
+ * @since Android 1.0
*/
protected FileChannel() {
super();
}
/**
- * Request that all updates to the channel are committed to the storage
+ * Requests that all updates to this channel are committed to the storage
* device.
* <p>
- * When this method returns all modifications made to the platform file
- * underlying this channel will be committed to a local storage device. If
- * the file is not hosted locally, such as a networked file system, then
- * applications cannot be certain that the modifications have been
- * committed.
+ * When this method returns, all modifications made to the platform file
+ * underlying this channel have been committed if the file resides on a
+ * local storage device. If the file is not hosted locally, for example on a
+ * networked file system, then applications cannot be certain that the
+ * modifications have been committed.
* </p>
* <p>
* There are no assurances given that changes made to the file using methods
@@ -153,31 +164,29 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* mapped byte buffer may not be committed.
* </p>
* <p>
- * The <code>metadata</code> parameter indicated whether the update should
+ * The <code>metadata</code> parameter indicates whether the update should
* include the file's metadata such as last modification time, last access
* time, etc. Note that passing <code>true</code> may invoke an underlying
* write to the operating system (if the platform is maintaining metadata
* such as last access time), even if the channel is opened read-only.
*
* @param metadata
- * true if the file metadata should be flushed in addition to the
- * file content, and false otherwise.
+ * {@code true} if the file metadata should be flushed in
+ * addition to the file content, {@code false} otherwise.
* @throws ClosedChannelException
- * if the channel is already closed.
+ * if this channel is already closed.
* @throws IOException
- * some other problem occurred.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract void force(boolean metadata) throws IOException;
/**
- * Obtain an exclusive lock on this file.
+ * Obtains an exclusive lock on this file.
* <p>
* This is a convenience method for acquiring a maximum length lock on a
* file. It is equivalent to:
- *
- * <pre>
- * fileChannel.lock(0L, Long.MAX_VALUE, false)
- * </pre>
+ * {@code fileChannel.lock(0L, Long.MAX_VALUE, false);}
*
* @return the lock object representing the locked file area.
* @throws ClosedChannelException
@@ -185,24 +194,26 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws NonWritableChannelException
* this channel was not opened for writing.
* @throws OverlappingFileLockException
- * Either a lock is already held that overlaps this lock
+ * either a lock is already held that overlaps this lock
* request, or another thread is waiting to acquire a lock that
* will overlap with this request.
* @throws FileLockInterruptionException
- * The calling thread was interrupted while waiting to acquire
+ * the calling thread was interrupted while waiting to acquire
* the lock.
* @throws AsynchronousCloseException
- * The channel was closed while the calling thread was waiting
+ * the channel was closed while the calling thread was waiting
* to acquire the lock.
* @throws IOException
- * some other problem occurred obtaining the requested lock.
+ * if another I/O error occurs while obtaining the requested
+ * lock.
+ * @since Android 1.0
*/
public final FileLock lock() throws IOException {
return lock(0L, Long.MAX_VALUE, false);
}
/**
- * Obtain a lock on a specified region of the file.
+ * Obtains a lock on a specified region of the file.
* <p>
* This is the blocking version of lock acquisition, see also the
* <code>tryLock()</code> methods.
@@ -215,19 +226,20 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* If the request is not for an overlapping lock, the thread calling this
* method will block until the lock is obtained (likely by no contention or
- * another process releasing a lock), or this thread being interrupted or
- * the channel closed.
+ * another process releasing a lock), or until this thread is interrupted or
+ * the channel is closed.
* </p>
* <p>
- * If the lock is obtained successfully then the FileLock object returned
- * represents the lock for subsequent operations on the locked region.
+ * If the lock is obtained successfully then the {@link FileLock} object
+ * returned represents the lock for subsequent operations on the locked
+ * region.
* </p>
* <p>
* If the thread is interrupted while waiting for the lock, the thread is
- * set to the interrupted state, and throws a
- * <code>FileLockInterruptionException</code>. If the channel is closed
- * while the thread is waiting to obtain the lock then the thread throws a
- * <code>AsynchronousCloseException</code>.
+ * set to the interrupted state and throws a
+ * {@link FileLockInterruptionException}. If this channel is closed while
+ * the thread is waiting to obtain the lock then the thread throws a
+ * {@link AsynchronousCloseException}.
* </p>
* <p>
* There is no requirement for the position and size to be within the
@@ -235,68 +247,72 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* </p>
* <p>
* Some platforms do not support shared locks, and if a request is made for
- * a shared lock on such a platform this method will attempt to acquire an
+ * a shared lock on such a platform, this method will attempt to acquire an
* exclusive lock instead. It is undefined whether the lock obtained is
* advisory or mandatory.
* </p>
*
* @param position
- * the starting position for the lock region
+ * the starting position for the locked region.
* @param size
- * the length of the lock, in bytes
+ * the length of the locked region in bytes.
* @param shared
* a flag indicating whether an attempt should be made to acquire
* a shared lock.
- * @return the file lock object
+ * @return the file lock object.
* @throws IllegalArgumentException
- * if the parameters are invalid.
+ * if {@code position} or {@code size} is negative.
* @throws ClosedChannelException
- * if the channel is already closed.
+ * if this channel is closed.
* @throws OverlappingFileLockException
* if the requested region overlaps an existing lock or pending
* lock request.
* @throws NonReadableChannelException
- * if the channel is not open in read-mode and shared is true.
+ * if the channel is not opened in read-mode but shared is true.
* @throws NonWritableChannelException
- * if the channel is not open in write mode and shared is false.
+ * if the channel is not opened in write mode but shared is
+ * false.
* @throws AsynchronousCloseException
- * if the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws FileLockInterruptionException
- * if the thread is interrupted while in the state of waiting
- * on the desired file lock.
+ * if the thread is interrupted while in the state of waiting on
+ * the desired file lock.
* @throws IOException
- * if some other IO problem occurs.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract FileLock lock(long position, long size, boolean shared)
throws IOException;
/**
- * Maps the file into memory.There can be three modes:Read-only,Read/write
- * and Private.
- *
- * After mapping, the memory and the file channel do not affect each other.
- *
- * Note : mapping a file into memory is usually expensive.
+ * Maps the file into memory. There can be three modes: read-only,
+ * read/write and private. After mapping, changes made to memory or the file
+ * channel do not affect the other storage place.
+ * <p>
+ * Note: mapping a file into memory is usually expensive.
+ * </p>
*
* @param mode
- * one of three modes to map
+ * one of the three mapping modes.
* @param position
- * the starting position of the file
+ * the starting position of the file.
* @param size
- * the size to map
- * @return the mapped byte buffer
- *
+ * the size of the region to map into memory.
+ * @return the mapped byte buffer.
* @throws NonReadableChannelException
- * If the file is not opened for reading but the given mode is
- * "READ_ONLY"
+ * if the FileChannel is not opened for reading but the given
+ * mode is "READ_ONLY".
* @throws NonWritableChannelException
- * If the file is not opened for writing but the mode is not
- * "READ_ONLY"
+ * if the FileChannel is not opened for writing but the given
+ * mode is not "READ_ONLY".
* @throws IllegalArgumentException
- * If the given parameters of position and size are not correct
+ * if the given parameters of position and size are not correct.
+ * Both must be non negative. {@code size} also must not be
+ * bigger than max integer.
* @throws IOException
- * If any I/O error occurs
+ * if any I/O error occurs.
+ * @since Android 1.0
*/
public abstract MappedByteBuffer map(FileChannel.MapMode mode,
long position, long size) throws IOException;
@@ -307,9 +323,10 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @return the current position as a positive integer number of bytes from
* the start of the file.
* @throws ClosedChannelException
- * if the channel is already closed.
+ * if this channel is closed.
* @throws IOException
- * if some other IO problem occurs.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract long position() throws IOException;
@@ -319,9 +336,9 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* The argument is the number of bytes counted from the start of the file.
* The position cannot be set to a value that is negative. The new position
* can be set beyond the current file size. If set beyond the current file
- * size, attempts to read will return end of file, and writes will succeed,
- * but fill-in the bytes between the current end of file and the position
- * with the required number of (unspecified) byte values.
+ * size, attempts to read will return end of file. Write operations will
+ * succeed but they will fill the bytes between the current end of file and
+ * the new position with the required number of (unspecified) byte values.
*
* @param offset
* the new file position, in bytes.
@@ -329,203 +346,279 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws IllegalArgumentException
* if the new position is negative.
* @throws ClosedChannelException
- * if the channel is already closed.
+ * if this channel is closed.
* @throws IOException
- * if some other IO problem occurs.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract FileChannel position(long offset) throws IOException;
/**
- * Reads bytes from the channel into the given byte buffer.
+ * Reads bytes from this file channel into the given buffer.
* <p>
- * The bytes are read starting at the current file position, and after some
- * number of bytes are read (up to the remaining number of bytes in the
- * buffer) the file position is increased by the number of bytes actually
- * read.
+ * The maximum number of bytes that will be read is the remaining number of
+ * bytes in the buffer when the method is invoked. The bytes will be copied
+ * into the buffer starting at the buffer's current position.
+ * </p>
+ * <p>
+ * The call may block if other threads are also attempting to read from this
+ * channel.
+ * </p>
+ * <p>
+ * Upon completion, the buffer's position is set to the end of the bytes
+ * that have been read. The buffer's limit is not changed.
+ * </p>
*
- * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
+ * @param buffer
+ * the byte buffer to receive the bytes.
+ * @return the number of bytes actually read.
+ * @throws AsynchronousCloseException
+ * if another thread closes the channel during the read.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread during the
+ * read.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IOException
+ * if another I/O error occurs, details are in the message.
+ * @throws NonReadableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public abstract int read(ByteBuffer buffer) throws IOException;
/**
- * Reads bytes from the file channel into the given buffer starting from the
- * given file position.
+ * Reads bytes from this file channel into the given buffer starting from
+ * the specified file position.
* <p>
* The bytes are read starting at the given file position (up to the
* remaining number of bytes in the buffer). The number of bytes actually
* read is returned.
* </p>
* <p>
- * If the position is beyond the current end of file, then no bytes are
+ * If {@code position} is beyond the current end of file, then no bytes are
* read.
* </p>
* <p>
- * Note that file position is unmodified by this method.
+ * Note that the file position is unmodified by this method.
* </p>
*
* @param buffer
- * the buffer to receive the bytes
+ * the buffer to receive the bytes.
* @param position
* the (non-negative) position at which to read the bytes.
* @return the number of bytes actually read.
- * @throws IllegalArgumentException
- * if <code>position</code> is less than <code>-1</code>.
- * @throws ClosedChannelException
- * if the channel is already closed.
- * @throws NonReadableChannelException
- * if the channel was not opened in read-mode.
* @throws AsynchronousCloseException
- * if the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws ClosedByInterruptException
- * if another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while this
* operation is in progress. The calling thread will have the
* interrupt state set, and the channel will be closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IllegalArgumentException
+ * if <code>position</code> is less than 0.
* @throws IOException
- * some other IO error occurred.
+ * if another I/O error occurs.
+ * @throws NonReadableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public abstract int read(ByteBuffer buffer, long position)
throws IOException;
/**
- * Reads bytes from the channel into all the given byte buffers.
- * <p>
- * The bytes are read starting at the current file position, and after some
- * number of bytes are read (up to the remaining number of bytes in all the
- * buffers) the file position is increased by the number of bytes actually
+ * Reads bytes from this file channel and stores them in the specified array
+ * of buffers. This method attempts to read as many bytes as can be stored
+ * in the buffer array from this channel and returns the number of bytes
+ * actually read. It also increases the file position by the number of bytes
* read.
+ * <p>
+ * If a read operation is in progress, subsequent threads will block until
+ * the read is completed and will then contend for the ability to read.
* </p>
* <p>
- * This method behaves exactly like:
- *
- * <pre>
- * read(buffers, 0, buffers.length);
- * </pre>
- *
+ * Calling this method is equivalent to calling
+ * {@code read(buffers, 0, buffers.length);}
* </p>
*
- * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
+ * @param buffers
+ * the array of byte buffers into which the bytes will be copied.
+ * @return the number of bytes actually read.
+ * @throws AsynchronousCloseException
+ * if this channel is closed by another thread during this read
+ * operation.
+ * @throws ClosedByInterruptException
+ * if the thread is interrupted by another thread during this
+ * read operation.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IOException
+ * if another I/O error occurs; details are in the message.
+ * @throws NonReadableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public final long read(ByteBuffer[] buffers) throws IOException {
return read(buffers, 0, buffers.length);
}
/**
- * Reads bytes from the file channel into a subset of the given byte
- * buffers.
+ * Reads bytes from this file channel and stores them in a subset of the
+ * specified array of buffers. The subset is defined by {@code start} and
+ * {@code number}, indicating the first buffer and the number of buffers to
+ * use. This method attempts to read as many bytes as can be stored in the
+ * buffer subset from this channel and returns the number of bytes actually
+ * read. It also increases the file position by the number of bytes read.
+ * <p>
+ * If a read operation is in progress, subsequent threads will block until
+ * the read is completed and will then contend for the ability to read.
+ * </p>
*
- * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
- * int, int)
+ * @param buffers
+ * the array of byte buffers into which the bytes will be copied.
+ * @param start
+ * the index of the first buffer to store bytes in.
+ * @param number
+ * the maximum number of buffers to store bytes in.
+ * @return the number of bytes actually read.
+ * @throws AsynchronousCloseException
+ * if this channel is closed by another thread during this read
+ * operation.
+ * @throws ClosedByInterruptException
+ * if the thread is interrupted by another thread during this
+ * read operation.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code start < 0} or {@code number < 0}, or if
+ * {@code start + number} is greater than the size of
+ * {@code buffers}.
+ * @throws IOException
+ * if another I/O error occurs; details are in the message.
+ * @throws NonReadableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public abstract long read(ByteBuffer[] buffers, int start, int number)
throws IOException;
/**
- * Returns the size of the file underlying this channel, in bytes.
+ * Returns the size of the file underlying this channel in bytes.
*
* @return the size of the file in bytes.
* @throws ClosedChannelException
- * if the channel is closed.
+ * if this channel is closed.
* @throws IOException
- * if a problem occurs getting the size of the file.
+ * if an I/O error occurs while getting the size of the file.
+ * @since Android 1.0
*/
public abstract long size() throws IOException;
/**
- * Transfers bytes into this channel's file from the given readable byte
- * channel. It may be very efficient.
- *
- * By invoking this method, it will read form the source channel and write
- * into the file channel.
- *
- * Note: no guarantee whether all bytes may be transferred. And it does not
- * modify the position of the channel.
+ * Reads up to {@code count} bytes from {@code src} and stores them in this
+ * channel's file starting at {@code position}. No bytes are transferred if
+ * {@code position} is larger than the size of this channel's file. Less
+ * than {@code count} bytes are transferred if there are less bytes
+ * remaining in the source channel or if the source channel is non-blocking
+ * and has less than {@code count} bytes immediately available in its output
+ * buffer.
+ * <p>
+ * Note that this channel's position is not modified.
+ * </p>
*
* @param src
- * the source channel to read
+ * the source channel to read bytes from.
* @param position
- * the non-negative position to begin
+ * the non-negative start position.
* @param count
- * the non-negative bytes to be transferred
+ * the non-negative number of bytes to transfer.
* @return the number of bytes that are transferred.
- *
* @throws IllegalArgumentException
- * If the parameters are not correct
+ * if the parameters are invalid.
* @throws NonReadableChannelException
- * If the source channel is not readable
+ * if the source channel is not readable.
* @throws NonWritableChannelException
- * If this channel is not writable
+ * if this channel is not writable.
* @throws ClosedChannelException
- * If either channel has already been closed
+ * if either channel has already been closed.
* @throws AsynchronousCloseException
- * If either channel is closed by other threads during this operation
+ * if either channel is closed by other threads during this
+ * operation.
* @throws ClosedByInterruptException
- * If the thread is interrupted during this operation
+ * if the thread is interrupted during this operation.
* @throws IOException
- * If any I/O error occurs
+ * if any I/O error occurs.
+ * @since Android 1.0
*/
public abstract long transferFrom(ReadableByteChannel src, long position,
long count) throws IOException;
/**
- * Transfers data from the file to the given channel. It may be very
- * efficient.
- *
- * By invoking this method, it will read form the file and write into the
- * writable channel.
- *
- * Note: no guarantee whether all bytes may be transfered.And it does not
- * modify the position of the channel.
+ * Reads up to {@code count} bytes from this channel's file starting at
+ * {@code position} and writes them to {@code target}. No bytes are
+ * transferred if {@code position} is larger than the size of this channel's
+ * file. Less than {@code count} bytes are transferred if there less bytes
+ * available from this channel's file or if the target channel is
+ * non-blocking and has less than {@code count} bytes free in its input
+ * buffer.
+ * <p>
+ * Note that this channel's position is not modified.
+ * </p>
*
* @param position
- * the non-negative position to begin
+ * the non-negative position to begin.
* @param count
- * the non-negative bytes to be transferred
+ * the non-negative number of bytes to transfer.
* @param target
- * the target channel to write into
+ * the target channel to write to.
* @return the number of bytes that were transferred.
- *
* @throws IllegalArgumentException
- * If the parameters are not correct
+ * if the parameters are invalid.
* @throws NonReadableChannelException
- * If this channel is not readable
+ * if this channel is not readable.
* @throws NonWritableChannelException
- * If the target channel is not writable
+ * if the target channel is not writable.
* @throws ClosedChannelException
- * If either channel has already been closed
+ * if either channel has already been closed.
* @throws AsynchronousCloseException
- * If either channel is closed by other threads during this
- * operation
+ * if either channel is closed by other threads during this
+ * operation.
* @throws ClosedByInterruptException
- * If the thread is interrupted during this operation
+ * if the thread is interrupted during this operation.
* @throws IOException
- * If any I/O error occurs
+ * if any I/O error occurs.
+ * @since Android 1.0
*/
public abstract long transferTo(long position, long count,
WritableByteChannel target) throws IOException;
/**
- * Truncates the file underlying this channel to a given size.
- * <p>
- * Any bytes beyond the given size are removed from the file. If there are
- * no bytes beyond the given size then the file contents are unmodified.
- * </p>
+ * Truncates the file underlying this channel to a given size. Any bytes
+ * beyond the given size are removed from the file. If there are no bytes
+ * beyond the given size then the file contents are unmodified.
* <p>
* If the file position is currently greater than the given size, then it is
- * set to be the given size.
+ * set to the new size.
* </p>
*
* @param size
- * the maximum size of the underlying file
+ * the maximum size of the underlying file.
* @throws IllegalArgumentException
- * the requested size is negative.
+ * if the requested size is negative.
* @throws ClosedChannelException
- * the channel is closed.
+ * if this channel is closed.
* @throws NonWritableChannelException
- * the channel cannot be written.
+ * if the channel cannot be written to.
* @throws IOException
- * some other IO problem occurred.
- * @return this channel
+ * if another I/O error occurs.
+ * @return this channel.
+ * @since Android 1.0
*/
public abstract FileChannel truncate(long size) throws IOException;
@@ -534,79 +627,92 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* This is a convenience method for attempting to acquire a maximum length
* lock on the file. It is equivalent to:
- *
- * <pre>
- * fileChannel.tryLock(0L, Long.MAX_VALUE, false)
- * </pre>
- *
+ * {@code fileChannel.tryLock(0L, Long.MAX_VALUE, false);}
* </p>
* <p>
- * The method returns <code>null</code> if the acquisition would result in
- * an overlapped lock with another OS process.
+ * The method returns {@code null} if the acquisition would result in an
+ * overlapped lock with another OS process.
* </p>
*
- * @return the file lock object, or <code>null</code> if the lock would
- * overlap an existing exclusive lock in another OS process.
+ * @return the file lock object, or {@code null} if the lock would overlap
+ * with an existing exclusive lock in another OS process.
* @throws ClosedChannelException
- * the file channel is closed.
+ * if the file channel is closed.
* @throws OverlappingFileLockException
- * Either a lock is already held that overlaps this lock
- * request, or another thread is waiting to acquire a lock that
- * will overlap with this request.
+ * if a lock already exists that overlaps this lock request or
+ * another thread is waiting to acquire a lock that will overlap
+ * with this request.
* @throws IOException
- * if any I/O error occurs
+ * if any I/O error occurs.
+ * @since Android 1.0
*/
public final FileLock tryLock() throws IOException {
return tryLock(0L, Long.MAX_VALUE, false);
}
/**
- * Attempts to acquire an exclusive lock on this file without blocking.
+ * Attempts to acquire an exclusive lock on this file without blocking. The
+ * method returns {@code null} if the acquisition would result in an
+ * overlapped lock with another OS process.
* <p>
- * The method returns <code>null</code> if the acquisition would result in
- * an overlapped lock with another OS process.
+ * It is possible to acquire a lock for any region even if it's completely
+ * outside of the file's size. The size of the lock is fixed. If the file
+ * grows outside of the lock that region of the file won't be locked by this
+ * lock.
* </p>
*
* @param position
- * the starting position
+ * the starting position.
* @param size
- * the size of file to lock
+ * the size of file to lock.
* @param shared
- * true if share
- * @return the file lock object, or <code>null</code> if the lock would
- * overlap an existing exclusive lock in another OS process.
- *
+ * true if the lock is shared.
+ * @return the file lock object, or {@code null} if the lock would overlap
+ * with an existing exclusive lock in another OS process.
* @throws IllegalArgumentException
- * If any parameters are bad
+ * if any parameters are invalid.
* @throws ClosedChannelException
- * the file channel is closed.
+ * if the file channel is closed.
* @throws OverlappingFileLockException
- * Either a lock is already held that overlaps this lock
- * request, or another thread is waiting to acquire a lock that
- * will overlap with this request.
+ * if a lock is already held that overlaps this lock request or
+ * another thread is waiting to acquire a lock that will overlap
+ * with this request.
* @throws IOException
- * if any I/O error occurs
+ * if any I/O error occurs.
+ * @since Android 1.0
*/
public abstract FileLock tryLock(long position, long size, boolean shared)
throws IOException;
/**
- * Writes bytes from the given byte buffer into the file channel.
+ * Writes bytes from the given byte buffer to this file channel.
* <p>
* The bytes are written starting at the current file position, and after
* some number of bytes are written (up to the remaining number of bytes in
* the buffer) the file position is increased by the number of bytes
* actually written.
*
- * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
- *
* @param src
- * the source buffer to write
+ * the byte buffer containing the bytes to be written.
+ * @return the number of bytes actually written.
+ * @throws NonWritableChannelException
+ * if the channel was not opened for writing.
+ * @throws ClosedChannelException
+ * if the channel was already closed.
+ * @throws AsynchronousCloseException
+ * if another thread closes the channel during the write.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws IOException
+ * if another I/O error occurs, details are in the message.
+ * @since Android 1.0
*/
public abstract int write(ByteBuffer src) throws IOException;
/**
- * Writes bytes from the given buffer to the file channel starting at the
+ * Writes bytes from the given buffer to this file channel starting at the
* given file position.
* <p>
* The bytes are written starting at the given file position (up to the
@@ -619,7 +725,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* byte values.
* </p>
* <p>
- * Note that file position is unmodified by this method.
+ * Note that the file position is not modified by this method.
* </p>
*
* @param buffer
@@ -628,51 +734,95 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* the (non-negative) position at which to write the bytes.
* @return the number of bytes actually written.
* @throws IllegalArgumentException
- * if <code>position</code> is less than <code>-1</code>.
+ * if <code>position</code> is less than 0.
* @throws ClosedChannelException
- * if the channel is already closed.
+ * if this channel is closed.
* @throws NonWritableChannelException
* if the channel was not opened in write-mode.
* @throws AsynchronousCloseException
- * if the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws ClosedByInterruptException
- * if another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
* @throws IOException
- * some other IO error occurred.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract int write(ByteBuffer buffer, long position)
throws IOException;
/**
- * Writes bytes from all the given byte buffers into the file channel.
+ * Writes bytes from all the given byte buffers to this file channel.
* <p>
* The bytes are written starting at the current file position, and after
- * some number of bytes are written (up to the remaining number of bytes in
- * all the buffers) the file position is increased by the number of bytes
- * actually written.
+ * the bytes are written (up to the remaining number of bytes in all the
+ * buffers), the file position is increased by the number of bytes actually
+ * written.
* <p>
- * This method behaves exactly like:
- *
- * <pre>
- * write(buffers, 0, buffers.length);
- * </pre>
- *
+ * Calling this method is equivalent to calling
+ * {@code write(buffers, 0, buffers.length);}
* </p>
*
- * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
+ * @param buffers
+ * the buffers containing bytes to write.
+ * @return the number of bytes actually written.
+ * @throws AsynchronousCloseException
+ * if this channel is closed by another thread during this write
+ * operation.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IOException
+ * if another I/O error occurs; details are in the message.
+ * @throws NonWritableChannelException
+ * if this channel was not opened for writing.
+ * @since Android 1.0
*/
public final long write(ByteBuffer[] buffers) throws IOException {
return write(buffers, 0, buffers.length);
}
/**
+ * Writes bytes from a subset of the specified array of buffers into this
+ * file channel. The subset is defined by {@code offset} and {@code length},
+ * indicating the first buffer and the number of buffers to use.
+ * <p>
+ * If a write operation is in progress, subsequent threads will block until
+ * the write is completed and then contend for the ability to write.
+ * </p>
*
- *
- * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
- * int, int)
+ * @param buffers
+ * the array of byte buffers that is the source for bytes written
+ * to this channel.
+ * @param offset
+ * the index of the first buffer in {@code buffers }to get bytes
+ * from.
+ * @param length
+ * the number of buffers to get bytes from.
+ * @return the number of bytes actually written to this channel.
+ * @throws AsynchronousCloseException
+ * if this channel is closed by another thread during this write
+ * operation.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if
+ * {@code offset + length} is greater than the size of
+ * {@code buffers}.
+ * @throws IOException
+ * if another I/O error occurs; details are in the message.
+ * @throws NonWritableChannelException
+ * if this channel was not opened for writing.
+ * @since Android 1.0
*/
public abstract long write(ByteBuffer[] buffers, int offset, int length)
throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/FileLock.java b/nio/src/main/java/java/nio/channels/FileLock.java
index 46c94dd..e9aae1f 100644
--- a/nio/src/main/java/java/nio/channels/FileLock.java
+++ b/nio/src/main/java/java/nio/channels/FileLock.java
@@ -19,58 +19,63 @@ package java.nio.channels;
import java.io.IOException;
-// BEGIN android-note
-// - fixed bad htm in javadoc comments -joeo
-// END android-note
-
/**
- * A <code>FileLock</code> represents a locked region of a file.
+ * A {@code FileLock} represents a locked region of a file.
* <p>
* Locks have certain properties that enable collaborating processes to avoid
- * the lost update problem, or reading inconsistent data.
- * </p>
- * <p>
- * logically, a file lock can be 'exclusive' or 'shared'. Multiple processes can
- * hold shared locks on the same region of a file, but only a single process can
- * hold an exclusive lock on a given region of a file and no other process can
+ * the lost update problem or reading inconsistent data. Logically, a file lock
+ * can be <em>exclusive</em> or <em>shared</em>. Multiple processes can hold
+ * shared locks on the same region of a file, but only a single process can hold
+ * an exclusive lock on a given region of a file and no other process can
* simultaneously hold a shared lock overlapping the exclusive lock. An
- * application can determine whether a FileLock is shared or exclusive via the
- * <code>isShared()</code> API.
+ * application can determine whether a {@code FileLock} is shared or exclusive
+ * via the {@code isShared()} method.
* </p>
* <p>
* Locks held by a particular process cannot overlap one another. Applications
- * can determine whether a proposed lock will overlap by using the
- * <code>overlaps(long, long)</code>) API. Locks held in
- * other processes may overlap locks held in this process.</p>
- * <p>
- * Locks are shared amongst all threads in the acquiring process, and are therefore unsuitable for
- * intra-process synchronization.</p>
- * <p>
- * Once a lock is acquired it is immutable in all its state except <code>isValid()</code>. The lock
- * will initially be valid, but may be rendered invalid by explicit removal of the lock, using <code>
- * release()</code>, or implicitly by closing the channel or exiting the process (terminating the JVM).</p>
+ * can determine whether a proposed lock will overlap by using the {@code
+ * overlaps(long, long)}) method. Locks held in other processes may overlap
+ * locks held in this process. Locks are shared amongst all threads in the
+ * acquiring process, and are therefore unsuitable for intra-process
+ * synchronization.
+ * </p>
* <p>
- * <em>Platform dependencies</em></p>
+ * Once a lock is acquired, it is immutable in all its state except {@code
+ * isValid()}. The lock will initially be valid, but may be rendered invalid by
+ * explicit removal of the lock, using {@code release()}, or implicitly by
+ * closing the channel or exiting the process (terminating the virtual machine).
+ * </p>
+ * <h3>Platform dependencies</h3>
* <p>
- * Locks are intended to be true platform operating system file locks, and therefore locks held by the
- * JVM process will be visible to other OS processes.</p>
+ * Locks are intended to be true platform operating system file locks, and
+ * therefore locks held by the virtual machine process will be visible to other
+ * operating system processes.
+ * </p>
* <p>
- * The characteristics of the underlying OS locks will show through in the Java implementation. For
- * example, some platforms' locks are 'mandatory' -- meaning the operating system enforces the locks
- * on processes that attempt to access locked regions of file; whereas other platforms' locks are
- * only 'advisory' -- meaning that processes are required to collaborate on ensuring locks are acquired
- * and there is a potential for processes not to play well. The only safe answer is to assume that
- * the platform is adopting advisory locks an always acquire shared locks when reading a region of file.</p>
+ * The characteristics of the underlying operating system locks will show
+ * through in the Java implementation. For example, some platforms' locks are
+ * 'mandatory' -- meaning the operating system enforces the locks on processes
+ * that attempt to access locked regions of files; whereas other platforms'
+ * locks are only 'advisory' -- meaning that processes are required to
+ * collaborate to ensure locks are acquired and there is a potential for
+ * processes to not play well. To be on the safe side, it is best to assume that
+ * the platform is adopting advisory locks and always acquire shared locks when
+ * reading a region of a file.
+ * </p>
* <p>
- * On some platforms the presence of a lock will prevent the file being memory mapped. On some platforms
- * closing a channel on a given file handle will release all the locks held on that file -- even if there
- * are other channels open on the same file (their locks will be released). The safe option here is to
- * ensure that you only acquire locks on a single channel for a particular file, and that becomes the
- * synchronization point.</p>
+ * On some platforms, the presence of a lock will prevent the file from being
+ * memory-mapped. On some platforms, closing a channel on a given file handle
+ * will release all the locks held on that file -- even if there are other
+ * channels open on the same file; their locks will also be released. The safe
+ * option here is to ensure that you only acquire locks on a single channel for
+ * a particular file and that becomes the synchronization point.
+ * </p>
* <p>
- * Further care should be exercised when locking files maintained on network file systems since they often
- * have further limitations.</p>
- *
+ * Further care should be exercised when locking files maintained on network
+ * file systems, since they often have further limitations.
+ * </p>
+ *
+ * @since Android 1.0
*/
public abstract class FileLock {
@@ -87,18 +92,19 @@ public abstract class FileLock {
private final boolean shared;
/**
- * Constructor for a new file lock instance for a given channel. The
- * constructor enforces the starting position, stretch, and shared status of
- * the lock.
+ * Constructs a new file lock instance for a given channel. The constructor
+ * enforces the starting position, length and sharing mode of the lock.
*
* @param channel
- * underlying file channel that holds the lock.
+ * the underlying file channel that holds the lock.
* @param position
- * starting point for the lock.
+ * the starting point for the lock.
* @param size
- * length of lock in number of bytes.
+ * the length of the lock in number of bytes.
* @param shared
- * shared status of lock (true is shared, false is exclusive).
+ * the lock's sharing mode of lock; {@code true} is shared,
+ * {@code false} is exclusive.
+ * @since Android 1.0
*/
protected FileLock(FileChannel channel, long position, long size,
boolean shared) {
@@ -113,9 +119,10 @@ public abstract class FileLock {
}
/**
- * Returns the lock's FileChannel.
+ * Returns the lock's {@link FileChannel}.
*
* @return the channel.
+ * @since Android 1.0
*/
public final FileChannel channel() {
return channel;
@@ -125,6 +132,7 @@ public abstract class FileLock {
* Returns the lock's starting position in the file.
*
* @return the lock position.
+ * @since Android 1.0
*/
public final long position() {
return position;
@@ -133,31 +141,35 @@ public abstract class FileLock {
/**
* Returns the length of the file lock in bytes.
*
- * @return the size of file lock in bytes.
+ * @return the size of the file lock in bytes.
+ * @since Android 1.0
*/
public final long size() {
return size;
}
/**
- * Returns true if the file lock is shared with other processes and false if
- * it is not.
+ * Indicates if the file lock is shared with other processes or if it is
+ * exclusive.
*
- * @return true if the lock is a shared lock, and false if it is exclusive.
+ * @return {@code true} if the lock is a shared lock, {@code false} if it is
+ * exclusive.
+ * @since Android 1.0
*/
public final boolean isShared() {
return shared;
}
/**
- * Returns true if the receiver's lock region overlapps the region described
- * in the parameter list,and returns false otherwise.
+ * Indicates if the receiver's lock region overlaps the region described
+ * in the parameter list.
*
* @param start
* the starting position for the comparative lock.
* @param length
* the length of the comparative lock.
- * @return true if there is an overlap, and false otherwise.
+ * @return {@code true} if there is an overlap, {@code false} otherwise.
+ * @since Android 1.0
*/
public final boolean overlaps(long start, long length) {
final long end = position + size - 1;
@@ -169,23 +181,25 @@ public abstract class FileLock {
}
/**
- * Returns whether the receiver is a valid file lock or not. The lock is
+ * Indicates whether this lock is a valid file lock. The lock is
* valid unless the underlying channel has been closed or it has been
* explicitly released.
*
- * @return true if the lock is valid, and false otherwise.
+ * @return {@code true} if the lock is valid, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isValid();
/**
* Releases this particular lock on the file. If the lock is invalid then
- * this method has no effect. Once released the lock becomes invalid.
+ * this method has no effect. Once released, the lock becomes invalid.
*
* @throws ClosedChannelException
* if the channel is already closed when an attempt to release
* the lock is made.
* @throws IOException
- * some other IO exception occurred.
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract void release() throws IOException;
@@ -194,6 +208,7 @@ public abstract class FileLock {
* to an end user.
*
* @return the display string.
+ * @since Android 1.0
*/
public final String toString() {
StringBuffer buffer = new StringBuffer(64); // Guess length of string
diff --git a/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java b/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
index 44295f2..0920f52 100644
--- a/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
+++ b/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
@@ -20,18 +20,22 @@ package java.nio.channels;
import java.io.IOException;
/**
- * Thrown when thread was interrupted while waiting to acquire a file lock.
+ * A {@code FileLockInterruptionException} is thrown when a thread is
+ * interrupted while waiting to acquire a file lock.
* <p>
* Note that the thread will also be in the 'interrupted' state.
* </p>
*
+ * @since Android 1.0
*/
public class FileLockInterruptionException extends IOException {
private static final long serialVersionUID = 7104080643653532383L;
/**
- * Default constructor.
+ * Constructs a {@code FileLockInterruptionException}.
+ *
+ * @since Android 1.0
*/
public FileLockInterruptionException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/GatheringByteChannel.java b/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
index 627aa3d..e8a6c73 100644
--- a/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
@@ -21,83 +21,81 @@ import java.io.IOException;
import java.nio.ByteBuffer;
/**
- * The interface to channels that can write a set of buffers in a single
- * operation.
- * <p>
- * The corresponding interface for reads is called
- * <code>ScatteringByteChannel</code>.
+ * The interface for channels that can write a set of buffers in a single
+ * operation. The corresponding interface for read operations is
+ * {@link ScatteringByteChannel}.
*
+ * @since Android 1.0
*/
public interface GatheringByteChannel extends WritableByteChannel {
/**
- * Writes bytes from all the given buffers to the channel.
+ * Writes bytes from all the given buffers to a channel.
* <p>
- * This method is equivalent to:
- *
- * <pre>
- * write(buffers, 0, buffers.length);
- * </pre>
- *
+ * This method is equivalent to: {@code write(buffers, 0, buffers.length);}
* </p>
*
* @param buffers
* the buffers containing bytes to be written.
* @return the number of bytes actually written.
+ * @throws AsynchronousCloseException
+ * if the channel is closed by another thread during this write
+ * operation.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while the
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if
+ * {@code offset + length} is greater than the size of
+ * {@code buffers}.
+ * @throws IOException
+ * if another I/O error occurs; details are in the message.
* @throws NonWritableChannelException
- * if the channel is open, but not in a mode that permits
+ * if the channel has not been opened in a mode that permits
* writing.
- * @throws ClosedByInterruptException
- * if the thread is interrupted in its IO operation by another
- * thread closing the channel.
- * @throws AsynchronousCloseException
- * if the write is interrupted by another thread sending an
- * explicit interrupt.
- * @throws IOException
- * if some other type of exception occurs. Details are in the
- * message.
+ * @since Android 1.0
*/
public long write(ByteBuffer[] buffers) throws IOException;
/**
- * Writes a subset of the given bytes from the buffers to the channel.
- * <p>
- * This method attempts to write all of the <code>remaining()</code> bytes
- * from <code>length</code> byte buffers, in order, starting at
- * <code>buffers[offset]</code>. The number of bytes actually written is
- * returned.
- * </p>
+ * Writes bytes from a subset of the specified array of buffers to a
+ * channel. The subset is defined by {@code offset} and {@code length},
+ * indicating the first buffer and the number of buffers to use.
* <p>
* If a write operation is in progress, subsequent threads will block until
- * the write is completed, and will then contend for the ability to write.
+ * the write is completed and then contend for the ability to write.
* </p>
*
* @param buffers
- * the array of byte buffers containing the source of remaining
- * bytes that will be attempted to be written.
+ * the array of byte buffers that is the source for bytes written
+ * to the channel.
* @param offset
- * the index of the first buffer to write.
+ * the index of the first buffer in {@code buffers }to get bytes
+ * from.
* @param length
- * the number of buffers to write.
+ * the number of buffers to get bytes from.
* @return the number of bytes actually written.
- * @throws IndexOutOfBoundsException
- * if offset < 0 or > buffers.length; or length < 0 or >
- * buffers.length - offset.
- * @throws NonWritableChannelException
- * if the channel was not opened for writing.
- * @throws ClosedChannelException
- * the channel is currently closed.
* @throws AsynchronousCloseException
- * the channel was closed by another thread while the write was
- * underway.
+ * if the channel is closed by another thread during this write
+ * operation.
* @throws ClosedByInterruptException
- * the thread was interrupted by another thread while the write
- * was underway.
+ * if another thread interrupts the calling thread while the
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if the channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if
+ * {@code offset + length} is greater than the size of
+ * {@code buffers}.
* @throws IOException
- * if some other type of exception occurs. Details are in the
- * message.
+ * if another I/O error occurs; details are in the message.
+ * @throws NonWritableChannelException
+ * if the channel was not opened for writing.
+ * @since Android 1.0
*/
public long write(ByteBuffer[] buffers, int offset, int length)
throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java b/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
index 187c21f..3efd94a 100644
--- a/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
+++ b/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
@@ -18,16 +18,20 @@ package java.nio.channels;
/**
- * Thrown when when operation that requires a specific blocking mode is invoked
- * on a channel that is in a different blocking mode.
+ * An {@code IllegalBlockingModeException} is thrown when an operation that
+ * requires a specific blocking mode is invoked on a channel that is in a
+ * different blocking mode.
*
+ * @since Android 1.0
*/
public class IllegalBlockingModeException extends IllegalStateException {
private static final long serialVersionUID = -3335774961855590474L;
/**
- * Default constructor.
+ * Constructs a {@code IllegalBlockingModeException}.
+ *
+ * @since Android 1.0
*/
public IllegalBlockingModeException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/IllegalSelectorException.java b/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
index 7a6235f..0cffd22 100644
--- a/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
+++ b/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
@@ -18,17 +18,19 @@ package java.nio.channels;
/**
- * Thrown when a call is made to register a channel on a selector that has been
- * created by a different provider.
+ * An {@code IllegalSelectorException} is thrown when a call is made to register
+ * a channel on a selector that has been created by a different provider.
*
+ * @since Android 1.0
*/
public class IllegalSelectorException extends IllegalArgumentException {
private static final long serialVersionUID = -8406323347253320987L;
/**
- * Default constructor.
+ * Constructs a {@code IllegalSelectorException}.
*
+ * @since Android 1.0
*/
public IllegalSelectorException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/InterruptibleChannel.java b/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
index c5e110d..0375618 100644
--- a/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
+++ b/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
@@ -20,38 +20,38 @@ package java.nio.channels;
import java.io.IOException;
/**
- * Channels that implement this interface are both asynchronously closable and
- * interruptible.
+ * Channels that implement this interface can be asynchronously closed and
+ * interrupted.
* <p>
- * A channel that is asynchronously closable permits a thread blocked on an IO
- * operation (the IO thread) to be released by another thread calling the
- * channel's <code>close()</code> method. The IO thread will throw an
- * <code>AsynchronousCloseException</code> and the channel will be closed.
+ * A channel that can be asynchronously closed permits that a thread blocked on
+ * an I/O operation (the I/O thread) can be released by another thread calling
+ * the channel's {@link #close()} method. The I/O thread will throw an
+ * {@link AsynchronousCloseException} and the channel will be closed.
* </p>
* <p>
- * A channel that is interruptible permits a thread blocked on an IO operation
- * (the IO thread) to be interrupted by another thread (by invoking
- * <code>interrupt()</code> on the IO thread). When the IO thread is
- * interrupted it will throw a <code>ClosedByInterruptException</code>
- * exception, it will have its interrupted status set, and the channel will be
- * closed. If the IO thread attempts to make an IO call with the interrupt
- * status set the call will immediately fail with a
- * <code>ClosedByInterruptException</code>.
+ * A channel that is interruptible permits a thread blocked on an I/O operation
+ * (the I/O thread) to be interrupted by another thread (by invoking
+ * {@link Thread#interrupt()} on the I/O thread). When the I/O thread is
+ * interrupted it will throw a {@link ClosedByInterruptException}, it will have
+ * its interrupted status set and the channel will be closed. If the I/O thread
+ * attempts to make an I/O call with the interrupt status set the call will
+ * immediately fail with a {@link ClosedByInterruptException}.
*
+ * @since Android 1.0
*/
public interface InterruptibleChannel extends Channel {
/**
- * Closes an InterruptibleChannel. This method is precisely the same as the
- * super-interface <code>close()</code>.
+ * Closes the channel.
* <p>
- * Any threads that are blocked on IO operations on this channel will be
- * interrupted with an <code>AsynchronousCloseException
- * </code>.
+ * Any threads that are blocked on I/O operations on this channel will be
+ * interrupted with an {@link AsynchronousCloseException}. Otherwise, this
+ * method behaves the same as defined in the {@code Channel} interface.
* </p>
*
* @throws IOException
- * if an IO problem occurs closing the channel.
+ * if an I/O error occurs while closing the channel.
+ * @since Android 1.0
*/
public void close() throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java b/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
index 7e19797..3434b87 100644
--- a/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
+++ b/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
@@ -18,17 +18,22 @@ package java.nio.channels;
/**
- * Thrown if SocketChannel's finishConnect method is called before the
- * SocketChannel's connect method completed without error.
+ * A {@code NoConnectionPendingException} is thrown if {@code SocketChannel}'s
+ * {@link SocketChannel#finishConnect() finishConnect} method is called before
+ * the {@code SocketChannel}'s
+ * {@link SocketChannel#connect(SocketAddress) connect} method completed without
+ * error.
*
+ * @since Android 1.0
*/
public class NoConnectionPendingException extends IllegalStateException {
private static final long serialVersionUID = -8296561183633134743L;
/**
- * Default constructor.
+ * Constructs a {@code NoConnectionPendingException}.
*
+ * @since Android 1.0
*/
public NoConnectionPendingException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NonReadableChannelException.java b/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
index 6dc318e..c436682 100644
--- a/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
+++ b/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
@@ -18,15 +18,19 @@ package java.nio.channels;
/**
- * Thrown when attempting to read from a channel that is not open for reading.
+ * A {@code NonReadableChannelException} is thrown when attempting to read from
+ * a channel that is not open for reading.
*
+ * @since Android 1.0
*/
public class NonReadableChannelException extends IllegalStateException {
private static final long serialVersionUID = -3200915679294993514L;
/**
- * Default constructor.
+ * Constructs a {@code NonReadableChannelException}.
+ *
+ * @since Android 1.0
*/
public NonReadableChannelException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NonWritableChannelException.java b/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
index 466f50a..81549cb 100644
--- a/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
+++ b/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
@@ -18,15 +18,19 @@ package java.nio.channels;
/**
- * Thrown when attempting to write to a channel that is not open for writing.
+ * A {@code NonWritableChannelException} is thrown when attempting to write to a
+ * channel that is not open for writing.
*
+ * @since Android 1.0
*/
public class NonWritableChannelException extends IllegalStateException {
private static final long serialVersionUID = -7071230488279011621L;
/**
- * Default constructor.
+ * Constructs a {@code NonWritableChannelException}.
+ *
+ * @since Android 1.0
*/
public NonWritableChannelException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NotYetBoundException.java b/nio/src/main/java/java/nio/channels/NotYetBoundException.java
index a41354a..2210903 100644
--- a/nio/src/main/java/java/nio/channels/NotYetBoundException.java
+++ b/nio/src/main/java/java/nio/channels/NotYetBoundException.java
@@ -18,17 +18,19 @@ package java.nio.channels;
/**
- * Thrown if the server socket channel is not bound before an IO operation is
- * made.
+ * A {@code NotYetBoundException} is thrown if the server socket channel is not
+ * bound before an I/O operation is made.
*
+ * @since Android 1.0
*/
public class NotYetBoundException extends IllegalStateException {
private static final long serialVersionUID = 4640999303950202242L;
/**
- * Default constructor.
+ * Constructs a {@code NotYetBoundException}.
*
+ * @since Android 1.0
*/
public NotYetBoundException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NotYetConnectedException.java b/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
index 06e73e5..393c77f 100644
--- a/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
+++ b/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
@@ -18,17 +18,19 @@ package java.nio.channels;
/**
- * Thrown if the socket channel is not connected before an IO operation is
- * invoked.
+ * A {@code NotYetConnectedException} is thrown if the socket channel is not
+ * connected before an I/O operation is invoked.
*
+ * @since Android 1.0
*/
public class NotYetConnectedException extends IllegalStateException {
private static final long serialVersionUID = 4697316551909513464L;
/**
- * Default constructor.
+ * Constructs a {@code NotYetConnectedException}.
*
+ * @since Android 1.0
*/
public NotYetConnectedException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java b/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
index 16a9645..6a00a6b 100644
--- a/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
+++ b/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
@@ -18,16 +18,19 @@ package java.nio.channels;
/**
- * Thrown when attempting to acquire a lock that overlaps an existing or pending
- * lock held by this process.
+ * An {@code OverlappingFileLockException} is thrown when attempting to acquire
+ * a lock that overlaps an existing or pending lock held by this process.
*
+ * @since Android 1.0
*/
public class OverlappingFileLockException extends IllegalStateException {
private static final long serialVersionUID = 2047812138163068433L;
/**
- * Default constructor.
+ * Constructs a {@code OverlappingFileLockException}.
+ *
+ * @since Android 1.0
*/
public OverlappingFileLockException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/Pipe.java b/nio/src/main/java/java/nio/channels/Pipe.java
index b0c44f4..e28812c 100644
--- a/nio/src/main/java/java/nio/channels/Pipe.java
+++ b/nio/src/main/java/java/nio/channels/Pipe.java
@@ -21,33 +21,37 @@ import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.SelectorProvider;
/**
- * A pipe contains two channels. One is the writable sink channel and the other is
- * readable source channel. When bytes are written into the writable channel they
- * can be read from readable channel. The order of these bytes remains unchanged.
- *
+ * A pipe contains two channels. One is the writable sink channel and the other
+ * is the readable source channel. When bytes are written into the writable
+ * channel they can be read from the readable channel. The order of these bytes
+ * remains unchanged.
+ * @since Android 1.0
*/
public abstract class Pipe {
/**
- * Writable sink channel for writing into.
+ * Writable sink channel used to write to a pipe.
+ * @since Android 1.0
*/
public static abstract class SinkChannel extends AbstractSelectableChannel
implements WritableByteChannel, GatheringByteChannel {
/**
- * The Constructor.
+ * Constructs a new {@code SinkChannel}.
*
* @param provider
- * the provider of the channel
+ * the provider of the channel.
+ * @since Android 1.0
*/
protected SinkChannel(SelectorProvider provider) {
super(provider);
}
/**
- * Indicates this channel supports only writing.
+ * Indicates that this channel only supports writing.
*
- * @return a static value of OP_WRITE
+ * @return a static value of OP_WRITE.
+ * @since Android 1.0
*/
public final int validOps() {
return SelectionKey.OP_WRITE;
@@ -55,26 +59,29 @@ public abstract class Pipe {
}
/**
- * Readable source channel for reading from.
+ * Readable source channel used to read from a pipe.
+ * @since Android 1.0
*/
public static abstract class SourceChannel extends
AbstractSelectableChannel implements ReadableByteChannel,
ScatteringByteChannel {
/**
- * The Constructor.
+ * Constructs a new {@code SourceChannel}.
*
* @param provider
- * the provider of the channel
+ * the provider of the channel.
+ * @since Android 1.0
*/
protected SourceChannel(SelectorProvider provider) {
super(provider);
}
/**
- * Indicates this channel supports only reading.
+ * Indicates that this channel only supports reading.
*
- * @return a static value of OP_READ
+ * @return a static value of OP_READ.
+ * @since Android 1.0
*/
public final int validOps() {
return SelectionKey.OP_READ;
@@ -85,17 +92,20 @@ public abstract class Pipe {
/**
* Initializes a pipe.
*
- * @return a new instance of pipe
+ * @return a new instance of pipe.
*
* @throws IOException
- * if I/O error occurs
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public static Pipe open() throws IOException {
return SelectorProvider.provider().openPipe();
}
/**
- * The protected constructor.
+ * The protected default constructor.
+ *
+ * @since Android 1.0
*/
protected Pipe() {
super();
@@ -104,14 +114,16 @@ public abstract class Pipe {
/**
* Returns the sink channel of the pipe.
*
- * @return a writable sink channel of the pipe
+ * @return a writable sink channel of the pipe.
+ * @since Android 1.0
*/
public abstract SinkChannel sink();
/**
* Returns the source channel of the pipe.
*
- * @return a readable source channel of the pipe
+ * @return a readable source channel of the pipe.
+ * @since Android 1.0
*/
public abstract SourceChannel source();
diff --git a/nio/src/main/java/java/nio/channels/ReadableByteChannel.java b/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
index f34e702..9be1a72 100644
--- a/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
@@ -21,12 +21,16 @@ import java.io.IOException;
import java.nio.ByteBuffer;
/**
- * A ReadableByteChannel is a type of Channel that can read bytes.
+ * A {@code ReadableByteChannel} is a type of {@link Channel} that can read
+ * bytes.
* <p>
- * Reads are synchronous on a ReadableByteChannel, that is, if a read is already
- * in progress on the channel then subsequent reads will block until the first
- * read completes. It is undefined whether non-read operations will block.
+ * Read operations are synchronous on a {@code ReadableByteChannel}, that is,
+ * if a read is already in progress on the channel then subsequent reads will
+ * block until the first read completes. It is undefined whether non-read
+ * operations will block.
+ * </p>
*
+ * @since Android 1.0
*/
public interface ReadableByteChannel extends Channel {
@@ -34,34 +38,37 @@ public interface ReadableByteChannel extends Channel {
* Reads bytes from the channel into the given buffer.
* <p>
* The maximum number of bytes that will be read is the
- * <code>remaining()</code> number of bytes in the buffer when the method
- * invoked. The bytes will be read into the buffer starting at the buffer's
- * <code>position</code>.
+ * {@link java.nio.Buffer#remaining() remaining} number of bytes in the
+ * buffer when the method is invoked. The bytes will be read into the buffer
+ * starting at the buffer's current
+ * {@link java.nio.Buffer#position() position}.
* </p>
* <p>
- * The call may block if other threads are also attempting to read on the
+ * The call may block if other threads are also attempting to read from the
* same channel.
* </p>
* <p>
- * Upon completion, the buffer's <code>position()</code> is updated to the
- * end of the bytes that were read. The buffer's <code>limit()</code> is
- * unmodified.
+ * Upon completion, the buffer's {@code position} is updated to the end of
+ * the bytes that were read. The buffer's
+ * {@link java.nio.Buffer#limit() limit} is not changed.
* </p>
*
* @param buffer
* the byte buffer to receive the bytes.
* @return the number of bytes actually read.
- * @throws NonReadableChannelException
- * if the channel was not opened for reading.
- * @throws ClosedChannelException
- * if the channel was already closed.
* @throws AsynchronousCloseException
* if another thread closes the channel during the read.
* @throws ClosedByInterruptException
- * if another thread interrupt the calling thread during the
- * read.
+ * if another thread interrupts the calling thread while the
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if the channel is closed.
* @throws IOException
- * another IO exception occurs, details are in the message.
+ * another I/O error occurs, details are in the message.
+ * @throws NonReadableChannelException
+ * if the channel was not opened for reading.
+ * @since Android 1.0
*/
public int read(ByteBuffer buffer) throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java b/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
index 41fb72f..2e654db 100644
--- a/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
@@ -21,82 +21,79 @@ import java.io.IOException;
import java.nio.ByteBuffer;
/**
- * The interface to channels that can read a set of buffers in a single
- * operation.
- * <p>
- * The corresponding interface for writes is called
- * <code>GatheringByteChannel</code>.
+ * The interface for channels that can read data into a set of buffers in a
+ * single operation. The corresponding interface for writes is
+ * {@link GatheringByteChannel}.
*
+ * @since Android 1.0
*/
public interface ScatteringByteChannel extends ReadableByteChannel {
/**
- * Reads bytes from the channel into all the given buffers.
+ * Reads bytes from this channel into the specified array of buffers.
* <p>
- * This method is equivalent to:
- *
- * <pre>
- * read(buffers, 0, buffers.length);
- * </pre>
- *
+ * This method is equivalent to {@code read(buffers, 0, buffers.length);}
* </p>
*
* @param buffers
- * the array of byte buffers to receive the bytes being read.
+ * the array of byte buffers to store the bytes being read.
* @return the number of bytes actually read.
+ * @throws AsynchronousCloseException
+ * if the channel is closed by another thread during this read
+ * operation.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while the
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
- * @throws NonReadableChannelException
- * if the channel is open, but not in a mode that permits
- * reading.
- * @throws ClosedByInterruptException
- * if the thread is interrupted in its IO operation by another
- * thread closing the channel.
- * @throws AsynchronousCloseException
- * if the read is interrupted by another thread sending an
- * explicit interrupt.
* @throws IOException
- * if some other type of exception occurs. Details are in the
- * message.
+ * if another I/O error occurs; details are in the message.
+ * @throws NonWritableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public long read(ByteBuffer[] buffers) throws IOException;
/**
- * Reads bytes from the channel into a subset of the given buffers.
- * <p>
- * This method attempts to read all of the <code>remaining()</code> bytes
- * from <code>length</code> byte buffers, in order, starting at
- * <code>buffers[offset]</code>. The number of bytes actually read is
- * returned.
- * </p>
+ * Reads bytes from this channel and stores them in a subset of the
+ * specified array of buffers. The subset is defined by {@code offset} and
+ * {@code length}, indicating the first buffer and the number of buffers to
+ * use. This method attempts to read as many bytes as can be stored in the
+ * buffer subset from the channel and returns the number of bytes actually
+ * read.
* <p>
* If a read operation is in progress, subsequent threads will block until
- * the read is completed, and will then contend for the ability to read.
+ * the read is completed and will then contend for the ability to read.
* </p>
*
* @param buffers
- * the array of byte buffers into which the bytes will be read.
+ * the array of byte buffers into which the bytes will be copied.
* @param offset
- * the index of the first buffer to read.
+ * the index of the first buffer to store bytes in.
* @param length
- * the maximum number of buffers to read.
+ * the maximum number of buffers to store bytes in.
* @return the number of bytes actually read.
- * @throws IndexOutOfBoundsException
- * if offset < 0 or > buffers.length; or length < 0 or >
- * buffers.length - offset.
- * @throws NonReadableChannelException
- * if the channel was not opened for reading.
- * @throws ClosedChannelException
- * the channel is currently closed.
* @throws AsynchronousCloseException
- * the channel was closed by another thread while the write was
- * underway.
+ * if the channel is closed by another thread during this read
+ * operation.
* @throws ClosedByInterruptException
- * the thread was interrupted by another thread while the write
- * was underway.
+ * if another thread interrupts the calling thread while the
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if the channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if
+ * {@code offset + length} is greater than the size of
+ * {@code buffers}.
* @throws IOException
- * if some other type of exception occurs. Details are in the
- * message.
+ * if another I/O error occurs; details are in the message.
+ * @throws NonWritableChannelException
+ * if the channel has not been opened in a mode that permits
+ * reading.
+ * @since Android 1.0
*/
public long read(ByteBuffer[] buffers, int offset, int length)
throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/SelectableChannel.java b/nio/src/main/java/java/nio/channels/SelectableChannel.java
index 7707c29..ded66e6 100644
--- a/nio/src/main/java/java/nio/channels/SelectableChannel.java
+++ b/nio/src/main/java/java/nio/channels/SelectableChannel.java
@@ -22,95 +22,136 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.nio.channels.spi.SelectorProvider;
/**
- * A channel that can be detected by a selector. The channel can be registered
- * with some selectors, and when invoke select method of the selectors, the
- * channel can be checked if it is readable, writable, connectable or
- * acceptable according to its interesting operation.
- *
+ * A channel that can be used with a {@link Selector}. The channel must be
+ * registered with a selector by calling one of the {@code register} methods,
+ * which return a {@link SelectionKey} object. In order to deregister a channel
+ * from a selector, its selection key must be canceled. This can be done
+ * explicitly by calling the {@link SelectionKey#cancel()} method but it is also
+ * done implicitly when the channel or the selector is closed.
+ * <p>
+ * A channel may be registered with several selectors at the same time but only
+ * once for any given selector.
+ * </p>
+ * @since Android 1.0
*/
public abstract class SelectableChannel extends AbstractInterruptibleChannel
implements Channel {
/**
- * Default constructor, can be overridden.
+ * Constructs a new {@code SelectableChannel}.
+ *
+ * @since Android 1.0
*/
protected SelectableChannel() {
super();
}
/**
- * Gets the blocking lock which synchronizes the configureBlocking and
- * register methods.
+ * Gets the blocking lock which synchronizes the {@code configureBlocking}
+ * and {@code register} methods.
*
- * @return the blocking object as lock
+ * @return the blocking object as lock.
+ * @since Android 1.0
*/
public abstract Object blockingLock();
/**
- * Sets blocking mode of the channel.
+ * Sets the blocking mode of this channel. A call to this method blocks if
+ * other calls to this method or to a {@code register} method are executing.
+ * The new blocking mode is valid for calls to other methods that are
+ * invoked after the call to this method. If other methods are already
+ * executing when this method is called, they still have the old mode and
+ * the call to this method might block depending on the implementation.
*
* @param block
- * true as blocking, false as non-blocking
- * @return this channel
+ * {@code true} for setting this channel's mode to blocking,
+ * {@code false} to set it to non-blocking.
+ * @return this channel.
* @throws ClosedChannelException
- * If this channel has been closed
+ * if this channel is closed.
* @throws IllegalBlockingModeException
- * If the channel has been registered
+ * if {@code block} is {@code true} and this channel has been
+ * registered with at least one selector.
* @throws IOException
- * if I/O error occurs
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract SelectableChannel configureBlocking(boolean block)
throws IOException;
/**
- * Returns if channel is in blocking mode.
+ * Indicates whether this channel is in blocking mode.
*
- * @return true if channel is blocking
+ * @return {@code true} if this channel is blocking, undefined if this
+ * channel is closed.
+ * @since Android 1.0
*/
public abstract boolean isBlocking();
/**
- * Returns if channel is registered.
+ * Indicates whether this channel is registered with at least one selector.
*
- * @return true if channel is registered
+ * @return {@code true} if this channel is registered, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public abstract boolean isRegistered();
/**
- * Gets the selection key for the channel with the given selector.
+ * Gets this channel's selection key for the specified selector.
*
* @param sel
- * the selector with which this channel may register
- * @return the selection key for the channel according to the given selector
+ * the selector with which this channel has been registered.
+ * @return the selection key for the channel or {@code null} if this channel
+ * has not been registered with {@code sel}.
+ * @since Android 1.0
*/
public abstract SelectionKey keyFor(Selector sel);
/**
- * Gets the provider of the channel.
+ * Gets the provider of this channel.
*
- * @return the provider of the channel
+ * @return the provider of this channel.
+ * @since Android 1.0
*/
public abstract SelectorProvider provider();
/**
- * Registers with the given selector with a certain interesting operation.
+ * Registers this channel with the specified selector for the specified
+ * interest set. If the channel is already registered with the selector, the
+ * corresponding selection key is returned but the
+ * {@link SelectionKey interest set} is updated to {@code operations}. The
+ * returned key is canceled if the channel is closed while registering is in
+ * progress.
+ * <p>
+ * Calling this method is valid at any time. If another thread executes this
+ * method or the {@code configureBlocking(boolean} method then this call is
+ * blocked until the other call finishes. After that, it will synchronize on
+ * the key set of the selector and thus may again block if other threads
+ * also hold locks on the key set of the same selector.
+ * </p>
+ * <p>
+ * Calling this method is equivalent to calling
+ * {@code register(selector, operations, null)}.
+ * </p>
*
* @param selector
- * the selector with which this channel shall be registered
+ * the selector with which to register this channel.
* @param operations
- * the interesting operation
- * @return the selection key indicates the channel
+ * this channel's {@link SelectionKey interest set}.
+ * @return the selection key for this registration.
* @throws ClosedChannelException
- * if the channel is closed
+ * if the channel is closed.
* @throws IllegalBlockingModeException
- * If the channel is in blocking mode
+ * if the channel is in blocking mode.
* @throws IllegalSelectorException
- * If this channel does not have the same provider as the
- * given selector
+ * if this channel does not have the same provider as the given
+ * selector.
* @throws CancelledKeyException
- * If this channel is registered but its key has been cancelled
+ * if this channel is registered but its key has been canceled.
* @throws IllegalArgumentException
- * If the operation given is unsupported by this channel
+ * if the operation given is not supported by this channel.
+ * @since Android 1.0
*/
public final SelectionKey register(Selector selector, int operations)
throws ClosedChannelException {
@@ -118,35 +159,49 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
}
/**
- * Registers with the given selector with a certain interesting operation
- * and an attached object.
+ * Registers this channel with the specified selector for the specified
+ * interest set and an object to attach. If the channel is already
+ * registered with the selector, the corresponding selection key is returned
+ * but its {@link SelectionKey interest set} is updated to {@code ops} and
+ * the attached object is updated to {@code att}. The returned key is
+ * canceled if the channel is closed while registering is in progress.
+ * <p>
+ * Calling this method is valid at any time. If another thread executes this
+ * method or the {@code configureBlocking(boolean)} method then this call is
+ * blocked until the other call finishes. After that, it will synchronize on
+ * the key set of the selector and thus may again block if other threads
+ * also hold locks on the key set of the same selector.
+ * </p>
*
* @param sel
- * the selector with which this channel shall be registered
+ * the selector with which to register this channel.
* @param ops
- * the interesting operation
+ * this channel's {@link SelectionKey interest set}.
* @param att
- * The attached object, which can be null
- * @return the selection key indicates the channel
+ * the object to attach, can be {@code null}.
+ * @return the selection key for this registration.
* @throws ClosedChannelException
- * if the channel is closed
+ * if this channel is closed.
+ * @throws IllegalArgumentException
+ * if {@code ops} is not supported by this channel.
* @throws IllegalBlockingModeException
- * If the channel is in blocking mode
+ * if this channel is in blocking mode.
* @throws IllegalSelectorException
- * If this channel does not have the same provider with the
- * given selector
+ * if this channel does not have the same provider as the given
+ * selector.
* @throws CancelledKeyException
- * If this channel is registered but its key has been cancelled
- * @throws IllegalArgumentException
- * If the operation given is unsupported by this channel
+ * if this channel is registered but its key has been canceled.
+ * @since Android 1.0
*/
public abstract SelectionKey register(Selector sel, int ops, Object att)
throws ClosedChannelException;
/**
- * Gets the possible interesting operation of the channel.
+ * Gets the set of valid {@link SelectionKey operations} of this channel.
+ * Instances of a concrete channel class always return the same value.
*
- * @return the possible interesting operation of the channel
+ * @return the set of operations that this channel supports.
+ * @since Android 1.0
*/
public abstract int validOps();
diff --git a/nio/src/main/java/java/nio/channels/SelectionKey.java b/nio/src/main/java/java/nio/channels/SelectionKey.java
index f52f99e..b3773fa 100644
--- a/nio/src/main/java/java/nio/channels/SelectionKey.java
+++ b/nio/src/main/java/java/nio/channels/SelectionKey.java
@@ -19,47 +19,73 @@ package java.nio.channels;
import java.nio.channels.Selector;
/**
- * A key that representing the relationship of a channel and the selector.
+ * A {@code SelectionKey} represents the relationship between a channel and a
+ * selector for which the channel is registered.
+ * <h3>Operation set</h3>
+ * An operation set is represented by an integer value. The bits of an operation
+ * set represent categories of operations for a key's channel: Accepting socket
+ * connections ({@code OP_ACCEPT}), connecting with a socket ({@code OP_CONNECT}),
+ * reading ({@code OP_READ}) and writing ({@code OP_WRITE}).
+ * <h4>Interest set</h4>
+ * The interest set is an operation set that defines the operations that a
+ * {@link SelectableChannel channel} is interested in performing.
+ * <h4>Ready set</h4>
+ * The ready set is an operation set that shows the operations that a
+ * {@code channel} is ready to execute.
*
+ * @since Android 1.0
*/
public abstract class SelectionKey {
/**
- * Interesting operation mask bit for socket-accept operations.
+ * Interest set mask bit for socket-accept operations.
+ *
+ * @since Android 1.0
*/
public static final int OP_ACCEPT = 16;
/**
- * Interesting operation mask bit for socket-connect operations.
+ * Interest set mask bit for socket-connect operations.
+ *
+ * @since Android 1.0
*/
public static final int OP_CONNECT = 8;
/**
* Interesting operation mask bit for read operations.
+ *
+ * @since Android 1.0
*/
public static final int OP_READ = 1;
/**
- * Interesting operation mask bit for write operations.
+ * Interest set mask bit for write operations.
+ *
+ * @since Android 1.0
*/
public static final int OP_WRITE = 4;
private volatile Object attachment = null;
/**
- * The constructor.
+ * Constructs a new {@code SelectionKey}.
*
+ * @since Android 1.0
*/
protected SelectionKey() {
super();
}
/**
- * Attaches an object to the key.
+ * Attaches an object to this key. It is acceptable to attach {@code null},
+ * this discards the old attachment.
*
* @param anObject
- * the object to attach
- * @return the last attached object
+ * the object to attach, or {@code null} to discard the current
+ * attachment.
+ * @return the last attached object or {@code null} if no object has been
+ * attached.
+ * @since Android 1.0
*/
public final Object attach(Object anObject) {
Object oldAttachment = attachment;
@@ -70,7 +96,9 @@ public abstract class SelectionKey {
/**
* Gets the attached object.
*
- * @return the attached object or null if no object has been attached
+ * @return the attached object or {@code null} if no object has been
+ * attached.
+ * @since Android 1.0
*/
public final Object attachment() {
return attachment;
@@ -78,112 +106,144 @@ public abstract class SelectionKey {
/**
* Cancels this key.
+ * <p>
+ * A key that has been canceled is no longer valid. Calling this method on
+ * an already canceled key does nothing.
+ * </p>
+ * <p>
+ * Calling this method is safe at any time. The call might block until
+ * another ongoing call to a method of this selector has finished. The
+ * reason is that it is synchronizing on the key set of the selector. After
+ * this call finishes, the key will have been added to the selectors
+ * canceled-keys set and will not be included in any future selects of this
+ * selector.
+ * </p>
*
+ * @since Android 1.0
*/
public abstract void cancel();
/**
* Gets the channel of this key.
*
- * @return the channel of this key
+ * @return the channel of this key.
+ * @since Android 1.0
*/
public abstract SelectableChannel channel();
/**
- * Gets the interesting operation of this key.
+ * Gets this key's {@link SelectionKey interest set}. The returned set has
+ * only those bits set that are valid for this key's channel.
*
- * @return the interesting operation of this key
+ * @return the interest set of this key.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public abstract int interestOps();
/**
- * Sets the interesting operation for this key.
+ * Sets the {@link SelectionKey interest set} for this key.
*
* @param operations
- * the interesting operation to set
- * @return this key
+ * the new interest set.
+ * @return this key.
* @throws IllegalArgumentException
- * if the given operation is not in the key's interesting
- * operation set
+ * if a bit in {@code operations} is not in the set of
+ * {@link SelectableChannel#validOps() valid operations} of this
+ * key's channel.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public abstract SelectionKey interestOps(int operations);
/**
- * Tells whether the channel of this key is interested in accept operation
- * and ready for acceptation.
+ * Indicates whether this key's channel is interested in the accept
+ * operation and is ready to accept new connections. A call to this method
+ * is equal to executing {@code (readyOps() & OP_ACCEPT) == OP_ACCEPT}.
*
- * @return true if the channel is interested in accept operation and ready
- * for acceptation
+ * @return {@code true} if the channel is interested in the accept operation
+ * and is ready to accept new connections, {@code false} otherwise.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public final boolean isAcceptable() {
return (readyOps() & OP_ACCEPT) == OP_ACCEPT;
}
/**
- * Tells whether the channel of this key is interested in connect operation
- * and ready for connection.
+ * Indicates whether this key's channel is interested in the connect
+ * operation and is ready to connect. A call to this method is equal to
+ * executing {@code (readyOps() & OP_CONNECT) == OP_CONNECT}.
*
- * @return true if the channel is interested in connect operation and ready
- * for connection
+ * @return {@code true} if the channel is interested in the connect
+ * operation and is ready to connect, {@code false} otherwise.
* @throws CancelledKeyException
- * If the key has been cancelled already
- */
+ * if the key has already been canceled.
+ * @since Android 1.0
+ */
public final boolean isConnectable() {
return (readyOps() & OP_CONNECT) == OP_CONNECT;
}
/**
- * Tells whether the channel of this key is interested in read operation and
- * ready for reading.
+ * Indicates whether this key's channel is interested in the read operation
+ * and is ready to read. A call to this method is equal to executing
+ * {@code (readyOps() & OP_READ) == OP_READ}.
*
- * @return true if the channel is interested in read operation and ready for
- * reading
+ * @return {@code true} if the channel is interested in the read operation
+ * and is ready to read, {@code false} otherwise.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public final boolean isReadable() {
return (readyOps() & OP_READ) == OP_READ;
}
/**
- * Tells whether the key is valid.
+ * Indicates whether this key is valid. A key is valid as long as it has not
+ * been canceled.
*
- * @return true if the key has not been cancelled
+ * @return {@code true} if this key has not been canceled, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public abstract boolean isValid();
/**
- * Tells whether the channel of this key is interested in write operation
- * and ready for writing.
+ * Indicates whether this key's channel is interested in the write operation
+ * and is ready to write. A call to this method is equal to executing
+ * {@code (readyOps() & OP_WRITE) == OP_WRITE}.
*
- * @return true if the channel is interested in write operation and ready
- * for writing
+ * @return {@code true} if the channel is interested in the wrie operation
+ * and is ready to write, {@code false} otherwise.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public final boolean isWritable() {
return (readyOps() & OP_WRITE) == OP_WRITE;
}
/**
- * Gets the ready operation.
+ * Gets the set of operations that are ready. The returned set has only
+ * those bits set that are valid for this key's channel.
*
- * @return the ready operation
+ * @return the operations for which this key's channel is ready.
* @throws CancelledKeyException
- * If the key has been cancelled already
+ * if the key has already been canceled.
+ * @since Android 1.0
*/
public abstract int readyOps();
/**
- * Gets the related selector.
+ * Gets the selector for which this key's channel is registered.
*
- * @return the related selector
+ * @return the related selector.
+ * @since Android 1.0
*/
public abstract Selector selector();
}
diff --git a/nio/src/main/java/java/nio/channels/Selector.java b/nio/src/main/java/java/nio/channels/Selector.java
index 91e4e01..d417f51 100644
--- a/nio/src/main/java/java/nio/channels/Selector.java
+++ b/nio/src/main/java/java/nio/channels/Selector.java
@@ -21,128 +21,167 @@ import java.nio.channels.spi.SelectorProvider;
import java.util.Set;
/**
- * A controller for selection of SelectableChannel objects.
- *
- * Selectable channels can be registered with a selector, and get SelectionKey
- * as a linkage. The keys are also added to the selector's keyset. The
- * SelectionKey can be cancelled so that the corresponding channel is no longer
- * registered with the selector.
- *
- * By invoking the select operation, the keyset is checked and all keys that are
- * cancelled since last select operation are moved to cancelledKey set. During
- * the select operation, the channels registered with this selector are checked
- * to see whether they are ready for operation according to their interesting
- * operation.
+ * A controller for the selection of {@link SelectableChannel} objects.
+ * Selectable channels can be registered with a selector and get a
+ * {@link SelectionKey} that represents the registration. The keys are also
+ * added to the selector's key set. Selection keys can be canceled so that the
+ * corresponding channel is no longer registered with the selector.
+ * <p>
+ * By invoking the {@code select} method, the key set is checked and all keys
+ * that have been canceled since last select operation are moved to the set of
+ * canceled keys. During the select operation, the channels registered with this
+ * selector are checked to see whether they are ready for operation according to
+ * their {@link SelectionKey interest set}.
+ * </p>
*
+ * @since Android 1.0
*/
public abstract class Selector {
/**
- * The factory method for selector.
+ * The factory method for selector. It returns the selector returned by the
+ * default {@link SelectorProvider} by calling its {@code openCollector}
+ * method.
*
- * @return a new selector
+ * @return a new selector.
* @throws IOException
- * if I/O error occurs
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public static Selector open() throws IOException {
return SelectorProvider.provider().openSelector();
}
/**
- * The constructor.
+ * Constructs a new {@code Selector}.
+ *
+ * @since Android 1.0
*/
protected Selector() {
super();
}
/**
- * Closes this selector.
+ * Closes this selector. Ongoing calls to the {@code select} methods of this
+ * selector will get interrupted. This interruption behaves as if the
+ * {@link #wakeup()} method of this selector is called. After this, all keys
+ * that are still valid are invalidated and their channels are unregistered.
+ * All resources held by this selector are released.
+ * <p>
+ * Any further attempt of using this selector after this method has been
+ * called (except calling {@link #close()} or {@link #wakeup()}) results in
+ * a {@link ClosedSelectorException} being thrown.
+ * </p>
*
* @throws IOException
- * if I/O error occurs
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract void close() throws IOException;
/**
- * Tells whether this selector is open.
+ * Indicates whether this selector is open.
*
- * @return true if this selector is not closed
+ * @return {@code true} if this selector is not closed, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public abstract boolean isOpen();
/**
- * Gets the set of registered keys.
+ * Gets the set of registered keys. The set is immutable and is not thread-
+ * safe.
*
- * @return the keyset of registered keys
+ * @return the set of registered keys.
+ * @since Android 1.0
*/
public abstract Set<SelectionKey> keys();
/**
* Gets the provider of this selector.
*
- * @return the provider of this selector
+ * @return the provider of this selector.
+ * @since Android 1.0
*/
public abstract SelectorProvider provider();
/**
- * Detects if any of the registered channels are ready for I/O operations
- * according to their interesting operation. This operation will not return
- * until some of the channels are ready or wakeup is invoked.
+ * Detects if any of the registered channels is ready for I/O operations
+ * according to its {@link SelectionKey interest set}. This method does not
+ * return until at least one channel is ready, {@link #wakeup()} is
+ * invoked or the calling thread is interrupted.
*
- * @return the number of channels that are ready for operation
+ * @return the number of channels that are ready for operation.
* @throws IOException
- * if I/O error occurs
+ * if an I/O error occurs.
* @throws ClosedSelectorException
- * If the selector is closed
+ * if the selector is closed.
+ * @since Android 1.0
*/
public abstract int select() throws IOException;
/**
- * Detects if any of the registered channels are ready for I/O operations
- * according to their interesting operation.This operation will not return
- * until some of the channels are ready or wakeup is invoked or timeout
- * expired.
+ * Detects if any of the registered channels is ready for I/O operations
+ * according to its {@link SelectionKey interest set}. This method does not
+ * return until at least one channel is ready, {@link #wakeup()} is invoked,
+ * the calling thread is interrupted or the specified {@code timeout}
+ * expires.
*
* @param timeout
- * the timeout in millisecond
- * @return the number of channels that are ready for operation
- * @throws IOException
- * if I/O error occurs
+ * the non-negative timeout in millisecond; 0 will block forever
+ * if no channels get ready.
+ * @return the number of channels that are ready for operation.
* @throws ClosedSelectorException
- * If the selector is closed
+ * if the selector is closed.
* @throws IllegalArgumentException
- * If the given timeout argument is less than zero
+ * if the given timeout argument is less than zero.
+ * @throws IOException
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract int select(long timeout) throws IOException;
/**
- * Gets the keys whose channels are ready for operation.
+ * Gets the selection keys whose channels are ready for operation. The set
+ * is not thread-safe and no keys may be added to it. Removing keys is
+ * allowed.
*
- * @return the keys whose channels are ready for operation
+ * @return the selection keys whose channels are ready for operation.
+ * @throws ClosedSelectorException
+ * if the selector is closed.
+ * @since Android 1.0
*/
public abstract Set<SelectionKey> selectedKeys();
/**
- * Detects if any of the registered channels are ready for I/O operations
- * according to their interesting operation.This operation will not return
- * immediately.
+ * Detects if any of the registered channels is ready for I/O operations
+ * according to its {@link SelectionKey interest set}. This operation will
+ * return immediately.
*
- * @return the number of channels that are ready for operation
+ * @return the number of channels that are ready for operation, 0 if none is
+ * ready.
* @throws IOException
- * if I/O error occur
+ * if an I/O error occurrs.
* @throws ClosedSelectorException
- * If the selector is closed
+ * if the selector is closed.
+ * @since Android 1.0
*/
public abstract int selectNow() throws IOException;
/**
- * Forces the blocked select operation to return immediately. If no select
- * operation is blocked currently, the next select operation shall return
- * immediately.
+ * Forces blocked {@code select} operations to return immediately.
+ * <p>
+ * If no {@code select} operation is blocked when {@code wakeup()} is called
+ * then the next {@code select} operation will return immediately. This can
+ * be undone by a call to {@code selectNow()}; after calling
+ * {@code selectNow()}, a subsequent call of {@code select} can block
+ * again.
+ * </p>
*
- * @return this selector
+ * @return this selector.
* @throws ClosedSelectorException
- * If the selector is closed
+ * if the selector is closed.
+ * @since Android 1.0
*/
public abstract Selector wakeup();
}
diff --git a/nio/src/main/java/java/nio/channels/ServerSocketChannel.java b/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
index ac37e7d..8ecb183 100644
--- a/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
+++ b/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
@@ -23,96 +23,103 @@ import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.SelectorProvider;
/**
- * A ServerSocketChannel is a partly abstracted stream-oriented listening socket
- * which is selectable. Binding and manipulation of socket options can only be done
- * through the associated <code>ServerSocket</code> object, returned by calling
- * socket method. ServerSocketChannels can not be constructed for a pre-existing
- * server socket, nor can it be assigned a SocketImpl.
- * <p>
- * A Server-Socket channel is open but not bound when created by
- * <code>open</code> method. (Calling <code>accept</code> before bound will cause a
- * <code>NotYetBoundException</code>). It can be bound by calling the bind method
- * of a related <code>ServerSocket</code> instance.</p>
+ * A {@code ServerSocketChannel} is a partial abstraction of a selectable,
+ * stream-oriented listening socket. Binding and manipulation of socket options
+ * can only be done through the associated {@link ServerSocket} object, returned
+ * by calling {@code socket()}. ServerSocketChannels can not be constructed for
+ * an already existing server-socket, nor can a {@link java.net.SocketImpl} be assigned.
+ * <p>
+ * A server-socket channel is open but not bound when created by the {@code
+ * open()} method. Calling {@code accept} before bound will cause a
+ * {@link NotYetBoundException}. It can be bound by calling the bind method of a
+ * related {@code ServerSocket} instance.
+ * </p>
+ *
+ * @since Android 1.0
*/
public abstract class ServerSocketChannel extends AbstractSelectableChannel {
/**
- * Construct a new instance for ServerSocketChannel
+ * Constructs a new {@link ServerSocketChannel}.
+ *
* @param selectorProvider
- * An instance of SelectorProvider
+ * an instance of SelectorProvider.
+ * @since Android 1.0
*/
-
protected ServerSocketChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
}
/**
- * Create an open and unbound server-socket channel.
+ * Creates an open and unbound server-socket channel.
* <p>
- * This channel is got by calling <code>openServerSocketChannel</code>
- * method of the default <code>SelectorProvider </code> instance.
- * </p>
+ * This channel is created by calling {@code openServerSocketChannel} method
+ * of the default {@code SelectorProvider} instance.
+ * </p>
*
- * @return The new created channel which is open but unbound.
+ * @return the new channel which is open but unbound.
* @throws IOException
- * If some IO problem occurs.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public static ServerSocketChannel open() throws IOException {
return SelectorProvider.provider().openServerSocketChannel();
}
/**
- * Get the valid operations of this channel. Server-socket channels support
- * accepting operation.Currently the only supported operation is OP_ACCEPT.
- * It always returns <code>SelectionKey.OP_ACCEPT</code>.
+ * Gets the valid operations of this channel. Server-socket channels support
+ * accepting operation, so this method returns {@code
+ * SelectionKey.OP_ACCEPT}.
*
* @see java.nio.channels.SelectableChannel#validOps()
- * @return Valid operations in bit-set.
+ * @return the operations supported by this channel.
+ * @since Android 1.0
*/
public final int validOps() {
return SelectionKey.OP_ACCEPT;
}
/**
- * Return the related server-socket of this channel.
- * All public methods declared in returned object should be declared in <code>ServerSocket</code>.
+ * Return the server-socket assigned this channel, which does not declare
+ * any public methods that are not declared in {@code ServerSocket}.
*
- * @return The related ServerSocket instance.
+ * @return the server-socket assigned to this channel.
+ * @since Android 1.0
*/
public abstract ServerSocket socket();
/**
- * Accepts a connection to this socket.
+ * Accepts a connection to this server-socket channel.
* <p>
- * It returns null when the channel is non-blocking and no connections available, otherwise it
- * blocks indefinitely until a new connection is available or an I/O error occurs.
- * The returned channel will be in blocking mode any way.
+ * This method returns {@code null} when this channel is non-blocking and no
+ * connection is available, otherwise it blocks until a new connection is
+ * available or an I/O error occurs. The socket channel returned by this
+ * method will always be in blocking mode.
* </p>
- *
* <p>
- * This method just execute the same security checks as the accept method of
- * the <code>ServerSocket</code> class.
+ * This method just executes the same security checks as the {@code
+ * accept()} method of the {@link ServerSocket} class.
* </p>
*
- * @return The accepted SocketChannel instance, or null as the channel is
- * non-blocking and no connections available.
- * @throws ClosedChannelException
- * If the channel is already closed.
+ * @return the accepted {@code SocketChannel} instance, or {@code null} if
+ * the channel is non-blocking and no connection is available.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
+ * if this channel is closed by another thread while this method
* is in operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IOException
+ * if another I/O error occurs.
* @throws NotYetBoundException
- * If the socket has not yet been bound.
+ * if the socket has not yet been bound.
* @throws SecurityException
- * If there is a security manager, and the new connection is not
- * permitted to access.
- * @throws IOException
- * Some other IO error occurred.
- *
+ * if there is a security manager and it does not permit to
+ * access the new connection.
+ * @since Android 1.0
*/
public abstract SocketChannel accept() throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/SocketChannel.java b/nio/src/main/java/java/nio/channels/SocketChannel.java
index 812d811..a709dee 100644
--- a/nio/src/main/java/java/nio/channels/SocketChannel.java
+++ b/nio/src/main/java/java/nio/channels/SocketChannel.java
@@ -27,36 +27,39 @@ import java.nio.channels.spi.SelectorProvider;
import org.apache.harmony.luni.platform.Platform;
/**
- * A SocketChannel is a selectable channel for part abstraction of stream
- * connecting socket. The <code>socket</code> method of this class can return
- * the related <code>Socket</code> instance, which can handle the socket.
+ * A {@code SocketChannel} is a selectable channel that provides a partial
+ * abstraction of stream connecting socket. {@code socket()} returns the related
+ * {@link Socket} instance which can handle the socket.
* <p>
- * A socket channel is open but not connected when created by <code>open</code>
- * method. After connected by calling the <code>connect</code> method, it will
- * keep connected before closed. The connection is non-blocking that the
- * <code>connect</code> method is for the initial connection and following
- * <code>finishConnect</code> method is for the final steps of connection. The
- * <code>isConnectionPending</code> method can tell the connection is blocked
- * or not; the <code>isConnected</code> method can tell the socket is
- * connected finally or not.
+ * A socket channel is open but not connected when created by {@code open()}.
+ * After connecting it by calling {@code connect(SocketAddress)}, it will remain
+ * connected until it gets closed. If the connection is non-blocking then
+ * {@code connect(SocketAddress)} is used to initiate the connection, followed
+ * by a call of {@code finishConnect()} to perform the final steps of
+ * connecting. {@code isConnectionPending()} indicates if the connection is
+ * blocked or not; {@code isConnected()} indicates if the socket is finally
+ * connected or not.
* </p>
* <p>
- * The shut down operation can be independent and asynchronous for input and
- * output. The <code>shutdownInput</code> method is for input, and can make
- * the following read operation fail as end of stream. If the input is shut down
- * and another thread is pending in read operation, the read will end without
- * effect and return end of stream. The <code>shutdownOutput</code> method is
- * for output, and can make the following write operation throwing a
- * <code>ClosedChannelException</code>. If the output is shut down and
- * another is pending in a write operation, an
- * <code>AsynchronousCloseException</code> will thrown to the pending thread.
+ * The input and output sides of a channel can be shut down independently and
+ * asynchronously without closing the channel. The {@code shutdownInput} method
+ * is used for the input side of a channel and subsequent read operations return
+ * -1, which means end of stream. If another thread is blocked in a read
+ * operation when the shutdown occurs, the read will end without effect and
+ * return end of stream. The {@code shutdownOutput} method is used for the
+ * output side of the channel; subsequent write operations throw a
+ * {@link ClosedChannelException}. If the output is shut down and another thread
+ * is blocked in a write operation, an {@link AsynchronousCloseException} will
+ * be thrown to the pending thread.
* </p>
* <p>
* Socket channels are thread-safe, no more than one thread can read or write at
- * given time. The <code>connect</code> and <code>finishConnect</code>
- * methods are concurrent each other, when they are processing, other read and
- * write will block.
+ * any given time. The {@code connect(SocketAddress)} and {@code
+ * finishConnect()} methods are synchronized against each other; when they are
+ * processing, calls to {@code read} and {@code write} will block.
* </p>
+ *
+ * @since Android 1.0
*/
public abstract class SocketChannel extends AbstractSelectableChannel implements
ByteChannel, ScatteringByteChannel, GatheringByteChannel {
@@ -66,57 +69,59 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
}
/**
- * Constructor for this class.
+ * Constructs a new {@code SocketChannel}.
*
* @param selectorProvider
- * A instance of SelectorProvider
+ * an instance of SelectorProvider.
+ * @since Android 1.0
*/
protected SocketChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
}
/**
- * Create a open and not-connected socket channel.
+ * Creates an open and unconnected socket channel.
* <p>
- * This channel is got by <code>openSocketChannel</code> method of the
- * default <code>SelectorProvider </code> instance.
+ * This channel is created by calling {@code openSocketChannel()} of the
+ * default {@link SelectorProvider} instance.
* </p>
*
- * @return The new created channel which is open but not-connected.
+ * @return the new channel which is open but unconnected.
* @throws IOException
- * If some IO problem occurs.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public static SocketChannel open() throws IOException {
return SelectorProvider.provider().openSocketChannel();
}
/**
- * Create a socket channel and connect it to a socket address.
+ * Creates a socket channel and connects it to a socket address.
* <p>
- * This method perform just as <code>open</code> method following by the
- * <code>connect</code> method.
+ * This method performs a call to {@code open()} followed by a call to
+ * {@code connect(SocketAdress)}.
* </p>
*
* @param address
- * The socket address to be connected.
- * @return The new opened channel.
+ * the socket address to be connected to.
+ * @return the new connected channel.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is executing. The calling thread will have the
+ * interrupt state set and the channel will be closed.
+ * @throws SecurityException
+ * if there is a security manager and it denies the access of
+ * {@code address}.
* @throws UnresolvedAddressException
- * If the address is not resolved.
+ * if the address is not resolved.
* @throws UnsupportedAddressTypeException
- * If the address type is not supported.
- * @throws SecurityException
- * If there is a security manager, and the address is not
- * permitted to access.
+ * if the address type is not supported.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public static SocketChannel open(SocketAddress address) throws IOException {
SocketChannel socketChannel = open();
@@ -127,240 +132,235 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
}
/**
- * Get the valid operations of this channel. Socket channels support
- * connect, read and write operation, so this method returns (
- * <code>SelectionKey.OP_CONNECT</code> |
- * <code>SelectionKey.OP_READ</code> | <code>SelectionKey.OP_WRITE</code> ).
+ * Gets the valid operations of this channel. Socket channels support
+ * connect, read and write operation, so this method returns
+ * {@code SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE}.
*
+ * @return the operations supported by this channel.
* @see java.nio.channels.SelectableChannel#validOps()
- * @return Valid operations in bit-set.
+ * @since Android 1.0
*/
public final int validOps() {
return (SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE);
}
/**
- * Return the related socket of this channel, which won't declare public
- * methods that not declared in <code>Socket</code>.
+ * Returns the socket assigned to this channel, which does not declare any public
+ * methods that are not declared in {@code Socket}.
*
- * @return The related Socket instance.
+ * @return the socket assigned to this channel.
+ * @since Android 1.0
*/
public abstract Socket socket();
/**
- * Answer whether this channel's socket is connected or not.
+ * Indicates whether this channel's socket is connected.
*
- * @return <code>true</code> for this channel's socket is connected;
- * <code>false</code> otherwise.
+ * @return {@code true} if this channel's socket is connected, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public abstract boolean isConnected();
/**
- * Answer whether this channel's socket is in connecting or not.
+ * Indicates whether this channel's socket is still trying to connect.
*
- * @return <code>true</code> for the connection is initiated but not
- * finished; <code>false</code> otherwise.
+ * @return {@code true} if the connection is initiated but not finished;
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean isConnectionPending();
/**
- * Connect the socket to remote address.
+ * Connects this channel's socket with a remote address.
* <p>
- * If the channel is blocking, this method will suspend before connection
- * finished or an I/O exception. If the channel is non-blocking, this method
- * will return <code>true</code> if the connection is finished at once or
- * return <code>false</code> and the connection must wait
- * <code>finishConnect</code> to finished otherwise.
+ * If this channel is blocking, this method will suspend until connecting is
+ * finished or an I/O exception occurrs. If the channel is non-blocking,
+ * this method will return {@code true} if the connection is finished at
+ * once or return {@code false} when the connection must be finished later
+ * by calling {@code finishConnect()}.
* </p>
* <p>
- * This method can be called at any moment, and can block other read and
- * write operations while connecting.
- * </p>
- * <p>
- * This method just execute the same security checks as the connect method
- * of the <code>Socket</code> class.
+ * This method can be called at any moment and can block other read and
+ * write operations while connecting. It executes the same security checks
+ * as the connect method of the {@code Socket} class.
* </p>
*
* @param address
- * The address to be connected.
- * @return <code>true</code> if connection is finished,<code>false</code>
+ * the address to connect with.
+ * @return {@code true} if the connection is finished, {@code false}
* otherwise.
* @throws AlreadyConnectedException
- * If the channel is connected already.
+ * if the channel is already connected.
* @throws ConnectionPendingException
- * A non-blocking connecting is doing on this channel.
+ * a non-blocking connecting operation is already executing on
+ * this channel.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if this channel is closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
+ * if another thread interrupts the calling thread while this
* operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * interrupt state set and this channel will be closed.
* @throws UnresolvedAddressException
- * If the address is not resolved.
+ * if the address is not resolved.
* @throws UnsupportedAddressTypeException
- * If the address type is not supported.
+ * if the address type is not supported.
* @throws SecurityException
- * If there is a security manager, and the address is not
- * permitted to access.
+ * if there is a security manager and it denies the access of
+ * {@code address}.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract boolean connect(SocketAddress address) throws IOException;
/**
- * Complete the connection.
+ * Completes the connection process initiated by a call of {@code
+ * connect(SocketAddress)}.
* <p>
- * This method is used when the channel is connectable to finish the
- * connection, and the connectable status of a channel means the channel is
- * after initiating in non-blocking mode and calling its
- * <code>connect</code> method. It will throw related
- * <code>IOException</code> if the connection failed.
+ * This method returns {@code true} if the connection is finished already
+ * and returns {@code false} if the channel is non-blocking and the
+ * connection is not finished yet.
* </p>
* <p>
- * This method will return <code>true</code> if the connection is finished
- * already, and return <code>false</code> if the channel is non-blocking
- * and the connection is not finished yet.
+ * If this channel is in blocking mode, this method will suspend and return
+ * {@code true} when the connection is finished. It closes this channel and
+ * throws an exception if the connection fails.
* </p>
* <p>
- * If the channel is in blocking mode, this method will suspend, and return
- * <code>true</code> for connection finished or throw some exception
- * otherwise. The channel will be closed if the connection failed and this
- * method thrown some exception.
- * </p>
- * <p>
- * This method can be called at any moment, and can block other read and
- * write operations while connecting.
+ * This method can be called at any moment and it can block other {@code
+ * read} and {@code write} operations while connecting.
* </p>
*
- * @return <code>true</code> if the connection is successfully finished,
- * <code>false</code> otherwise.
+ * @return {@code true} if the connection is successfully finished, {@code
+ * false} otherwise.
* @throws NoConnectionPendingException
- * If the channel is not connected and the connection is not
- * initiated.
+ * if the channel is not connected and the connection process
+ * has not been initiated.
* @throws ClosedChannelException
- * If the channel is already closed.
+ * if this channel is closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread while this method
+ * is executing.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The calling thread has the
+ * interrupt state set, and this channel is closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract boolean finishConnect() throws IOException;
/**
- * Reads bytes from the channel into the given buffer.
+ * Reads bytes from this socket channel into the given buffer.
* <p>
- * The maximum number of bytes that will be read is the
- * <code>remaining()</code> number of bytes in the buffer when the method
- * invoked. The bytes will be read into the buffer starting at the buffer's
- * <code>position</code>.
+ * The maximum number of bytes that will be read is the remaining number of
+ * bytes in the buffer when the method is invoked. The bytes will be copied
+ * into the buffer starting at the buffer's current position.
* </p>
* <p>
- * The call may block if other threads are also attempting to read on the
- * same channel.
+ * The call may block if other threads are also attempting to read from this
+ * channel.
* </p>
* <p>
- * Upon completion, the buffer's <code>position()</code> is updated to the
- * end of the bytes that were read. The buffer's <code>limit()</code> is
- * unmodified.
+ * Upon completion, the buffer's position is set to the end of the bytes
+ * that have been read. The buffer's limit is not changed.
* </p>
*
- * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
* @param target
- * The byte buffer to receive the bytes.
- * @return The number of bytes actually read.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
+ * the byte buffer to receive the bytes.
+ * @return the number of bytes actually read.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if another thread closes the channel during the read.
+ * @throws NotYetConnectedException
+ * if this channel is not yet connected.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @since Android 1.0
*/
public abstract int read(ByteBuffer target) throws IOException;
/**
- * Reads bytes from the channel into a subset of the given buffers.
- * <p>
- * This method attempts to read all of the <code>remaining()</code> bytes
- * from <code>length</code> byte buffers, in order, starting at
- * <code>targets[offset]</code>. The number of bytes actually read is
- * returned.
- * </p>
+ * Reads bytes from this socket channel and stores them in a subset of the
+ * specified array of buffers. The subset is defined by {@code offset} and
+ * {@code length}, indicating the first buffer and the number of buffers to
+ * use. This method attempts to read as many bytes as can be stored in the
+ * buffer subset from this channel and returns the number of bytes actually
+ * read.
* <p>
* If a read operation is in progress, subsequent threads will block until
- * the read is completed, and will then contend for the ability to read.
+ * the read is completed and will then contend for the ability to read.
* </p>
*
- * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
- * int, int)
* @param targets
- * the array of byte buffers into which the bytes will be read.
+ * the array of byte buffers into which the bytes will be copied.
* @param offset
- * the index of the first buffer to read.
+ * the index of the first buffer to store bytes in.
* @param length
- * the maximum number of buffers to read.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
+ * the maximum number of buffers to store bytes in.
+ * @return the number of bytes actually read.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread during this read
+ * operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if {@code
+ * offset + length} is greater than the size of {@code targets}.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @throws NotYetConnectedException
+ * if this channel is not yet connected.
+ * @since Android 1.0
*/
public abstract long read(ByteBuffer[] targets, int offset, int length)
throws IOException;
/**
- * Reads bytes from the channel into all the given buffers.
+ * Reads bytes from this socket channel and stores them in the specified
+ * array of buffers. This method attempts to read as many bytes as can be
+ * stored in the buffer array from this channel and returns the number of
+ * bytes actually read.
* <p>
- * This method is equivalent to:
- *
- * <pre>
- * read(targets, 0, targets.length);
- * </pre>
+ * If a read operation is in progress, subsequent threads will block until
+ * the read is completed and will then contend for the ability to read.
+ * </p>
+ * <p>
+ * Calling this method is equivalent to calling {@code read(targets, 0,
+ * targets.length);}
+ * </p>
*
- * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
* @param targets
- * the array of byte buffers to receive the bytes being read.
+ * the array of byte buffers into which the bytes will be copied.
* @return the number of bytes actually read.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread during this read
+ * operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @throws NotYetConnectedException
+ * if this channel is not yet connected.
+ * @since Android 1.0
*/
public synchronized final long read(ByteBuffer[] targets)
throws IOException {
@@ -368,114 +368,101 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
}
/**
- * Writes bytes from the given buffer to the channel.
- * <p>
- * The maximum number of bytes that will be written is the
- * <code>remaining()</code> number of bytes in the buffer when the method
- * invoked. The bytes will be written from the buffer starting at the
- * buffer's <code>position</code>.
- * </p>
+ * Writes bytes from the given byte buffer to this socket channel. The
+ * maximum number of bytes that are written is the remaining number of bytes
+ * in the buffer when this method is invoked. The bytes are taken from the
+ * buffer starting at the buffer's position.
* <p>
- * The call may block if other threads are also attempting to write on the
+ * The call may block if other threads are also attempting to write to the
* same channel.
* </p>
* <p>
- * Upon completion, the buffer's <code>position()</code> is updated to the
- * end of the bytes that were written. The buffer's <code>limit()</code>
- * is unmodified.
+ * Upon completion, the buffer's position is updated to the end of the bytes
+ * that have been written. The buffer's limit is not changed.
* </p>
*
- * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
* @param source
* the byte buffer containing the bytes to be written.
* @return the number of bytes actually written.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if another thread closes the channel during the write.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if the channel was already closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @throws NotYetConnectedException
+ * if this channel is not connected yet.
+ * @since Android 1.0
*/
public abstract int write(ByteBuffer source) throws IOException;
/**
- * Writes a subset of the given bytes from the buffers to the channel.
- * <p>
- * This method attempts to write all of the <code>remaining()</code> bytes
- * from <code>length</code> byte buffers, in order, starting at
- * <code>sources[offset]</code>. The number of bytes actually written is
- * returned.
- * </p>
+ * Writes bytes from a subset of the specified array of buffers into this
+ * socket channel. The subset is defined by {@code offset} and {@code
+ * length}, indicating the first buffer and the number of buffers to use.
* <p>
* If a write operation is in progress, subsequent threads will block until
- * the write is completed, and will then contend for the ability to write.
+ * the write is completed and then contend for the ability to write.
* </p>
*
- * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
- * int, int)
* @param sources
- * the array of byte buffers containing the source of remaining
- * bytes that will be attempted to be written.
+ * the array of byte buffers that is the source for bytes written
+ * to this channel.
* @param offset
- * the index of the first buffer to write.
+ * the index of the first buffer in {@code buffers }to get bytes
+ * from.
* @param length
- * the number of buffers to write.
- * @return the number of bytes actually written.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
+ * the number of buffers to get bytes from.
+ * @return the number of bytes actually written to this channel.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread during this write
+ * operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IndexOutOfBoundsException
+ * if {@code offset < 0} or {@code length < 0}, or if {@code
+ * offset + length} is greater than the size of {@code sources}.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @throws NotYetConnectedException
+ * if this channel is not yet connected.
+ * @since Android 1.0
*/
public abstract long write(ByteBuffer[] sources, int offset, int length)
throws IOException;
/**
- * Writes bytes from all the given buffers to the channel.
+ * Writes bytes from all the given byte buffers to this socket channel.
* <p>
- * This method is equivalent to:
- *
- * <pre>
- * write(buffers, 0, buffers.length);
- * </pre>
- *
+ * Calling this method is equivalent to calling {@code write(sources, 0,
+ * sources.length);}
* </p>
*
- * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
* @param sources
- * the buffers containing bytes to be written.
+ * the buffers containing bytes to write.
* @return the number of bytes actually written.
- * @throws NotYetConnectedException
- * If the channel is not connected yet.
- * @throws ClosedChannelException
- * If the channel is already closed.
* @throws AsynchronousCloseException
- * If the channel is closed by another thread while this method
- * is in operation.
+ * if this channel is closed by another thread during this write
+ * operation.
* @throws ClosedByInterruptException
- * If another thread interrupts the calling thread while the
- * operation is in progress. The calling thread will have the
- * interrupt state set, and the channel will be closed.
+ * if another thread interrupts the calling thread while this
+ * operation is in progress. The interrupt state of the calling
+ * thread is set and the channel is closed.
+ * @throws ClosedChannelException
+ * if this channel is closed.
* @throws IOException
- * Some other IO error occurred.
- *
+ * if another I/O error occurs.
+ * @throws NotYetConnectedException
+ * if this channel is not yet connected.
+ * @since Android 1.0
*/
public synchronized final long write(ByteBuffer[] sources)
throws IOException {
diff --git a/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java b/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
index cd69a61..dfb475b 100644
--- a/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
+++ b/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
@@ -18,17 +18,19 @@ package java.nio.channels;
/**
- * Thrown when trying to use an unresolved network address in a network
- * operation.
+ * An {@code UnresolvedAddressException} is thrown when trying to use an
+ * unresolved network address in a network operation.
*
+ * @since Android 1.0
*/
public class UnresolvedAddressException extends IllegalArgumentException {
private static final long serialVersionUID = 6136959093620794148L;
/**
- * Default constructor.
+ * Constructs an {@code UnresolvedAddressException}.
*
+ * @since Android 1.0
*/
public UnresolvedAddressException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java b/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
index 29e6840..ba613ac 100644
--- a/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
+++ b/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
@@ -18,16 +18,19 @@ package java.nio.channels;
/**
- * Thrown when connecting or binding to an unsupported address type.
+ * An {@code UnsupportedAddressTypeException} is thrown when connecting or
+ * binding to an unsupported address type.
*
+ * @since Android 1.0
*/
public class UnsupportedAddressTypeException extends IllegalArgumentException {
private static final long serialVersionUID = -2964323842829700493L;
/**
- * Default constructor.
+ * Constructs an {@code UnsupportedAddressTypeException}.
*
+ * @since Android 1.0
*/
public UnsupportedAddressTypeException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/WritableByteChannel.java b/nio/src/main/java/java/nio/channels/WritableByteChannel.java
index ccfa558..f8ea77f 100644
--- a/nio/src/main/java/java/nio/channels/WritableByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/WritableByteChannel.java
@@ -21,13 +21,15 @@ import java.io.IOException;
import java.nio.ByteBuffer;
/**
- * A WritableByteChannel is a type of Channel that can write bytes.
+ * A {@code WritableByteChannel} is a type of {@link Channel} that can write
+ * bytes.
* <p>
- * Writes are synchronous on a WritableByteChannel, that is, if a write is
- * already in progress on the channel then subsequent writes will block until
- * the first write completes. It is undefined whether non-write operations will
- * block.
+ * Write operations are synchronous on a {@code WritableByteChannel}, that is,
+ * if a write is already in progress on the channel then subsequent writes will
+ * block until the first write completes. It is undefined whether non-write
+ * operations will block.
*
+ * @since Android 1.0
*/
public interface WritableByteChannel extends Channel {
@@ -63,6 +65,7 @@ public interface WritableByteChannel extends Channel {
* write.
* @throws IOException
* another IO exception occurs, details are in the message.
+ * @since Android 1.0
*/
public int write(ByteBuffer buffer) throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/package.html b/nio/src/main/java/java/nio/channels/package.html
index 454b671..7ca1a48 100644
--- a/nio/src/main/java/java/nio/channels/package.html
+++ b/nio/src/main/java/java/nio/channels/package.html
@@ -3,7 +3,8 @@
<p>
Channels provide a way to connect to sources of data such as
files, sockets or other structures that allow input and/or output of
- data. The selector supports multiplexing of non-blocking channels.
+ data. Selectors support multiplexing of non-blocking channels.
</p>
+ @since Android 1.0
</body>
</html>
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java b/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
index bed6db8..8f84e10 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
@@ -27,15 +27,17 @@ import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
/**
- * This class roots the implementation of interruptible channels.
+ * {@code AbstractInterruptibleChannel} is the root class for interruptible
+ * channels.
* <p>
* The basic usage pattern for an interruptible channel is to invoke
- * <code>begin()</code> before any IO operations, then
- * <code>end(boolean)</code> after completing the operation. The argument to
- * the end method shows whether there has been any change to the java
- * environment that is visible to the API user.
+ * {@code begin()} before any I/O operation that potentially blocks
+ * indefinitely, then {@code end(boolean)} after completing the operation. The
+ * argument to the {@code end} method should indicate if the I/O operation has
+ * actually completed so that any change may be visible to the invoker.
* </p>
*
+ * @since Android 1.0
*/
public abstract class AbstractInterruptibleChannel implements Channel,
InterruptibleChannel {
@@ -67,29 +69,42 @@ public abstract class AbstractInterruptibleChannel implements Channel,
/**
* Default constructor.
+ *
+ * @since Android 1.0
*/
protected AbstractInterruptibleChannel() {
super();
}
/**
- * Returns whether the channel is open.
+ * Indicates whether this channel is open.
*
- * @return true if the channel is open, and false if it is closed.
+ * @return {@code true} if this channel is open, {@code false} if it is
+ * closed.
* @see java.nio.channels.Channel#isOpen()
+ * @since Android 1.0
*/
public synchronized final boolean isOpen() {
return !closed;
}
/**
- * Closes the channel.
+ * Closes an open channel. If the channel is already closed then this method
+ * has no effect, otherwise it closes the receiver via the
+ * {@code implCloseChannel} method.
+ * <p>
+ * If an attempt is made to perform an operation on a closed channel then a
+ * {@link java.nio.channels.ClosedChannelException} is thrown.
+ * </p>
* <p>
- * If the channel is already closed then this method has no effect,
- * otherwise it closes the receiver via the implCloseChannel method.
+ * If multiple threads attempt to simultaneously close a channel, then only
+ * one thread will run the closure code and the others will be blocked until
+ * the first one completes.
* </p>
*
- * @see java.nio.channels.Channel#close()
+ * @throws IOException
+ * if a problem occurs while closing this channel.
+ * @since Android 1.0
*/
public final void close() throws IOException {
if (!closed) {
@@ -103,10 +118,11 @@ public abstract class AbstractInterruptibleChannel implements Channel,
}
/**
- * Start an IO operation that is potentially blocking.
- * <p>
- * Once the operation is completed the application should invoke a
- * corresponding <code>end(boolean)</code>.
+ * Indicates the beginning of a code section that includes an I/O operation
+ * that is potentially blocking. After this operation, the application
+ * should invoke the corresponding {@code end(boolean)} method.
+ *
+ * @since Android 1.0
*/
protected final void begin() {
// FIXME: be accommodate before VM actually provides
@@ -131,16 +147,19 @@ public abstract class AbstractInterruptibleChannel implements Channel,
}
/**
- * End an IO operation that was previously started with <code>begin()</code>.
+ * Indicates the end of a code section that has been started with
+ * {@code begin()} and that includes a potentially blocking I/O operation.
*
* @param success
- * pass true if the operation succeeded and had a side effect on
- * the Java system, or false if not.
+ * pass {@code true} if the blocking operation has succeeded and
+ * has had a noticeable effect; {@code false} otherwise.
* @throws AsynchronousCloseException
- * the channel was closed while the IO operation was in
- * progress.
- * @throws java.nio.channels.ClosedByInterruptException
- * the thread conducting the IO operation was interrupted.
+ * if this channel is closed by another thread while this method
+ * is executing.
+ * @throws ClosedByInterruptException
+ * if another thread interrupts the calling thread while this
+ * method is executing.
+ * @since Android 1.0
*/
protected final void end(boolean success) throws AsynchronousCloseException {
// FIXME: be accommodate before VM actually provides
@@ -163,18 +182,21 @@ public abstract class AbstractInterruptibleChannel implements Channel,
}
/**
- * Implements the close channel behavior.
+ * Implements the channel closing behavior.
* <p>
* Closes the channel with a guarantee that the channel is not currently
- * closed via <code>close()</code> and that the method is thread-safe.
+ * closed through another invocation of {@code close()} and that the method
+ * is thread-safe.
* </p>
* <p>
- * any outstanding threads blocked on IO operations on this channel must be
- * released with either a normal return code, or an
- * <code>AsynchronousCloseException</code>.
+ * Any outstanding threads blocked on I/O operations on this channel must be
+ * released with either a normal return code, or by throwing an
+ * {@code AsynchronousCloseException}.
+ * </p>
*
* @throws IOException
- * if a problem occurs closing the channel.
+ * if a problem occurs while closing the channel.
+ * @since Android 1.0
*/
protected abstract void implCloseChannel() throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
index 97184a2..a9bee52 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -29,12 +29,11 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Abstract class for selectable channels.
- * <p>
- * In this class, there are methods about registering/deregistering a channel,
- * about channel closing. It realize the multi-thread safe.
- * </p>
+ * {@code AbstractSelectableChannel} is the base implementation class for
+ * selectable channels. It declares methods for registering, unregistering and
+ * closing selectable channels. It is thread-safe.
*
+ * @since Android 1.0
*/
public abstract class AbstractSelectableChannel extends SelectableChannel {
@@ -53,10 +52,11 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
boolean isBlocking = true;
/**
- * Constructor for this class.
+ * Constructs a new {@code AbstractSelectableChannel}.
*
* @param selectorProvider
- * A instance of SelectorProvider
+ * the selector provider that creates this channel.
+ * @since Android 1.0
*/
protected AbstractSelectableChannel(SelectorProvider selectorProvider) {
super();
@@ -64,24 +64,35 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * Answer the SelectorProvider of this channel.
+ * Returns the selector provider that has created this channel.
*
* @see java.nio.channels.SelectableChannel#provider()
- * @return The provider of this channel.
+ * @return this channel's selector provider.
+ * @since Android 1.0
*/
public final SelectorProvider provider() {
return provider;
}
/**
- * @see java.nio.channels.SelectableChannel#isRegistered()
+ * Indicates whether this channel is registered with one or more selectors.
+ *
+ * @return {@code true} if this channel is registered with a selector,
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
synchronized public final boolean isRegistered() {
return !keyList.isEmpty();
}
/**
- * @see java.nio.channels.SelectableChannel#keyFor(java.nio.channels.Selector)
+ * Gets this channel's selection key for the specified selector.
+ *
+ * @param selector
+ * the selector with which this channel has been registered.
+ * @return the selection key for the channel or {@code null} if this channel
+ * has not been registered with {@code selector}.
+ * @since Android 1.0
*/
synchronized public final SelectionKey keyFor(Selector selector) {
for (int i = 0; i < keyList.size(); i++) {
@@ -94,18 +105,32 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * Realize the register function.
- * <p>
- * It registers current channel to the selector, then answer the selection
- * key. The channel must be open and the interest op set must be valid. If
- * the current channel is already registered to the selector, the method
- * only set the new interest op set; otherwise it will call the
- * <code>register</code> in <code>selector</code>, and add the relative
- * key to the key set of the current channel.
- * </p>
+ * Registers this channel with the specified selector for the specified
+ * interest set. If the channel is already registered with the selector, the
+ * {@link SelectionKey interest set} is updated to {@code interestSet} and
+ * the corresponding selection key is returned. If the channel is not yet
+ * registered, this method calls the {@code register} method of
+ * {@code selector} and adds the selection key to this channel's key set.
*
- * @see java.nio.channels.SelectableChannel#register(java.nio.channels.Selector,
- * int, java.lang.Object)
+ * @param selector
+ * the selector with which to register this channel.
+ * @param interestSet
+ * this channel's {@link SelectionKey interest set}.
+ * @param attachment
+ * the object to attach, can be {@code null}.
+ * @return the selection key for this registration.
+ * @throws CancelledKeyException
+ * if this channel is registered but its key has been canceled.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IllegalArgumentException
+ * if {@code interestSet} is not supported by this channel.
+ * @throws IllegalBlockingModeException
+ * if this channel is in blocking mode.
+ * @throws IllegalSelectorException
+ * if this channel does not have the same provider as the given
+ * selector.
+ * @since Android 1.0
*/
public final SelectionKey register(Selector selector, int interestSet,
Object attachment) throws ClosedChannelException {
@@ -149,9 +174,14 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * Implement the closing function.
+ * Implements the channel closing behavior. Calls
+ * {@code implCloseSelectableChannel()} first, then loops through the list
+ * of selection keys and cancels them, which unregisters this channel from
+ * all selectors it is registered with.
*
- * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
+ * @throws IOException
+ * if a problem occurs while closing the channel.
+ * @since Android 1.0
*/
synchronized protected final void implCloseChannel() throws IOException {
implCloseSelectableChannel();
@@ -164,15 +194,21 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * Implement the closing function of the SelectableChannel.
+ * Implements the closing function of the SelectableChannel. This method is
+ * called from {@code implCloseChannel()}.
*
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O exception occurs.
+ * @since Android 1.0
*/
protected abstract void implCloseSelectableChannel() throws IOException;
/**
- * @see java.nio.channels.SelectableChannel#isBlocking()
+ * Indicates whether this channel is in blocking mode.
+ *
+ * @return {@code true} if this channel is blocking, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public final boolean isBlocking() {
synchronized (blockingLock) {
@@ -181,19 +217,34 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * @see java.nio.channels.SelectableChannel#blockingLock()
+ * Gets the object used for the synchronization of {@code register} and
+ * {@code configureBlocking}.
+ *
+ * @return the synchronization object.
+ * @since Android 1.0
*/
public final Object blockingLock() {
return blockingLock;
}
/**
- * Set the blocking mode of this channel.
+ * Sets the blocking mode of this channel. A call to this method blocks if
+ * other calls to this method or to {@code register} are executing. The
+ * actual setting of the mode is done by calling
+ * {@code implConfigureBlocking(boolean)}.
*
- * @see java.nio.channels.SelectableChannel#configureBlocking(boolean)
* @param blockingMode
- * <code>true</code> for blocking mode; <code>false</code>
- * for non-blocking mode.
+ * {@code true} for setting this channel's mode to blocking,
+ * {@code false} to set it to non-blocking.
+ * @return this channel.
+ * @throws ClosedChannelException
+ * if this channel is closed.
+ * @throws IllegalBlockingModeException
+ * if {@code block} is {@code true} and this channel has been
+ * registered with at least one selector.
+ * @throws IOException
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public final SelectableChannel configureBlocking(boolean blockingMode)
throws IOException {
@@ -215,13 +266,14 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
/**
- * Implement the setting of blocking mode.
+ * Implements the setting of the blocking mode.
*
* @param blockingMode
- * <code>true</code> for blocking mode; <code>false</code>
- * for non-blocking mode.
+ * {@code true} for setting this channel's mode to blocking,
+ * {@code false} to set it to non-blocking.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
protected abstract void implConfigureBlocking(boolean blockingMode)
throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
index bca1f87..e839126 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
@@ -19,11 +19,10 @@ package java.nio.channels.spi;
import java.nio.channels.SelectionKey;
/**
- * Abstract class for selection key.
- * <p>
- * The class takes charge of the validation and cancellation of key.
- * </p>
- *
+ * {@code AbstractSelectionKey} is the base implementation class for selection keys.
+ * It implements validation and cancellation methods.
+ *
+ * @since Android 1.0
*/
public abstract class AbstractSelectionKey extends SelectionKey {
@@ -33,23 +32,34 @@ public abstract class AbstractSelectionKey extends SelectionKey {
boolean isValid = true;
/**
- * Constructor for this class.
+ * Constructs a new {@code AbstractSelectionKey}.
+ *
+ * @since Android 1.0
*/
protected AbstractSelectionKey() {
super();
}
/**
- * @see java.nio.channels.SelectionKey#isValid()
+ * Indicates whether this key is valid. A key is valid as long as it has not
+ * been canceled.
+ *
+ * @return {@code true} if this key has not been canceled, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public final boolean isValid() {
return isValid;
}
/**
- * Cancels this key and adds it to the cancelled key set.
+ * Cancels this key.
+ * <p>
+ * A key that has been canceled is no longer valid. Calling this method on
+ * an already canceled key does nothing.
+ * </p>
*
- * @see java.nio.channels.SelectionKey#cancel()
+ * @since Android 1.0
*/
public final void cancel() {
if (isValid) {
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
index a744fb8..adef243 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
@@ -24,13 +24,12 @@ import java.util.HashSet;
import java.util.Set;
/**
- * Abstract class for selectors.
- * <p>
- * This class realizes the interruption of selection by <code>begin</code> and
- * <code>end</code>. It also holds the cancelled and the deletion of the key
+ * {@code AbstractSelector} is the base implementation class for selectors.
+ * It realizes the interruption of selection by {@code begin} and
+ * {@code end}. It also holds the cancellation and the deletion of the key
* set.
- * </p>
*
+ * @since Android 1.0
*/
public abstract class AbstractSelector extends Selector {
private volatile boolean isOpen = true;
@@ -43,19 +42,24 @@ public abstract class AbstractSelector extends Selector {
private Set<SelectionKey> cancelledKeysSet = new HashSet<SelectionKey>();
/**
- * Constructor for this class.
+ * Constructs a new {@code AbstractSelector}.
*
* @param selectorProvider
- * A instance of SelectorProvider
+ * the selector provider that creates this selector.
+ * @since Android 1.0
*/
protected AbstractSelector(SelectorProvider selectorProvider) {
provider = selectorProvider;
}
/**
- * Closes this channel.
+ * Closes this selector. This method does nothing if this selector is
+ * already closed. The actual closing must be implemented by subclasses in
+ * {@code implCloseSelector()}.
*
- * @see java.nio.channels.Selector#close()
+ * @throws IOException
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public synchronized final void close() throws IOException {
if (isOpen) {
@@ -68,54 +72,63 @@ public abstract class AbstractSelector extends Selector {
* Implements the closing of this channel.
*
* @throws IOException
- * If some I/O exception occurs.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
protected abstract void implCloseSelector() throws IOException;
/**
- * @see java.nio.channels.Selector#isOpen()
+ * Indicates whether this selector is open.
+ *
+ * @return {@code true} if this selector is not closed, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public final boolean isOpen() {
return isOpen;
}
/**
- * Returns the SelectorProvider of this channel.
+ * Gets this selector's provider.
*
- * @see java.nio.channels.Selector#provider()
+ * @return the provider of this selector.
+ * @since Android 1.0
*/
public final SelectorProvider provider() {
return provider;
}
/**
- * Returns the cancelled key set of this channel.
+ * Returns this channel's set of canceled selection keys.
*
- * @return The cancelled key set.
+ * @return the set of canceled selection keys.
+ * @since Android 1.0
*/
protected final Set<SelectionKey> cancelledKeys() {
return cancelledKeysSet;
}
/**
- * Registers a channel to this selector.
+ * Registers a channel with this selector.
*
* @param channel
- * The channel to be registered.
+ * the channel to be registered.
* @param operations
- * The interest set.
+ * the {@link SelectionKey interest set} of {@code channel}.
* @param attachment
- * The attachment of the key.
- * @return The key related with the channel and the selector.
+ * the attachment for the selection key.
+ * @return the key related to the channel and this selector.
+ * @since Android 1.0
*/
protected abstract SelectionKey register(AbstractSelectableChannel channel,
int operations, Object attachment);
/**
- * Deletes the key from channel's key set.
+ * Deletes the key from the channel's key set.
*
* @param key
- * The key.
+ * the key.
+ * @since Android 1.0
*/
protected final void deregister(AbstractSelectionKey key) {
((AbstractSelectableChannel) key.channel()).deregister(key);
@@ -123,7 +136,11 @@ public abstract class AbstractSelector extends Selector {
}
/**
- * This starts a potentially blocking I/O operation
+ * Indicates the beginning of a code section that includes an I/O operation
+ * that is potentially blocking. After this operation, the application
+ * should invoke the corresponding {@code end(boolean)} method.
+ *
+ * @since Android 1.0
*/
protected final void begin() {
// FIXME: be accommodate before VM actually provides
@@ -143,7 +160,10 @@ public abstract class AbstractSelector extends Selector {
}
/**
- * This ends a potentially blocking I/O operation
+ * Indicates the end of a code section that has been started with
+ * {@code begin()} and that includes a potentially blocking I/O operation.
+ *
+ * @since Android 1.0
*/
protected final void end() {
// FIXME: be accommodate before VM actually provides
diff --git a/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java b/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
index 92733c7..b4b18e3 100644
--- a/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
+++ b/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
@@ -34,16 +34,17 @@ import org.apache.harmony.luni.platform.Platform;
import org.apache.harmony.nio.internal.SelectorProviderImpl;
/**
- * Provider for nio selector and selectable channel.
+ * {@code SelectorProvider} is an abstract base class that declares methods for
+ * providing instances of {@link DatagramChannel}, {@link Pipe},
+ * {@link java.nio.channels.Selector} , {@link ServerSocketChannel}, and
+ * {@link SocketChannel}. All the methods of this class are thread-safe.
* <p>
- * The provider can be got by system property or the configuration file in a jar
- * file, if not, the system default provider will return. The main function of
- * this class is to return the instance of implementation class of
- * <code>DatagramChannel</code>, <code>Pipe</code>, <code>Selector</code> ,
- * <code>ServerSocketChannel</code>, and <code>SocketChannel</code>. All
- * the methods of this class are multi-thread safe.
+ * A provider instance can be retrieved through a system property or the
+ * configuration file in a jar file; if no provide is available that way then
+ * the system default provider is returned.
* </p>
*
+ * @since Android 1.0
*/
public abstract class SelectorProvider extends Object {
@@ -58,11 +59,12 @@ public abstract class SelectorProvider extends Object {
private static Channel inheritedChannel;
/**
- * Constructor for this class.
+ * Constructs a new {@code SelectorProvider}.
*
* @throws SecurityException
- * If there is a security manager, and it denies
- * RuntimePermission("selectorProvider").
+ * if there is a security manager installed that does not permit
+ * the runtime permission labeled "selectorProvider".
+ * @since Android 1.0
*/
protected SelectorProvider() {
super();
@@ -73,21 +75,21 @@ public abstract class SelectorProvider extends Object {
}
/**
- * Get the provider by following steps in the first calling.
- * <p>
+ * Gets a provider instance by executing the following steps when called for
+ * the first time:
* <ul>
- * <li> If the system property "java.nio.channels.spi.SelectorProvider" is
- * set, the value of this property is the class name of the return provider.
- * </li>
- * <li>If there is a provider-configuration file named
- * "java.nio.channels.spi.SelectorProvider" in META-INF/services of some jar
- * file valid in the system class loader, the first class name is the return
- * provider's class name. </li>
- * <li> Otherwise, a system default provider will be returned. </li>
+ * <li> if the system property "java.nio.channels.spi.SelectorProvider" is
+ * set, the value of this property is the class name of the provider
+ * returned; </li>
+ * <li>if there is a provider-configuration file named
+ * "java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar
+ * file valid in the system class loader, the first class name is the
+ * provider's class name; </li>
+ * <li> otherwise, a system default provider will be returned.</li>
* </ul>
- * </p>
*
- * @return The provider.
+ * @return the provider.
+ * @since Android 1.0
*/
synchronized public static SelectorProvider provider() {
if (null == provider) {
@@ -195,62 +197,76 @@ public abstract class SelectorProvider extends Object {
}
/**
- * Create a new open <code>DatagramChannel</code>.
+ * Creates a new open {@code DatagramChannel}.
*
- * @return The channel.
+ * @return the new channel.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract DatagramChannel openDatagramChannel() throws IOException;
/**
- * Create a new <code>Pipe</code>.
+ * Creates a new {@code Pipe}.
*
- * @return The pipe.
+ * @return the new pipe.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract Pipe openPipe() throws IOException;
/**
- * Create a new selector.
+ * Creates a new selector.
*
- * @return The selector.
+ * @return the new selector.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract AbstractSelector openSelector() throws IOException;
/**
- * Create a new open <code>ServerSocketChannel</code>.
+ * Creates a new open {@code ServerSocketChannel}.
*
- * @return The channel.
+ * @return the new channel.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract ServerSocketChannel openServerSocketChannel()
throws IOException;
/**
- * Create a new open <code>SocketChannel</code>.
+ * Create a new open {@code SocketChannel}.
*
- * @return The channel.
+ * @return the new channel.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
+ * @since Android 1.0
*/
public abstract SocketChannel openSocketChannel() throws IOException;
/**
- * Answer the channel inherited from the instance which created this JVM.
+ * Returns the channel inherited from the instance that created this
+ * virtual machine.
*
- * @return The channel.
+ * @return the channel.
* @throws IOException
- * If some I/O exception occurred.
+ * if an I/O error occurs.
* @throws SecurityException
- * If there is a security manager, and it denies
- * RuntimePermission("selectorProvider").
+ * if there is a security manager installed that does not permit
+ * the runtime permission labeled "selectorProvider".
+ * @since Android 1.0
*/
public Channel inheritedChannel() throws IOException {
+ // BEGIN android-added
+ SecurityManager smngr = System.getSecurityManager();
+ if (smngr != null) {
+ smngr.checkPermission(
+ new RuntimePermission("inheritedChannel")); //$NON-NLS-1$
+ }
+ // END android-added
if (null == inheritedChannel) {
inheritedChannel = Platform.getNetworkSystem().inheritedChannel();
}
diff --git a/nio/src/main/java/java/nio/channels/spi/package.html b/nio/src/main/java/java/nio/channels/spi/package.html
index e7b8a49..fde3d3e 100644
--- a/nio/src/main/java/java/nio/channels/spi/package.html
+++ b/nio/src/main/java/java/nio/channels/spi/package.html
@@ -3,5 +3,6 @@
<p>
Service-provider classes for nio channels.
</p>
+ @since Android 1.0
</body>
</html>
diff --git a/nio/src/main/java/java/nio/package.html b/nio/src/main/java/java/nio/package.html
index 17d6ceb..46b6aaf 100644
--- a/nio/src/main/java/java/nio/package.html
+++ b/nio/src/main/java/java/nio/package.html
@@ -5,11 +5,12 @@
</p>
<p>
There are buffers for most primitive data types such as
- FloatBuffer, IntBuffer, ... They all give means to put/get data from the
- buffers, to compact, slice or duplicate it, or to wrap an existing
- array. A buffer also manages the position of the current element in the
- buffer, lets you rewind to the beginning, skip elements or go to the
- last element.
+ <code>FloatBuffer</code>, <code>IntBuffer</code>, etc. These classes
+ provide methods to get and put data from the
+ buffers, to compact, slice or duplicate them, or to wrap an existing
+ array. Buffers also manage the position of the current element in the
+ buffer, they can be rewound to the beginning and allow skipping of elements.
</p>
+ @since Android 1.0
</body>
</html>
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java b/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
index ec12665..52a7b65 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
@@ -1,5 +1,4 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
+/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
index 54a7c2e..687b438 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
@@ -412,7 +412,7 @@ public abstract class FileChannelImpl extends FileChannel {
}
ByteBuffer buffer = null;
-
+ // BEGIN android-changed
try {
if (src instanceof FileChannel) {
FileChannel fileSrc = (FileChannel) src;
@@ -435,6 +435,7 @@ public abstract class FileChannelImpl extends FileChannel {
((DirectBuffer) buffer).free();
}
}
+ // END android-changed
}
public long transferTo(long position, long count, WritableByteChannel target)
@@ -461,7 +462,7 @@ public abstract class FileChannelImpl extends FileChannel {
return kernelTransfer(handle, ((SocketChannelImpl) target).getFD(),
position, count);
}
-
+ // BEGIN android-changed
try {
buffer = map(MapMode.READ_ONLY, position, count);
return target.write(buffer);
@@ -473,6 +474,7 @@ public abstract class FileChannelImpl extends FileChannel {
((DirectBuffer) buffer).free();
}
}
+ // END android-changed
}
private long kernelTransfer(int l, FileDescriptor fd, long position,
@@ -593,7 +595,7 @@ public abstract class FileChannelImpl extends FileChannel {
int[] handles = new int[length];
int[] offsets = new int[length];
int[] lengths = new int[length];
-
+ // BEGIN android-changed
// list of allocated direct ByteBuffers to prevent them from being GC-ed
DirectBuffer[] allocatedBufs = new DirectBuffer[length];
@@ -614,6 +616,7 @@ public abstract class FileChannelImpl extends FileChannel {
handles[i] = ((DirectBuffer) buffer).getEffectiveAddress().toInt();
lengths[i] = buffer.remaining();
}
+ // END android-changed
long bytesWritten = 0;
boolean completed = false;
@@ -625,13 +628,14 @@ public abstract class FileChannelImpl extends FileChannel {
completed = true;
} finally {
end(completed);
-
+ // BEGIN android-added
// free temporary direct buffers
for (int i = 0; i < length; ++i) {
if (allocatedBufs[i] != null) {
allocatedBufs[i].free();
}
}
+ // END android-added
}
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
index b8b6a15..f8e7d80 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
@@ -182,9 +182,12 @@ final class SelectorImpl extends AbstractSelector {
doCancel();
int[] readyChannels = null;
boolean isBlock = (SELECT_NOW != timeout);
- if (keys.size() == 0) {
- return 0;
- }
+ // BEGIN android-removed
+ // copied from newer version of harmony
+ // if (keys.size() == 0) {
+ // return 0;
+ // }
+ // END android-removed
prepareChannels();
try {
if (isBlock) {
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
index 0786498..3bc368f 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
@@ -264,6 +264,10 @@ public class ServerSocketChannelImpl extends ServerSocketChannel implements
synchronized (this) {
super.implAccept(aSocket);
sockChannel.setConnected();
+ // BEGIN android-added
+ // copied from a newer version of harmony
+ sockChannel.setBound(true);
+ // END android-added
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
index bc8a9bb..8e6c52f 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
@@ -120,8 +120,11 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorHandler {
// At first, uninitialized.
int status = SOCKET_STATUS_UNINIT;
+ // BEGIN android-changed
+ // copied from a newer version of harmony
// whether the socket is bound
- boolean isBound = false;
+ volatile boolean isBound = false;
+ // END adroid-changed
private final Object readLock = new Object();
@@ -229,6 +232,13 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorHandler {
status = SOCKET_STATUS_CONNECTED;
}
+ // BEGIN android-added
+ // copied from a newer version of harmony
+ void setBound(boolean flag) {
+ isBound = flag;
+ }
+ // END android-added
+
/*
* @see java.nio.channels.SocketChannel#isConnectionPending()
*/
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java b/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
index 35c3900..d291f12 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
@@ -23,7 +23,16 @@
package org.apache.harmony.nio.internal.nls;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+// BEGIN android-changed
import org.apache.harmony.luni.util.MsgHelp;
+// END android-changed
/**
* This class retrieves strings from a resource bundle and returns them,
@@ -40,9 +49,11 @@ import org.apache.harmony.luni.util.MsgHelp;
*
*/
public class Messages {
-
+
+ // BEGIN android-changed
private static final String sResource =
"org.apache.harmony.nio.internal.nls.messages"; //$NON-NLS-1$
+ // END android-changed
/**
* Retrieves a message which has no arguments.
@@ -52,7 +63,9 @@ public class Messages {
* @return String the message for that key in the system message bundle.
*/
static public String getString(String msg) {
+ // BEGIN android-changed
return MsgHelp.getString(sResource, msg);
+ // END android-changed
}
/**
@@ -119,6 +132,12 @@ public class Messages {
* @return String the message for that key in the system message bundle.
*/
static public String getString(String msg, Object[] args) {
+ // BEGIN android-changed
return MsgHelp.getString(sResource, msg, args);
+ // END android-changed
}
+
+ // BEGIN android-note
+ // Duplicate code was dropped in favor of using MsgHelp.
+ // END android-note
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
index 57c1471..f58bf7d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
@@ -16,12 +16,17 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.InvalidMarkException;
import junit.framework.TestCase;
-
+@TestTargetClass(java.nio.Buffer.class)
/**
* Tests a java.nio.Buffer instance.
*/
@@ -37,12 +42,29 @@ public class AbstractBufferTest extends TestCase {
protected void tearDown() throws Exception{
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check capacity with which the buffer is created.",
+ targets = {
+ @TestTarget(
+ methodName = "capacity",
+ methodArgs = {}
+ )
+ })
public void testCapacity() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ // level = TestLevel.PARTIAL
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clear",
+ methodArgs = {}
+ )
+ })
public void testClear() {
// save state
int oldPosition = baseBuf.position();
@@ -63,7 +85,15 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check that mark is discarted.",
+ targets = {
+ @TestTarget(
+ methodName = "flip",
+ methodArgs = {}
+ )
+ })
public void testFlip() {
// save state
int oldPosition = baseBuf.position();
@@ -84,7 +114,15 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hasRemaining",
+ methodArgs = {}
+ )
+ })
public void testHasRemaining() {
// save state
int oldPosition = baseBuf.position();
@@ -98,7 +136,15 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
baseBuf.isReadOnly();
}
@@ -106,6 +152,15 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for int limit()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "limit",
+ methodArgs = {}
+ )
+ })
public void testLimit() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
@@ -114,6 +169,15 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for Buffer limit(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "limit",
+ methodArgs = {int.class}
+ )
+ })
public void testLimitint() {
// save state
int oldPosition = baseBuf.position();
@@ -163,7 +227,15 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "mark",
+ methodArgs = {}
+ )
+ })
public void testMark() {
// save state
int oldPosition = baseBuf.position();
@@ -190,6 +262,15 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for int position()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void testPosition() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
@@ -198,6 +279,15 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for Buffer position(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {int.class}
+ )
+ })
public void testPositionint() {
// save state
int oldPosition = baseBuf.position();
@@ -248,11 +338,27 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "remaining",
+ methodArgs = {}
+ )
+ })
public void testRemaining() {
assertEquals(baseBuf.remaining(), baseBuf.limit() - baseBuf.position());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "reset",
+ methodArgs = {}
+ )
+ })
public void testReset() {
// save state
int oldPosition = baseBuf.position();
@@ -283,7 +389,15 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "rewind",
+ methodArgs = {}
+ )
+ })
public void testRewind() {
// save state
int oldPosition = baseBuf.position();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
index cefb2da..5b4cbc5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
@@ -96,6 +96,7 @@ public class AllTests {
suite.addTestSuite(DuplicateDirectByteBufferTest.class);
suite.addTestSuite(WrappedIntBufferTest.class);
suite.addTestSuite(HeapCharBufferTest.class);
+ suite.addTestSuite(MappedByteBufferTest.class);
//$JUnit-END$
return suite;
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
index 4046739..7d8c763 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
@@ -16,17 +16,32 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
+@TestTargetClass(BufferOverflowException.class)
public class BufferOverflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new BufferOverflowException());
@@ -35,6 +50,15 @@ public class BufferOverflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new BufferOverflowException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java
index a7cc642..a2ee5fd 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java
@@ -17,16 +17,33 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.Buffer;
import java.nio.InvalidMarkException;
import junit.framework.TestCase;
-
/**
* Test a java.nio.Buffer instance.
*/
+@TestTargetClass(Buffer.class)
public class BufferTest extends TestCase {
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that buffer's state doesn't change after testing.",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "limit",
+ methodArgs = {}
+ )
+ })
public static void testBufferInstance(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -50,12 +67,28 @@ public class BufferTest extends TestCase {
assertEquals(buf.position(), oldPosition);
assertEquals(buf.limit(), oldLimit);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check capacity with which the buffer is created.",
+ targets = {
+ @TestTarget(
+ methodName = "capacity",
+ methodArgs = {}
+ )
+ })
public static void testCapacity(Buffer buf) {
assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
&& buf.limit() <= buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clear",
+ methodArgs = {}
+ )
+ })
public static void testClear(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -76,7 +109,16 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check that mark is discarded after a call of flip " +
+ "method. ",
+ targets = {
+ @TestTarget(
+ methodName = "flip",
+ methodArgs = {}
+ )
+ })
public static void testFlip(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -97,7 +139,15 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hasRemaining",
+ methodArgs = {}
+ )
+ })
public static void testHasRemaining(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -111,7 +161,15 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public static void testIsReadOnly(Buffer buf) {
buf.isReadOnly();
}
@@ -119,6 +177,15 @@ public class BufferTest extends TestCase {
/*
* Class under test for int limit()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "limit",
+ methodArgs = {}
+ )
+ })
public static void testLimit(Buffer buf) {
assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
&& buf.limit() <= buf.capacity());
@@ -127,6 +194,15 @@ public class BufferTest extends TestCase {
/*
* Class under test for Buffer limit(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "limit",
+ methodArgs = {int.class}
+ )
+ })
public static void testLimitint(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -176,7 +252,15 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "mark",
+ methodArgs = {}
+ )
+ })
public static void testMark(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -203,6 +287,15 @@ public class BufferTest extends TestCase {
/*
* Class under test for int position()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public static void testPosition(Buffer buf) {
assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
&& buf.limit() <= buf.capacity());
@@ -211,6 +304,15 @@ public class BufferTest extends TestCase {
/*
* Class under test for Buffer position(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {int.class}
+ )
+ })
public static void testPositionint(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -261,11 +363,27 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "remaining",
+ methodArgs = {}
+ )
+ })
public static void testRemaining(Buffer buf) {
assertEquals(buf.remaining(), buf.limit() - buf.position());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "reset",
+ methodArgs = {}
+ )
+ })
public static void testReset(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -296,7 +414,15 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "rewind",
+ methodArgs = {}
+ )
+ })
public static void testRewind(Buffer buf) {
// save state
int oldPosition = buf.position();
@@ -316,7 +442,15 @@ public class BufferTest extends TestCase {
buf.limit(oldLimit);
buf.position(oldPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Doesn't test anything. Just to remove JUnit warning.",
+ targets = {
+ @TestTarget(
+ methodName = "",
+ methodArgs = {}
+ )
+ })
public void testNothing() {
// to remove JUnit warning
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
index 3372473..5180f52 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
@@ -16,12 +16,18 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferUnderflowException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
+@TestTargetClass(BufferUnderflowException.class)
/**
* Tests for BufferUnderflowException
*/
@@ -30,6 +36,15 @@ public class BufferUnderflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new BufferUnderflowException());
@@ -38,6 +53,15 @@ public class BufferUnderflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new BufferUnderflowException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
index 6e22230..f97ad5f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
@@ -35,6 +40,7 @@ import java.util.Arrays;
* Tests java.nio.ByteBuffer
*
*/
+@TestTargetClass(ByteBuffer.class)
public class ByteBufferTest extends AbstractBufferTest {
protected static final int SMALL_TEST_LENGTH = 5;
protected static final int BUFFER_LENGTH = 250;
@@ -56,7 +62,16 @@ public class ByteBufferTest extends AbstractBufferTest {
* 1. case for check ByteBuffer testBuf properties
* 2. case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check backing array. Doesn't check boundary value " +
+ "of capacity.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: ByteBuffer testBuf properties is satisfy the conditions specification
ByteBuffer testBuf = ByteBuffer.allocate(20);
@@ -76,7 +91,16 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* test for method static ByteBuffer allocateDirect(int capacity)
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check check backing array. Doesn't check boundary " +
+ "value of capacity.",
+ targets = {
+ @TestTarget(
+ methodName = "allocateDirect",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateDirectI() {
// case: ByteBuffer testBuf properties is satisfy the conditions specification
ByteBuffer testBuf = ByteBuffer.allocateDirect(20);
@@ -91,7 +115,15 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The second if/else verifies the same case.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
if (buf.hasArray()) {
byte array[] = buf.array();
@@ -129,7 +161,15 @@ public class ByteBufferTest extends AbstractBufferTest {
}
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The second if/else verifies the same case.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
if (buf.hasArray()) {
byte array[] = buf.array();
@@ -167,7 +207,15 @@ public class ByteBufferTest extends AbstractBufferTest {
}
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -191,7 +239,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
if (buf.isReadOnly()) {
try {
@@ -252,7 +308,15 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -280,7 +344,15 @@ public class ByteBufferTest extends AbstractBufferTest {
assertTrue(ByteBuffer.wrap(new byte[21]).compareTo(ByteBuffer.allocateDirect(21)) == 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -312,7 +384,15 @@ public class ByteBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -338,6 +418,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for byte get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -355,6 +444,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer get(byte[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {byte[].class}
+ )
+ })
public void testGetbyteArray() {
byte array[] = new byte[1];
buf.clear();
@@ -381,6 +479,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer get(byte[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {byte[].class, int.class, int.class}
+ )
+ })
public void testGetbyteArrayintint() {
buf.clear();
byte array[] = new byte[buf.capacity()];
@@ -448,6 +555,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for byte get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -467,7 +583,15 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same verification in if/else block.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
if (buf.hasArray()) {
assertNotNull(buf.array());
@@ -492,7 +616,15 @@ public class ByteBufferTest extends AbstractBufferTest {
}
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
loadTestData1(buf);
@@ -517,11 +649,27 @@ public class ByteBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity()/2);
assertTrue(buf.hashCode()!= duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
buf.isDirect();
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
// BIG_ENDIAN is the default byte order
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
@@ -544,7 +692,15 @@ public class ByteBufferTest extends AbstractBufferTest {
* test covers following usecases:
* 1. case for check
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {java.nio.ByteOrder.class}
+ )
+ })
public void test_OrderLjava_lang_ByteOrder() {
// BIG_ENDIAN is the default byte order
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
@@ -565,6 +721,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(byte)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {byte.class}
+ )
+ })
public void testPutbyte() {
if (buf.isReadOnly()) {
try {
@@ -595,6 +760,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(byte[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {byte[].class}
+ )
+ })
public void testPutbyteArray() {
byte array[] = new byte[1];
if (buf.isReadOnly()) {
@@ -632,6 +806,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(byte[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {byte[].class, int.class, int.class}
+ )
+ })
public void testPutbyteArrayintint() {
buf.clear();
byte array[] = new byte[buf.capacity()];
@@ -710,6 +893,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(java.nio.ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testPutByteBuffer() {
ByteBuffer other = ByteBuffer.allocate(buf.capacity());
if (buf.isReadOnly()) {
@@ -762,6 +954,15 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(int, byte)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, byte.class}
+ )
+ })
public void testPutintbyte() {
if (buf.isReadOnly()) {
try {
@@ -793,7 +994,15 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > SMALL_TEST_LENGTH);
buf.position(1);
@@ -821,7 +1030,15 @@ public class ByteBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 100);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Byte") >= 0 || str.indexOf("byte") >= 0);
@@ -829,7 +1046,15 @@ public class ByteBufferTest extends AbstractBufferTest {
assertTrue(str.indexOf("" + buf.limit()) >= 0);
assertTrue(str.indexOf("" + buf.capacity()) >= 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asCharBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsCharBuffer() {
CharBuffer charBuffer;
byte bytes[] = new byte[2];
@@ -885,7 +1110,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asDoubleBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsDoubleBuffer() {
DoubleBuffer doubleBuffer;
byte bytes[] = new byte[8];
@@ -948,7 +1181,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asFloatBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsFloatBuffer() {
FloatBuffer floatBuffer;
byte bytes[] = new byte[4];
@@ -1011,7 +1252,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asIntBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsIntBuffer() {
IntBuffer intBuffer;
byte bytes[] = new byte[4];
@@ -1068,7 +1317,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asLongBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsLongBuffer() {
LongBuffer longBuffer;
byte bytes[] = new byte[8];
@@ -1125,7 +1382,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asShortBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsShortBuffer() {
ShortBuffer shortBuffer;
byte bytes[] = new byte[2];
@@ -1182,7 +1447,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getChar",
+ methodArgs = {}
+ )
+ })
public void testGetChar() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1208,7 +1481,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getChar",
+ methodArgs = {int.class}
+ )
+ })
public void testGetCharint() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1239,7 +1520,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "putChar",
+ methodArgs = {char.class}
+ )
+ })
public void testPutChar() {
if (buf.isReadOnly()) {
try {
@@ -1277,7 +1566,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "putChar",
+ methodArgs = {int.class, char.class}
+ )
+ })
public void testPutCharint() {
if (buf.isReadOnly()) {
try {
@@ -1325,7 +1622,15 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDouble",
+ methodArgs = {}
+ )
+ })
public void testGetDouble() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1354,7 +1659,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDouble",
+ methodArgs = {int.class}
+ )
+ })
public void testGetDoubleint() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1394,7 +1707,15 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putDouble",
+ methodArgs = {double.class}
+ )
+ })
public void testPutDouble() {
if (buf.isReadOnly()) {
try {
@@ -1432,7 +1753,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putDouble",
+ methodArgs = {int.class, double.class}
+ )
+ })
public void testPutDoubleint() {
if (buf.isReadOnly()) {
try {
@@ -1474,7 +1803,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFloat",
+ methodArgs = {}
+ )
+ })
public void testGetFloat() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1503,7 +1840,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFloat",
+ methodArgs = {int.class}
+ )
+ })
public void testGetFloatint() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1537,7 +1882,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putFloat",
+ methodArgs = {float.class}
+ )
+ })
public void testPutFloat() {
if (buf.isReadOnly()) {
try {
@@ -1575,7 +1928,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putFloat",
+ methodArgs = {int.class, float.class}
+ )
+ })
public void testPutFloatint() {
if (buf.isReadOnly()) {
try {
@@ -1617,7 +1978,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInt",
+ methodArgs = {}
+ )
+ })
public void testGetInt() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1643,7 +2012,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInt",
+ methodArgs = {int.class}
+ )
+ })
public void testGetIntint() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1679,7 +2056,15 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putInt",
+ methodArgs = {int.class}
+ )
+ })
public void testPutInt() {
if (buf.isReadOnly()) {
try {
@@ -1717,7 +2102,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putInt",
+ methodArgs = {int.class, int.class}
+ )
+ })
public void testPutIntint() {
if (buf.isReadOnly()) {
try {
@@ -1759,7 +2152,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLong",
+ methodArgs = {}
+ )
+ })
public void testGetLong() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1785,7 +2186,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLong",
+ methodArgs = {int.class}
+ )
+ })
public void testGetLongint() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1816,7 +2225,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putLong",
+ methodArgs = {long.class}
+ )
+ })
public void testPutLong() {
if (buf.isReadOnly()) {
try {
@@ -1854,7 +2271,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putLong",
+ methodArgs = {int.class, long.class}
+ )
+ })
public void testPutLongint() {
if (buf.isReadOnly()) {
try {
@@ -1896,7 +2321,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getShort",
+ methodArgs = {}
+ )
+ })
public void testGetShort() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1922,7 +2355,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getShort",
+ methodArgs = {int.class}
+ )
+ })
public void testGetShortint() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1953,7 +2394,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putShort",
+ methodArgs = {short.class}
+ )
+ })
public void testPutShort() {
if (buf.isReadOnly()) {
try {
@@ -1991,7 +2440,15 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "putShort",
+ methodArgs = {int.class, short.class}
+ )
+ })
public void testPutShortint() {
if (buf.isReadOnly()) {
try {
@@ -2037,6 +2494,16 @@ public class ByteBufferTest extends AbstractBufferTest {
/**
* @tests java.nio.ByteBuffer.wrap(byte[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Verifies NullPointerException, " +
+ "IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {byte[].class, int.class, int.class}
+ )
+ })
public void testWrappedByteBuffer_null_array() {
// Regression for HARMONY-264
byte array[] = null;
@@ -2059,7 +2526,15 @@ public class ByteBufferTest extends AbstractBufferTest {
* 2. case for check equal between buf2 and byte array[]
* 3. case for check a buf2 dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {byte[].class}
+ )
+ })
public void test_Wrap$B() {
byte array[] = new byte[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -2086,7 +2561,15 @@ public class ByteBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[]
* 4. case expected IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {byte[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$BII() {
byte array[] = new byte[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
index 3a0907c..1fc82ab 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
@@ -17,10 +17,15 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteOrder;
import junit.framework.TestCase;
-
+@TestTargetClass(ByteOrder.class)
/**
* Test java.nio.ByteOrder
*
@@ -30,12 +35,28 @@ public class ByteOrderTest extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(ByteOrderTest.class);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
assertEquals(ByteOrder.BIG_ENDIAN.toString(), "BIG_ENDIAN");
assertEquals(ByteOrder.LITTLE_ENDIAN.toString(), "LITTLE_ENDIAN");
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "nativeOrder",
+ methodArgs = {}
+ )
+ })
public void testNativeOrder() {
ByteOrder o = ByteOrder.nativeOrder();
assertTrue(o == ByteOrder.BIG_ENDIAN || o == ByteOrder.LITTLE_ENDIAN);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
index 0a4ded9..ce394a5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
@@ -29,6 +34,7 @@ import java.nio.ReadOnlyBufferException;
* Tests java.nio.CharBuffer
*
*/
+@TestTargetClass(CharBuffer.class)
public class CharBufferTest extends AbstractBufferTest {
protected static final int SMALL_TEST_LENGTH = 5;
@@ -55,7 +61,15 @@ public class CharBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check CharBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: CharBuffer testBuf properties is satisfy the conditions
// specification
@@ -73,7 +87,15 @@ public class CharBufferTest extends AbstractBufferTest {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test code as in testArrayOffset method.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
char array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -90,7 +112,15 @@ public class CharBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test code as in testArrayOffset method.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
char array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -107,7 +137,15 @@ public class CharBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -157,7 +195,15 @@ public class CharBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), originalPosition);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -208,7 +254,15 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -234,7 +288,15 @@ public class CharBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
// mark the position 0
buf.clear();
@@ -296,7 +358,15 @@ public class CharBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -322,6 +392,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for char get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -339,6 +418,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer get(char[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify different arrays: empty, null and etc.",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {char[].class}
+ )
+ })
public void testGetcharArray() {
char array[] = new char[1];
buf.clear();
@@ -359,6 +447,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer get(char[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void testGetcharArrayintint() {
buf.clear();
char array[] = new char[buf.capacity()];
@@ -426,6 +523,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for char get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -445,7 +551,15 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
loadTestData1(buf);
@@ -460,6 +574,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char.class}
+ )
+ })
public void testPutchar() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -479,6 +602,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char[].class}
+ )
+ })
public void testPutcharArray() {
char array[] = new char[1];
@@ -507,6 +639,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void testPutcharArrayintint() {
buf.clear();
char array[] = new char[buf.capacity()];
@@ -579,6 +720,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(java.nio.CharBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(buf.capacity());
@@ -621,6 +771,15 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(int, char)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, char.class}
+ )
+ })
public void testPutintchar() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -642,7 +801,15 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -670,7 +837,15 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String expected = "";
for (int i = buf.position(); i < buf.limit(); i++) {
@@ -679,7 +854,15 @@ public class CharBufferTest extends AbstractBufferTest {
String str = buf.toString();
assertEquals(expected, str);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "charAt",
+ methodArgs = {int.class}
+ )
+ })
public void testCharAt() {
for (int i = 0; i < buf.remaining(); i++) {
assertEquals(buf.get(buf.position() + i), buf.charAt(i));
@@ -697,11 +880,27 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "length",
+ methodArgs = {}
+ )
+ })
public void testLength() {
assertEquals(buf.length(), buf.remaining());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "subSequence",
+ methodArgs = {int.class, int.class}
+ )
+ })
public void testSubSequence() {
try {
buf.subSequence(-1, buf.length());
@@ -737,7 +936,15 @@ public class CharBufferTest extends AbstractBufferTest {
.toString().substring(1, buf.length() - 1));
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testPutString() {
String str = " ";
@@ -762,7 +969,15 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.lang.String.class, int.class, int.class}
+ )
+ })
public void testPutStringintint() {
buf.clear();
String str = String.valueOf(new char[buf.capacity()]);
@@ -877,7 +1092,16 @@ public class CharBufferTest extends AbstractBufferTest {
value = (char) (value + 1);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies append method with the same CharSequence object " +
+ "for which it's called.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class}
+ )
+ })
public void testAppendSelf() throws Exception {
CharBuffer cb = CharBuffer.allocate(10);
CharBuffer cb2 = cb.duplicate();
@@ -903,7 +1127,23 @@ public class CharBufferTest extends AbstractBufferTest {
cb2.clear();
assertEquals(cb, cb2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies BufferOverflowException.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {char.class}
+ ),
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class}
+ ),
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testAppendOverFlow() throws IOException {
CharBuffer cb = CharBuffer.allocate(1);
CharSequence cs = "String";
@@ -927,7 +1167,23 @@ public class CharBufferTest extends AbstractBufferTest {
// expected;
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {char.class}
+ ),
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class}
+ ),
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testReadOnlyMap() throws IOException {
CharBuffer cb = CharBuffer.wrap("ABCDE").asReadOnlyBuffer();
CharSequence cs = "String";
@@ -951,14 +1207,30 @@ public class CharBufferTest extends AbstractBufferTest {
}
cb.append(cs, 1, 1);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {char.class}
+ )
+ })
public void testAppendCNormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(2);
cb.put('A');
assertSame(cb, cb.append('B'));
assertEquals('B', cb.get(1));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class}
+ )
+ })
public void testAppendCharSequenceNormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.put('A');
@@ -967,7 +1239,16 @@ public class CharBufferTest extends AbstractBufferTest {
cb.append(null);
assertEquals("null", cb.flip().toString());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies positive case, and null as CharSequence " +
+ "parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testAppendCharSequenceIINormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.put('A');
@@ -977,7 +1258,15 @@ public class CharBufferTest extends AbstractBufferTest {
cb.append(null, 0, 1);
assertEquals("n", cb.flip().toString());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "append",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testAppendCharSequenceII_IllegalArgument() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.append("String", 0, 0);
@@ -1013,7 +1302,15 @@ public class CharBufferTest extends AbstractBufferTest {
// expected;
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testReadCharBuffer() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(10);
@@ -1030,7 +1327,15 @@ public class CharBufferTest extends AbstractBufferTest {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testReadReadOnly() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(10).asReadOnlyBuffer();
@@ -1044,7 +1349,16 @@ public class CharBufferTest extends AbstractBufferTest {
target.flip();
assertEquals(0, source.read(target));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies read method with CharBuffer parameter which length " +
+ "is less than read CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testReadOverflow() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(1);
@@ -1052,7 +1366,15 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals("S", target.flip().toString());
assertEquals(1, source.position());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testReadSelf() throws Exception {
CharBuffer source = CharBuffer.wrap("abuffer");
try {
@@ -1062,19 +1384,51 @@ public class CharBufferTest extends AbstractBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify false returned value.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertTrue(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
@@ -1085,7 +1439,15 @@ public class CharBufferTest extends AbstractBufferTest {
* for check equal between buf2 and char array[] 3. case for check a buf2
* dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {char[].class}
+ )
+ })
public void test_Wrap$C() {
char array[] = new char[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -1113,7 +1475,15 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[]
* 4. case expected IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$CII() {
char array[] = new char[BUFFER_LENGTH];
int offset = 5;
@@ -1152,7 +1522,15 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check String
* 4. case for check CharBuffer
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {java.lang.CharSequence.class}
+ )
+ })
public void test_WrapLjava_lang_CharSequence() {
// added this if clause to prevent Tests failing under special conditions.
// If the test extending this test is made for a read only buffer it fails
@@ -1209,7 +1587,15 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check String
* 4. case for check CharBuffer
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void test_WrapLjava_lang_CharSequenceII() {
int start = buf.position();
int end = buf.limit();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
index 776f505..20f3f8f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
+@TestTargetClass(ByteBuffer.class)
public class DirectByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
@@ -35,6 +41,15 @@ public class DirectByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocateDirect(int)
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocateDirect",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedByteBuffer_IllegalArg() {
try {
ByteBuffer.allocateDirect(-1);
@@ -43,15 +58,39 @@ public class DirectByteBufferTest extends ByteBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isDirect method for direct ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for direct ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for direct ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
index 83cfc9d..0a7c91d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+@TestTargetClass(java.nio.CharBuffer.class)
public class DirectCharBufferTest extends CharBufferTest {
public void setUp(){
@@ -30,11 +36,27 @@ public class DirectCharBufferTest extends CharBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies hasArray method for direct CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -42,7 +64,15 @@ public class DirectCharBufferTest extends CharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -50,11 +80,27 @@ public class DirectCharBufferTest extends CharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isDirect method for direct CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
index 561c0fa..f157fb1 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class DirectDoubleBufferTest extends DoubleBufferTest {
public void setUp(){
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*8).asDoubleBuffer();
@@ -29,11 +35,27 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies hasArray method for direct DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -41,7 +63,15 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -49,11 +79,27 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for direct DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
index 8739c1b..3a48c70 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class DirectFloatBufferTest extends FloatBufferTest {
public void setUp(){
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asFloatBuffer();
@@ -29,11 +35,27 @@ public class DirectFloatBufferTest extends FloatBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for direct FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -41,7 +63,15 @@ public class DirectFloatBufferTest extends FloatBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -50,11 +80,27 @@ public class DirectFloatBufferTest extends FloatBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for direct FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
index 393366e..b28cab0 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+@TestTargetClass(java.nio.IntBuffer.class)
public class DirectIntBufferTest extends IntBufferTest {
public void setUp(){
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asIntBuffer();
@@ -29,11 +35,27 @@ public class DirectIntBufferTest extends IntBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for direct IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -41,7 +63,15 @@ public class DirectIntBufferTest extends IntBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -50,11 +80,27 @@ public class DirectIntBufferTest extends IntBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for direct IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
index 245cd25..c148aba 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
@@ -15,10 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-
+@TestTargetClass(java.nio.LongBuffer.class)
public class DirectLongBufferTest extends LongBufferTest {
public void setUp(){
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*8).asLongBuffer();
@@ -30,11 +35,27 @@ public class DirectLongBufferTest extends LongBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for direct LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -42,7 +63,15 @@ public class DirectLongBufferTest extends LongBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -51,11 +80,27 @@ public class DirectLongBufferTest extends LongBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for direct LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
index 9ae290a..184adb9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class DirectShortBufferTest extends ShortBufferTest {
public void setUp(){
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*2).asShortBuffer();
@@ -29,11 +35,27 @@ public class DirectShortBufferTest extends ShortBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies array method for direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -41,7 +63,15 @@ public class DirectShortBufferTest extends ShortBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies arrayOffset method for direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -50,11 +80,27 @@ public class DirectShortBufferTest extends ShortBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertTrue(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies order method for direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
index 86f86ab..64b0c97 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
@@ -27,6 +32,7 @@ import java.nio.InvalidMarkException;
/**
* Tests java.nio.DoubleBuffer
*/
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class DoubleBufferTest extends AbstractBufferTest {
protected static final int SMALL_TEST_LENGTH = 5;
@@ -51,7 +57,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check DoubleBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verifies boundary value.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: DoubleBuffer testBuf properties is satisfy the conditions
// specification
@@ -73,6 +87,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
* Test with bit sequences that represent the IEEE754 doubles Positive
* infinity, negative infinity, and NaN.
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double.class}
+ )
+ })
public void testNaNs() {
long[] nans = new long[] { 0x7ff0000000000000L, 0xfff0000000000000L,
0x7ff8000000000000L };
@@ -93,7 +116,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertTrue(longBitsIn == bufLongOut);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArrayOffset.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
double array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -110,7 +141,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArray.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
double array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -127,7 +166,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -151,7 +198,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -202,7 +257,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.DoubleBuffer.class}
+ )
+ })
public void testCompareTo() {
DoubleBuffer other = DoubleBuffer.allocate(buf.capacity());
loadTestData1(other);
@@ -218,8 +281,27 @@ public class DoubleBufferTest extends AbstractBufferTest {
other.limit(5);
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
- }
+ DoubleBuffer dbuffer1 = DoubleBuffer.wrap(new double[] { Double.NaN });
+ DoubleBuffer dbuffer2 = DoubleBuffer.wrap(new double[] { Double.NaN });
+ DoubleBuffer dbuffer3 = DoubleBuffer.wrap(new double[] { 42d });
+
+ assertEquals("Failed equal comparison with NaN entry", 0, dbuffer1
+ .compareTo(dbuffer2));
+ assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer3
+ .compareTo(dbuffer1));
+ assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer1
+ .compareTo(dbuffer3));
+ }
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -252,7 +334,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -278,6 +368,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for double get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -295,6 +394,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer get(double[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {double[].class}
+ )
+ })
public void testGetdoubleArray() {
double array[] = new double[1];
buf.clear();
@@ -315,6 +423,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer get(double[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {double[].class, int.class, int.class}
+ )
+ })
public void testGetdoubleArrayintint() {
buf.clear();
double array[] = new double[buf.capacity()];
@@ -382,6 +499,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for double get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -401,11 +527,27 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify false returned value.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertTrue(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
DoubleBuffer readonly = buf.asReadOnlyBuffer();
@@ -416,11 +558,27 @@ public class DoubleBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify direct buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
@@ -428,6 +586,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify boundary values, and ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double.class}
+ )
+ })
public void testPutdouble() {
buf.clear();
@@ -448,6 +615,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double[].class}
+ )
+ })
public void testPutdoubleArray() {
double array[] = new double[1];
@@ -470,6 +646,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double[].class, int.class, int.class}
+ )
+ })
public void testPutdoubleArrayintint() {
buf.clear();
double array[] = new double[buf.capacity()];
@@ -537,6 +722,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(java.nio.DoubleBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.DoubleBuffer.class}
+ )
+ })
public void testPutDoubleBuffer() {
DoubleBuffer other = DoubleBuffer.allocate(buf.capacity());
@@ -566,6 +760,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(int, double)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, double.class}
+ )
+ })
public void testPutintdouble() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -587,7 +790,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -616,7 +827,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500, 0.0);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Double") >= 0 || str.indexOf("double") >= 0);
@@ -631,7 +850,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
* case for check equal between buf2 and double array[] 3. case for check a
* buf2 dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {double[].class}
+ )
+ })
public void test_Wrap$D() {
double array[] = new double[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -658,7 +885,15 @@ public class DoubleBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {double[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$DII() {
double array[] = new double[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java
index 656241a..b67de0c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java
@@ -16,7 +16,9 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class DuplicateDirectByteBufferTest extends DirectByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
index 9f44d7a..29af679 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class DuplicateHeapByteBufferTest extends HeapByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
index 2796b88..7b38bac 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class DuplicateWrappedByteBufferTest extends WrappedByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
index 64c831b..67f2c2d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
@@ -17,9 +17,15 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
+import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.InvalidMarkException;
@@ -27,6 +33,7 @@ import java.nio.InvalidMarkException;
* Tests java.nio.FloatBuffer
*
*/
+@TestTargetClass(java.nio.FloatBuffer.class)
public class FloatBufferTest extends AbstractBufferTest {
protected static final int SMALL_TEST_LENGTH = 5;
@@ -51,7 +58,15 @@ public class FloatBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check FloatBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary case.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: FloatBuffer testBuf properties is satisfy the conditions
// specification
@@ -68,7 +83,15 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArrayOffset.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
float array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -85,7 +108,15 @@ public class FloatBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArray.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
float array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -102,7 +133,15 @@ public class FloatBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -126,7 +165,15 @@ public class FloatBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
@@ -178,7 +225,15 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.FloatBuffer.class}
+ )
+ })
public void testCompareTo() {
try {
buf.compareTo(null);
@@ -207,8 +262,28 @@ public class FloatBufferTest extends AbstractBufferTest {
other.limit(5);
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
- }
-
+
+ FloatBuffer fbuffer1 = FloatBuffer.wrap(new float[] { Float.NaN });
+ FloatBuffer fbuffer2 = FloatBuffer.wrap(new float[] { Float.NaN });
+ FloatBuffer fbuffer3 = FloatBuffer.wrap(new float[] { 42f });
+
+ assertEquals("Failed equal comparison with NaN entry", 0, fbuffer1
+ .compareTo(fbuffer2));
+ assertEquals("Failed greater than comparison with NaN entry", 1, fbuffer3
+ .compareTo(fbuffer1));
+ assertEquals("Failed greater than comparison with NaN entry", 1, fbuffer1
+ .compareTo(fbuffer3));
+
+ }
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -240,7 +315,15 @@ public class FloatBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -266,6 +349,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for float get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -283,6 +375,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer get(float[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {float[].class}
+ )
+ })
public void testGetfloatArray() {
float array[] = new float[1];
buf.clear();
@@ -311,6 +412,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer get(float[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {float[].class, int.class, int.class}
+ )
+ })
public void testGetfloatArrayintint() {
buf.clear();
float array[] = new float[buf.capacity()];
@@ -378,6 +488,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for float get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -397,11 +516,27 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that array method doesn't return null.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertNotNull(buf.array());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
FloatBuffer readonly = buf.asReadOnlyBuffer();
@@ -412,11 +547,27 @@ public class FloatBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify direct buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
buf.order();
if (buf.hasArray()) {
@@ -427,6 +578,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float.class}
+ )
+ })
public void testPutfloat() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -446,6 +606,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float[].class}
+ )
+ })
public void testPutfloatArray() {
float array[] = new float[1];
buf.clear();
@@ -474,6 +643,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float[].class, int.class, int.class}
+ )
+ })
public void testPutfloatArrayintint() {
buf.clear();
float array[] = new float[buf.capacity()];
@@ -540,6 +718,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(java.nio.FloatBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.FloatBuffer.class}
+ )
+ })
public void testPutFloatBuffer() {
FloatBuffer other = FloatBuffer.allocate(buf.capacity());
try {
@@ -575,6 +762,15 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(int, float)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, float.class}
+ )
+ })
public void testPutintfloat() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -596,7 +792,15 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -624,7 +828,15 @@ public class FloatBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500, 0.0);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Float") >= 0 || str.indexOf("float") >= 0);
@@ -639,7 +851,15 @@ public class FloatBufferTest extends AbstractBufferTest {
* for check equal between buf2 and float array[] 3. case for check a buf2
* dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {float[].class}
+ )
+ })
public void test_Wrap$S() {
float array[] = new float[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -666,7 +886,15 @@ public class FloatBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {float[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$SII() {
float array[] = new float[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
index 2f8e44b..13949e6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
@@ -16,9 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
-import java.nio.ByteBuffer;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import java.nio.ByteBuffer;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class HeapByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
@@ -37,6 +42,15 @@ public class HeapByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocate(int)
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedByteBuffer_IllegalArg() {
try {
ByteBuffer.allocate(-1);
@@ -45,15 +59,39 @@ public class HeapByteBufferTest extends ByteBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isDirect method with not direct buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that hasArray returns true value.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertTrue(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method with non read only buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
index a0c8d74..ba9e681 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
@@ -16,9 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
-import java.nio.CharBuffer;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import java.nio.CharBuffer;
+@TestTargetClass(java.nio.CharBuffer.class)
public class HeapCharBufferTest extends CharBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -32,7 +37,15 @@ public class HeapCharBufferTest extends CharBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedCharBuffer_IllegalArg() {
try {
CharBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
index 2985899..e5f8c3e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.DoubleBuffer;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class HeapDoubleBufferTest extends DoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -30,7 +36,15 @@ public class HeapDoubleBufferTest extends DoubleBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedDoubleBuffer_IllegalArg() {
try {
DoubleBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
index f90b34e..2d1f7fd 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.FloatBuffer;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class HeapFloatBufferTest extends FloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -30,7 +36,15 @@ public class HeapFloatBufferTest extends FloatBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedFloatBuffer_IllegalArg() {
try {
FloatBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
index 0d68835..946f75c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.IntBuffer;
+@TestTargetClass(java.nio.IntBuffer.class)
public class HeapIntBufferTest extends IntBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -30,7 +36,15 @@ public class HeapIntBufferTest extends IntBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedIntBuffer_IllegalArg() {
try {
IntBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
index f4f2ae1..a08d93e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.LongBuffer;
+@TestTargetClass(java.nio.LongBuffer.class)
public class HeapLongBufferTest extends LongBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -30,7 +36,15 @@ public class HeapLongBufferTest extends LongBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedLongBuffer_IllegalArg() {
try {
LongBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
index 327a035..15d7f0a 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ShortBuffer;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class HeapShortBufferTest extends ShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -30,7 +36,15 @@ public class HeapShortBufferTest extends ShortBufferTest {
buf = null;
baseBuf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void testAllocatedShortBuffer_IllegalArg() {
try {
ShortBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
index 18a6860..308bfd6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
@@ -27,6 +32,7 @@ import java.nio.InvalidMarkException;
* Tests java.nio.IntBuffer
*
*/
+@TestTargetClass(java.nio.IntBuffer.class)
public class IntBufferTest extends AbstractBufferTest {
@@ -52,7 +58,15 @@ public class IntBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check IntBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't veify boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: IntBuffer testBuf properties is satisfy the conditions
// specification
@@ -69,7 +83,15 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArrayOffset.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
int array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -86,7 +108,15 @@ public class IntBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArray.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
int array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -103,7 +133,15 @@ public class IntBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -127,7 +165,15 @@ public class IntBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -178,7 +224,15 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.IntBuffer.class}
+ )
+ })
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -201,7 +255,15 @@ public class IntBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -233,7 +295,15 @@ public class IntBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -259,6 +329,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for int get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -276,6 +355,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer get(int[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int[].class}
+ )
+ })
public void testGetintArray() {
int array[] = new int[1];
buf.clear();
@@ -302,6 +390,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer get(int[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int[].class, int.class, int.class}
+ )
+ })
public void testGetintArrayintint() {
buf.clear();
int array[] = new int[buf.capacity()];
@@ -369,6 +466,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for int get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -388,11 +494,27 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that array method doesn't return null.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertNotNull(buf.array());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
IntBuffer readonly = buf.asReadOnlyBuffer();
@@ -403,11 +525,27 @@ public class IntBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for non direct buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
@@ -416,6 +554,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class}
+ )
+ })
public void testPutint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -435,6 +582,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int[].class}
+ )
+ })
public void testPutintArray() {
int array[] = new int[1];
buf.clear();
@@ -463,6 +619,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int[].class, int.class, int.class}
+ )
+ })
public void testPutintArrayintint() {
buf.clear();
int array[] = new int[buf.capacity()];
@@ -529,6 +694,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(java.nio.IntBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.IntBuffer.class}
+ )
+ })
public void testPutIntBuffer() {
IntBuffer other = IntBuffer.allocate(buf.capacity());
try {
@@ -564,6 +738,15 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, int.class}
+ )
+ })
public void testPutintint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -585,7 +768,15 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -613,7 +804,15 @@ public class IntBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Int") >= 0 || str.indexOf("int") >= 0);
@@ -628,7 +827,15 @@ public class IntBufferTest extends AbstractBufferTest {
* equal between buf2 and int array[] 3. case for check a buf2 dependens to
* array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {int[].class}
+ )
+ })
public void test_Wrap$I() {
int array[] = new int[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -655,7 +862,15 @@ public class IntBufferTest extends AbstractBufferTest {
* for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {int[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$III() {
int array[] = new int[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
index f291ff4..b18d3da 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
@@ -15,17 +15,32 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.InvalidMarkException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
+@TestTargetClass(InvalidMarkException.class)
public class InvalidMarkExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new InvalidMarkException());
@@ -34,6 +49,15 @@ public class InvalidMarkExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new InvalidMarkException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
index 3fb15a6..1529df7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
@@ -27,6 +32,7 @@ import java.nio.LongBuffer;
* Tests java.nio.LongBuffer
*
*/
+@TestTargetClass(java.nio.LongBuffer.class)
public class LongBufferTest extends AbstractBufferTest {
@@ -52,7 +58,15 @@ public class LongBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check LongBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary value.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: LongBuffer testBuf properties is satisfy the conditions
// specification
@@ -69,7 +83,15 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArrayOffset.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
long array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -86,7 +108,15 @@ public class LongBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArray.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
long array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -103,7 +133,15 @@ public class LongBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -127,7 +165,15 @@ public class LongBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -178,7 +224,15 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.LongBuffer.class}
+ )
+ })
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -201,7 +255,15 @@ public class LongBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -233,7 +295,15 @@ public class LongBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -259,6 +329,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for long get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -276,6 +355,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer get(long[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {long[].class}
+ )
+ })
public void testGetlongArray() {
long array[] = new long[1];
buf.clear();
@@ -303,6 +391,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer get(long[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {long[].class, int.class, int.class}
+ )
+ })
public void testGetlongArrayintint() {
buf.clear();
long array[] = new long[buf.capacity()];
@@ -370,6 +467,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for long get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -389,11 +495,27 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that array method doesn't return null.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertNotNull(buf.array());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
LongBuffer readonly = buf.asReadOnlyBuffer();
@@ -404,11 +526,27 @@ public class LongBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for non direct buffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
@@ -417,6 +555,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long.class}
+ )
+ })
public void testPutlong() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -436,6 +583,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(long[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long[].class}
+ )
+ })
public void testPutlongArray() {
long array[] = new long[1];
buf.clear();
@@ -464,6 +620,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(long[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long[].class, int.class, int.class}
+ )
+ })
public void testPutlongArrayintint() {
buf.clear();
long array[] = new long[buf.capacity()];
@@ -536,6 +701,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(java.nio.LongBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.LongBuffer.class}
+ )
+ })
public void testPutLongBuffer() {
LongBuffer other = LongBuffer.allocate(buf.capacity());
try {
@@ -571,6 +745,15 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(int, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, long.class}
+ )
+ })
public void testPutintlong() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -592,7 +775,15 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -620,7 +811,15 @@ public class LongBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Long") >= 0 || str.indexOf("long") >= 0);
@@ -635,7 +834,15 @@ public class LongBufferTest extends AbstractBufferTest {
* for check equal between buf2 and ling array[] 3. case for check a buf2
* dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {long[].class}
+ )
+ })
public void test_Wrap$L() {
long array[] = new long[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -662,7 +869,15 @@ public class LongBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {long[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$LII() {
long array[] = new long[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java
new file mode 100644
index 0000000..60c50ae
--- /dev/null
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.nio.tests.java.nio;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileChannel.MapMode;
+
+import junit.framework.TestCase;
+
+public class MappedByteBufferTest extends TestCase {
+
+ File tmpFile;
+
+ /**
+ * A regression test for failing to correctly set capacity of underlying
+ * wrapped buffer from a mapped byte buffer.
+ */
+ public void testasIntBuffer() throws IOException {
+ // Map file
+ FileInputStream fis = new FileInputStream(tmpFile);
+ FileChannel fc = fis.getChannel();
+ MappedByteBuffer mmb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc
+ .size());
+ int len = mmb.capacity();
+ assertEquals("Got wrong number of bytes", 46, len); //$NON-NLS-1$
+
+ // Read in our 26 bytes
+ for (int i = 0; i < 26; i++) {
+ byte b = mmb.get();
+ assertEquals("Got wrong byte value", (byte) 'A' + i, b); //$NON-NLS-1$
+ }
+
+ // Now convert to an IntBuffer to read our ints
+ IntBuffer ibuffer = mmb.asIntBuffer();
+ for (int i = 0; i < 5; i++) {
+ int val = ibuffer.get();
+ assertEquals("Got wrong int value", i + 1, val); //$NON-NLS-1$
+ }
+ fc.close();
+ }
+
+ /**
+ * @tests {@link java.nio.MappedByteBuffer#force()}
+ */
+ public void test_force() throws IOException {
+ // buffer was not mapped in read/write mode
+ FileInputStream fileInputStream = new FileInputStream(tmpFile);
+ FileChannel fileChannelRead = fileInputStream.getChannel();
+ MappedByteBuffer mmbRead = fileChannelRead.map(MapMode.READ_ONLY, 0,
+ fileChannelRead.size());
+
+ mmbRead.force();
+
+ FileInputStream inputStream = new FileInputStream(tmpFile);
+ FileChannel fileChannelR = inputStream.getChannel();
+ MappedByteBuffer resultRead = fileChannelR.map(MapMode.READ_ONLY, 0,
+ fileChannelR.size());
+
+ //If this buffer was not mapped in read/write mode, then invoking this method has no effect.
+ assertEquals(
+ "Invoking force() should have no effect when this buffer was not mapped in read/write mode",
+ mmbRead, resultRead);
+
+ // Buffer was mapped in read/write mode
+ RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
+ FileChannel fileChannelReadWrite = randomFile.getChannel();
+ MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
+ FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
+
+ mmbReadWrite.put((byte) 'o');
+ mmbReadWrite.force();
+
+ RandomAccessFile random = new RandomAccessFile(tmpFile, "rw");
+ FileChannel fileChannelRW = random.getChannel();
+ MappedByteBuffer resultReadWrite = fileChannelRW.map(
+ FileChannel.MapMode.READ_WRITE, 0, fileChannelRW.size());
+
+ // Invoking force() will change the buffer
+ assertFalse(mmbReadWrite.equals(resultReadWrite));
+
+ fileChannelRead.close();
+ fileChannelR.close();
+ fileChannelReadWrite.close();
+ fileChannelRW.close();
+ }
+
+ /**
+ * @tests {@link java.nio.MappedByteBuffer#load()}
+ */
+ public void test_load() throws IOException {
+ FileInputStream fileInputStream = new FileInputStream(tmpFile);
+ FileChannel fileChannelRead = fileInputStream.getChannel();
+ MappedByteBuffer mmbRead = fileChannelRead.map(MapMode.READ_ONLY, 0,
+ fileChannelRead.size());
+
+ assertEquals(mmbRead, mmbRead.load());
+
+ RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
+ FileChannel fileChannelReadWrite = randomFile.getChannel();
+ MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
+ FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
+
+ assertEquals(mmbReadWrite, mmbReadWrite.load());
+
+ fileChannelRead.close();
+ fileChannelReadWrite.close();
+ }
+
+ protected void setUp() throws IOException {
+ // Create temp file with 26 bytes and 5 ints
+ tmpFile = File.createTempFile("harmony", "test"); //$NON-NLS-1$//$NON-NLS-2$
+ tmpFile.deleteOnExit();
+ FileOutputStream fileOutputStream = new FileOutputStream(tmpFile);
+ FileChannel fileChannel = fileOutputStream.getChannel();
+ ByteBuffer byteBuffer = ByteBuffer.allocateDirect(26 + 20);
+ for (int i = 0; i < 26; i++) {
+ byteBuffer.put((byte) ('A' + i));
+ }
+ for (int i = 0; i < 5; i++) {
+ byteBuffer.putInt(i + 1);
+ }
+ byteBuffer.rewind();
+ fileChannel.write(byteBuffer);
+ fileChannel.close();
+ fileOutputStream.close();
+ }
+}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
index 856bd5b..7a8dc4c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
@@ -15,17 +15,32 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ReadOnlyBufferException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
+@TestTargetClass(ReadOnlyBufferException.class)
public class ReadOnlyBufferExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ReadOnlyBufferException());
@@ -34,6 +49,15 @@ public class ReadOnlyBufferExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ReadOnlyBufferException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
index e84cc9c..69ae84c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.CharBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.CharBuffer.class)
public class ReadOnlyCharBufferTest extends CharBufferTest {
protected void setUp() throws Exception {
@@ -32,15 +38,41 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
baseBuf = null;
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that isReadOnly returns true for read only " +
+ "CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that hasArray returns false for read only " +
+ "CharBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -48,12 +80,28 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
} catch (ReadOnlyBufferException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
CharBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -61,7 +109,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -70,7 +126,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char.class}
+ )
+ })
public void testPutchar() {
try {
buf.put((char) 0);
@@ -79,7 +143,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException and NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char[].class}
+ )
+ })
public void testPutcharArray() {
char array[] = new char[1];
try {
@@ -95,7 +167,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void testPutcharArrayintint() {
char array[] = new char[1];
try {
@@ -123,7 +203,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(1);
try {
@@ -145,7 +233,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, char.class}
+ )
+ })
public void testPutintchar() {
try {
buf.put(0, (char) 0);
@@ -160,7 +256,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.lang.String.class, int.class, int.class}
+ )
+ })
public void testPutStringintint() {
buf.clear();
String str = String.valueOf(new char[buf.capacity()]);
@@ -190,7 +294,15 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testPutString() {
String str = " ";
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
index 20c7914..d1a5265 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class ReadOnlyDirectByteBufferTest extends DirectByteBufferTest {
protected void setUp() throws Exception {
@@ -28,15 +33,39 @@ public class ReadOnlyDirectByteBufferTest extends DirectByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that hasArray method returns false.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
super.readOnlyHashCode();
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
index 0834d33..46522c2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.DoubleBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
protected void setUp() throws Exception {
@@ -29,15 +35,39 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only DoubleBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that hasArray returns false value.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -45,12 +75,28 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
} catch (ReadOnlyBufferException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
DoubleBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -58,7 +104,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -67,7 +121,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double.class}
+ )
+ })
public void testPutdouble() {
try {
buf.put(0);
@@ -76,7 +138,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double[].class}
+ )
+ })
public void testPutdoubleArray() {
double array[] = new double[1];
try {
@@ -92,7 +162,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {double[].class, int.class, int.class}
+ )
+ })
public void testPutdoubleArrayintint() {
double array[] = new double[1];
try {
@@ -120,7 +198,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.DoubleBuffer.class}
+ )
+ })
public void testPutDoubleBuffer() {
DoubleBuffer other = DoubleBuffer.allocate(1);
try {
@@ -142,7 +228,15 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, double.class}
+ )
+ })
public void testPutintdouble() {
try {
buf.put(0, (double) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
index 3acc5c4..1edcecb 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.FloatBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class ReadOnlyFloatBufferTest extends FloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -28,15 +34,40 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that hasArray returns false for Read Only " +
+ "FloatBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -45,12 +76,28 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
FloatBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -59,7 +106,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -68,7 +123,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float.class}
+ )
+ })
public void testPutfloat() {
try {
buf.put(0);
@@ -77,7 +140,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float[].class}
+ )
+ })
public void testPutfloatArray() {
float array[] = new float[1];
try {
@@ -93,7 +164,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {float[].class, int.class, int.class}
+ )
+ })
public void testPutfloatArrayintint() {
float array[] = new float[1];
try {
@@ -121,7 +200,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.FloatBuffer.class}
+ )
+ })
public void testPutFloatBuffer() {
FloatBuffer other = FloatBuffer.allocate(1);
try {
@@ -143,7 +230,15 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, float.class}
+ )
+ })
public void testPutintfloat() {
try {
buf.put(0, (float) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
index 7452a24..7c0f093 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class ReadOnlyHeapByteBufferTest extends HeapByteBufferTest {
protected void setUp() throws Exception {
@@ -28,15 +33,39 @@ public class ReadOnlyHeapByteBufferTest extends HeapByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies false returned value.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
super.readOnlyHashCode();
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
index 4c7792a..e5a437d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
@@ -16,9 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
-import java.nio.CharBuffer;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import java.nio.CharBuffer;
+@TestTargetClass(java.nio.CharBuffer.class)
public class ReadOnlyHeapCharBufferTest extends ReadOnlyCharBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
index 5c229a2..8848e21 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.DoubleBuffer;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class ReadOnlyHeapDoubleBufferTest extends ReadOnlyDoubleBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
index f2c6644..6cda42c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestLevel;
+
import java.nio.FloatBuffer;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class ReadOnlyHeapFloatBufferTest extends ReadOnlyFloatBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = FloatBuffer.allocate(BUFFER_LENGTH);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
index f9a3877..098b9ab 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.IntBuffer;
+@TestTargetClass(java.nio.IntBuffer.class)
public class ReadOnlyHeapIntBufferTest extends ReadOnlyIntBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = IntBuffer.allocate(BUFFER_LENGTH);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
index efba978..6e14615 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.LongBuffer;
+@TestTargetClass(java.nio.LongBuffer.class)
public class ReadOnlyHeapLongBufferTest extends ReadOnlyLongBufferTest{
+
protected void setUp() throws Exception {
super.setUp();
buf = LongBuffer.allocate(BUFFER_LENGTH);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
index bbbd616..4d38aa7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestLevel;
+
import java.nio.ShortBuffer;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class ReadOnlyHeapShortBufferTest extends ReadOnlyShortBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = ShortBuffer.allocate(BUFFER_LENGTH);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
index 61e78a6..6c97ae2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.IntBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.IntBuffer.class)
public class ReadOnlyIntBufferTest extends IntBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -28,15 +34,40 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method returns false for read only " +
+ "IntBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -45,12 +76,28 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
IntBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -59,7 +106,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -68,7 +123,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class}
+ )
+ })
public void testPutint() {
try {
buf.put(0);
@@ -77,7 +140,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int[].class}
+ )
+ })
public void testPutintArray() {
int array[] = new int[1];
try {
@@ -93,7 +164,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int[].class, int.class, int.class}
+ )
+ })
public void testPutintArrayintint() {
int array[] = new int[1];
try {
@@ -121,7 +200,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.IntBuffer.class}
+ )
+ })
public void testPutIntBuffer() {
IntBuffer other = IntBuffer.allocate(1);
try {
@@ -143,7 +230,15 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, int.class}
+ )
+ })
public void testPutintint() {
try {
buf.put(0, (int) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
index b670606..b299d06 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.LongBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.LongBuffer.class)
public class ReadOnlyLongBufferTest extends LongBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -28,15 +34,40 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that hasArray method returns false for read only " +
+ "LongBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -45,12 +76,28 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
LongBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -59,7 +106,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -68,7 +123,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long.class}
+ )
+ })
public void testPutlong() {
try {
buf.put(0);
@@ -77,7 +140,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long[].class}
+ )
+ })
public void testPutlongArray() {
long array[] = new long[1];
try {
@@ -93,7 +164,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {long[].class, int.class, int.class}
+ )
+ })
public void testPutlongArrayintint() {
long array[] = new long[1];
try {
@@ -121,7 +200,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.LongBuffer.class}
+ )
+ })
public void testPutLongBuffer() {
LongBuffer other = LongBuffer.allocate(1);
try {
@@ -143,7 +230,15 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, long.class}
+ )
+ })
public void testPutintlong() {
try {
buf.put(0, (long) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
index 611f6bf..13c2558 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
@@ -15,9 +15,15 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ReadOnlyBufferException;
import java.nio.ShortBuffer;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class ReadOnlyShortBufferTest extends ShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -28,15 +34,39 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for read only ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -45,12 +75,28 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
ShortBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -59,7 +105,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
//expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
try {
buf.compact();
@@ -68,7 +122,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short.class}
+ )
+ })
public void testPutshort() {
try {
buf.put((short)0);
@@ -77,7 +139,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short[].class}
+ )
+ })
public void testPutshortArray() {
short array[] = new short[1];
try {
@@ -93,7 +163,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short[].class, int.class, int.class}
+ )
+ })
public void testPutshortArrayintint() {
short array[] = new short[1];
try {
@@ -121,7 +199,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.ShortBuffer.class}
+ )
+ })
public void testPutShortBuffer() {
ShortBuffer other = ShortBuffer.allocate(1);
try {
@@ -143,7 +229,15 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, short.class}
+ )
+ })
public void testPutintshort() {
try {
buf.put(0, (short) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
index 031d75b..b5e1ae0 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class ReadOnlyWrappedByteBufferTest extends WrappedByteBufferTest {
protected void setUp() throws Exception {
@@ -28,15 +33,40 @@ public class ReadOnlyWrappedByteBufferTest extends WrappedByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isReadOnly method for read only wrapped " +
+ "ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for read only wrapped ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertFalse(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
super.readOnlyHashCode();
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
index 57c04bf..481dd9c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
@@ -16,8 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.CharBuffer;
+@TestTargetClass(java.nio.CharBuffer.class)
public class ReadOnlyWrappedCharBufferTest1 extends ReadOnlyCharBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
index d1ba9df..bdd6066 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.DoubleBuffer;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class ReadOnlyWrappedDoubleBufferTest extends ReadOnlyDoubleBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = DoubleBuffer.wrap(new double[BUFFER_LENGTH]);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
index affddaa..7e4d28b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.FloatBuffer;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class ReadOnlyWrappedFloatBufferTest extends ReadOnlyFloatBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = FloatBuffer.wrap(new float[BUFFER_LENGTH]);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
index a4d0155..3c560bb 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.IntBuffer;
+@TestTargetClass(java.nio.IntBuffer.class)
public class ReadOnlyWrappedIntBufferTest extends ReadOnlyIntBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = IntBuffer.wrap(new int[BUFFER_LENGTH]);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
index 58491da..b23001a 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.LongBuffer;
+@TestTargetClass(java.nio.LongBuffer.class)
public class ReadOnlyWrappedLongBufferTest extends ReadOnlyLongBufferTest{
+
protected void setUp() throws Exception {
super.setUp();
buf = LongBuffer.wrap(new long[BUFFER_LENGTH]);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
index 0ecb3a4..97f1703 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
@@ -15,9 +15,16 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ShortBuffer;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class ReadOnlyWrappedShortBufferTest extends ReadOnlyShortBufferTest {
+
protected void setUp() throws Exception {
super.setUp();
buf = ShortBuffer.wrap(new short[BUFFER_LENGTH]);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
index 86bad2d..997865a 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
@@ -27,6 +32,7 @@ import java.nio.ShortBuffer;
* Tests java.nio.ShortBuffer
*
*/
+@TestTargetClass(java.nio.ShortBuffer.class)
public class ShortBufferTest extends AbstractBufferTest {
protected static final int SMALL_TEST_LENGTH = 5;
@@ -51,7 +57,15 @@ public class ShortBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check ShortBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary value.",
+ targets = {
+ @TestTarget(
+ methodName = "allocate",
+ methodArgs = {int.class}
+ )
+ })
public void test_AllocateI() {
// case: ShortBuffer testBuf properties is satisfy the conditions
// specification
@@ -68,7 +82,15 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArrayOffset.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
short array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -85,7 +107,15 @@ public class ShortBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "The same test as testArray.",
+ targets = {
+ @TestTarget(
+ methodName = "arrayOffset",
+ methodArgs = {}
+ )
+ })
public void testArrayOffset() {
short array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -102,7 +132,15 @@ public class ShortBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "asReadOnlyBuffer",
+ methodArgs = {}
+ )
+ })
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -126,7 +164,15 @@ public class ShortBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compact",
+ methodArgs = {}
+ )
+ })
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -177,7 +223,15 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.nio.ShortBuffer.class}
+ )
+ })
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -200,7 +254,15 @@ public class ShortBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "duplicate",
+ methodArgs = {}
+ )
+ })
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -232,7 +294,15 @@ public class ShortBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -258,6 +328,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for short get()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {}
+ )
+ })
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -275,6 +354,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer get(short[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {short[].class}
+ )
+ })
public void testGetshortArray() {
short array[] = new short[1];
buf.clear();
@@ -295,6 +383,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer get(short[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {short[].class, int.class, int.class}
+ )
+ })
public void testGetshortArrayintint() {
buf.clear();
short array[] = new short[buf.capacity()];
@@ -356,6 +453,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for short get(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get",
+ methodArgs = {int.class}
+ )
+ })
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -375,11 +481,27 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that array method doesn't return null.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertNotNull(buf.array());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() {
buf.clear();
ShortBuffer readonly = buf.asReadOnlyBuffer();
@@ -390,11 +512,27 @@ public class ShortBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies isDirect method for non direct ShortBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "order",
+ methodArgs = {}
+ )
+ })
public void testOrder() {
buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
@@ -403,6 +541,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(short)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short.class}
+ )
+ })
public void testPutshort() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -422,6 +569,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(short[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short[].class}
+ )
+ })
public void testPutshortArray() {
short array[] = new short[1];
buf.clear();
@@ -450,6 +606,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(short[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {short[].class, int.class, int.class}
+ )
+ })
public void testPutshortArrayintint() {
buf.clear();
short array[] = new short[buf.capacity()];
@@ -516,6 +681,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(java.nio.ShortBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {java.nio.ShortBuffer.class}
+ )
+ })
public void testPutShortBuffer() {
ShortBuffer other = ShortBuffer.allocate(buf.capacity());
try {
@@ -551,6 +725,15 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(int, short)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify ReadOnlyBufferException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {int.class, short.class}
+ )
+ })
public void testPutintshort() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -572,7 +755,15 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "slice",
+ methodArgs = {}
+ )
+ })
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -600,7 +791,15 @@ public class ShortBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Short") >= 0 || str.indexOf("short") >= 0);
@@ -615,7 +814,15 @@ public class ShortBufferTest extends AbstractBufferTest {
* for check equal between buf2 and short array[] 3. case for check a buf2
* dependens to array[]
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {short[].class}
+ )
+ })
public void test_Wrap$S() {
short array[] = new short[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -642,7 +849,15 @@ public class ShortBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {short[].class, int.class, int.class}
+ )
+ })
public void test_Wrap$SII() {
short array[] = new short[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
index 541cde0..f6d611e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class SliceDirectByteBufferTest extends DirectByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
index 9f9f7aa..2b4a7f5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class SliceHeapByteBufferTest extends HeapByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
index f1ddfb9..84f37e7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
@@ -16,7 +16,12 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class SliceWrappedByteBufferTest extends WrappedByteBufferTest {
protected void setUp() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
index 6460d2e..78b96fc 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
@@ -16,8 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ByteBuffer;
+@TestTargetClass(java.nio.ByteBuffer.class)
public class WrappedByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
@@ -36,6 +42,15 @@ public class WrappedByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocate(byte[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IndexOutOfBoundsException, NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {byte[].class, int.class, int.class}
+ )
+ })
public void testWrappedByteBuffer_IllegalArg() {
byte array[] = new byte[BUFFER_LENGTH];
try {
@@ -81,15 +96,39 @@ public class WrappedByteBufferTest extends ByteBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies isDirect method for non direct ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "isDirect",
+ methodArgs = {}
+ )
+ })
public void testIsDirect() {
assertFalse(buf.isDirect());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies hasArray method for wrapped ByteBuffer.",
+ targets = {
+ @TestTarget(
+ methodName = "hasArray",
+ methodArgs = {}
+ )
+ })
public void testHasArray() {
assertTrue(buf.hasArray());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isReadOnly",
+ methodArgs = {}
+ )
+ })
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
index 9181a77..3187746 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
@@ -16,8 +16,14 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.CharBuffer;
+@TestTargetClass(java.nio.CharBuffer.class)
public class WrappedCharBufferTest1 extends CharBufferTest {
protected void setUp() throws Exception {
@@ -37,6 +43,15 @@ public class WrappedCharBufferTest1 extends CharBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IndexOutOfBoundsException, NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testWrappedCharBuffer_IllegalArg() {
char array[] = new char[BUFFER_LENGTH];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
index 1e98d63..a009a41 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
@@ -16,10 +16,16 @@
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.BufferOverflowException;
import java.nio.CharBuffer;
import java.nio.ReadOnlyBufferException;
+@TestTargetClass(java.nio.CharBuffer.class)
public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
protected static final String TEST_STRING = "123456789abcdef12345";
@@ -34,7 +40,15 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
baseBuf = null;
buf = null;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NullPointerException, IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ )
+ })
public void testWrappedCharSequence_IllegalArg() {
String str = TEST_STRING;
try {
@@ -68,7 +82,15 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedOperationException.",
+ targets = {
+ @TestTarget(
+ methodName = "array",
+ methodArgs = {}
+ )
+ })
public void testArray() {
try {
buf.array();
@@ -76,7 +98,16 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException, NullPointerException, " +
+ "BufferOverflowException, IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "put",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void testPutcharArrayintint() {
char array[] = new char[1];
try {
@@ -104,7 +135,16 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ReadOnlyBufferException, NullPointerException, " +
+ "IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.CharBuffer.class}
+ )
+ })
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(1);
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
index f89b41e..4fff361 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.DoubleBuffer;
+@TestTargetClass(java.nio.DoubleBuffer.class)
public class WrappedDoubleBufferTest extends DoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -35,6 +41,15 @@ public class WrappedDoubleBufferTest extends DoubleBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {double[].class, int.class, int.class}
+ )
+ })
public void testWrappedDoubleuffer_IllegalArg() {
double array[] = new double[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
index 43b13c3..a309868 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.FloatBuffer;
+@TestTargetClass(java.nio.FloatBuffer.class)
public class WrappedFloatBufferTest extends FloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -35,6 +41,15 @@ public class WrappedFloatBufferTest extends FloatBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {float[].class, int.class, int.class}
+ )
+ })
public void testWrappedFloatBuffer_IllegalArg() {
float array[] = new float[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
index 383e964..cccb633 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.IntBuffer;
+@TestTargetClass(java.nio.IntBuffer.class)
public class WrappedIntBufferTest extends IntBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -35,6 +41,15 @@ public class WrappedIntBufferTest extends IntBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {int[].class, int.class, int.class}
+ )
+ })
public void testWrappedIntBuffer_IllegalArg() {
int array[] = new int[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
index 581c912..52e8eae 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.LongBuffer;
+@TestTargetClass(java.nio.LongBuffer.class)
public class WrappedLongBufferTest extends LongBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -35,6 +41,15 @@ public class WrappedLongBufferTest extends LongBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {long[].class, int.class, int.class}
+ )
+ })
public void testWrappedLongBuffer_IllegalArg() {
long array[] = new long[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
index 9c6f781..36794b5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
@@ -15,8 +15,14 @@
*/
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.ShortBuffer;
+@TestTargetClass(java.nio.ShortBuffer.class)
public class WrappedShortBufferTest extends ShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
@@ -35,6 +41,15 @@ public class WrappedShortBufferTest extends ShortBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wrap",
+ methodArgs = {short[].class, int.class, int.class}
+ )
+ })
public void testWrappedShortBuffer_IllegalArg() {
short array[] = new short[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
index ee1efe2..c236659 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
@@ -15,12 +15,18 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.AlreadyConnectedException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
+@TestTargetClass(AlreadyConnectedException.class)
/**
* Tests for AlreadyConnectedException
*/
@@ -29,6 +35,15 @@ public class AlreadyConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new AlreadyConnectedException());
@@ -37,6 +52,15 @@ public class AlreadyConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new AlreadyConnectedException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
index d766d0d..7a8c426 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.AsynchronousCloseException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for AsynchronousCloseException
*/
+@TestTargetClass(AsynchronousCloseException.class)
public class AsynchronousCloseExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new AsynchronousCloseException());
@@ -37,6 +52,15 @@ public class AsynchronousCloseExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new AsynchronousCloseException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
index e823622..8e398a9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.CancelledKeyException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for CancelledKeyException
*/
+@TestTargetClass(CancelledKeyException.class)
public class CancelledKeyExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new CancelledKeyException());
@@ -37,6 +52,15 @@ public class CancelledKeyExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new CancelledKeyException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
index acf5c75..a791c20 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -46,7 +51,7 @@ import junit.framework.TestCase;
* characters : "P@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]"
*
*/
-
+@TestTargetClass(Channels.class)
public class ChannelsTest extends TestCase {
private static final String CODE_SET = "GB2312"; //$NON-NLS-1$
@@ -112,6 +117,15 @@ public class ChannelsTest extends TestCase {
}
// test if new Channel to input is null
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.InputStream.class}
+ )
+ })
public void testNewChannelInputStream_InputNull() throws IOException {
ByteBuffer byteBuf = ByteBuffer.allocate(this.testNum);
this.fins = null;
@@ -128,6 +142,15 @@ public class ChannelsTest extends TestCase {
}
// test if buffer to read is null
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.InputStream.class}
+ )
+ })
public void testNewChannelInputStream_BufferNull() throws IOException {
ByteBuffer byteBuf = ByteBuffer.allocate(this.testNum);
int readres = this.testNum;
@@ -153,6 +176,15 @@ public class ChannelsTest extends TestCase {
/*
* Test method for 'java.nio.channels.Channels.NewChannel'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.InputStream.class}
+ )
+ })
public void testNewChannelInputStream() throws IOException {
int bufSize = 10;
int readres = 0;
@@ -181,6 +213,15 @@ public class ChannelsTest extends TestCase {
}
// test if fout to change is null
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.OutputStream.class}
+ )
+ })
public void testNewChannelOutputStream_inputNull() throws IOException {
int writeres = this.testNum;
ByteBuffer writebuf = ByteBuffer.allocate(this.writebufSize);
@@ -201,6 +242,15 @@ public class ChannelsTest extends TestCase {
}
// test if write buf is null
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.OutputStream.class}
+ )
+ })
public void testNewChannelOutputStream_BufNull() throws IOException {
int writeres = this.testNum;
ByteBuffer writebuf = null;
@@ -223,6 +273,15 @@ public class ChannelsTest extends TestCase {
/*
* Test method for 'java.nio.channels.Channels.NewChannel(OutputStream)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newChannel",
+ methodArgs = {java.io.OutputStream.class}
+ )
+ })
public void testNewChannelOutputStream() throws IOException {
int writeNum = 0;
ByteBuffer writebuf = ByteBuffer.allocateDirect(this.writebufSize);
@@ -267,7 +326,15 @@ public class ChannelsTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newInputStream",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class}
+ )
+ })
public void testNewInputStreamReadableByteChannel_InputNull()
throws Exception {
byte[] readbuf = new byte[this.testNum];
@@ -293,7 +360,16 @@ public class ChannelsTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify IllegalBlockingModeException for read methods " +
+ "according to the specification.",
+ targets = {
+ @TestTarget(
+ methodName = "newInputStream",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class}
+ )
+ })
public void testNewInputStreamReadableByteChannel() throws Exception {
ByteBuffer readbcbuf = ByteBuffer.allocateDirect(this.testNum);
byte[] readbuf = new byte[this.testNum];
@@ -320,7 +396,15 @@ public class ChannelsTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newOutputStream",
+ methodArgs = {java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void testNewOutputStreamWritableByteChannel_InputNull()
throws Exception {
byte[] writebuf = new byte[this.testNum];
@@ -349,7 +433,16 @@ public class ChannelsTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify IllegalBlockingModeException for write methods " +
+ "according to the specification.",
+ targets = {
+ @TestTarget(
+ methodName = "newOutputStream",
+ methodArgs = {java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void testNewOutputStreamWritableByteChannel() throws Exception {
byte[] writebuf = new byte[this.testNum];
ByteBuffer writebcbuf = ByteBuffer.allocateDirect(this.testNum);
@@ -376,7 +469,16 @@ public class ChannelsTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedCharsetException.",
+ targets = {
+ @TestTarget(
+ methodName = "newReader",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class,
+ java.nio.charset.CharsetDecoder.class, int.class}
+ )
+ })
public void testnewReaderCharsetError() throws Exception {
this.fins = new FileInputStream(tmpFile);
@@ -390,7 +492,17 @@ public class ChannelsTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify IllegalBlockingModeException for " +
+ "non-blocking mode.",
+ targets = {
+ @TestTarget(
+ methodName = "newWriter",
+ methodArgs = {java.nio.channels.WritableByteChannel.class,
+ java.nio.charset.CharsetEncoder.class, int.class}
+ )
+ })
public void testnewWriterCharsetError() throws Exception {
this.fouts = new FileOutputStream(tmpFile);
WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
@@ -407,6 +519,16 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newReader",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class,
+ java.nio.charset.CharsetDecoder.class, int.class}
+ )
+ })
public void testNewReaderReadableByteChannelString_InputNull()
throws IOException {
int bufSize = this.testNum;
@@ -452,6 +574,17 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't check IllegalBlockingModeException exception while " +
+ "read method.",
+ targets = {
+ @TestTarget(
+ methodName = "newReader",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class,
+ java.nio.charset.CharsetDecoder.class, int.class}
+ )
+ })
public void testNewReaderReadableByteChannelString_internalBufferZero()
throws IOException {
int bufSize = this.testNum;
@@ -497,6 +630,16 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify UnsupportedCharsetException.",
+ targets = {
+ @TestTarget(
+ methodName = "newReader",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class,
+ java.lang.String.class}
+ )
+ })
public void testNewReaderReadableByteChannelString() throws IOException {
int bufSize = this.testNum;
int readres = 0;
@@ -533,6 +676,15 @@ public class ChannelsTest extends TestCase {
/*
* Zero-Buffer
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "newWriter",
+ methodArgs = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
+ )
+ })
public void testNewWriterWritableByteChannelString_internalBufZero()
throws IOException {
@@ -584,6 +736,16 @@ public class ChannelsTest extends TestCase {
/*
* this test cannot be passed when buffer set to 0!
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify IllegalBlockingModeException for write methods.",
+ targets = {
+ @TestTarget(
+ methodName = "newWriter",
+ methodArgs = {java.nio.channels.WritableByteChannel.class,
+ java.nio.charset.CharsetEncoder.class, int.class}
+ )
+ })
public void testNewWriterWritableByteChannelString_InputNull()
throws IOException {
this.fouts = new FileOutputStream(tmpFile);
@@ -607,6 +769,16 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newWriter(WritableByteChannel, String)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify UnsupportedCharsetException.",
+ targets = {
+ @TestTarget(
+ methodName = "newWriter",
+ methodArgs = {java.nio.channels.WritableByteChannel.class,
+ java.lang.String.class}
+ )
+ })
public void testNewWriterWritableByteChannelString() throws IOException {
this.fouts = new FileOutputStream(tmpFile);
WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
@@ -651,6 +823,16 @@ public class ChannelsTest extends TestCase {
* @tests java.nio.channels.Channels#newReader(ReadableByteChannel channel,
* String charsetName)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalBlockingModeException.",
+ targets = {
+ @TestTarget(
+ methodName = "newReader",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class,
+ java.lang.String.class}
+ )
+ })
public void test_newReader_LReadableByteChannel_LString()
throws IOException {
InetSocketAddress localAddr = new InetSocketAddress("127.0.0.1",
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
index eca50a3..4e48945 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.ClosedByInterruptException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for ClosedByInterruptException
*/
+@TestTargetClass(ClosedByInterruptException.class)
public class ClosedByInterruptExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ClosedByInterruptException());
@@ -37,6 +52,15 @@ public class ClosedByInterruptExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ClosedByInterruptException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
index 57b5d12..277ec34 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.ClosedChannelException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for ClosedChannelException
*/
+@TestTargetClass(ClosedChannelException.class)
public class ClosedChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ClosedChannelException());
@@ -37,6 +52,15 @@ public class ClosedChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ClosedChannelException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
index 006b88f..2f00113 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.ClosedSelectorException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for ClosedSelectorException
*/
+@TestTargetClass(ClosedSelectorException.class)
public class ClosedSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ClosedSelectorException());
@@ -37,6 +52,15 @@ public class ClosedSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ClosedSelectorException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
index d293d86..47496f7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestLevel;
+
import java.nio.channels.ConnectionPendingException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for ConnectionPendingException
*/
+@TestTargetClass(ConnectionPendingException.class)
public class ConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ConnectionPendingException());
@@ -37,6 +52,15 @@ public class ConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ConnectionPendingException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
index b1c6143..ca6d052 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
@@ -42,6 +47,7 @@ import tests.support.Support_PortManager;
* Test for DatagramChannel
*
*/
+@TestTargetClass(DatagramChannel.class)
public class DatagramChannelTest extends TestCase {
private static final int CAPACITY_NORMAL = 200;
@@ -123,6 +129,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.validOps()'
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ )
+ })
public void testValidOps() {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -136,6 +151,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.open()'
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Doesn't call open method.",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void testOpen() {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -149,6 +173,16 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.read(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException, IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testReadByteBufferArray() throws IOException {
final int testNum = 0;
long readres = testNum;
@@ -185,6 +219,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.read(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testReadByteBufferArray_BufNull() throws IOException {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -214,6 +257,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.write(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer() throws IOException {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -250,6 +302,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.write(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testWriteByteBuffer_Bufnull() throws IOException {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -284,6 +345,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws SocketException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_BasicStatusBeforeConnect() throws SocketException {
assertFalse(this.channel1.isConnected());// not connected
DatagramSocket s1 = this.channel1.socket();
@@ -298,6 +368,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_BasicStatusAfterConnect() throws IOException {
this.channel1.connect(localAddr1);
DatagramSocket s1 = this.channel1.socket();
@@ -306,7 +385,15 @@ public class DatagramChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_BasicStatusAfterConnect()
throws IOException {
this.channel1.connect(localAddr1);
@@ -323,6 +410,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_ActionsBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
DatagramSocket s = this.channel1.socket();
@@ -334,13 +430,30 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_ActionsAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
this.channel1.connect(localAddr1);
DatagramSocket s = this.channel1.socket();
assertSocketActionAfterConnect(s);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_ActionsAfterConnect() throws IOException {
this.channel1.connect(localAddr1);
this.channel1.configureBlocking(false);
@@ -425,7 +538,15 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test for configureBlocking()
// -------------------------------------------------------------------
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testConfigureBlocking_Read() throws Exception {
assertTrue(this.channel1.isBlocking());
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_1KB);
@@ -454,6 +575,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isConnected",
+ methodArgs = {}
+ )
+ })
public void testIsConnected_WithServer() throws IOException {
connectLocalServer();
disconnectAfterConnected();
@@ -469,6 +599,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_BlockWithServer() throws IOException {
// blocking mode
assertTrue(this.channel1.isBlocking());
@@ -480,6 +619,16 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException, SecurityException, IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_BlockNoServer() throws IOException {
connectWithoutServer();
disconnectAfterConnected();
@@ -490,6 +639,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_NonBlockWithServer() throws IOException {
// Non blocking mode
this.channel1.configureBlocking(false);
@@ -503,6 +661,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_Null() throws IOException {
assertFalse(this.channel1.isConnected());
try {
@@ -518,6 +685,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnsupportedAddressTypeException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_UnsupportedType() throws IOException {
assertFalse(this.channel1.isConnected());
class SubSocketAddress extends SocketAddress {
@@ -541,6 +717,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies UnresolvedAddressException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_Unresolved() throws IOException {
assertFalse(this.channel1.isConnected());
InetSocketAddress unresolved = new InetSocketAddress(
@@ -552,7 +737,15 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_EmptyHost() throws Exception {
assertFalse(this.channel1.isConnected());
@@ -567,6 +760,15 @@ public class DatagramChannelTest extends TestCase {
* @throws IOException
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_ClosedChannelException() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -585,6 +787,15 @@ public class DatagramChannelTest extends TestCase {
* @throws IOException
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalStateException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_IllegalStateException() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.connect(localAddr1);
@@ -604,6 +815,15 @@ public class DatagramChannelTest extends TestCase {
* @throws IOException
*
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testConnect_CheckOpenBeforeStatus() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.connect(localAddr1);
@@ -657,6 +877,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_BeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());
assertEquals(this.channel1, this.channel1.disconnect());
@@ -668,6 +897,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_UnconnectedClosed() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -681,6 +919,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_BlockWithServerChannelClosed()
throws IOException {
assertTrue(this.channel1.isBlocking());
@@ -695,6 +942,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_NonBlockWithServerChannelClosed()
throws IOException {
this.channel1.configureBlocking(false);
@@ -709,6 +965,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_BlockWithServerServerClosed() throws IOException {
assertTrue(this.channel1.isBlocking());
connectLocalServer();
@@ -724,6 +989,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws IOException
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "disconnect",
+ methodArgs = {}
+ )
+ })
public void testDisconnect_NonBlockWithServerServerClosed()
throws IOException {
this.channel1.configureBlocking(false);
@@ -745,6 +1019,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedNull() throws Exception {
assertFalse(this.channel1.isConnected());
try {
@@ -760,6 +1043,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedReadonly() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL)
@@ -778,6 +1070,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedBufEmpty() throws Exception {
this.channel1.configureBlocking(false);
assertFalse(this.channel1.isConnected());
@@ -790,6 +1091,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedBufZero() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_ZERO);
@@ -801,6 +1111,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedBufNotEmpty() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -815,6 +1134,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedBufFull() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_ONE);
@@ -829,6 +1157,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedClose() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -847,6 +1184,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedCloseNull() throws Exception {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -865,6 +1211,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_UnconnectedCloseReadonly() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL)
@@ -885,6 +1240,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerBufEmpty() throws Exception {
this.channel1.configureBlocking(false);
receiveNonBlockNoServer(CAPACITY_NORMAL);
@@ -895,6 +1259,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_BlockNoServerNull() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerNull();
@@ -905,6 +1278,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerNull() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerNull();
@@ -915,6 +1297,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_BlockNoServerReadonly() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerReadonly();
@@ -925,6 +1316,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerReadonly() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerReadonly();
@@ -935,6 +1335,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerBufZero() throws Exception {
this.channel1.configureBlocking(false);
receiveNonBlockNoServer(CAPACITY_ZERO);
@@ -945,6 +1354,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerBufNotEmpty() throws Exception {
this.channel1.configureBlocking(false);
connectWithoutServer();
@@ -958,6 +1376,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerBufFull() throws Exception {
this.channel1.configureBlocking(false);
connectWithoutServer();
@@ -970,6 +1397,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_BlockNoServerChannelClose() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelClose();
@@ -980,6 +1416,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerChannelClose() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelClose();
@@ -990,6 +1435,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_BlockNoServerCloseNull() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelCloseNull();
@@ -1000,6 +1454,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerCloseNull() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelCloseNull();
@@ -1010,6 +1473,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_NonBlockNoServerCloseReadonly() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelCloseReadonly();
@@ -1020,6 +1492,15 @@ public class DatagramChannelTest extends TestCase {
*
* @throws Exception
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_BlockNoServerCloseReadonly() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelCloseReadonly();
@@ -1139,16 +1620,41 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.send(ByteBuffer, SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerBlockingCommon() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataBlocking(localAddr1, writeBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerNonblockingCommon() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataNonBlocking(localAddr1, writeBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataBlocking(localAddr1, writeBuf);
@@ -1161,7 +1667,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerNonBlockingTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataNonBlocking(localAddr1, writeBuf);
@@ -1174,7 +1688,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerBufNull() throws IOException {
try {
sendDataBlocking(localAddr1, null);
@@ -1183,7 +1705,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerBufNullTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1200,7 +1730,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "DOesn't verify all exceptions according to spec.",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerAddrNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1210,7 +1748,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_NoServerAddrNullTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1231,7 +1777,19 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test for receive()and send(): Send and Receive with Real Data
// -------------------------------------------------------------------
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("some normal string in testReceiveSend_Normal",
@@ -1239,7 +1797,19 @@ public class DatagramChannelTest extends TestCase {
receiveByChannel(CAPACITY_NORMAL, localAddr2,
"some normal string in testReceiveSend_Normal");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_NotBound() throws Exception {
// not bound
sendByChannel("some normal string in testReceiveSend_Normal",
@@ -1248,7 +1818,19 @@ public class DatagramChannelTest extends TestCase {
assertNull(channel1.receive(buf));
assertFalse(channel1.socket().isBound());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_NotBound() throws Exception {
// not bound
this.channel1.configureBlocking(false);
@@ -1258,7 +1840,19 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer buf = ByteBuffer.wrap(new byte[CAPACITY_NORMAL]);
assertNull((InetSocketAddress) this.channel1.receive(buf));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket(
@@ -1266,14 +1860,38 @@ public class DatagramChannelTest extends TestCase {
receiveByChannel(CAPACITY_NORMAL, localAddr2,
"some normal string in testReceiveSend_Normal_S2C");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
String str1 = "some normal string in testReceiveSend_Normal_C2S";
sendByChannel(str1, localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, str1);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Normal_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1282,7 +1900,19 @@ public class DatagramChannelTest extends TestCase {
sendByChannel(str1, localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, str1);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Normal_S2S() throws Exception {
String msg = "normal string in testReceiveSend_Normal_S2S";
this.datagramSocket1 = new DatagramSocket(testPort);
@@ -1296,13 +1926,33 @@ public class DatagramChannelTest extends TestCase {
this.datagramSocket2.receive(rdp);
assertEquals(new String(buf, 0, CAPACITY_NORMAL).trim(), msg);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1310,13 +1960,37 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty_S2C() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1324,13 +1998,37 @@ public class DatagramChannelTest extends TestCase {
sendByDatagramSocket("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
sendByChannel("", localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1338,7 +2036,15 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("", localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, "");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceiveSend_Empty_S2S() throws Exception {
String msg = "";
this.datagramSocket1 = new DatagramSocket(testPort);
@@ -1352,19 +2058,55 @@ public class DatagramChannelTest extends TestCase {
this.datagramSocket2.receive(rdp);
assertEquals(new String(buf, 0, CAPACITY_NORMAL).trim(), msg);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("0123456789", localAddr2);
receiveByChannel(5, localAddr2, "01234");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
sendByChannel("0123456789", localAddr2);
receiveByDatagramSocket(5, localAddr2, "01234");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Oversize_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1372,13 +2114,37 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("0123456789", localAddr2);
receiveByDatagramSocket(5, localAddr2, "01234");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket("0123456789", localAddr2);
receiveByChannel(5, localAddr2, "01234");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_8K() throws Exception {
StringBuffer str8k = new StringBuffer();
for (int i = 0; i < 8 * CAPACITY_1KB; i++) {
@@ -1389,7 +2155,16 @@ public class DatagramChannelTest extends TestCase {
sendByChannel(str, localAddr2);
receiveByChannel(8 * CAPACITY_1KB, localAddr2, str);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException.",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_64K() throws Exception {
StringBuffer str64k = new StringBuffer();
for (int i = 0; i < CAPACITY_64KB; i++) {
@@ -1481,7 +2256,15 @@ public class DatagramChannelTest extends TestCase {
private class mockAddress extends SocketAddress {
private static final long serialVersionUID = 1L;
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testSend_MockSocketAddress() throws Exception {
SocketAddress badAddr = new mockAddress();
@@ -1505,7 +2288,16 @@ public class DatagramChannelTest extends TestCase {
System.setSecurityManager(sm);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException, IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testRead_Security() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
@@ -1524,7 +2316,15 @@ public class DatagramChannelTest extends TestCase {
System.setSecurityManager(sm);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "receive",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReceive_Peek_Security_Nonblocking() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
@@ -1566,17 +2366,42 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.write(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_Block() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
connectWriteBuf(localAddr1, writeBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_NonBlock() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
this.channel1.configureBlocking(false);
connectWriteBuf(localAddr1, writeBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_Block_closed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
InetSocketAddress ipAddr = localAddr1;
@@ -1591,7 +2416,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_NonBlock_closed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
InetSocketAddress ipAddr = localAddr1;
@@ -1608,7 +2441,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_Block_BufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
InetSocketAddress ipAddr = localAddr1;
@@ -1635,7 +2476,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_NonBlock_BufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
InetSocketAddress ipAddr = localAddr1;
@@ -1670,6 +2519,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.write(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_Block() throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1688,7 +2546,15 @@ public class DatagramChannelTest extends TestCase {
assertEquals(0, this.channel1.write(writeBuf, 0, 1));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_NonBlock() throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1709,7 +2575,15 @@ public class DatagramChannelTest extends TestCase {
assertEquals(0, this.channel1.write(writeBuf, 0, 1));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_NoConnectIndexBad()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
@@ -1734,7 +2608,15 @@ public class DatagramChannelTest extends TestCase {
// cannot be buffered again!
assertEquals(0, this.channel1.write(writeBuf, 0, 1));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_ConnectedIndexBad()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
@@ -1756,7 +2638,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_BufNullNoConnect()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
@@ -1780,7 +2670,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_BufNullConnect()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
@@ -1816,6 +2714,15 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.read(ByteBuffer)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadByteBuffer() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1837,7 +2744,15 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadByteBuffer_bufNull() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocateDirect(0);
InetSocketAddress ipAddr = localAddr1;
@@ -1864,6 +2779,16 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.read(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException, IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt() throws IOException {
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1902,7 +2827,15 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt_BufNull() throws IOException {
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1942,7 +2875,19 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// test read and write
// -------------------------------------------------------------------
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testReadWrite_configureBlock() throws Exception {
byte[] targetArray = new byte[2];
// bind and connect
@@ -1970,7 +2915,15 @@ public class DatagramChannelTest extends TestCase {
// ok
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_Zero() throws Exception {
byte[] sourceArray = new byte[0];
byte[] targetArray = new byte[0];
@@ -1990,7 +2943,19 @@ public class DatagramChannelTest extends TestCase {
assertEquals(0, readCount);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_Normal() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2007,7 +2972,15 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, CAPACITY_NORMAL, "testReadWrite_Block_Normal");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_Empty() throws Exception {
// empty buf
byte[] sourceArray = "".getBytes();
@@ -2029,7 +3002,19 @@ public class DatagramChannelTest extends TestCase {
// empty message let the reader blocked
closeBlockedReaderChannel2(targetBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_changeBlock_Empty() throws Exception {
// empty buf
byte[] sourceArray = "".getBytes();
@@ -2070,7 +3055,19 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_8KB() throws Exception {
byte[] sourceArray = new byte[CAPACITY_1KB * 8];
byte[] targetArray = new byte[CAPACITY_1KB * 8];
@@ -2121,7 +3118,16 @@ public class DatagramChannelTest extends TestCase {
assertEquals(targetArray[i], (byte) i);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify NotYetConnectedException, " +
+ "ClosedChannelException, ClosedByInterruptException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_64K() throws Exception {
byte[] sourceArray = new byte[CAPACITY_64KB];
for (int i = 0; i < sourceArray.length; i++) {
@@ -2143,7 +3149,15 @@ public class DatagramChannelTest extends TestCase {
// too big
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_DifferentAddr() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2167,7 +3181,15 @@ public class DatagramChannelTest extends TestCase {
// we close the blocked channel
closeBlockedReaderChannel2(targetBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_WriterNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2188,7 +3210,15 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
closeBlockedReaderChannel2(targetBuf);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_WriterBindLater() throws Exception {
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2240,7 +3270,15 @@ public class DatagramChannelTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_ReaderNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2288,6 +3326,19 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test read and write in non-block mode.
// -------------------------------------------------------------------
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_Normal() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2307,7 +3358,19 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, CAPACITY_NORMAL, "testReadWrite_NonBlock_Normal");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_8KB() throws Exception {
byte[] sourceArray = new byte[CAPACITY_1KB * 8];
byte[] targetArray = new byte[CAPACITY_1KB * 8];
@@ -2327,7 +3390,19 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, 8 * CAPACITY_1KB, "testReadWrite_NonBlock_8KB");
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_DifferentAddr() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2352,7 +3427,19 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_WriterNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2376,7 +3463,19 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_ReaderNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2400,7 +3499,15 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_write_LBuffer_positioned() throws Exception {
// Regression test for Harmony-683
int postion = 16;
@@ -2412,7 +3519,15 @@ public class DatagramChannelTest extends TestCase {
sourceBuf.position(postion);
assertEquals(CAPACITY_NORMAL - postion, dc.write(sourceBuf));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void test_send_LBuffer_LSocketAddress_PositonNotZero()
throws Exception {
// regression test for Harmony-701
@@ -2433,6 +3548,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void test_read_$LByteBuffer() throws Exception {
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
@@ -2452,6 +3576,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#read(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read_$LByteBufferII() throws Exception {
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
@@ -2471,6 +3604,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_read_LByteBuffer_closed_nullBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = null;
@@ -2487,6 +3629,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_read_LByteBuffer_NotConnected_nullBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = null;
@@ -2502,6 +3653,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_read_LByteBuffer_readOnlyBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = ByteBuffer.allocate(1);
@@ -2524,6 +3684,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#send(ByteBuffer, SocketAddress)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "send",
+ methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void test_send_LByteBuffer_LSocketAddress_closed() throws IOException{
// regression test for Harmony-913
channel1.close();
@@ -2557,6 +3726,15 @@ public class DatagramChannelTest extends TestCase {
/**
* @tests DatagramChannel#socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_IllegalBlockingModeException() throws Exception {
// regression test for Harmony-1036
DatagramChannel channel = DatagramChannel.open();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java
index a8df907..4d707c7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -33,6 +38,7 @@ import junit.framework.TestCase;
/**
* API tests for the NIO FileChannel locking APIs
*/
+@TestTargetClass(java.nio.channels.FileChannel.class)
public class FileChannelLockingTest extends TestCase {
private FileChannel readOnlyChannel;
@@ -70,7 +76,19 @@ public class FileChannelLockingTest extends TestCase {
"rw");
readWriteChannel = randomAccessFile.getChannel();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_illegalLocks() throws IOException {
// Cannot acquire an exclusive lock on a read-only file channel
try {
@@ -88,7 +106,15 @@ public class FileChannelLockingTest extends TestCase {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {}
+ )
+ })
public void test_lockReadWrite() throws IOException {
// Acquire an exclusive lock across the entire file.
FileLock flock = readWriteChannel.lock();
@@ -96,7 +122,15 @@ public class FileChannelLockingTest extends TestCase {
flock.release();
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_illegalLockParameters() throws IOException {
// Cannot lock negative positions
try {
@@ -129,7 +163,15 @@ public class FileChannelLockingTest extends TestCase {
flock1.release();
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't call isShared, isValid methods after lock.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockLLZ() throws IOException {
// Lock a range at the front, non-shared.
FileLock flock1 = readWriteChannel.lock(0, 10, false);
@@ -141,7 +183,15 @@ public class FileChannelLockingTest extends TestCase {
flock1.release();
flock2.release();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {}
+ )
+ })
public void test_tryLock() throws IOException {
try {
readOnlyChannel.tryLock();
@@ -150,7 +200,15 @@ public class FileChannelLockingTest extends TestCase {
// Expected.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockLLZ() throws IOException {
// It is illegal to request an exclusive lock on a read-only channel
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
index 10f2fcc..68c8223 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -47,6 +52,7 @@ import org.apache.harmony.luni.platform.Platform;
import junit.framework.TestCase;
+@TestTargetClass(FileChannel.class)
public class FileChannelTest extends TestCase {
private static final int CAPACITY = 100;
@@ -229,6 +235,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify force method with false parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "force",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_forceJ() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
writeOnlyFileChannel.write(writeBuffer);
@@ -243,6 +258,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "force",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_forceJ_closed() throws Exception {
writeOnlyFileChannel.close();
try {
@@ -263,6 +287,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "force",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_forceJ_ReadOnlyChannel() throws Exception {
// force on a read only file channel has no effect.
readOnlyFileChannel.force(true);
@@ -272,6 +305,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_Init() throws Exception {
assertEquals(0, readOnlyFileChannel.position());
assertEquals(0, writeOnlyFileChannel.position());
@@ -281,6 +323,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -331,6 +382,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_WriteOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
writeOnlyFileChannel.write(writeBuffer);
@@ -340,6 +400,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_ReadWrite() throws Exception {
writeDataToFile(fileOfReadWriteFileChannel);
@@ -356,6 +425,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -385,6 +463,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {long.class}
+ )
+ })
public void test_positionJ_Closed() throws Exception {
final long POSITION = 100;
@@ -416,6 +503,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {long.class}
+ )
+ })
public void test_positionJ_Negative() throws Exception {
final long NEGATIVE_POSITION = -1;
try {
@@ -443,6 +539,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {long.class}
+ )
+ })
public void test_positionJ_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -467,6 +572,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {long.class}
+ )
+ })
public void test_positionJ_WriteOnly() throws Exception {
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -501,6 +615,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies zero size.",
+ targets = {
+ @TestTarget(
+ methodName = "size",
+ methodArgs = {}
+ )
+ })
public void test_size_Init() throws Exception {
assertEquals(0, readOnlyFileChannel.size());
assertEquals(0, writeOnlyFileChannel.size());
@@ -510,6 +633,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies positive case.",
+ targets = {
+ @TestTarget(
+ methodName = "size",
+ methodArgs = {}
+ )
+ })
public void test_size() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
assertEquals(fileOfReadOnlyFileChannel.length(), readOnlyFileChannel
@@ -519,6 +651,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "size",
+ methodArgs = {}
+ )
+ })
public void test_size_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -548,6 +689,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "truncate",
+ methodArgs = {long.class}
+ )
+ })
public void test_truncateJ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -577,6 +727,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "truncate",
+ methodArgs = {long.class}
+ )
+ })
public void test_truncateJ_IllegalArgument() throws Exception {
// regression test for Harmony-941
try {
@@ -604,6 +763,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NonWritableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "truncate",
+ methodArgs = {long.class}
+ )
+ })
public void test_truncateJ_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
try {
@@ -624,6 +792,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "truncate",
+ methodArgs = {long.class}
+ )
+ })
public void test_truncateJ() throws Exception {
writeDataToFile(fileOfReadWriteFileChannel);
@@ -646,6 +823,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {}
+ )
+ })
public void test_lock() throws Exception {
MockFileChannel mockFileChannel = new MockFileChannel();
// Verify that calling lock() leads to the method
@@ -659,6 +845,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -696,6 +891,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_IllegalArgument() throws Exception {
try {
writeOnlyFileChannel.lock(0, -1, false);
@@ -729,6 +933,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonWritableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_NonWritable() throws Exception {
try {
readOnlyFileChannel.lock(0, 10, false);
@@ -749,6 +962,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonReadableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_NonReadable() throws Exception {
try {
writeOnlyFileChannel.lock(0, 10, true);
@@ -769,6 +991,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies shared channel.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_Shared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -785,6 +1016,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that unshared channel.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_NotShared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -799,6 +1039,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies lok method with Long max value as a size.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_Long_MAX_VALUE() throws Exception {
final long POSITION = 0;
final long SIZE = Long.MAX_VALUE;
@@ -813,6 +1062,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies OverlappingFileLockException.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_Overlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -830,6 +1088,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that not overlaping regions can be locked.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_NotOverlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -843,6 +1110,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long,long,boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies functionality after release method.",
+ targets = {
+ @TestTarget(
+ methodName = "lock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_lockJJZ_After_Release() throws Exception {
fileLock = writeOnlyFileChannel.lock(0, 10, false);
fileLock.release();
@@ -854,6 +1130,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {}
+ )
+ })
public void test_tryLock() throws Exception {
MockFileChannel mockFileChannel = new MockFileChannel();
// Verify that calling tryLock() leads to the method
@@ -867,6 +1152,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -904,6 +1198,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_IllegalArgument() throws Exception {
try {
writeOnlyFileChannel.tryLock(0, -1, false);
@@ -937,6 +1240,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonWritableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_NonWritable() throws Exception {
try {
readOnlyFileChannel.tryLock(0, 10, false);
@@ -957,6 +1269,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonReadableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_NonReadable() throws Exception {
try {
writeOnlyFileChannel.tryLock(0, 10, true);
@@ -977,6 +1298,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_Shared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -993,6 +1323,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_NotShared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1007,6 +1346,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_Long_MAX_VALUE() throws Exception {
final long POSITION = 0;
final long SIZE = Long.MAX_VALUE;
@@ -1021,6 +1369,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies OverlappingFileLockException.",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_Overlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1038,6 +1395,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_NotOverlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1053,6 +1419,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long,long,boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tryLock",
+ methodArgs = {long.class, long.class, boolean.class}
+ )
+ })
public void test_tryLockJJZ_After_Release() throws Exception {
fileLock = writeOnlyFileChannel.tryLock(0, 10, false);
fileLock.release();
@@ -1065,6 +1440,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer_Null() throws Exception {
ByteBuffer readBuffer = null;
@@ -1086,6 +1470,17 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException. Doesn't verify " +
+ "AsynchronousCloseException, ClosedByInterruptException, " +
+ "IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer_Closed() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1126,6 +1521,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonReadableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer_WriteOnly() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1149,6 +1553,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer_EmptyFile() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
int result = readOnlyFileChannel.read(readBuffer);
@@ -1159,6 +1572,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer_LimitedCapacity() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1175,6 +1597,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_readLByteBuffer() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1191,6 +1622,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_Null() throws Exception {
ByteBuffer readBuffer = null;
@@ -1238,6 +1678,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_Closed() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1261,6 +1710,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_IllegalArgument() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1298,6 +1756,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_WriteOnly() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1321,6 +1788,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_Emptyfile() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
int result = readOnlyFileChannel.read(readBuffer, 0);
@@ -1331,6 +1807,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_Postion_BeyondFileLimit()
throws Exception {
@@ -1346,6 +1831,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IOException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ_Postion_As_Long() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
try {
@@ -1358,6 +1852,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_readLByteBufferJ() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1380,6 +1883,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void test_read$LByteBuffer() throws Exception {
// regression test for Harmony-849
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1400,6 +1912,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void test_read$LByteBuffer_mock() throws Exception {
FileChannel mockChannel = new MockFileChannel();
ByteBuffer[] buffers = new ByteBuffer[2];
@@ -1412,6 +1933,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_Null() throws Exception {
ByteBuffer[] readBuffers = null;
@@ -1456,6 +1986,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_Closed() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -1509,6 +2048,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_WriteOnly() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -1533,6 +2081,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_IndexOutOfBound() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -1579,6 +2136,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_EmptyFile() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -1592,6 +2158,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_EmptyBuffers() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
try {
@@ -1615,6 +2190,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_EmptyFile_EmptyBuffers()
throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -1626,6 +2210,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_Length_Zero() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -1638,6 +2231,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_LimitedCapacity() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -1659,6 +2261,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -1680,6 +2291,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#isOpen()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Doesn't verify that isOpen returns true.",
+ targets = {
+ @TestTarget(
+ methodName = "isOpen",
+ methodArgs = {}
+ )
+ })
public void test_isOpen() throws Exception {
// Regression for HARMONY-40
File logFile = File.createTempFile("out", "tmp");
@@ -1694,6 +2314,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position_append() throws Exception {
// Regression test for Harmony-508
File tmpfile = File.createTempFile("FileOutputStream", "tmp");
@@ -1715,6 +2344,18 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NonReadableChannelException, " +
+ "NonWritableChannelException , ClosedChannelException, " +
+ "IllegalArgumentException, IOException. ",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_AbnormalMode() throws IOException {
try {
writeOnlyFileChannel.map(MapMode.READ_ONLY, 0, CONTENT_LENGTH);
@@ -1806,6 +2447,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_ReadOnly_CloseChannel() throws IOException {
// close channel has no effect on map if mapped
assertEquals(0, readWriteFileChannel.size());
@@ -1819,6 +2470,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_Private_CloseChannel() throws IOException {
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 0,
CONTENT_LENGTH);
@@ -1831,6 +2492,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_ReadOnly() throws IOException {
MappedByteBuffer mapped = null;
// try put something to readonly map
@@ -1862,6 +2533,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_ReadOnly_NonZeroPosition() throws IOException {
this.writeDataToFile(fileOfReadOnlyFileChannel);
MappedByteBuffer mapped = readOnlyFileChannel.map(MapMode.READ_ONLY,
@@ -1874,6 +2555,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_Private() throws IOException {
this.writeDataToFile(fileOfReadWriteFileChannel);
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 0,
@@ -1899,6 +2590,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_Private_NonZeroPosition() throws IOException {
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 10,
CONTENT_LENGTH - 10);
@@ -1910,6 +2611,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_ReadWrite() throws IOException {
MappedByteBuffer mapped = null;
writeDataToFile(fileOfReadWriteFileChannel);
@@ -1937,6 +2648,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class,
+ long.class, long.class}
+ )
+ })
public void test_map_ReadWrite_NonZeroPosition() throws IOException {
// test position non-zero
writeDataToFile(fileOfReadWriteFileChannel);
@@ -1959,6 +2680,15 @@ public class FileChannelTest extends TestCase {
*
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "map",
+ methodArgs = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
+ })
public void test_map_LargePosition() throws IOException {
// Regression test for HARMONY-3085
int[] sizes = {
@@ -2001,6 +2731,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_writeLByteBuffer_Null() throws Exception {
ByteBuffer writeBuffer = null;
@@ -2022,6 +2761,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_writeLByteBuffer_Closed() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2062,6 +2810,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonWritableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_writeLByteBuffer_ReadOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2085,6 +2842,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_writeLByteBuffer() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
@@ -2105,6 +2871,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_writeLByteBuffer_positioned() throws Exception {
final int pos = 5;
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
@@ -2127,6 +2902,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_writeLByteBufferJ_Null() throws Exception {
ByteBuffer writeBuffer = null;
@@ -2172,6 +2956,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_writeLByteBufferJ_Closed() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2195,6 +2988,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonWritableChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_writeLByteBufferJ_ReadOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2236,6 +3038,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_writeLByteBufferJ_IllegalArgument() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2273,6 +3084,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class, long.class}
+ )
+ })
public void test_writeLByteBufferJ() throws Exception {
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -2299,6 +3119,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void test_write$LByteBuffer() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
MockFileChannel mockFileChannel = new MockFileChannel();
@@ -2311,6 +3140,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_Null() throws Exception {
ByteBuffer[] writeBuffers = null;
@@ -2348,6 +3186,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_Closed() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -2390,6 +3237,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NonWritableChannelException, " +
+ "IndexOutOfBoundsException, NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_ReadOnly() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -2432,6 +3289,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_EmptyBuffers() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
try {
@@ -2452,6 +3318,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.wrap(CONTENT_AS_BYTES);
@@ -2480,6 +3355,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_Closed()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -2519,6 +3403,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_SourceClosed()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -2557,6 +3450,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_IllegalArgument()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -2578,6 +3480,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_NonWritable()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -2592,6 +3503,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_SourceNonReadable()
throws Exception {
try {
@@ -2609,6 +3529,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_PositionBeyondSize()
throws Exception {
// init data to file.
@@ -2631,6 +3560,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_FileChannel()
throws Exception {
// init data to file.
@@ -2668,6 +3606,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_DatagramChannel()
throws Exception {
// connects two datagramChannels.
@@ -2709,6 +3656,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_SocketChannel()
throws Exception {
// connects two socketChannels.
@@ -2748,6 +3704,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferFrom",
+ methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
+ })
public void test_transferFromLReadableByteChannelJJ_Pipe() throws Exception {
// inits data in file.
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -2783,6 +3748,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_Null() throws Exception {
writableByteChannel = null;
try {
@@ -2819,6 +3793,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_Closed() throws Exception {
writableByteChannel = DatagramChannel.open();
readOnlyFileChannel.close();
@@ -2857,6 +3840,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_SourceClosed()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -2895,6 +3887,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_IllegalArgument()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -2916,6 +3917,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_NonReadable()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -2930,6 +3940,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_TargetNonWritable()
throws Exception {
try {
@@ -2968,6 +3987,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_PositionBeyondSize()
throws Exception {
// init data to file.
@@ -2990,6 +4018,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_FileChannel()
throws Exception {
// init data to file.
@@ -3028,6 +4065,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_SocketChannel()
throws Exception {
// inits data into file.
@@ -3086,6 +4132,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_DatagramChannel()
throws Exception {
// inits data to file.
@@ -3135,6 +4190,15 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "transferTo",
+ methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
+ })
public void test_transferToJJLWritableByteChannel_Pipe() throws Exception {
// inits data in file.
writeDataToFile(fileOfReadOnlyFileChannel);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
index a6d60d5..bc537cf 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.FileLockInterruptionException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for FileLockInterruptionException
*/
+@TestTargetClass(FileLockInterruptionException.class)
public class FileLockInterruptionExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new FileLockInterruptionException());
@@ -37,6 +52,15 @@ public class FileLockInterruptionExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
index d13c521..5bee734 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -25,7 +30,7 @@ import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import junit.framework.TestCase;
-
+@TestTargetClass(FileLock.class)
/**
* Tests class FileLock.
*/
@@ -66,6 +71,15 @@ public class FileLockTest extends TestCase {
* @tests java.nio.channels.FileLock#FileLock(FileChannel, long, long,
* boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "FileLock",
+ methodArgs = {java.nio.channels.FileChannel.class, long.class, long.class, boolean.class}
+ )
+ })
public void test_Constructor_Ljava_nio_channels_FileChannelJJZ() {
FileLock fileLock1 = new MockFileLock(null, 0, 0, false);
assertNull(fileLock1.channel());
@@ -94,6 +108,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#channel()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "channel",
+ methodArgs = {}
+ )
+ })
public void test_channel() {
assertSame(readWriteChannel, mockLock.channel());
FileLock lock = new MockFileLock(null, 0, 10, true);
@@ -103,6 +126,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#position()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "position",
+ methodArgs = {}
+ )
+ })
public void test_position() {
FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
assertEquals(20, fileLock1.position());
@@ -116,6 +148,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#size()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "size",
+ methodArgs = {}
+ )
+ })
public void test_size() {
FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
assertEquals(100, fileLock1.size());
@@ -130,6 +171,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#isShared()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "[check with false shared parameter]",
+ targets = {
+ @TestTarget(
+ methodName = "isShared",
+ methodArgs = {}
+ )
+ })
public void test_isShared() {
assertFalse(mockLock.isShared());
FileLock lock = new MockFileLock(null, 0, 10, true);
@@ -139,6 +189,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#overlaps(long, long)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "overlaps",
+ methodArgs = {long.class, long.class}
+ )
+ })
public void test_overlaps_JJ() {
assertTrue(mockLock.overlaps(0, 11));
assertFalse(mockLock.overlaps(0, 10));
@@ -153,6 +212,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#isValid()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid() throws IOException {
FileLock fileLock = readWriteChannel.lock();
assertTrue(fileLock.isValid());
@@ -163,6 +231,15 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#release()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "release",
+ methodArgs = {}
+ )
+ })
public void test_release() throws Exception {
File file = File.createTempFile("test", "tmp");
file.deleteOnExit();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
index 1e26eb0..af9db67 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.IllegalBlockingModeException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for IllegalBlockingModeException
*/
+@TestTargetClass(IllegalBlockingModeException.class)
public class IllegalBlockingModeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new IllegalBlockingModeException());
@@ -37,6 +52,15 @@ public class IllegalBlockingModeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
index 3d80375..070aeb6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.IllegalSelectorException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for IllegalSelectorException
*/
+@TestTargetClass(IllegalSelectorException.class)
public class IllegalSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new IllegalSelectorException());
@@ -37,6 +52,15 @@ public class IllegalSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new IllegalSelectorException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
index 33234eb..7a6699f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.FileChannel;
import junit.framework.TestCase;
@@ -23,11 +28,21 @@ import junit.framework.TestCase;
/**
* Tests for FileChannel.MapMode
*/
+@TestTargetClass(java.nio.channels.FileChannel.MapMode.class)
public class MapModeTest extends TestCase {
/**
* java.nio.channels.FileChannel.MapMode#PRIVATE,READONLY,READWRITE
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies fields.",
+ targets = {
+ @TestTarget(
+ methodName = "!Constants",
+ methodArgs = {}
+ )
+ })
public void test_PRIVATE_READONLY_READWRITE() {
assertNotNull(FileChannel.MapMode.PRIVATE);
assertNotNull(FileChannel.MapMode.READ_ONLY);
@@ -44,6 +59,15 @@ public class MapModeTest extends TestCase {
/**
* java.nio.channels.FileChannel.MapMode#toString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void test_toString() {
assertNotNull(FileChannel.MapMode.PRIVATE.toString());
assertNotNull(FileChannel.MapMode.READ_ONLY.toString());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
index 6fcc71f..d78c466 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.NoConnectionPendingException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for NoConnectionPendingException
*/
+@TestTargetClass(NoConnectionPendingException.class)
public class NoConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NoConnectionPendingException());
@@ -37,6 +52,15 @@ public class NoConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
index e287e2f..ac6f820 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.NonReadableChannelException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for NonReadableChannelException
*/
+@TestTargetClass(NonReadableChannelException.class)
public class NonReadableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NonReadableChannelException());
@@ -37,6 +52,15 @@ public class NonReadableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NonReadableChannelException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
index c145354..9f767b9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.NonWritableChannelException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for NonWritableChannelException
*/
+@TestTargetClass(NonWritableChannelException.class)
public class NonWritableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NonWritableChannelException());
@@ -37,6 +52,15 @@ public class NonWritableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NonWritableChannelException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
index 35fd7df..95f209b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.NotYetBoundException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for NotYetBoundException
*/
+@TestTargetClass(NotYetBoundException.class)
public class NotYetBoundExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetBoundException());
@@ -37,6 +52,15 @@ public class NotYetBoundExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetBoundException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
index 6cfb0af..be27cc7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.NotYetConnectedException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for NotYetConnectedException
*/
+@TestTargetClass(NotYetConnectedException.class)
public class NotYetConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetConnectedException());
@@ -37,6 +52,15 @@ public class NotYetConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetConnectedException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
index 9d3a786..5412b43 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.OverlappingFileLockException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for OverlappingFileLockException
*/
+@TestTargetClass(OverlappingFileLockException.class)
public class OverlappingFileLockExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new OverlappingFileLockException());
@@ -37,6 +52,15 @@ public class OverlappingFileLockExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
index c1b2111..fb02750 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
@@ -16,13 +16,18 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.Pipe;
import java.nio.channels.Pipe.SinkChannel;
import java.nio.channels.Pipe.SourceChannel;
import junit.framework.TestCase;
-
+@TestTargetClass(Pipe.class)
/*
* Tests for Pipe and its default implementation
*/
@@ -31,6 +36,15 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#open()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void test_open() throws IOException{
Pipe pipe = Pipe.open();
assertNotNull(pipe);
@@ -39,6 +53,15 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#sink()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "sink",
+ methodArgs = {}
+ )
+ })
public void test_sink() throws IOException {
Pipe pipe = Pipe.open();
SinkChannel sink = pipe.sink();
@@ -48,6 +71,15 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#source()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "source",
+ methodArgs = {}
+ )
+ })
public void test_source() throws IOException {
Pipe pipe = Pipe.open();
SourceChannel source = pipe.source();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
index 25b5f00..23478ff 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectableChannel;
@@ -27,11 +32,21 @@ import junit.framework.TestCase;
/*
* Tests for SelectableChannel
*/
+@TestTargetClass(SelectableChannel.class)
public class SelectableChannelTest extends TestCase {
/**
* @tests SelectableChannel#register(Selector, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Abstract method.",
+ targets = {
+ @TestTarget(
+ methodName = "register",
+ methodArgs = {java.nio.channels.Selector.class, int.class}
+ )
+ })
public void test_register_LSelectorI() throws IOException {
MockSelectableChannel msc = new MockSelectableChannel();
// Verify that calling register(Selector, int) leads to the method
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
index ed33752..68b6532 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
@@ -31,6 +36,7 @@ import tests.support.Support_PortManager;
/*
* Tests for SelectionKey and its default implementation
*/
+@TestTargetClass(SelectionKey.class)
public class SelectionKeyTest extends TestCase {
Selector selector;
@@ -96,6 +102,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#attach(Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "attach",
+ methodArgs = {Object.class}
+ )
+ })
public void test_attach() {
MockSelectionKey mockSelectionKey = new MockSelectionKey(SelectionKey.OP_ACCEPT);
// no previous, return null
@@ -114,6 +129,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#attachment()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "attachment",
+ methodArgs = {}
+ )
+ })
public void test_attachment() {
MockSelectionKey mockSelectionKey = new MockSelectionKey(SelectionKey.OP_ACCEPT);
assertNull(mockSelectionKey.attachment());
@@ -125,6 +149,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#channel()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "channel",
+ methodArgs = {}
+ )
+ })
public void test_channel() {
assertSame(sc, selectionKey.channel());
// can be invoked even canceled
@@ -135,6 +168,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#interestOps()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "interestOps",
+ methodArgs = {}
+ )
+ })
public void test_interestOps() {
assertEquals(SelectionKey.OP_CONNECT, selectionKey.interestOps());
}
@@ -142,6 +184,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#interestOps(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify CancelledKeyException.",
+ targets = {
+ @TestTarget(
+ methodName = "interestOps",
+ methodArgs = {int.class}
+ )
+ })
public void test_interestOpsI() {
selectionKey.interestOps(SelectionKey.OP_WRITE);
assertEquals(SelectionKey.OP_WRITE, selectionKey.interestOps());
@@ -171,6 +222,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid() {
assertTrue(selectionKey.isValid());
}
@@ -178,6 +238,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid_KeyCancelled() {
selectionKey.cancel();
assertFalse(selectionKey.isValid());
@@ -186,6 +255,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid_ChannelColsed() throws IOException {
sc.close();
assertFalse(selectionKey.isValid());
@@ -194,6 +272,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid_SelectorClosed() throws IOException {
selector.close();
assertFalse(selectionKey.isValid());
@@ -202,6 +289,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isAcceptable()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isAcceptable",
+ methodArgs = {}
+ )
+ })
public void test_isAcceptable() throws IOException {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_ACCEPT);
assertTrue(mockSelectionKey1.isAcceptable());
@@ -212,6 +308,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isConnectable()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isConnectable",
+ methodArgs = {}
+ )
+ })
public void test_isConnectable() {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_CONNECT);
assertTrue(mockSelectionKey1.isConnectable());
@@ -222,6 +327,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isReadable()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isReadable",
+ methodArgs = {}
+ )
+ })
public void test_isReadable() {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_READ);
assertTrue(mockSelectionKey1.isReadable());
@@ -232,6 +346,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isWritable()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify CancelledKeyException.",
+ targets = {
+ @TestTarget(
+ methodName = "isWritable",
+ methodArgs = {}
+ )
+ })
public void test_isWritable() {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_WRITE);
assertTrue(mockSelectionKey1.isWritable());
@@ -242,6 +365,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#cancel()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "cancel",
+ methodArgs = {}
+ )
+ })
public void test_cancel() {
selectionKey.cancel();
try {
@@ -294,6 +426,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#readyOps()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify CancelledKeyException.",
+ targets = {
+ @TestTarget(
+ methodName = "readyOps",
+ methodArgs = {}
+ )
+ })
public void test_readyOps() throws IOException {
int port = Support_PortManager.getNextPort();
ServerSocket ss = new ServerSocket(port);
@@ -313,6 +454,15 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#selector()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "selector",
+ methodArgs = {}
+ )
+ })
public void test_selector() {
assertSame(selector, selectionKey.selector());
selectionKey.cancel();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
index 9f73172..feb1c92 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
@@ -35,6 +40,7 @@ import tests.support.Support_PortManager;
/*
* Tests for Selector and its default implementation
*/
+@TestTargetClass(Selector.class)
public class SelectorTest extends TestCase {
private static final int WAIT_TIME = 100;
@@ -79,6 +85,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#open()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void test_open() throws IOException {
assertNotNull(selector);
}
@@ -86,6 +101,15 @@ public class SelectorTest extends TestCase {
/**
* @tests Selector#isOpen()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isOpen",
+ methodArgs = {}
+ )
+ })
public void test_isOpen() throws IOException {
assertTrue(selector.isOpen());
selector.close();
@@ -95,6 +119,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#provider()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ )
+ })
public void test_provider() throws IOException {
// should be system default provider
assertNotNull(selector.provider());
@@ -104,6 +137,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#keys()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "keys",
+ methodArgs = {}
+ )
+ })
public void test_keys() throws IOException {
SelectionKey key = ssc.register(selector, SelectionKey.OP_ACCEPT);
@@ -150,6 +192,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#keys()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "selectedKeys",
+ methodArgs = {}
+ )
+ })
public void test_selectedKeys() throws IOException {
SocketChannel sc = SocketChannel.open();
ssc.register(selector, SelectionKey.OP_ACCEPT);
@@ -195,6 +246,17 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#selectNow()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies selectNow() method for Selector registered with " +
+ "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
+ "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
+ targets = {
+ @TestTarget(
+ methodName = "selectNow",
+ methodArgs = {}
+ )
+ })
public void test_selectNow() throws IOException {
assert_select_OP_ACCEPT(SelectType.NOW, 0);
assert_select_OP_CONNECT(SelectType.NOW, 0);
@@ -205,6 +267,16 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#selectNow()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that ClosedSelectorException is thrown " +
+ "if selectNow() method is called for closed Selector.",
+ targets = {
+ @TestTarget(
+ methodName = "selectNow",
+ methodArgs = {}
+ )
+ })
public void test_selectNow_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.NOW, 0);
}
@@ -212,6 +284,15 @@ public class SelectorTest extends TestCase {
/**
* @test java.nio.channels.Selector#selectNow()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that selectNow() method doesn't block.",
+ targets = {
+ @TestTarget(
+ methodName = "selectNow",
+ methodArgs = {}
+ )
+ })
public void test_selectNow_Timeout() throws IOException {
// make sure selectNow doesn't block
selector.selectNow();
@@ -220,6 +301,17 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies select() method for Selector registered with " +
+ "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
+ "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {}
+ )
+ })
public void test_select() throws IOException {
assert_select_OP_ACCEPT(SelectType.NULL, 0);
assert_select_OP_CONNECT(SelectType.NULL, 0);
@@ -230,6 +322,16 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that ClosedSelectorException is thrown " +
+ "if select() method is called for closed Selector.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {}
+ )
+ })
public void test_select_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.NULL, 0);
}
@@ -237,6 +339,18 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies select(long) method for Selector registered with " +
+ "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
+ "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys and different " +
+ "timeout's values.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {long.class}
+ )
+ })
public void test_selectJ() throws IOException {
assert_select_OP_ACCEPT(SelectType.TIMEOUT, 0);
assert_select_OP_CONNECT(SelectType.TIMEOUT, 0);
@@ -252,6 +366,16 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that ClosedSelectorException is thrown " +
+ "if select(long) method is called for closed Selector.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {long.class}
+ )
+ })
public void test_selectJ_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.TIMEOUT, 0);
selector = Selector.open();
@@ -261,6 +385,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {long.class}
+ )
+ })
public void test_selectJ_Exception() throws IOException {
try {
selector.select(-1);
@@ -272,6 +405,15 @@ public class SelectorTest extends TestCase {
/**
* @test java.nio.channels.Selector#select(long)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies that select(timeout) doesn't block.",
+ targets = {
+ @TestTarget(
+ methodName = "select",
+ methodArgs = {long.class}
+ )
+ })
public void test_selectJ_Timeout() throws IOException {
// make sure select(timeout) doesn't block
selector.select(WAIT_TIME);
@@ -280,6 +422,15 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#wakeup()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "wakeup",
+ methodArgs = {}
+ )
+ })
public void test_wakeup() throws IOException {
/*
* make sure the test does not block on select
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
index 1c45e6c..9c8ab91 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -39,6 +44,7 @@ import tests.support.Support_PortManager;
/*
* test for ServerSocketChannel
*/
+@TestTargetClass(ServerSocketChannel.class)
public class ServerSocketChannelTest extends TestCase {
private static final int CAPACITY_NORMAL = 200;
@@ -88,6 +94,15 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.ServerSocketChannel.validOps()'
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ )
+ })
public void testValidOps() {
MockServerSocketChannel testMSChnlnull = new MockServerSocketChannel(
null);
@@ -102,6 +117,15 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.ServerSocketChannel.open()'
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Doesn't call open() method.",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void testOpen() {
MockServerSocketChannel testMSChnl = new MockServerSocketChannel(null);
MockServerSocketChannel testMSChnlnotnull = new MockServerSocketChannel(
@@ -121,6 +145,15 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'com.ibm.io.nio.ServerSocketChannelImpl.socket()'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_BeforeClose() throws Exception {
assertTrue(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
@@ -136,7 +169,15 @@ public class ServerSocketChannelTest extends TestCase {
assertFalse(this.serverChannel.isOpen());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_BeforeClose() throws Exception {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
@@ -152,7 +193,15 @@ public class ServerSocketChannelTest extends TestCase {
assertFalse(this.serverChannel.isOpen());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_Closed() throws Exception {
this.serverChannel.close();
assertFalse(this.serverChannel.isOpen());
@@ -164,7 +213,15 @@ public class ServerSocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_Closed() throws Exception {
this.serverChannel.configureBlocking(false);
this.serverChannel.close();
@@ -185,7 +242,27 @@ public class ServerSocketChannelTest extends TestCase {
assertNull(s.getLocalSocketAddress());
assertEquals(0, s.getSoTimeout());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies default status of ServerSocketChannel.",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRegistered",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isBlocking",
+ methodArgs = {}
+ )
+ })
public void testChannelBasicStatus() {
ServerSocket gotSocket = this.serverChannel.socket();
assertFalse(gotSocket.isClosed());
@@ -202,7 +279,15 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'com.ibm.io.nio.ServerSocketChannelImpl.accept()'
*/
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NotYetBoundException.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void testAccept_Block_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
@@ -213,7 +298,15 @@ public class ServerSocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NotYetBoundException.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void testAccept_NonBlock_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
@@ -224,7 +317,15 @@ public class ServerSocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void testAccept_ClosedChannel() throws Exception {
this.serverChannel.close();
assertFalse(this.serverChannel.isOpen());
@@ -235,7 +336,15 @@ public class ServerSocketChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies AsynchronousCloseException.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void testAccept_Block_NoConnect() throws IOException {
assertTrue(this.serverChannel.isBlocking());
ServerSocket gotSocket = this.serverChannel.socket();
@@ -260,7 +369,16 @@ public class ServerSocketChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that accept() returns null if the channel is in " +
+ "non-blocking mode and no connection is available to be accepted.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void testAccept_NonBlock_NoConnect() throws IOException {
ServerSocket gotSocket = this.serverChannel.socket();
gotSocket.bind(localAddr1);
@@ -272,6 +390,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_read_Blocking_RealData() throws IOException {
serverChannel.socket().bind(localAddr1);
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -310,6 +437,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_read_NonBlocking_RealData() throws Exception {
serverChannel.configureBlocking(false);
serverChannel.socket().bind(localAddr1);
@@ -329,6 +465,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_write_Blocking_RealData() throws IOException {
assertTrue(serverChannel.isBlocking());
ServerSocket serverSocket = serverChannel.socket();
@@ -351,6 +496,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_write_NonBlocking_RealData() throws Exception {
serverChannel.configureBlocking(false);
ServerSocket serverSocket = serverChannel.socket();
@@ -371,6 +525,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_read_LByteBuffer_Blocking_ReadWriteRealLargeData()
throws IOException {
serverChannel.socket().bind(localAddr1);
@@ -390,6 +553,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_read_LByteBuffer_NonBlocking_ReadWriteRealLargeData()
throws Exception {
serverChannel.configureBlocking(false);
@@ -410,6 +582,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_write_LByteBuffer_NonBlocking_ReadWriteRealLargeData()
throws Exception {
serverChannel.configureBlocking(false);
@@ -429,6 +610,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_write_LByteBuffer_Blocking_ReadWriteRealLargeData()
throws Exception {
serverChannel.socket().bind(localAddr1);
@@ -469,6 +659,16 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#socket().getSoTimeout()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that accept method returns null since " +
+ "there are no pending connections. Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "accept",
+ methodArgs = {}
+ )
+ })
public void test_accept_SOTIMEOUT() throws IOException {
// regression test for Harmony-707
final int SO_TIMEOUT = 10;
@@ -492,6 +692,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Verifies IllegalBlockingModeException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_accept_Blocking_NotBound() throws IOException {
// regression test for Harmony-748
ServerSocket gotSocket = serverChannel.socket();
@@ -514,6 +723,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Verifies IllegalBlockingModeException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_accept_Nonblocking_NotBound() throws IOException {
// regression test for Harmony-748
ServerSocket gotSocket = serverChannel.socket();
@@ -536,6 +754,16 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Verifies IllegalBlockingModeException, " +
+ "ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_accept_Nonblocking_Bound() throws IOException {
// regression test for Harmony-748
serverChannel.configureBlocking(false);
@@ -559,6 +787,15 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_accept_Blocking_Bound() throws IOException {
// regression test for Harmony-748
serverChannel.configureBlocking(true);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
index 97c4c4d..5cf7dd0 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -27,7 +32,7 @@ import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import junit.framework.TestCase;
-
+@TestTargetClass(java.nio.channels.Pipe.SinkChannel.class)
/**
* Tests for Pipe.SinkChannel class
*/
@@ -60,13 +65,31 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#validOps()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ )
+ })
public void test_validOps() {
assertEquals(SelectionKey.OP_WRITE, sink.validOps());
}
/**
- * @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
+ * @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer [])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -102,6 +125,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_LByteBuffer_mutliThread() throws IOException,
InterruptedException {
final int THREAD_NUM = 20;
@@ -146,6 +178,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_LByteBuffer_Exception() throws IOException {
// write null ByteBuffer
ByteBuffer nullBuf = null;
@@ -160,6 +201,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_LByteBuffer_SourceClosed() throws IOException {
source.close();
int written = sink.write(buffer);
@@ -169,6 +219,16 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException, " +
+ "NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_LByteBuffer_SinkClosed() throws IOException {
sink.close();
try {
@@ -191,6 +251,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_$LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -224,6 +293,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_$LByteBuffer_Exception() throws IOException {
// write null ByteBuffer[]
ByteBuffer[] nullBufArrayRef = null;
@@ -248,6 +326,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_$LByteBuffer_SourceClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
source.close();
@@ -258,6 +345,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException, NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_write_$LByteBuffer_SinkClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
sink.close();
@@ -290,6 +386,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write_$LByteBufferII() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -319,6 +424,16 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException, " +
+ "IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write_$LByteBufferII_Exception() throws IOException {
// write null ByteBuffer[]
ByteBuffer[] nullBufArrayRef = null;
@@ -393,6 +508,15 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write_$LByteBufferII_SourceClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
source.close();
@@ -403,6 +527,16 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException, NullPointerException, " +
+ "IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write_$LByteBufferII_SinkClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
sink.close();
@@ -487,11 +621,33 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#close()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies write method after close.",
+ targets = {
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_close() throws IOException {
sink.close();
assertFalse(sink.isOpen());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies that NullPointerException is thrown if " +
+ "write method is called for closed channel.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_socketChannel_read_close() throws Exception {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(),49999));
@@ -515,7 +671,15 @@ public class SinkChannelTest extends TestCase {
}
sock.close();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_socketChannel_read_write() throws Exception {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(),49999));
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
index 0d48c62..f7c8822 100755
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
@@ -17,6 +17,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestLevel;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -43,6 +48,7 @@ import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
import tests.support.Support_PortManager;
+@TestTargetClass(SocketChannel.class)
/**
* Tests for SocketChannel and its default implementation.
*/
@@ -115,6 +121,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.validOps()'
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ )
+ })
public void testValidOps() {
MockSocketChannel testMSChannel = new MockSocketChannel(null);
assertEquals(13, this.channel1.validOps());
@@ -124,6 +139,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.open()'
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void testOpen() throws IOException {
java.nio.ByteBuffer[] buf = new java.nio.ByteBuffer[1];
buf[0] = java.nio.ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -145,6 +169,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.open(SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testOpenSocketAddress_Null() throws IOException {
SocketChannel channel1IP = null;
try {
@@ -159,6 +192,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.read(ByteBuffer[])'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testReadByteBufferArray() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -194,6 +236,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.read(ByteBuffer[])'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testReadByteBufferArray_BufNull() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -222,6 +273,16 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.write(ByteBuffer[])'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException, ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testWriteByteBufferArray() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -247,6 +308,15 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.write(ByteBuffer[])'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void testWriteByteBufferArray_BufNull() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -271,7 +341,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_BasicStatusBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
Socket s1 = this.channel1.socket();
@@ -280,7 +358,15 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_BasicStatusAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
assertTrue(this.channel1.connect(localAddr1));
@@ -293,7 +379,15 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_BasicStatusAfterConnect() throws Exception {
assertFalse(this.channel1.isConnected());// not connected
this.channel1.configureBlocking(false);
@@ -316,13 +410,29 @@ public class SocketChannelTest extends TestCase {
assertSame(s1, s2);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_ActionsBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
Socket s = this.channel1.socket();
assertSocketAction_Block_BeforeConnect(s);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_Block_ActionsAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
assertTrue(this.channel1.connect(localAddr1));
@@ -331,7 +441,15 @@ public class SocketChannelTest extends TestCase {
assertSocketAction_Block_AfterConnect(s);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_ActionsAfterConnectBeforeFinish()
throws IOException {
assertFalse(this.channel1.isConnected());// not connected
@@ -346,7 +464,15 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_NonBlock_ActionsAfterConnectAfterFinish()
throws Exception {
assertFalse(this.channel1.isConnected());// not connected
@@ -557,6 +683,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_Norml_NoServer_Block() throws Exception {
// ensure
ensureServerClosed();
@@ -581,6 +720,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_Norml_NoServer_NonBlock() throws Exception {
connectNoServerNonBlock();
@@ -591,6 +743,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_Norml_Server_Block() throws Exception {
connectServerBlock();
@@ -602,6 +767,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_Norml_Server_NonBlock() throws Exception {
connectServerNonBlock();
@@ -612,6 +790,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->server closed-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerClosed_Block() throws Exception {
// ensure
ensureServerOpen();
@@ -633,6 +824,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->server closed-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerClosed_NonBlock() throws Exception {
// ensure
ensureServerOpen();
@@ -653,6 +857,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->server closed-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerClosedAfterFinish_Block() throws Exception {
connectServerBlock();
@@ -666,6 +883,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->server closed-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerClosedAfterFinish_NonBlock() throws Exception {
connectServerNonBlock();
@@ -678,6 +908,19 @@ public class SocketChannelTest extends TestCase {
/**
* no server-->connect-->server open-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerStartLater_Block() throws Exception {
// ensure
ensureServerClosed();
@@ -703,6 +946,19 @@ public class SocketChannelTest extends TestCase {
/**
* no server-->connect-->server open-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ServerStartLater_NonBlock() throws Exception {
// ensure
ensureServerClosed();
@@ -726,6 +982,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishTwice_NoServer_NonBlock() throws Exception {
// ensure
ensureServerClosed();
@@ -749,6 +1018,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishTwice_Server_Block() throws Exception {
connectServerBlock();
tryFinish();
@@ -760,6 +1042,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishTwice_Server_NonBlock() throws Exception {
connectServerNonBlock();
tryFinish();
@@ -770,6 +1065,24 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies case: connect-->finish-->connect-->close. " +
+ "Verifies ClosedChannelException, ConnectException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testCFII_ConnectAfterFinish_NoServer_Block() throws Exception {
// ensure
ensureServerClosed();
@@ -802,6 +1115,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies case: connect-->finish-->connect-->close. " +
+ "Verifies ConnectionPendingException, ConnectException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ConnectAfterFinish_NoServer_NonBlock()
throws Exception {
// ensure
@@ -856,6 +1183,15 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies AlreadyConnectedException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_ConnectAfterFinish_Server_Block() throws Exception {
connectServerBlock();
@@ -901,6 +1237,15 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies AlreadyConnectedException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_ConnectAfterFinish_Server_NonBlock() throws Exception {
connectServerNonBlock();
@@ -945,6 +1290,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies case: connect-->connect-->finish-->close. " +
+ "Verifies ConnectionPendingException, ConnectException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ConnectTwice_NoServer_NonBlock() throws Exception {
// ensure
ensureServerClosed();
@@ -996,6 +1355,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies case connect-->connect-->finish-->close. " +
+ "Verifies AlreadyConnectedException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ConnectTwice_Server_Block() throws Exception {
// ensure
ensureServerOpen();
@@ -1043,6 +1416,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies case connect-->connect-->finish-->close. " +
+ "Verifies ConnectionPendingException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_ConnectTwice_Server_NonBlock() throws Exception {
// ensure
ensureServerOpen();
@@ -1089,6 +1476,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishFirst_NoServer_Block() throws Exception {
// ensure
ensureServerClosed();
@@ -1122,6 +1522,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishFirst_NoServer_NonBlock() throws Exception {
// ensure
ensureServerClosed();
@@ -1153,6 +1566,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishFirst_Server_Block() throws Exception {
// ensure
ensureServerOpen();
@@ -1180,6 +1606,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_FinishFirst_Server_NonBlock() throws Exception {
// ensure
ensureServerOpen();
@@ -1202,7 +1641,15 @@ public class SocketChannelTest extends TestCase {
this.channel1.close();
statusChannelClosed();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_Null() throws Exception {
statusNotConnected_NotPending();
try {
@@ -1212,7 +1659,15 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_UnsupportedType() throws Exception {
class SubSocketAddress extends SocketAddress {
private static final long serialVersionUID = 1L;
@@ -1231,7 +1686,15 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_Unresolved() throws IOException {
statusNotConnected_NotPending();
InetSocketAddress unresolved = new InetSocketAddress(
@@ -1243,7 +1706,15 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_EmptyHost() throws Exception {
statusNotConnected_NotPending();
ServerSocket server = new ServerSocket(0);
@@ -1256,7 +1727,23 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testCFII_CloseFirst() throws Exception {
this.channel1.close();
statusChannelClosed();
@@ -1283,7 +1770,19 @@ public class SocketChannelTest extends TestCase {
}
statusChannelClosed();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_StatusAfterFinish() throws Exception {
// 1. close server, finish must return false, check the status
ensureServerClosed();
@@ -1440,6 +1939,15 @@ public class SocketChannelTest extends TestCase {
*
* 'SocketChannelImpl.connect(SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ )
+ })
public void testCFII_Data_ConnectWithServer() throws Exception {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -1473,6 +1981,23 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'SocketChannelImpl.connect(SocketAddress)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testCFII_Data_ConnectWithServer_nonBlocking() throws Exception {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -1508,6 +2033,19 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'SocketChannelImpl.finishConnect()'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testCFII_Data_FinishConnect_nonBlocking() throws IOException {
ensureServerOpen();
@@ -1542,7 +2080,23 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isRegistered());
tryFinish();
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "connect",
+ methodArgs = {java.net.SocketAddress.class}
+ ),
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "open",
+ methodArgs = {}
+ )
+ })
public void testCFII_Data_FinishConnect_AddrSetServerStartLater()
throws IOException, InterruptedException {
ensureServerClosed();
@@ -1612,7 +2166,15 @@ public class SocketChannelTest extends TestCase {
// FIXME: assertEquals(e.getMessage(), "Connection refused");
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void testCFII_Data_FinishConnect_ServerStartLater()
throws IOException {
ensureServerClosed();
@@ -1671,7 +2233,19 @@ public class SocketChannelTest extends TestCase {
// FIXME: assertEquals(e.getMessage(), "Connection refused");
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void testCFII_Data_FinishConnect_Blocking() throws IOException {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -1709,6 +2283,15 @@ public class SocketChannelTest extends TestCase {
/**
* Regression test for Harmony-1947.
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "finishConnect",
+ methodArgs = {}
+ )
+ })
public void test_finishConnect() throws Exception {
SocketAddress address = new InetSocketAddress("localhost", 2046);
@@ -1750,6 +2333,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_readLjava_nio_ByteBuffer_Blocking() throws IOException {
// initialize write content
byte[] writeContent = new byte[CAPACITY_NORMAL];
@@ -1793,6 +2385,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_readLjava_nio_ByteBuffer_Nonblocking() throws IOException {
// initialize write content
byte[] writeContent = new byte[CAPACITY_NORMAL];
@@ -1839,6 +2440,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_wrtieLjava_nio_ByteBuffer_Blocking() throws IOException {
// initialize write content
ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -1889,6 +2499,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_wrtieLjava_nio_ByteBuffer_NonBlocking() throws Exception {
// initialize write content
ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -1959,7 +2578,15 @@ public class SocketChannelTest extends TestCase {
// -------------------------------------------------
// Test for read/write but no real data expressed
// -------------------------------------------------
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all exceptions according to specification.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadByteBuffer() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer
@@ -1993,7 +2620,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadByteBuffer_Direct() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer
@@ -2027,7 +2662,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadByteBuffer_BufNull() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer.allocate(0);
@@ -2061,6 +2704,15 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.read(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2100,6 +2752,15 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.read(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt_Direct() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2135,7 +2796,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt_BufNull() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2179,7 +2848,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2210,7 +2887,16 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException.",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_Direct() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2241,7 +2927,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void testWriteByteBuffer_BufNull() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer.allocate(0);
@@ -2258,6 +2952,16 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.write(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify AsynchronousCloseException, " +
+ "ClosedByInterruptException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[2];
writeBuf[0] = java.nio.ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -2296,6 +3000,15 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.write(ByteBuffer[], int, int)'
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_Direct() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[2];
writeBuf[0] = java.nio.ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -2330,7 +3043,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_BufNull() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[0];
@@ -2369,7 +3090,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testWriteByteBufferArrayIntInt_SizeError() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[0];
@@ -2408,7 +3137,15 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void testReadByteBufferArrayIntInt_SizeError() throws IOException {
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[0];
@@ -2458,6 +3195,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read$LByteBuffer() throws IOException {
MockSocketChannel sc = new MockSocketChannel(null);
ByteBuffer [] byteBufferArray = { ByteBuffer.allocate(1), ByteBuffer.allocate(1)};
@@ -2470,6 +3216,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_blocking() throws Exception {
assert_read$LByteBuffer(true);
}
@@ -2477,6 +3232,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read$LByteBufferII_nonblocking() throws Exception {
assert_read$LByteBuffer(false);
}
@@ -2539,6 +3303,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_blocking() throws Exception {
assert_write$LByteBuffer(true);
}
@@ -2546,6 +3319,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_write$LByteBufferII_nonblocking()
throws Exception {
assert_write$LByteBuffer(false);
@@ -2611,6 +3393,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class}
+ )
+ })
public void test_write$LByteBuffer() throws IOException {
MockSocketChannel sc = new MockSocketChannel(null);
ByteBuffer [] byteBufferArray = { ByteBuffer.allocate(1), ByteBuffer.allocate(1)};
@@ -2620,7 +3411,15 @@ public class SocketChannelTest extends TestCase {
sc.write(byteBufferArray);
assertTrue(sc.isWriteCalled);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalBlockingModeException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void testSocket_configureblocking() throws IOException {
byte[] serverWBuf = new byte[CAPACITY_NORMAL];
for (int i = 0; i < serverWBuf.length; i++) {
@@ -2651,6 +3450,15 @@ public class SocketChannelTest extends TestCase {
* @tests SocketChannel#read(ByteBuffer[], int, int) when remote server
* closed
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_socketChannel_read_ByteBufferII_remoteClosed()
throws Exception {
// regression 1 for HARMONY-549
@@ -2668,6 +3476,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_socketChannel_write_ByteBufferII() throws Exception {
// regression 2 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -2691,6 +3508,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#read(ByteBuffer[], int, int) with a null ByteBuffer
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_socketChannel_read_ByteBufferII_bufNULL() throws Exception {
// regression 3 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -2714,6 +3540,19 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer) after close
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ ),
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_socketChannel_write_close() throws Exception {
// regression 4 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -2736,6 +3575,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer) if position is not zero
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "write",
+ methodArgs = {java.nio.ByteBuffer.class}
+ )
+ })
public void test_socketChannel_write_ByteBuffer_posNotZero()
throws Exception {
// regression 5 for HARMONY-549
@@ -2763,6 +3611,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_$ByteBuffer_Blocking() throws IOException {
// regression test for Harmony-728
byte[] data = new byte[CAPACITY_NORMAL];
@@ -2790,6 +3647,16 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().read
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalBlockingModeException, " +
+ "NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_getOutputStream_nonBlocking_read_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -2844,6 +3711,16 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().read
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NullPointerException, ClosedChannelException, " +
+ "IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_getOutputStream_blocking_read_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -2897,6 +3774,16 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NullPointerException, " +
+ "IllegalBlockingModeException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_getOutputStream_nonBlocking_write_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -2963,6 +3850,16 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies NullPointerException, " +
+ "IndexOutOfBoundsException, ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_getOutputStream_blocking_write_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -3016,6 +3913,15 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "socket",
+ methodArgs = {}
+ )
+ })
public void test_socket_getOutputStream_write_oneByte()
throws IOException {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
index 05dca90..9225d0a 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestLevel;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
@@ -23,7 +28,7 @@ import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
import junit.framework.TestCase;
-
+@TestTargetClass(java.nio.channels.Pipe.SourceChannel.class)
/**
* Tests for java.nio.channels.Pipe.SourceChannel
*/
@@ -56,6 +61,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#validOps()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "validOps",
+ methodArgs = {}
+ )
+ })
public void test_validOps() {
assertEquals(SelectionKey.OP_READ, source.validOps());
}
@@ -63,6 +77,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_LByteBuffer_DataAvailable() throws IOException {
// if anything can read, read method will not block
sink.write(ByteBuffer.allocate(1));
@@ -73,6 +96,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_LByteBuffer_Exception() throws IOException {
ByteBuffer nullBuf = null;
try {
@@ -86,6 +118,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_LByteBuffer_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
sink.write(buffer);
@@ -104,6 +145,16 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException, " +
+ "NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_LByteBuffer_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
source.close();
@@ -150,6 +201,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer[])
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_$LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -201,6 +261,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_$LByteBuffer_Exception() throws IOException {
ByteBuffer[] nullBufArrayRef = null;
try {
@@ -232,6 +301,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_$LByteBuffer_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -252,6 +330,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ClosedChannelException, NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class}
+ )
+ })
public void test_read_$LByteBuffer_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -293,6 +380,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer[], int, int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read_$LByteBufferII() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -344,6 +440,16 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException, " +
+ "IndexOutOfBoundsException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read_$LByteBufferII_Exception() throws IOException {
ByteBuffer[] nullBufArrayRef = null;
@@ -416,6 +522,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read_$LByteBufferII_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -435,6 +550,16 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IndexOutOfBoundsException, " +
+ "ClosedChannelException.",
+ targets = {
+ @TestTarget(
+ methodName = "read",
+ methodArgs = {ByteBuffer[].class, int.class, int.class}
+ )
+ })
public void test_read_$LByteBufferII_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -524,6 +649,15 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#close()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_close() throws IOException {
sink.close();
assertFalse(sink.isOpen());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
index 3157f3b..ff9227e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.UnresolvedAddressException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for UnresolvedAddressException
*/
+@TestTargetClass(UnresolvedAddressException.class)
public class UnresolvedAddressExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new UnresolvedAddressException());
@@ -37,6 +52,15 @@ public class UnresolvedAddressExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new UnresolvedAddressException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
index eb8baba..7dd0508 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
@@ -15,6 +15,11 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.UnsupportedAddressTypeException;
import junit.framework.TestCase;
@@ -24,11 +29,21 @@ import org.apache.harmony.testframework.serialization.SerializationTest;
/**
* Tests for UnsupportedAddressTypeException
*/
+@TestTargetClass(UnsupportedAddressTypeException.class)
public class UnsupportedAddressTypeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new UnsupportedAddressTypeException());
@@ -37,6 +52,15 @@ public class UnsupportedAddressTypeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
index e8c24ed..a5af1fa 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
@@ -16,17 +16,31 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import junit.framework.TestCase;
-
+@TestTargetClass(AbstractInterruptibleChannel.class)
public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#close()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_close() throws IOException {
MockInterruptibleChannel testMiChannel = new MockInterruptibleChannel();
assertTrue(testMiChannel.isOpen());
@@ -39,6 +53,19 @@ public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#begin/end()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "begin",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "end",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_begin_end() throws IOException {
boolean complete = false;
MockInterruptibleChannel testChannel = new MockInterruptibleChannel();
@@ -78,6 +105,23 @@ public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#close/begin/end()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "begin",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "end",
+ methodArgs = {boolean.class}
+ ),
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_close_begin_end() throws IOException {
boolean complete = false;
MockInterruptibleChannel testChannel = new MockInterruptibleChannel();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
index d6e0e08..cf68b8e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.IllegalBlockingModeException;
@@ -32,6 +37,7 @@ import junit.framework.TestCase;
/**
* Tests for AbstractSelectableChannel
*/
+@TestTargetClass(AbstractSelectableChannel.class)
public class AbstractSelectableChannelTest extends TestCase {
private MockSelectableChannel testChannel;
@@ -50,6 +56,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#implCloseChannel()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "implCloseChannel",
+ methodArgs = {}
+ )
+ })
public void test_implClose() throws IOException {
testChannel.isImplCloseSelectableChannelCalled = false;
testChannel.implCloseSelectableChannelCount = 0;
@@ -73,6 +88,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#provider()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ )
+ })
public void test_provider() {
SelectorProvider provider = testChannel.provider();
assertSame(SelectorProvider.provider(), provider);
@@ -84,6 +108,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#isBlocking()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isBlocking",
+ methodArgs = {}
+ )
+ })
public void test_isBlocking() throws IOException {
assertTrue(testChannel.isBlocking());
testChannel.configureBlocking(false);
@@ -96,6 +129,15 @@ public class AbstractSelectableChannelTest extends TestCase {
*
* @tests AbstractSelectableChannel#blockingLock()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "blockingLock",
+ methodArgs = {}
+ )
+ })
public void test_blockingLock() {
Object gotObj = testChannel.blockingLock();
assertNotNull(gotObj);
@@ -104,6 +146,16 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#register(Selector, int, Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "register",
+ methodArgs = {java.nio.channels.Selector.class,
+ int.class, java.lang.Object.class}
+ )
+ })
public void test_register_LSelectorILObject() throws IOException {
assertFalse(testChannel.isRegistered());
Selector acceptSelector1 = SelectorProvider.provider().openSelector();
@@ -125,6 +177,16 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#register(Selector, int, Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "register",
+ methodArgs = {java.nio.channels.Selector.class,
+ int.class, java.lang.Object.class}
+ )
+ })
public void test_register_LSelectorILObject_IllegalArgument()
throws IOException {
Selector acceptSelector = SelectorProvider.provider().openSelector();
@@ -222,6 +284,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#keyFor(Selector)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "keyFor",
+ methodArgs = {java.nio.channels.Selector.class}
+ )
+ })
public void test_keyfor_LSelector() throws Exception {
SocketChannel sc = SocketChannel.open();
Object argObj = new Object();
@@ -244,6 +315,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#configureBlocking(boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_configureBlocking_Z_IllegalBlockingMode() throws Exception {
SocketChannel sc = SocketChannel.open();
sc.configureBlocking(false);
@@ -264,6 +344,15 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#configureBlocking(boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "configureBlocking",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_configureBlocking_Z() throws Exception {
MockSelectableChannel mock = new MockSelectableChannel(SelectorProvider
.provider());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
index 1404fc1..9eca42e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
@@ -16,18 +16,32 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectionKey;
import junit.framework.TestCase;
-
+@TestTargetClass(AbstractSelectionKey.class)
public class AbstractSelectionKeyTest extends TestCase {
/**
* @tests AbstractSelectionKey#isValid() without selector
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isValid",
+ methodArgs = {}
+ )
+ })
public void test_isValid() throws Exception {
MockSelectionKey testKey = new MockSelectionKey();
assertTrue(testKey.isValid());
@@ -36,6 +50,15 @@ public class AbstractSelectionKeyTest extends TestCase {
/**
* @tests AbstractSelectionKey#cancel
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "cancel",
+ methodArgs = {}
+ )
+ })
public void test_cancel() throws Exception {
MockSelectionKey testKey = new MockSelectionKey();
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
index 4b39001..8ad2432 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
@@ -16,15 +16,21 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.spi.SelectorProvider;
+import java.nio.channels.spi.AbstractSelector;
import junit.framework.TestCase;
-
+@TestTargetClass(AbstractSelector.class)
/**
* Tests for AbstractSelector and register of its default implementation
*/
@@ -33,6 +39,15 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#provider()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ )
+ })
public void test_provider() throws IOException {
Selector mockSelector = new MockAbstractSelector(SelectorProvider
.provider());
@@ -45,6 +60,15 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#close()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "close",
+ methodArgs = {}
+ )
+ })
public void test_close() throws IOException {
MockAbstractSelector mockSelector = new MockAbstractSelector(
SelectorProvider.provider());
@@ -56,6 +80,19 @@ public class AbstractSelectorTest extends TestCase {
*
* @tests AbstractSelector#begin/end()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "begin",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "end",
+ methodArgs = {}
+ )
+ })
public void test_begin_end() throws IOException {
MockAbstractSelector mockSelector = new MockAbstractSelector(
SelectorProvider.provider());
@@ -100,6 +137,15 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#isOpen()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isOpen",
+ methodArgs = {}
+ )
+ })
public void test_isOpen() throws Exception {
Selector acceptSelector = SelectorProvider.provider().openSelector();
assertTrue(acceptSelector.isOpen());
@@ -110,6 +156,16 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#register(Selector,int)
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Verifies register method from SelectableChannel " +
+ "class.",
+ targets = {
+ @TestTarget(
+ methodName = "register",
+ methodArgs = {Selector.class, int.class}
+ )
+ })
public void test_register_LSelectorI() throws Exception {
Selector acceptSelector = SelectorProvider.provider().openSelector();
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -126,6 +182,16 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#register(Selector,int)
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Verifies register method from SelectableChannel " +
+ "class.",
+ targets = {
+ @TestTarget(
+ methodName = "register",
+ methodArgs = {Selector.class, int.class}
+ )
+ })
public void test_register_LSelectorI_error() throws IOException {
Selector acceptSelector = SelectorProvider.provider().openSelector();
ServerSocketChannel ssc = ServerSocketChannel.open();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
index 305e9e2..27fffdf 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
@@ -16,6 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.IOException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
@@ -26,12 +31,21 @@ import java.nio.channels.spi.SelectorProvider;
import java.security.Permission;
import junit.framework.TestCase;
-
+@TestTargetClass(SelectorProvider.class)
public class SelectorProviderTest extends TestCase {
/**
* @tests SelectorProvider#provider() using security manager
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ )
+ })
public void test_provider_security() {
SecurityManager originalSecuirtyManager = System.getSecurityManager();
System.setSecurityManager(new MockSelectorProviderSecurityManager());
@@ -48,6 +62,15 @@ public class SelectorProviderTest extends TestCase {
/**
* @tests SelectorProvider#provider() using security manager
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "provider",
+ methodArgs = {}
+ )
+ })
public void test_provider_security_twice() {
SelectorProvider.provider();
SecurityManager originalSecuirtyManager = System.getSecurityManager();